Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove old type of ibc channels #22

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _package/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
20 changes: 6 additions & 14 deletions _package/src/types/Chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
56 changes: 10 additions & 46 deletions _package/src/zods/Chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down
78 changes: 23 additions & 55 deletions chain.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 1 addition & 12 deletions devnets/mahalo/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
13 changes: 2 additions & 11 deletions devnets/minimove/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
22 changes: 4 additions & 18 deletions devnets/miniwasm/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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",
Expand Down Expand Up @@ -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"
}
}
Loading