From 063273fe7e69ac6c08514144d53edaa28585324d Mon Sep 17 00:00:00 2001 From: ALPAC-4 <81249838+ALPAC-4@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:07:30 +0900 Subject: [PATCH 1/2] fix: allow url that is not in main branch (#21) --- _package/package.json | 2 +- _package/src/zods/Chain.ts | 8 ++++---- chain.schema.json | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/_package/package.json b/_package/package.json index 06686c1..393d765 100644 --- a/_package/package.json +++ b/_package/package.json @@ -1,6 +1,6 @@ { "name": "@initia/initia-registry-types", - "version": "0.0.7", + "version": "0.0.8", "description": "The package provides TypeScript type definitions and Zod integration for initia-registry.", "types": "./dist/types/index.d.ts", "exports": { diff --git a/_package/src/zods/Chain.ts b/_package/src/zods/Chain.ts index 9c93b20..51867d9 100644 --- a/_package/src/zods/Chain.ts +++ b/_package/src/zods/Chain.ts @@ -266,7 +266,7 @@ export const ChainSchema = z .string() .regex( new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.png$" + "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" ) ) .optional(), @@ -274,7 +274,7 @@ export const ChainSchema = z .string() .regex( new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.svg$" + "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" ) ) .optional(), @@ -312,7 +312,7 @@ export const ChainSchema = z .string() .regex( new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.png$" + "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" ) ) .optional(), @@ -320,7 +320,7 @@ export const ChainSchema = z .string() .regex( new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.svg$" + "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" ) ) .optional(), diff --git a/chain.schema.json b/chain.schema.json index 8317000..963cb29 100644 --- a/chain.schema.json +++ b/chain.schema.json @@ -425,12 +425,12 @@ "png": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.png$" + "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" }, "svg": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.svg$" + "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" }, "theme": { "type": "object", @@ -486,12 +486,12 @@ "png": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.png$" + "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" }, "svg": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/main/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.svg$" + "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" } }, "additionalProperties": false From 394643edca63476b22a0f12e867bb994c8168f7a Mon Sep 17 00:00:00 2001 From: ALPAC-4 <81249838+ALPAC-4@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:25:53 +0900 Subject: [PATCH 2/2] fix: remove old type of ibc channels (#22) * fix: remove old type of ibc channels * fix: remove channels for merge --- _package/package.json | 2 +- _package/src/types/Chain.ts | 20 +++------- _package/src/zods/Chain.ts | 56 +++++--------------------- chain.schema.json | 78 +++++++++++-------------------------- devnets/mahalo/chain.json | 13 +------ devnets/minimove/chain.json | 13 +------ devnets/miniwasm/chain.json | 22 ++--------- 7 files changed, 47 insertions(+), 157 deletions(-) diff --git a/_package/package.json b/_package/package.json index 393d765..8dd4b2a 100644 --- a/_package/package.json +++ b/_package/package.json @@ -1,6 +1,6 @@ { "name": "@initia/initia-registry-types", - "version": "0.0.8", + "version": "0.0.9", "description": "The package provides TypeScript type definitions and Zod integration for initia-registry.", "types": "./dist/types/index.d.ts", "exports": { diff --git a/_package/src/types/Chain.ts b/_package/src/types/Chain.ts index 3378a0f..118e801 100644 --- a/_package/src/types/Chain.ts +++ b/_package/src/types/Chain.ts @@ -226,20 +226,12 @@ export interface Chain { /** * [Optional] The list of IBC channels that are supported by the chain. */ - ibc_channels?: - | { - chain_id: string; - port_id: string; - channel_id: string; - version: string; - }[] - | { - channel?: { - chain_id: string; - transfer?: string; - "nft-transfer"?: string; - }[]; - }; + ibc_channels?: { + chain_id: string; + port_id: string; + channel_id: string; + version: string; + }[]; /** * URL pointing to the asset list, which provides metadata associated with Cosmos denoms. */ diff --git a/_package/src/zods/Chain.ts b/_package/src/zods/Chain.ts index 51867d9..8d6ef21 100644 --- a/_package/src/zods/Chain.ts +++ b/_package/src/zods/Chain.ts @@ -496,52 +496,16 @@ export const ChainSchema = z ) .optional(), ibc_channels: z - .any() - .superRefine((x, ctx) => { - const schemas = [ - z.array( - z - .object({ - chain_id: z.string(), - port_id: z.string(), - channel_id: z.string(), - version: z.string(), - }) - .strict() - ), - z - .object({ - channel: z - .array( - z - .object({ - chain_id: z.string(), - transfer: z.string().optional(), - "nft-transfer": z.string().optional(), - }) - .strict() - ) - .optional(), - }) - .strict(), - ]; - const errors = schemas.reduce( - (errors: z.ZodError[], schema) => - ((result) => - "error" in result ? [...errors, result.error] : errors)( - schema.safeParse(x) - ), - [] - ); - if (schemas.length - errors.length !== 1) { - ctx.addIssue({ - path: ctx.path, - code: "invalid_union", - unionErrors: errors, - message: "Invalid input: Should pass single schema", - }); - } - }) + .array( + z + .object({ + chain_id: z.string(), + port_id: z.string(), + channel_id: z.string(), + version: z.string(), + }) + .strict() + ) .describe( "[Optional] The list of IBC channels that are supported by the chain." ) diff --git a/chain.schema.json b/chain.schema.json index 963cb29..a8eb022 100644 --- a/chain.schema.json +++ b/chain.schema.json @@ -639,63 +639,31 @@ "description": "[Optional] A list specifying coin amounts by denomination that exempt users from transaction fees when their balance meets or exceeds these amounts." }, "ibc_channels": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "object", - "required": [ - "chain_id", - "port_id", - "channel_id", - "version" - ], - "properties": { - "chain_id": { - "type": "string" - }, - "port_id": { - "type": "string" - }, - "channel_id": { - "type": "string" - }, - "version": { - "type": "string" - } - }, - "additionalProperties": false + "type": "array", + "items": { + "type": "object", + "required": [ + "chain_id", + "port_id", + "channel_id", + "version" + ], + "properties": { + "chain_id": { + "type": "string" }, - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "channel": { - "type": "array", - "items": { - "type": "object", - "required": [ - "chain_id" - ], - "properties": { - "chain_id": { - "type": "string" - }, - "transfer": { - "type": "string" - }, - "nft-transfer": { - "type": "string" - } - }, - "additionalProperties": false - } - } + "port_id": { + "type": "string" }, - "additionalProperties": false - } - ], + "channel_id": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false + }, "description": "[Optional] The list of IBC channels that are supported by the chain." }, "assetlist": { diff --git a/devnets/mahalo/chain.json b/devnets/mahalo/chain.json index 04bdc57..5076511 100644 --- a/devnets/mahalo/chain.json +++ b/devnets/mahalo/chain.json @@ -142,18 +142,7 @@ }, "metadata": { "is_l1": true, - "ibc_channels": { - "channel": [ - { - "chain_id": "minimove-1", - "transfer": "channel-0" - }, - { - "chain_id": "miniwasm-1", - "transfer": "channel-1" - } - ] - }, + "ibc_channels": [], "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/main/devnets/mahalo/assetlist.json" } } diff --git a/devnets/minimove/chain.json b/devnets/minimove/chain.json index 60eff60..298eb6e 100644 --- a/devnets/minimove/chain.json +++ b/devnets/minimove/chain.json @@ -128,17 +128,8 @@ "metadata": { "op_bridge_id": "1", "creator": "0x723e7894466de983976cc54302f9c436b3291106", - "op_denoms": [ - "uinit" - ], - "ibc_channels": { - "channel": [ - { - "chain_id": "mahalo-1", - "transfer": "channel-0" - } - ] - }, + "op_denoms": ["uinit"], + "ibc_channels": [], "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/main/devnets/minimove/assetlist.json" } } diff --git a/devnets/miniwasm/chain.json b/devnets/miniwasm/chain.json index 14793e2..7341721 100644 --- a/devnets/miniwasm/chain.json +++ b/devnets/miniwasm/chain.json @@ -9,9 +9,7 @@ "bech32_prefix": "init", "daemon_name": "minitiad", "node_home": "$HOME/.minitia", - "key_algos": [ - "secp256k1" - ], + "key_algos": ["secp256k1"], "slip44": 118, "fees": { "fee_tokens": [ @@ -37,10 +35,7 @@ "codebase": { "git_repo": "https://github.com/initia-labs/miniwasm", "recommended_version": "v0.2.0-beta.2", - "compatible_versions": [ - "v0.2.0-beta.2", - "main" - ], + "compatible_versions": ["v0.2.0-beta.2", "main"], "binaries": { "linux/amd64": "https://initia.s3.ap-southeast-1.amazonaws.com/miniwasm-1/miniwasm_v0.2.0-beta.2_Linux_x86_64.tar.gz", "linux/arm64": "https://initia.s3.ap-southeast-1.amazonaws.com/miniwasm-1/miniwasm_v0.2.0-beta.2_Linux_aarch64.tar.gz", @@ -133,17 +128,8 @@ "metadata": { "op_bridge_id": "2", "creator": "0xf324bf4f355abec6d49fdfd0d45419ba99d363d9", - "op_denoms": [ - "uinit" - ], - "ibc_channels": { - "channel": [ - { - "chain_id": "mahalo-1", - "transfer": "channel-0" - } - ] - }, + "op_denoms": ["uinit"], + "ibc_channels": [], "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/main/devnets/miniwasm/assetlist.json" } }