WalletConnect / WalletConnectKotlinV2

WalletConnect Kotlin SDK v2
Apache License 2.0
197 stars 70 forks source link

Wallet Connect: Using "eth_sendTransaction" Instead of "eth_signTransaction" #1429

Closed ronaldoguedess closed 3 weeks ago

ronaldoguedess commented 2 months ago

I have identified an issue where Wallet Connect is incorrectly receiving parameters. Specifically, when approving a token, it is not receiving the correct argument:

Supported namespaces include "eth_signTransaction":

        val supportedNamespaces = mapOf(
            "eip155" to Wallet.Model.Namespace.Session(
                chains   = listOf("eip155:1", "eip155:56", "eip155:137", "eip155:3", "eip155:7000", "eip155:7001"),
                methods  = listOf("personal_sign", "eth_signTransaction", "eth_sendTransaction", "eth_sign", "eth_signTypedData", "eth_signTypedData_v3", "eth_signTypedData_v4", "wallet_switchEthereumChain"), //eth_accounts, eth_requestAccounts, eth_sendRawTransaction, eth_sign, eth_signTransaction, eth_signTypedData, eth_signTypedData_v3, eth_signTypedData_v4, eth_sendTransaction, personal_sign, wallet_switchEthereumChain, wallet_addEthereumChain, wallet_getPermissions, wallet_requestPermissions, wallet_registerOnboarding, wallet_watchAsset, wallet_scanQRCode, wallet_sendCalls, wallet_getCapabilities, wallet_getCallsStatus, wallet_showCallsStatus
                events   = listOf("chainChanged", "accountsChanged", "message", "connect", "disconnect"), //chainChanged, accountsChanged, message, disconnect, connect
                accounts = listOf("eip155:1:0x60aE4E7e00284baC073Efd1d617FE8Cc55af8098", "eip155:56:0x60aE4E7e00284baC073Efd1d617FE8Cc55af8098", "eip155:137:0x60aE4E7e00284baC073Efd1d617FE8Cc55af8098", "eip155:3:0x60aE4E7e00284baC073Efd1d617FE8Cc55af8098", "eip155:7000:0x60aE4E7e00284baC073Efd1d617FE8Cc55af8098", "eip155:7001:0x60aE4E7e00284baC073Efd1d617FE8Cc55af8098")
            ),
        )

The incorrect method returned is: eth_sendTransaction and it should return: eth_signTransaction

SessionRequest SessionRequest(
topic=76f090c8317a9b18b7adcd4e93472077d2b444aafc08b7b0d45af7bed165ebe2, 
chainId=eip155:56, 
peerMetaData=AppMetaData(name=Exchange | PancakeSwap, description=Trade, earn, and own crypto on the all-in-one multichain DEX, url=https://pancakeswap.finance, icons=[https://pancakeswap.finance/favicon.ico, https://pancakeswap.finance/logo.png], redirect=, verifyUrl=null), 
request=JSONRPCRequest(id=1720144611426330, 
method=eth_sendTransaction, 
params=[{"data":"0x095ea7b300000000000000000000000031c2f6fcff4f8759b3bd5bf0e1084a055615c768ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","from":"0x60aE4E7e00284baC073Efd1d617FE8Cc55af8098","gas":"0x102fb","gasPrice":"0x3b9aca00","to":"0x7d38315b92d0E7A85B35B2b7FE969B25935619D7","value":"0x0"}]))

Include the screenshot to help clarify the issue to see i'm approving:

Imagem do WhatsApp de 2024-07-04 à(s) 23 04 13_133a6364

ronaldoguedess commented 2 months ago

??

jakubuid commented 2 months ago

Hi thanks for reporting! Please help me understand why it's wrong. The protocol doesn't manipulate requests, it passes through what app sends. What can I do to reproduce it?

ronaldoguedess commented 3 weeks ago

I initially thought there was an issue because the TrustWallet provider was returning a different function when dApps called the approval function. In WalletConnect, it's defined as eth_sendTransaction. I later realized I needed to check the first 10 characters of the data to identify if it was an approval or not.

After investigating, I understood it wasn't actually an issue, just a difference in implementation.