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
trevor/port-over-addtl-igp-cmds
J M Rossy 10 months ago committed by GitHub
parent 78e50e7da4
commit f3b7ddb699
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/light-coins-walk.md
  2. 3
      typescript/sdk/src/consts/chainMetadata.ts
  3. 2
      typescript/sdk/src/metadata/chainMetadata.test.ts
  4. 18
      typescript/sdk/src/metadata/chainMetadataTypes.ts

@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': patch
---
Add optional grpcUrl field to ChainMetadata

@ -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,
};

@ -60,6 +60,8 @@ describe('ChainMetadataSchema', () => {
chainId: 'cosmos',
bech32Prefix: 'cosmos',
slip44: 118,
restUrls: [],
grpcUrls: [],
}),
).to.eq(true);
});

@ -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<Ext = object> = z.infer<typeof ChainMetadataSchema> &

Loading…
Cancel
Save