Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/other token details #10

Merged
merged 24 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2f771f2
feat: adding token manager type and address
canhtrinh Jan 31, 2024
520b0d2
feat: add other details to interchain token schema
canhtrinh Jan 31, 2024
e4d964f
chore: update existing data to follow schema
canhtrinh Jan 31, 2024
4d466bb
Update cli/schemas/interchain-tokenlist.ts
canhtrinh Feb 2, 2024
b200732
Update cli/wizard/commands/list-squid-token/index.ts
canhtrinh Feb 2, 2024
dfd27a6
Update registry/mainnet/interchain/squid.tokenlist.json
canhtrinh Feb 2, 2024
9a243fc
Update registry/mainnet/interchain/squid.tokenlist.json
canhtrinh Feb 2, 2024
9dee800
chore: update schemas for tokenManager, minter, and salt
canhtrinh Feb 2, 2024
67d8c0a
chore: update schema of squid list
canhtrinh Feb 2, 2024
db1a885
feat: add TDBG19 token
canhtrinh Feb 2, 2024
cc2558c
chore: adding tokenType and srcTxHash to cli
canhtrinh Feb 2, 2024
d607238
chore: add srcTxHash to schema
canhtrinh Feb 2, 2024
bf48b8b
chore: clean up stagenet file
canhtrinh Feb 2, 2024
2f87f1a
chore: code cleanup
canhtrinh Feb 2, 2024
2c51a15
chore: updating lint job for cli,registry,scripts
canhtrinh Feb 2, 2024
80d2f8d
chore: set latest bun
alanrsoares Feb 3, 2024
6d2a2cc
chore: rebuild lockfile
alanrsoares Feb 3, 2024
eca0ecd
chore: rename property srcTxHash -> deploymentTxHash
alanrsoares Feb 3, 2024
88cfcff
chore: rename property tokenManagerAddress -> tokenManager
alanrsoares Feb 3, 2024
0cb0266
fix: type mapping on script
alanrsoares Feb 3, 2024
ab42ea3
chore: fix tokenList
alanrsoares Feb 3, 2024
383635c
chore: schema cleanup
canhtrinh Feb 4, 2024
e51dce9
chore: change interface name for InterchainTokenInfoBaseAPIResponse
canhtrinh Feb 4, 2024
80da059
chore: replace deploymentMessageId with deploymentTxHash
canhtrinh Feb 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ jobs:

- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Format files
run: bun run format
run: bun format

- name: Check for changes
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:

- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install
Expand Down
Binary file modified bun.lockb
Binary file not shown.
19 changes: 12 additions & 7 deletions cli/schemas/interchain-tokenlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,28 @@ export const IconUrlsSchema = z.object({
svg: z.string().url(),
});

