MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.18k stars 1.12k forks source link

[Bug]: Attempting an ethSendTransaction request but receiving Unknown Method on confirmation #11759

Open matthewgallagher-es opened 1 month ago

matthewgallagher-es commented 1 month ago

Describe the bug

When performing an ethSendTransaction request I pass in a contract and perform a send request. This then passes the request to the MataMask app where you can connect your account, and then bring up the transaction to Confirm.
However, this is where instead of showing Connect as expected, it is showing Unknown Method on the confirmation screen.

Based on metamask docs : https://docs.metamask.io/wallet/how-to/display/method-names/#:~:text=MetaMask%20uses%20the%20Ethereum%20Signature,names%20by%20their%20method%20signature MetaMask uses the Ethereum Signature Database to display method names on the confirmation screen and our method send is definitely in there (https://www.4byte.directory/signatures/?bytes4_signature=0x9bd9bbc6). Contract (beacons) is verified. It works fine when interacting through Etherscan Explorer and connecting via MetaMask on the web

Expected behavior

Seeing Confirm label on confirm transaction sheet.

Metamask should fetch the contract method and display it on the confirmation screen.

Web works as expected:

Details Hex
image image

Screenshots/Recordings

image

Steps to reproduce

Error messages or log output

No error messages found, only the `Unknown Method` label shown instead of `Connect`

Detection stage

In production (default)

Version

7.31.1

Build type

None

Device

iPhone 15 Pro

Operating system

iOS

Additional context

SDK version: 0.8.8

Code:

let contractJsonABI = Self.tokenABI.data(using: .utf8)!
let contract = try web3.eth.Contract(json: contractJsonABI, abiKey: nil, address: contractAddress)
let toAddress = try EthereumAddress(hex: bridge, eip55: true)
let data = Data(hex: key)
let transactionData = contract["send"]?(toAddress, amount, data).encodeABI()

let transaction = Transaction(
    to: token,
    from: metamaskSDK.account,
    value: "0x0",
    data: transactionData!.hex()
)

let request = EthereumRequest(method: .ethSendTransaction, params: [transaction])
let result = await metamaskSDK.connectWith(request)

ABI:

 private static let tokenABI = """
    [{
        "inputs": [
          {
            "internalType": "address",
            "name": "to",
            "type": "address"
          },
          {
            "internalType": "uint256",
            "name": "amount",
            "type": "uint256"
          },
          {
            "internalType": "bytes",
            "name": "data",
            "type": "bytes"
          }
        ],
        "name": "send",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    }]
    """

Hash (Testnet): https://sepolia.etherscan.io/tx/0x30f18176dce1b36a00e6098635c7d18457efc1774dc820429be9716b70652d00 Hash (Mainnet): https://etherscan.io/tx/0xa3472fcdbe127a9994d2292e59fbc1f39964ddc873ba7ec3903fac18577c048c

Linked issues:

Severity

This could stop users trusting this feature and therefore would stop us being able to offer it

BarryHelfrich commented 1 month ago

This is also affecting android, exactly the same so no need to add further evidence but can if required.

andrzejbogacz commented 1 month ago

This is also affecting android, exactly the same so no need to add further evidence but can if required.

+1, having the same issue on Android, can't do a release because of that. Not sure why it's marked as low as normal severity, it essentially blocks the feature from going onto the market, no one wants to proceed with payment if the fees suggest they might go bankrupt...