axelarnetwork / axelar-examples

Sample cross-chain dapps & contracts using the Axelar protocol.
184 stars 163 forks source link

`execute` failing for multiple worded chains #197

Open lordshashank opened 1 month ago

lordshashank commented 1 month ago

Describe the bug When one tries to run npm run execute in axelar-examples with parent chain being more than one word like Arbitrum-Sepolia, Optimism-Sepolia, axelarjs-sdk, etc throws type error

/home/wsl-ubuntu/blockchain/axelar/axelar-examples/node_modules/@axelar-network/axelarjs-sdk/dist/src/utils/validateChain.js:21
        const foundChain = chainIdentifiers.find((identifier) => identifier === chainIdentifier.toLowerCase());
                                                                                                ^

TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at /home/wsl-ubuntu/blockchain/axelar/axelar-examples/node_modules/@axelar-network/axelarjs-sdk/dist/src/utils/validateChain.js:21:97
    at Array.find (<anonymous>)
    at /home/wsl-ubuntu/blockchain/axelar/axelar-examples/node_modules/@axelar-network/axelarjs-sdk/dist/src/utils/validateChain.js:21:45
    at Generator.next (<anonymous>)
    at fulfilled (/home/wsl-ubuntu/blockchain/axelar/axelar-examples/node_modules/@axelar-network/axelarjs-sdk/dist/src/utils/validateChain.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The issue here is that chains in our sdk supported-chain-list has _ in between two words while on sending multiple word chain as parent we have - in between two words leading mismatch and hence the Chain being undefined going into the calculateGasFee() or any other solution.

To Reproduce Steps to reproduce the behavior:

  1. Clone axelar-examples and build the contracts as per readme instructions
  2. Deploy any contract lets say evm/call-contract once on multiple word chain like Arbitrum-Sepolia, Optimism-Sepolia, etc and then other on any other chain.
  3. Remove the defaulting of sourceChain to arbitrum otherwise it defaults to their instead of any other chain.
  4. Run npm run execute taking multiple word chain as parent and any other as child.
  5. See error

Expected behavior Ideally transaction should run successfully

Screenshots image

Possible Solution

Desktop (please complete the following information):

Additional context Blocks devs starting to using axelar, should be resolved soon.

benjamin852 commented 1 month ago

Hi @lordshashank. Can you confirm you deployed the contracts without any issue on testnet? I just ran a testnet transaction for Base Sepolia (a multi worded chain) and it worked fine. See here

❯ npm run execute evm/call-contract testnet "Base-Sepolia" "Avalanche" "Hello World"

> axelar-examples@1.0.0 execute
> node scripts/runExecute evm/call-contract testnet Base-Sepolia Avalanche Hello World

--- Initially ---
value at Avalanche is ""
You can track the GMP transaction status on https://testnet.axelarscan.io/gmp/0x124b254eeea59eb15decb3f9c1d93430fee02b1eb1706b3b50be723fea71dc07

--- After ---
value at Avalanche is "Hello World"