fix: sort cosmwasm funds by denom (#4385)

### Description
CosmWasm `ExecuteContract` message require that the attached `funds`
attached are sorted by denom
([ref](1d0c66c4cf/x/wasm/types/tx.go (L131))
and
[ref](19e0de5e0a/types/coin.go (L270))).

The current hyperlane-sdk
[implementation](092ce5fd39/typescript/sdk/src/token/adapters/CosmWasmTokenAdapter.ts (L405-L414))
does not have sorting, which causes both the message simulation and
submission to fail.

### Drive-by changes
No

### Related issues
#4384 

### Backward compatibility
Yes

### Testing
Manual
pull/4391/head
sampocs 3 months ago committed by GitHub
parent f2783c03bb
commit 9563a8bebe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/red-nails-trade.md
  2. 3
      typescript/sdk/src/token/adapters/CosmWasmTokenAdapter.ts

@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': minor
---
Sorted cwNative funds by denom in transfer tx

@ -394,6 +394,7 @@ export class CwHypNativeAdapter
const { addressOrDenom: igpDenom, amount: igpAmount } = interchainGas;
assert(igpDenom, 'Interchain gas denom required for Cosmos');
// If more than one denom is used as funds, they must be sorted by the denom
const funds: Coin[] =
collateralDenom === igpDenom
? [
@ -411,7 +412,7 @@ export class CwHypNativeAdapter
amount: igpAmount.toString(),
denom: igpDenom,
},
];
].sort((a, b) => a.denom.localeCompare(b.denom));
return this.cw20adapter.prepareRouter(
{

Loading…
Cancel
Save