From 341d1acef1d753afe6636decb34cee719896aea1 Mon Sep 17 00:00:00 2001 From: ALPAC-4 Date: Thu, 28 Mar 2024 14:56:27 +0900 Subject: [PATCH] fix: allow external image uris --- _package/package.json | 2 +- _package/src/zods/AssetList.ts | 24 ++++------------------- _package/src/zods/Chain.ts | 36 ++++------------------------------ assetlist.schema.json | 9 ++++----- chain.schema.json | 9 ++++----- 5 files changed, 17 insertions(+), 63 deletions(-) diff --git a/_package/package.json b/_package/package.json index 0ae5875..8b61305 100644 --- a/_package/package.json +++ b/_package/package.json @@ -1,6 +1,6 @@ { "name": "@initia/initia-registry-types", - "version": "0.0.10", + "version": "0.0.11", "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/AssetList.ts b/_package/src/zods/AssetList.ts index 08b09e0..2da5dc3 100644 --- a/_package/src/zods/AssetList.ts +++ b/_package/src/zods/AssetList.ts @@ -207,19 +207,11 @@ export const AssetListSchema = z .object({ png: z .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" - ) - ) + .regex(new RegExp("^https://.+\\.png$")) .optional(), svg: z .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" - ) - ) + .regex(new RegExp("^https://.+\\.svg$")) .optional(), }) .strict() @@ -249,19 +241,11 @@ export const AssetListSchema = z .optional(), png: z .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" - ) - ) + .regex(new RegExp("^https://.+\\.png$")) .optional(), svg: z .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" - ) - ) + .regex(new RegExp("^https://.+\\.svg$")) .optional(), theme: z .object({ diff --git a/_package/src/zods/Chain.ts b/_package/src/zods/Chain.ts index 8d6ef21..a3c52f3 100644 --- a/_package/src/zods/Chain.ts +++ b/_package/src/zods/Chain.ts @@ -262,22 +262,8 @@ export const ChainSchema = z "The (primary) key used to identify an object within the Chain Registry." ) .optional(), - png: z - .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" - ) - ) - .optional(), - svg: z - .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" - ) - ) - .optional(), + png: z.string().regex(new RegExp("^https://.+\\.png$")).optional(), + svg: z.string().regex(new RegExp("^https://.+\\.svg$")).optional(), theme: z .object({ primary_color_hex: z @@ -308,22 +294,8 @@ export const ChainSchema = z .optional(), logo_URIs: z .object({ - png: z - .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" - ) - ) - .optional(), - svg: z - .string() - .regex( - new RegExp( - "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" - ) - ) - .optional(), + png: z.string().regex(new RegExp("^https://.+\\.png$")).optional(), + svg: z.string().regex(new RegExp("^https://.+\\.svg$")).optional(), }) .strict() .optional(), diff --git a/assetlist.schema.json b/assetlist.schema.json index f711551..0bc678c 100644 --- a/assetlist.schema.json +++ b/assetlist.schema.json @@ -1,5 +1,4 @@ { - "$id": "https://osmosis.zone/assetlists.schema.json", "$schema": "https://json-schema.org/draft-07/schema", "title": "Asset Lists", "description": "Asset lists are a similar mechanism to allow frontends and other UIs to fetch metadata associated with Cosmos SDK denoms, especially for assets sent over IBC.", @@ -106,12 +105,12 @@ "png": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" + "pattern": "^https://.+\\.png$" }, "svg": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" + "pattern": "^https://.+\\.svg$" } }, "additionalProperties": false @@ -127,12 +126,12 @@ "png": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" + "pattern": "^https://.+\\.png$" }, "svg": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" + "pattern": "^https://.+\\.svg$" }, "theme": { "type": "object", diff --git a/chain.schema.json b/chain.schema.json index a8eb022..684c76e 100644 --- a/chain.schema.json +++ b/chain.schema.json @@ -1,5 +1,4 @@ { - "$id": "https://sikka.tech/chain.schema.json", "$schema": "https://json-schema.org/draft-07/schema", "title": "Cosmos Chain", "description": "Cosmos Chain.json is a metadata file that contains information about a cosmos sdk based chain.", @@ -425,12 +424,12 @@ "png": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" + "pattern": "^https://.+\\.png$" }, "svg": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" + "pattern": "^https://.+\\.svg$" }, "theme": { "type": "object", @@ -486,12 +485,12 @@ "png": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.png$" + "pattern": "^https://.+\\.png$" }, "svg": { "type": "string", "format": "uri-reference", - "pattern": "^https://raw\\.githubusercontent\\.com/initia-labs/initia-registry/.+\\.svg$" + "pattern": "^https://.+\\.svg$" } }, "additionalProperties": false