Skip to content

Commit

Permalink
Neutron warp route configs fixes and tests (#56)
Browse files Browse the repository at this point in the history
### Description

- Fix warp route file names not matching IDs 
- Add missing token def for neutron-manta route
- Remove dupe chain names in warp route IDs
- Add unit test to validate all warp configs

#### Other notes

### Backward compatibility

Yes

### Testing

Added new unit tests
  • Loading branch information
jmrossy authored Jun 12, 2024
1 parent a484456 commit 594b14e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-zoos-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/registry': patch
---

Fixes for some neutron warp route configs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ tokens:
name: TIA.n
standard: EvmHypSynthetic
symbol: TIA.n
- addressOrDenom: neutron1jyyjd3x0jhgswgm6nnctxvzla8ypx50tew3ayxxwkrjfxhvje6kqzvzudq
chainName: neutron
collateralAddressOrDenom: ibc/773B4D0A3CD667B2275D5A4A7A2F0909C0BA0F4059C0B9181E680DDF4965DCC7
decimals: 6
logoURI: /deployments/warp_routes/TIA/logo.svg
name: TIA.
standard: CwHypCollateral
symbol: TIA.n
- addressOrDenom: ibc/773B4D0A3CD667B2275D5A4A7A2F0909C0BA0F4059C0B9181E680DDF4965DCC7
chainName: neutron
decimals: 6
Expand Down
2 changes: 1 addition & 1 deletion deployments/warp_routes/milkTIA/manta-osmosis-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tokens:
- addressOrDenom: "0x32474653127048d9fC20000e21dEd396b47968E8"
chainName: mantapacific
connections:
- token: cosmos|osmosis1|osmo17xuecsykqw2xcxwv8cau7uy4hgdwqt0u4qxflyc2yshhggpazfjs6kfqd3
- token: cosmos|osmosis|osmo17xuecsykqw2xcxwv8cau7uy4hgdwqt0u4qxflyc2yshhggpazfjs6kfqd3
decimals: 6
name: milkTIA.o
standard: EvmHypSynthetic
Expand Down
4 changes: 2 additions & 2 deletions src/registry/warp-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function warpRouteConfigToId(config: WarpCoreConfig): WarpRouteId {
if (!config?.tokens?.length) throw new Error('Cannot generate ID for empty warp config');
const tokenSymbol = config.tokens[0].symbol;
if (!tokenSymbol) throw new Error('Cannot generate warp config ID without a token symbol');
const chains = config.tokens.map((token) => token.chainName);
return createWarpRouteConfigId(tokenSymbol, chains);
const chains = new Set(config.tokens.map((token) => token.chainName));
return createWarpRouteConfigId(tokenSymbol, [...chains.values()]);
}

export function createWarpRouteConfigId(tokenSymbol: string, chains: ChainName[]): WarpRouteId {
Expand Down
21 changes: 21 additions & 0 deletions test/unit/warp-routes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from 'chai';

import { MultiProtocolProvider, WarpCore } from '@hyperlane-xyz/sdk';
import { FileSystemRegistry } from '../../src/registry/FileSystemRegistry.js';

describe('Warp Route Configs', () => {
const localRegistry = new FileSystemRegistry({ uri: './' });
const chainMetadata = localRegistry.getMetadata();
const multiProvider = new MultiProtocolProvider(chainMetadata);
const routes = localRegistry.getWarpRoutes();

for (const id of Object.keys(routes)) {
it(`Route ${id} is valid`, async () => {
const config = routes[id];
// WarpCore will validate the config
const warpCore = WarpCore.FromConfig(multiProvider, config);
expect(warpCore).to.be.an.instanceOf(WarpCore);
expect(warpCore.tokens.length).to.be.greaterThan(0);
});
}
});

0 comments on commit 594b14e

Please sign in to comment.