Skip to content

Commit

Permalink
Merge branch 'main' into mahalo-2
Browse files Browse the repository at this point in the history
  • Loading branch information
ALPAC-4 authored Mar 27, 2024
2 parents 7e1f38b + 394643e commit caee683
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 73 deletions.
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.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": {
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
64 changes: 14 additions & 50 deletions _package/src/zods/Chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ 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(),
svg: 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(),
Expand Down Expand Up @@ -312,15 +312,15 @@ 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(),
svg: 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(),
Expand Down 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
13 changes: 8 additions & 5 deletions chain.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -643,7 +643,10 @@
"items": {
"type": "object",
"required": [
"chain_id"
"chain_id",
"port_id",
"channel_id",
"version"
],
"properties": {
"chain_id": {
Expand Down
2 changes: 1 addition & 1 deletion devnets/mahalo/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion devnets/minimove/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion devnets/miniwasm/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit caee683

Please sign in to comment.