export const remoteToken = z.object({
export const chains = z.object({
axelarChainId: z.string(),
tokenAddress: address,
tokenManager: address,
tokenManagerType: z.string(),
symbol: z.string(),
name: z.string(),
});

export const interchainToken = z.object({
tokenId: hash,
tokenAddress: address,
symbol: z.string(),
deployer: address,
originalMinter: address,
prettySymbol: z.string(),
decimals: z.number().int(),
name: z.string(),
originAxelarChainId: z.string(),
transferType: z.string(),
tokenType: z.string(),
iconUrls: IconUrlsSchema,
remoteTokens: z.array(remoteToken),
deploySalt: z.string(),
chains: z.array(chains),
coinGeckoId: z.string().optional(),
deploymentTxHash: hash,
});

export const version = z.object({
Expand All @@ -36,7 +41,7 @@ const interchainTokenList = z.object({
.regex(/^(?:\.\.\/)+schemas\/interchain-tokenlist\.schema\.json$/),
name: z.string(),
version,
tokens: z.array(interchainToken),
tokens: z.record(z.string(), interchainToken),
});

export default interchainTokenList;
Expand Down
80 changes: 55 additions & 25 deletions cli/wizard/commands/list-squid-token/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { input, confirm } from "@inquirer/prompts";
import chalk from "chalk";
import { $, fs, path, spinner } from "zx";
import { convertCase } from "@axelarjs/utils";

import {
InterchainTokenConfig,
Expand Down Expand Up @@ -57,7 +58,7 @@ export async function listSquidToken() {
() =>
fetch(detailsApiUrl)
.then((res) => res.json())
.catch(() => ({})) as Promise<InterchainTokenDetails>
.catch(() => ({})) as Promise<InterchainTokenDetailsApiResponse>
);

const newTokenConfig = parseAsInterchainTokenConfig(tokenDetails);
Expand All @@ -75,15 +76,14 @@ export async function listSquidToken() {
await patchConfig<InterchainTokenListConfig, InterchainTokenListConfig>(
relativePath,
{
tokens: (tokens) => [...(tokens ?? []), newTokenConfig],
tokens: (tokens) => ({
...tokens,
[newTokenConfig.tokenId]: newTokenConfig,
}),
},
{
isDuplicate: (config) =>
config.tokens.some(
(token) =>
token.tokenAddress === newTokenConfig.tokenAddress ||
token.tokenId === newTokenConfig.tokenId
),
config.tokens[newTokenConfig.tokenId] !== undefined,
}
);

Expand All @@ -92,7 +92,7 @@ export async function listSquidToken() {
process.cwd(),
"images",
"tokens",
`${newTokenConfig.symbol.toLowerCase()}.svg`
`${newTokenConfig.prettySymbol.toLowerCase()}.svg`
);
const tokenIconContent = await fs.readFile(
path.resolve(process.cwd(), "images", "tokens", "axl.svg"),
Expand All @@ -115,69 +115,95 @@ export async function listSquidToken() {
const tokenListPath = path.resolve(process.cwd(), ...relativePath);

await spinner("Creating PR...", async () => {
await $`git checkout -b feat/add-${newTokenConfig.symbol}-token`;
await $`git checkout -b feat/add-${newTokenConfig.prettySymbol}-token`;
await $`git add ${tokenListPath}`;
await $`git commit -m "feat: add ${newTokenConfig.symbol} token"`;
await $`git commit -m "feat: add ${newTokenConfig.prettySymbol} token"`;
await $`git push -u origin HEAD`;
});
}

export type InterchainTokenInfo = {
tokenId: string;
tokenAddress: string;
tokenManagerAddress: string;
tokenManagerType: string;
isOriginToken: boolean;
isRegistered: boolean;
chainId: number;
axelarChainId: string;
chainName: string;
wasDeployedByAccount?: boolean;
kind: "canonical" | "standardized";
kind: "canonical" | "interchain" | "customInterchain";
canhtrinh marked this conversation as resolved.
Show resolved Hide resolved
};

export type InterchainTokenSearchResult = InterchainTokenInfo & {
matchingTokens: InterchainTokenInfo[];
};

export type RemoteInterchainToken = {
export type RemoteInterchainTokenApiResponse = {
name: string;
symbol: string;
axelarChainId: string;
tokenAddress: string;
tokenManagerAddress: string;
tokenManagerType: string;
deploymentStatus: string;
deploymentTxHash: string;
};

export type InterchainTokenDetails = {
export type InterchainTokenDetailsApiResponse = {
kind: string;
canhtrinh marked this conversation as resolved.
Show resolved Hide resolved
salt: string;
tokenName: string;
tokenSymbol: string;
tokenDecimals: number;
tokenAddress: string;
tokenManagerAddress: string;
canhtrinh marked this conversation as resolved.
Show resolved Hide resolved
tokenManagerType: string;
originalMinterAddress: string;
canhtrinh marked this conversation as resolved.
Show resolved Hide resolved
axelarChainId: string;
tokenId: string;
deploymentTxHash: string;
deployerAddress: string;
remoteTokens: RemoteInterchainToken[];
deploymentMessageId: string;
deployer: string;
remoteTokens: RemoteInterchainTokenApiResponse[];
canhtrinh marked this conversation as resolved.
Show resolved Hide resolved
};

function parseAsInterchainTokenConfig(
data: InterchainTokenDetails
data: InterchainTokenDetailsApiResponse
): InterchainTokenConfig {
return {
tokenId: hash.parse(data.tokenId),
tokenAddress: address.parse(data.tokenAddress),
symbol: data.tokenSymbol,
deployer: data.deployer,
originalMinter: data.originalMinterAddress,
prettySymbol: data.tokenSymbol,
decimals: data.tokenDecimals,
name: data.tokenName,
originAxelarChainId: data.axelarChainId,
transferType: data.kind,
tokenType: data.kind,
deploySalt: data.salt,
iconUrls: {
svg: `${BASE_REPO_URL}/images/tokens/${data.tokenSymbol.toLowerCase()}.svg`,
},
remoteTokens: data.remoteTokens.map((token) => ({
axelarChainId: token.axelarChainId,
tokenAddress: address.parse(token.tokenAddress),
})),
deploymentTxHash: data.deploymentMessageId?.split("-")[0] ?? "",
canhtrinh marked this conversation as resolved.
Show resolved Hide resolved
chains: [
...[
{
symbol: data.tokenSymbol,
name: data.tokenName,
axelarChainId: data.axelarChainId,
tokenAddress: address.parse(data.tokenAddress),
tokenManager: address.parse(data.tokenManagerAddress),
tokenManagerType: convertToCamelCase(data.tokenManagerType),
},
],
...data.remoteTokens.map((token) => ({
symbol: data.tokenSymbol,
name: data.tokenName,
axelarChainId: token.axelarChainId,
tokenAddress: address.parse(token.tokenAddress),
tokenManager: address.parse(token.tokenManagerAddress),
tokenManagerType: convertToCamelCase(token.tokenManagerType),
})),
],
};
}

Expand All @@ -186,3 +212,7 @@ function getEnvironmentFromUrl(tokenDetailsUrl: string) {
? "mainnet"
: "testnet";
}

function convertToCamelCase(input: string) {
return convertCase("CONSTANT_CASE", "camelCase")(input ?? "unknown");
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@inquirer/prompts": "^3.2.0"
},
"devDependencies": {
"@axelarjs/utils": "^0.1.12",
"@types/prettier": "^2.7.3",
"bun-types": "^0.8.1",
"chalk": "^5.3.0",
Expand Down
Loading