From f3b7ddb699fda050af7c90bd34ad91c4f6864021 Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Fri, 19 Jan 2024 12:38:47 -0500 Subject: [PATCH] Add optional gRpcUrls field to ChainMetadata schema (#3163) ### Description - Add optional gRpcUrls field to ChainMetadata schema - Enforce inclusion of restUrls and gRpcUrls for cosmos chains - Fix neutron rest url ### Related Issues Fixes https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/3161 ### Backward compatibility Yes ### Testing Unit test --- .changeset/light-coins-walk.md | 5 +++++ typescript/sdk/src/consts/chainMetadata.ts | 3 ++- .../sdk/src/metadata/chainMetadata.test.ts | 2 ++ .../sdk/src/metadata/chainMetadataTypes.ts | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .changeset/light-coins-walk.md diff --git a/.changeset/light-coins-walk.md b/.changeset/light-coins-walk.md new file mode 100644 index 000000000..b9dfd77c5 --- /dev/null +++ b/.changeset/light-coins-walk.md @@ -0,0 +1,5 @@ +--- +'@hyperlane-xyz/sdk': patch +--- + +Add optional grpcUrl field to ChainMetadata diff --git a/typescript/sdk/src/consts/chainMetadata.ts b/typescript/sdk/src/consts/chainMetadata.ts index b76a673a5..00df3f733 100644 --- a/typescript/sdk/src/consts/chainMetadata.ts +++ b/typescript/sdk/src/consts/chainMetadata.ts @@ -601,6 +601,7 @@ export const neutron: ChainMetadata = { chainId: 'neutron-1', displayName: 'Neutron', domainId: 1853125230, + grpcUrls: [{ http: 'grpc-kralum.neutron-1.neutron.org:80' }], isTestnet: false, name: Chains.neutron, nativeToken: { @@ -609,7 +610,7 @@ export const neutron: ChainMetadata = { symbol: 'NTRN', }, protocol: ProtocolType.Cosmos, - restUrls: [{ http: 'grpc-kralum.neutron-1.neutron.org:80' }], + restUrls: [{ http: 'https://rest-lb.neutron.org' }], rpcUrls: [{ http: 'https://rpc-kralum.neutron-1.neutron.org' }], slip44: 118, }; diff --git a/typescript/sdk/src/metadata/chainMetadata.test.ts b/typescript/sdk/src/metadata/chainMetadata.test.ts index 347f3400c..ed0c403fd 100644 --- a/typescript/sdk/src/metadata/chainMetadata.test.ts +++ b/typescript/sdk/src/metadata/chainMetadata.test.ts @@ -60,6 +60,8 @@ describe('ChainMetadataSchema', () => { chainId: 'cosmos', bech32Prefix: 'cosmos', slip44: 118, + restUrls: [], + grpcUrls: [], }), ).to.eq(true); }); diff --git a/typescript/sdk/src/metadata/chainMetadataTypes.ts b/typescript/sdk/src/metadata/chainMetadataTypes.ts index 240174fb0..d8ee61642 100644 --- a/typescript/sdk/src/metadata/chainMetadataTypes.ts +++ b/typescript/sdk/src/metadata/chainMetadataTypes.ts @@ -111,6 +111,10 @@ export const ChainMetadataSchemaObject = z.object({ .array(RpcUrlSchema) .describe('For cosmos chains only, a list of Rest API URLs') .optional(), + grpcUrls: z + .array(RpcUrlSchema) + .describe('For cosmos chains only, a list of gRPC API URLs') + .optional(), blockExplorers: z .array( z.object({ @@ -216,6 +220,20 @@ export const ChainMetadataSchema = ChainMetadataSchemaObject.refine( message: 'Bech32Prefix and Slip44 required for Cosmos chains', path: ['bech32Prefix', 'slip44'], }, + ) + .refine( + (metadata) => { + if ( + metadata.protocol === ProtocolType.Cosmos && + (!metadata.restUrls || !metadata.grpcUrls) + ) + return false; + else return true; + }, + { + message: 'Rest and gRPC URLs required for Cosmos chains', + path: ['restUrls', 'grpcUrls'], + }, ); export type ChainMetadata = z.infer &