Skip to content

Commit

Permalink
chore: schema cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
canhtrinh committed Feb 4, 2024
1 parent ab42ea3 commit 383635c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 58 deletions.
7 changes: 2 additions & 5 deletions cli/schemas/interchain-tokenlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
50 changes: 23 additions & 27 deletions cli/wizard/commands/list-squid-token/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,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 Down Expand Up @@ -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,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`;
});
}
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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),
})),
],
};
Expand All @@ -220,3 +212,7 @@ function getEnvironmentFromUrl(tokenDetailsUrl: string) {
? "mainnet"
: "testnet";
}

function convertToCamelCase(input: string) {
return convertCase("CONSTANT_CASE", "camelCase")(input ?? "unknown");
}
27 changes: 16 additions & 11 deletions registry/mainnet/interchain/squid.tokenlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
}
]
}
Expand Down
21 changes: 6 additions & 15 deletions registry/schemas/interchain-tokenlist.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,28 @@
"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
},
"interchainToken": {
"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" },
Expand All @@ -75,15 +71,10 @@
},
"required": [
"tokenId",
"tokenAddress",
"tokenManager",
"deployer",
"originalMinter",
"tokenManagerType",
"symbol",
"prettySymbol",
"decimals",
"name",
"originAxelarChainId",
"tokenType",
"iconUrls",
Expand Down

0 comments on commit 383635c

Please sign in to comment.