From 383635c19757ee424520e8c271c3e7803a8a75b6 Mon Sep 17 00:00:00 2001 From: Canh Trinh Date: Sat, 3 Feb 2024 23:10:18 -0500 Subject: [PATCH] chore: schema cleanup --- cli/schemas/interchain-tokenlist.ts | 7 +-- cli/wizard/commands/list-squid-token/index.ts | 50 +++++++++---------- .../mainnet/interchain/squid.tokenlist.json | 27 ++++++---- .../schemas/interchain-tokenlist.schema.json | 21 +++----- 4 files changed, 47 insertions(+), 58 deletions(-) diff --git a/cli/schemas/interchain-tokenlist.ts b/cli/schemas/interchain-tokenlist.ts index 21ccfc7..cd88705 100644 --- a/cli/schemas/interchain-tokenlist.ts +++ b/cli/schemas/interchain-tokenlist.ts @@ -10,19 +10,16 @@ export const chains = z.object({ tokenAddress: address, tokenManager: address, tokenManagerType: z.string(), + symbol: z.string(), + name: z.string(), }); export const interchainToken = z.object({ tokenId: hash, - tokenAddress: address, - tokenManager: address, deployer: address, originalMinter: address, - tokenManagerType: z.string(), - symbol: z.string(), prettySymbol: z.string(), decimals: z.number().int(), - name: z.string(), originAxelarChainId: z.string(), tokenType: z.string(), iconUrls: IconUrlsSchema, diff --git a/cli/wizard/commands/list-squid-token/index.ts b/cli/wizard/commands/list-squid-token/index.ts index 8837131..00dfc9a 100644 --- a/cli/wizard/commands/list-squid-token/index.ts +++ b/cli/wizard/commands/list-squid-token/index.ts @@ -58,7 +58,7 @@ export async function listSquidToken() { () => fetch(detailsApiUrl) .then((res) => res.json()) - .catch(() => ({})) as Promise + .catch(() => ({})) as Promise ); const newTokenConfig = parseAsInterchainTokenConfig(tokenDetails); @@ -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"), @@ -115,9 +115,9 @@ 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`; }); } @@ -133,23 +133,25 @@ export type InterchainTokenInfo = { axelarChainId: string; chainName: string; wasDeployedByAccount?: boolean; - kind: "canonical" | "standardized"; + kind: "canonical" | "interchain" | "customInterchain"; }; export type InterchainTokenSearchResult = InterchainTokenInfo & { matchingTokens: InterchainTokenInfo[]; }; -export type RemoteInterchainToken = { +export type RemoteInterchainTokenApiResponse = { + name: string; + symbol: string; axelarChainId: string; tokenAddress: string; - tokenManager: string; + tokenManagerAddress: string; tokenManagerType: string; deploymentStatus: string; deploymentTxHash: string; }; -export type InterchainTokenDetails = { +export type InterchainTokenDetailsApiResponse = { kind: string; salt: string; tokenName: string; @@ -163,26 +165,18 @@ export type InterchainTokenDetails = { tokenId: string; deploymentMessageId: string; deployer: string; - remoteTokens: RemoteInterchainToken[]; + remoteTokens: RemoteInterchainTokenApiResponse[]; }; function parseAsInterchainTokenConfig( - data: InterchainTokenDetails + data: InterchainTokenDetailsApiResponse ): InterchainTokenConfig { return { tokenId: hash.parse(data.tokenId), - tokenAddress: address.parse(data.tokenAddress), - tokenManager: address.parse(data.tokenManagerAddress), - tokenManagerType: convertCase( - "CONSTANT_CASE", - "camelCase" - )(data.tokenManagerType), deployer: data.deployer, originalMinter: data.originalMinterAddress, - symbol: data.tokenSymbol, prettySymbol: data.tokenSymbol, decimals: data.tokenDecimals, - name: data.tokenName, originAxelarChainId: data.axelarChainId, tokenType: data.kind, deploySalt: data.salt, @@ -193,23 +187,21 @@ function parseAsInterchainTokenConfig( chains: [ ...[ { + symbol: data.tokenSymbol, + name: data.tokenName, axelarChainId: data.axelarChainId, tokenAddress: address.parse(data.tokenAddress), tokenManager: address.parse(data.tokenManagerAddress), - tokenManagerType: convertCase( - "CONSTANT_CASE", - "camelCase" - )(data.tokenManagerType), + 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.tokenManager), - tokenManagerType: convertCase( - "CONSTANT_CASE", - "camelCase" - )(token.tokenManagerType), + tokenManager: address.parse(token.tokenManagerAddress), + tokenManagerType: convertToCamelCase(token.tokenManagerType), })), ], }; @@ -220,3 +212,7 @@ function getEnvironmentFromUrl(tokenDetailsUrl: string) { ? "mainnet" : "testnet"; } + +function convertToCamelCase(input: string) { + return convertCase("CONSTANT_CASE", "camelCase")(input ?? "unknown"); +} diff --git a/registry/mainnet/interchain/squid.tokenlist.json b/registry/mainnet/interchain/squid.tokenlist.json index 6b6ed4d..a2c1e18 100644 --- a/registry/mainnet/interchain/squid.tokenlist.json +++ b/registry/mainnet/interchain/squid.tokenlist.json @@ -9,15 +9,10 @@ "tokens": { "0xb689de707e78469c6a115fdcfd9a0c2db9f8e7ce5ade7b29526d63f4e01d77fb": { "tokenId": "0xb689de707e78469c6a115fdcfd9a0c2db9f8e7ce5ade7b29526d63f4e01d77fb", - "tokenAddress": "0x524d524B4c9366be706D3A90dcf70076ca037aE3", - "tokenManager": "0x5F53895484af488e27fd33CE70a3dbD745aeAA52", - "tokenManagerType": "mintBurn", - "symbol": "RMRK", "prettySymbol": "RMRK", "decimals": 18, - "name": "RMRK", "originAxelarChainId": "moonbeam", - "tokenType": "interchain", + "tokenType": "customInterchain", "iconUrls": { "svg": "https://raw.githubusercontent.com/axelarnetwork/axelar-configs/main/images/tokens/rmrk.svg" }, @@ -30,31 +25,41 @@ "axelarChainId": "moonbeam", "tokenAddress": "0x524d524B4c9366be706D3A90dcf70076ca037aE3", "tokenManager": "0x5F53895484af488e27fd33CE70a3dbD745aeAA52", - "tokenManagerType": "mintBurn" + "tokenManagerType": "mintBurn", + "symbol": "RMRK", + "name": "RMRK" }, { "axelarChainId": "polygon", "tokenAddress": "0x524d524B4c9366be706D3A90dcf70076ca037aE3", "tokenManager": "0x5F53895484af488e27fd33CE70a3dbD745aeAA52", - "tokenManagerType": "mintBurn" + "tokenManagerType": "mintBurn", + "symbol": "RMRK", + "name": "RMRK" }, { "axelarChainId": "ethereum", "tokenAddress": "0x524d524B4c9366be706D3A90dcf70076ca037aE3", "tokenManager": "0x5F53895484af488e27fd33CE70a3dbD745aeAA52", - "tokenManagerType": "mintBurn" + "tokenManagerType": "mintBurn", + "symbol": "RMRK", + "name": "RMRK" }, { "axelarChainId": "base", "tokenAddress": "0x524d524B4c9366be706D3A90dcf70076ca037aE3", "tokenManager": "0x5F53895484af488e27fd33CE70a3dbD745aeAA52", - "tokenManagerType": "mintBurn" + "tokenManagerType": "mintBurn", + "symbol": "RMRK", + "name": "RMRK" }, { "axelarChainId": "binance", "tokenAddress": "0x524d524B4c9366be706D3A90dcf70076ca037aE3", "tokenManager": "0x5F53895484af488e27fd33CE70a3dbD745aeAA52", - "tokenManagerType": "mintBurn" + "tokenManagerType": "mintBurn", + "symbol": "RMRK", + "name": "RMRK" } ] } diff --git a/registry/schemas/interchain-tokenlist.schema.json b/registry/schemas/interchain-tokenlist.schema.json index be572fb..99927b9 100644 --- a/registry/schemas/interchain-tokenlist.schema.json +++ b/registry/schemas/interchain-tokenlist.schema.json @@ -31,13 +31,17 @@ "tokenManager": { "$ref": "#/definitions/chains/properties/tokenAddress" }, - "tokenManagerType": { "type": "string" } + "tokenManagerType": { "type": "string" }, + "name": { "type": "string" }, + "symbol": { "type": "string" } }, "required": [ "axelarChainId", "tokenAddress", "tokenManager", - "tokenManagerType" + "tokenManagerType", + "name", + "symbol" ], "additionalProperties": false }, @@ -45,18 +49,10 @@ "type": "object", "properties": { "tokenId": { "type": "string", "pattern": "^0x[a-fA-F0-9]{64}$" }, - "tokenAddress": { - "$ref": "#/definitions/chains/properties/tokenAddress" - }, - "tokenManager": { - "$ref": "#/definitions/chains/properties/tokenAddress" - }, "deployer": { "$ref": "#/definitions/chains/properties/tokenAddress" }, "originalMinter": { "$ref": "#/definitions/chains/properties/tokenAddress" }, - "tokenManagerType": { "type": "string" }, - "symbol": { "type": "string" }, "prettySymbol": { "type": "string" }, "decimals": { "type": "integer" }, "name": { "type": "string" }, @@ -75,15 +71,10 @@ }, "required": [ "tokenId", - "tokenAddress", - "tokenManager", "deployer", "originalMinter", - "tokenManagerType", - "symbol", "prettySymbol", "decimals", - "name", "originAxelarChainId", "tokenType", "iconUrls",