diff --git a/cli/schemas/interchain-tokenlist.ts b/cli/schemas/interchain-tokenlist.ts index 0d4afd5..47c6ecf 100644 --- a/cli/schemas/interchain-tokenlist.ts +++ b/cli/schemas/interchain-tokenlist.ts @@ -6,30 +6,34 @@ export const IconUrlsSchema = z.object({ }); export const remoteToken = z.object({ - chain_id: z.string(), - axelar_chain_id: z.string(), - token_address: address, + chainId: z.string(), + axelarChainId: z.string(), + tokenAddress: address, }); export const interchainToken = z.object({ - token_id: hash, - token_address: address, + tokenId: hash, + tokenAddress: address, symbol: z.string(), - pretty_symbol: z.string(), + prettySymbol: z.string(), decimals: z.number().int(), name: z.string(), - origin_chain_id: z.string(), - origin_axelar_chain_id: z.string(), - transfer_type: z.string(), + originChainId: z.string(), + originAxelarChainId: z.string(), + transferType: z.string(), iconUrls: IconUrlsSchema, - remote_tokens: z.array(remoteToken), + remoteTokens: z.array(remoteToken), }); const interchainTokenList = z.object({ $schema: z .string() .regex(/^(?:\.\.\/)+schemas\/interchain-tokenlist\.schema\.json$/), - version: z.string(), + version: z.object({ + major: z.number().int(), + minor: z.number().int(), + patch: z.number().int(), + }), items: z.array(interchainToken), }); diff --git a/registry/mainnet/interchain/squid.tokenlist.json b/registry/mainnet/interchain/squid.tokenlist.json new file mode 100644 index 0000000..3c106aa --- /dev/null +++ b/registry/mainnet/interchain/squid.tokenlist.json @@ -0,0 +1,71 @@ +{ + "$schema": "../../schemas/interchain-tokenlist.schema.json", + "version": { + "major": 0, + "minor": 1, + "patch": 0 + }, + "items": [ + { + "tokenId": "0x42cf40c325b764af70ce0cef78ab550b212cb66a812e442e425630523b303785", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975", + "symbol": "tSUSHI", + "prettySymbol": "tSUSHI", + "decimals": 18, + "name": "Testnet Sushi Token", + "originChainId": "5", + "originAxelarChainId": "ethereum-2", + "transferType": "interchain_token", + "iconUrls": { + "svg": "https://raw.githubusercontent.com/axelarnetwork/public-chain-configs/images/tokens/sushi.svg" + }, + "remoteTokens": [ + { + "chainId": "80001", + "axelarChainId": "polygon", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "43113", + "axelarChainId": "avalance", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "97", + "axelarChainId": "binance", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "4002", + "axelarChainId": "fantom", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "1287", + "axelarChainId": "moonbeam", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "421613", + "axelarChainId": "arbitrum", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "84531", + "axelarChainId": "base", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "2221", + "axelarChainId": "kava", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "44787", + "axelarChainId": "celo", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + } + ] + } + ] +} diff --git a/registry/mainnet/interchain_tokens/squid.json b/registry/mainnet/interchain_tokens/squid.json deleted file mode 100644 index 023ffec..0000000 --- a/registry/mainnet/interchain_tokens/squid.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "$schema": "../../schemas/interchain-tokenlist.schema.json", - "items": [ - { - "token_id": "0x42cf40c325b764af70ce0cef78ab550b212cb66a812e442e425630523b303785", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975", - "symbol": "tSUSHI", - "pretty_symbol": "tSUSHI", - "decimals": 18, - "name": "Testnet Sushi Token", - "origin_chain_id": "5", - "origin_axelar_chain_id": "ethereum-2", - "transfer_type": "interchain_token", - "iconUrls": { - "svg": "https://raw.githubusercontent.com/axelarnetwork/public-chain-configs/images/tokens/sushi.svg" - }, - "remote_tokens": [ - { - "chain_id": "80001", - "axelar_chain_id": "polygon", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "43113", - "axelar_chain_id": "avalance", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "97", - "axelar_chain_id": "binance", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "4002", - "axelar_chain_id": "fantom", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "1287", - "axelar_chain_id": "moonbeam", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "421613", - "axelar_chain_id": "arbitrum", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "84531", - "axelar_chain_id": "base", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "2221", - "axelar_chain_id": "kava", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "44787", - "axelar_chain_id": "celo", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - } - ] - } - ] -} diff --git a/registry/schemas/interchain-tokenlist.schema.json b/registry/schemas/interchain-tokenlist.schema.json index 87d56f8..648721e 100644 --- a/registry/schemas/interchain-tokenlist.schema.json +++ b/registry/schemas/interchain-tokenlist.schema.json @@ -7,7 +7,16 @@ "type": "string", "pattern": "^(?:\\.\\.\\/)+schemas\\/interchain-tokenlist\\.schema\\.json$" }, - "version": { "type": "string" }, + "version": { + "type": "object", + "properties": { + "major": { "type": "integer" }, + "minor": { "type": "integer" }, + "patch": { "type": "integer" } + }, + "required": ["major", "minor", "patch"], + "additionalProperties": false + }, "items": { "type": "array", "items": { "$ref": "#/definitions/interchainToken" } @@ -25,46 +34,46 @@ "interchainToken": { "type": "object", "properties": { - "token_id": { "type": "string", "pattern": "^0x[a-fA-F0-9]{64}$" }, - "token_address": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" }, + "tokenId": { "type": "string", "pattern": "^0x[a-fA-F0-9]{64}$" }, + "tokenAddress": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" }, "symbol": { "type": "string" }, - "pretty_symbol": { "type": "string" }, + "prettySymbol": { "type": "string" }, "decimals": { "type": "integer" }, "name": { "type": "string" }, - "origin_chain_id": { "type": "string" }, - "origin_axelar_chain_id": { "type": "string" }, - "transfer_type": { "type": "string" }, + "originChainId": { "type": "string" }, + "originAxelarChainId": { "type": "string" }, + "transferType": { "type": "string" }, "iconUrls": { "$ref": "#/definitions/IconUrlsSchema" }, - "remote_tokens": { + "remoteTokens": { "type": "array", "items": { "$ref": "#/definitions/remoteToken" } } }, "required": [ - "token_id", - "token_address", + "tokenId", + "tokenAddress", "symbol", - "pretty_symbol", + "prettySymbol", "decimals", "name", - "origin_chain_id", - "origin_axelar_chain_id", - "transfer_type", + "originChainId", + "originAxelarChainId", + "transferType", "iconUrls", - "remote_tokens" + "remoteTokens" ], "additionalProperties": false }, "remoteToken": { "type": "object", "properties": { - "chain_id": { "type": "string" }, - "axelar_chain_id": { "type": "string" }, - "token_address": { - "$ref": "#/definitions/interchainToken/properties/token_address" + "chainId": { "type": "string" }, + "axelarChainId": { "type": "string" }, + "tokenAddress": { + "$ref": "#/definitions/interchainToken/properties/tokenAddress" } }, - "required": ["chain_id", "axelar_chain_id", "token_address"], + "required": ["chainId", "axelarChainId", "tokenAddress"], "additionalProperties": false } } diff --git a/registry/testnet/interchain/squid.tokenlist.json b/registry/testnet/interchain/squid.tokenlist.json new file mode 100644 index 0000000..3c106aa --- /dev/null +++ b/registry/testnet/interchain/squid.tokenlist.json @@ -0,0 +1,71 @@ +{ + "$schema": "../../schemas/interchain-tokenlist.schema.json", + "version": { + "major": 0, + "minor": 1, + "patch": 0 + }, + "items": [ + { + "tokenId": "0x42cf40c325b764af70ce0cef78ab550b212cb66a812e442e425630523b303785", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975", + "symbol": "tSUSHI", + "prettySymbol": "tSUSHI", + "decimals": 18, + "name": "Testnet Sushi Token", + "originChainId": "5", + "originAxelarChainId": "ethereum-2", + "transferType": "interchain_token", + "iconUrls": { + "svg": "https://raw.githubusercontent.com/axelarnetwork/public-chain-configs/images/tokens/sushi.svg" + }, + "remoteTokens": [ + { + "chainId": "80001", + "axelarChainId": "polygon", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "43113", + "axelarChainId": "avalance", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "97", + "axelarChainId": "binance", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "4002", + "axelarChainId": "fantom", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "1287", + "axelarChainId": "moonbeam", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "421613", + "axelarChainId": "arbitrum", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "84531", + "axelarChainId": "base", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "2221", + "axelarChainId": "kava", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + }, + { + "chainId": "44787", + "axelarChainId": "celo", + "tokenAddress": "0xD772a13cf187272e2A914aD90e06c47990014975" + } + ] + } + ] +} diff --git a/registry/testnet/interchain_tokens/squid.json b/registry/testnet/interchain_tokens/squid.json deleted file mode 100644 index 97a2451..0000000 --- a/registry/testnet/interchain_tokens/squid.json +++ /dev/null @@ -1,63 +0,0 @@ -[ - { - "token_id": "0x42cf40c325b764af70ce0cef78ab550b212cb66a812e442e425630523b303785", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975", - "symbol": "tSUSHI", - "pretty_symbol": "tSUSHI", - "decimals": 18, - "name": "Testnet Sushi Token", - "origin_chain_id": "5", - "origin_axelar_chain_id": "ethereum-2", - "transfer_type": "interchain_token", - "iconUrls": { - "svg": "https://raw.githubusercontent.com/axelarnetwork/public-chain-configs/images/tokens/sushi.svg" - }, - "remote_tokens": [ - { - "chain_id": "80001", - "axelar_chain_id": "polygon", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "43113", - "axelar_chain_id": "avalance", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "97", - "axelar_chain_id": "binance", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "4002", - "axelar_chain_id": "fantom", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "1287", - "axelar_chain_id": "moonbeam", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "421613", - "axelar_chain_id": "arbitrum", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "84531", - "axelar_chain_id": "base", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "2221", - "axelar_chain_id": "kava", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - }, - { - "chain_id": "44787", - "axelar_chain_id": "celo", - "token_address": "0xD772a13cf187272e2A914aD90e06c47990014975" - } - ] - } -] diff --git a/specs/interchain.spec.ts b/specs/interchain.spec.ts new file mode 100644 index 0000000..9bb5776 --- /dev/null +++ b/specs/interchain.spec.ts @@ -0,0 +1,24 @@ +import { test, describe, expect } from "vitest"; +import { globby } from "zx"; +import { validate } from "jsonschema"; + +const files = await globby("registry/**/interchain/*tokenlist.json"); +const schema = await import( + "../registry/schemas/interchain-tokenlist.schema.json" +); + +describe("InterchainTokenList Configs", async () => { + for (const file of files) { + test(`${file} should match the schema`, async () => { + const { default: config } = await import(`../${file}`); + + const result = validate(config, schema); + + if (!result.valid) { + console.log({ errors: result.errors }); + } + + expect(result.valid).toBe(true); + }); + } +});