Skip to content

Commit 7af7728

Browse files
Xarozclaude
andauthored
feat(sdk): add warpRouteId for token disambiguation in WarpCore (#8335)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b892e61 commit 7af7728

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperlane-xyz/sdk": minor
3+
---
4+
5+
Added optional `warpRouteId` field to TokenConfigSchema for disambiguating tokens that share the same addressOrDenom on the same chain (e.g. M0 Portal tokens). When present, WarpCore.FromConfig uses it during connection resolution to ensure tokens connect only within their own warp route.

typescript/sdk/src/token/IToken.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ export const TokenConfigSchema = z.object({
5252
.optional()
5353
.describe('The CoinGecko id of the token, used for price lookups'),
5454
scale: ZUint.lt(256).optional().describe('The scaling factor of the token'),
55+
warpRouteId: z
56+
.string()
57+
.min(1)
58+
.optional()
59+
.describe(
60+
'Unique warp route identifier, used to disambiguate tokens that share the same addressOrDenom on the same chain (e.g. M0 Portal tokens)',
61+
),
5562
});
5663

5764
export type TokenArgs = Omit<

typescript/sdk/src/warp/WarpCore.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ export class WarpCore {
113113
const { chainName, addressOrDenom } = parseTokenConnectionId(
114114
connection.token,
115115
);
116+
// If token1 has a warpRouteId, token2 must share it — disambiguates
117+
// tokens at the same address (e.g. M0 Portal: mUSD, wM, USDSC)
116118
const token2 = tokens.find(
117119
(t) =>
118-
t.chainName === chainName && t.addressOrDenom === addressOrDenom,
120+
t.chainName === chainName &&
121+
t.addressOrDenom === addressOrDenom &&
122+
(!token1.warpRouteId || t.warpRouteId === token1.warpRouteId),
119123
);
120124
assert(
121125
token2,

0 commit comments

Comments
 (0)