WalletConnect / WalletConnectFlutterV2

WalletConnect v2 client made in Dart for Flutter.
https://pub.dev/packages/walletconnect_flutter_v2
Apache License 2.0
117 stars 61 forks source link

`EtheraAmountExtension` Fails to parse large values. #304

Closed CyberWake closed 3 months ago

CyberWake commented 3 months ago

Describe the bug Extension EtheraAmountExtension fails to parse when the actual transaction includes a hex value which on decoding is higher radix value to BigInt.

To Reproduce Steps to reproduce the behavior:

  1. Go to wallet example and dapp example run both apps. In dApp example under the file example/dapp/lib/utils/crypto/eip155.dart:94 update the value to be more than 10.0 ETH example replace 11->11111.
  2. Connect dapp with the wallet example.
  3. After connection in dapp go to sessions and for the current session use eth_sendTransaction option.
  4. On wallet side the functionality breaks in parsing the transaction. With the following error {id: 1723111024688480, jsonrpc: 2.0, error: {code: -32602, message: FormatException: Positive input exceeds the limit of integer 9a3233a1a35d8000}}

Expected behavior Large values should also parse properly

Reproducible code Replace line 94 in example/dapp/lib/utils/crypto/eip155.dart with value: EtherAmount.fromInt(EtherUnit.finney, 11111),

Screenshots

Screenshot 2024-08-08 at 3 29 45 PM

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Instead of parsing the hex to int with radix 16 and then to BigInt. We can directly parse hex to BigInt with radix as 16. I'd like to fix this one.

quetool commented 3 months ago

Hello @CyberWake! EtherAmountExtension is part of web3dart package, which is a thirty party package, so any issue with that should be rose up in their repo.

Furthermore, on the example dapp/wallet this is used just to construct the Transaction to then pass as a json object to the request:

return await web3App.request(
  topic: topic,
  chainId: chainId,
  request: SessionRequestParams(
    method: methods[EIP155Methods.ethSendTransaction]!,
    params: [transaction.toJson()], // <= Transaction data as Map<String, dynamic>
  ),
);

So you can construct your transaction object as you please and pass it into params.

However, I will take a look at your report anyway ASAP.

quetool commented 3 months ago

Oh wait I see what you meant! Thanks for the PR! I'll check it soon!

quetool commented 3 months ago

It's merged! Will be deployed soon!

quetool commented 3 months ago

It's deployed in beta https://pub.dev/packages/walletconnect_flutter_v2/versions/2.3.1-beta02