MetaMask / metamask-android-sdk

MetaMask SDK for Android
Other
46 stars 14 forks source link

[Bug]: connectSign returns wrong chainId signature #150

Closed rainman-wf closed 2 weeks ago

rainman-wf commented 2 weeks ago

Provide environment information

Android studio: 2024.1.1 Patch 1 Testnet: hardhat (chain id 1337)

MetaMask Android SDK Version

0.6.6

MetaMask Mobile app Version

7.31.0

Android Version

14

Describe the Bug

Sending transaction with reterned by metamask sign returns error "Nonce too high. Expected nonce to be 0 but got 18". If I set the nonce value to zero, then I get an error such as "insufficient funds". But when I accept message signing in metamask app acitivity, I see my testnet and may test wallet account with 10k coins. image Besides, if I sign my transaction with web3j lib using wallet credentials, the transaction is proceeding successfully It is very similar that metamask ignores the testnet I have chosen, and signs the transaction for the main network

Expected Behavior

To get the correct signature considering the selected testnet

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/rainman-wf/Metamask_SDK_test.git

To Reproduce

  1. Setup hadhat testnet with 1337 (0x539) chain id

  2. Deploy simple solidity smart contract for raw transaction handling

  3. Instal metamask app to android device

  4. Add testnet to metamask app and select it as active

  5. Add one of hardhat test accounts to metamask wallet

  6. Make simple android project with metamask sdk implementation

  7. Write function to create raw transaction signature

  8. Implement connectSign function to get message signature

  9. Sign transaction using returned by metamask signature

  10. Push transaction to testnet