diff --git a/_package/package.json b/_package/package.json index 06686c1..8dd4b2a 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.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 9c93b20..8d6ef21 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(), @@ -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 cc37c7f..8ec1b2d 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/mahalo-2/(|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/mahalo-2/(|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/mahalo-2/(|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/mahalo-2/(|testnets/|devnets/)[a-z0-9]+/images/.+\\.svg$" + "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" } }, "additionalProperties": false @@ -643,7 +643,10 @@ "items": { "type": "object", "required": [ - "chain_id" + "chain_id", + "port_id", + "channel_id", + "version" ], "properties": { "chain_id": { diff --git a/devnets/mahalo/chain.json b/devnets/mahalo/chain.json index 68c8356..3fed870 100644 --- a/devnets/mahalo/chain.json +++ b/devnets/mahalo/chain.json @@ -147,6 +147,6 @@ "version": "ics721-1" } ], - "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/mahalo-2/devnets/mahalo/assetlist.json" + "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 36f5eaa..448745f 100644 --- a/devnets/minimove/chain.json +++ b/devnets/minimove/chain.json @@ -122,6 +122,6 @@ "version": "ics721-1" } ], - "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/mahalo-2/devnets/minimove/assetlist.json" + "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/mahalo-2/main/minimove/assetlist.json" } } \ No newline at end of file diff --git a/devnets/miniwasm/chain.json b/devnets/miniwasm/chain.json index c9fe61b..7dda816 100644 --- a/devnets/miniwasm/chain.json +++ b/devnets/miniwasm/chain.json @@ -122,6 +122,6 @@ "version": "ics721-1" } ], - "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/mahalo-2/devnets/miniwasm/assetlist.json" + "assetlist": "https://raw.githubusercontent.com/initia-labs/initia-registry/main/devnets/miniwasm/assetlist.json" } }