My NodeJS Web3Wallet app crash when Error: Unsupported chains. connect() optionalNamespaces occur
If user provide invalid URI or Dapp provide invalid optionalNamespaces, expect WC just throw an "Error", not crash
How to fix it? Do you guys have any ideas on this issue?
SDK Version
"@walletconnect/core": "^2.10.2"
"@walletconnect/web3wallet": "^1.9.2"
Error
I get WalletConnect URI connect from www.dexscreener.com
Run await web3wallet.pair({ uri });
An error occur and my NodeJS app crash. I have to run it again.
There are my code:
web3wallet.on('session_proposal', async proposal => {...})
await web3wallet.pair({ uri }); // This step success, no error
Error: Unsupported chains. connect() optionalNamespaces, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }
at le.validateNamespaces (/path/to/my-app/node_modules/@walletconnect/sign-client/dist/index.cjs.js:1:22935)
at le.isValidConnect (/path/to/my-app/node_modules/@walletconnect/sign-client/dist/index.cjs.js:1:22728)
at le.onSessionProposeRequest (/path/to/my-app/node_modules/@walletconnect/sign-client/dist/index.cjs.js:1:15182)
at le.processRequest (/path/to/my-app/node_modules/@walletconnect/sign-client/dist/index.cjs.js:1:13762)
at le.processRequestsQueue (/path/to/my-app/node_modules/@walletconnect/sign-client/dist/index.cjs.js:1:13527)
at le.onRelayEventRequest (/path/to/my-app/node_modules/@walletconnect/sign-client/dist/index.cjs.js:1:13128)
at EventEmitter.<anonymous> (/path/to/my-app/node_modules/@walletconnect/sign-client/dist/index.cjs.js:1:28916)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Hey @truongezgg, the error states that chains must be defined in your optionalNamespaces. Either as eip155:1 in the key, or in chains: string[] property
My NodeJS Web3Wallet app crash when
Error: Unsupported chains. connect() optionalNamespaces
occurIf user provide invalid URI or Dapp provide invalid optionalNamespaces, expect WC just throw an "Error", not crash
How to fix it? Do you guys have any ideas on this issue?
SDK Version
"@walletconnect/core": "^2.10.2"
"@walletconnect/web3wallet": "^1.9.2"
Error
await web3wallet.pair({ uri });
There are my code: