near / near-wallet

Web wallet for NEAR Protocol which stores keys in browser's localStorage
https://wallet.near.org
MIT License
213 stars 176 forks source link

signMessage costs gas fees #3135

Open oneeuroquestion opened 2 months ago

oneeuroquestion commented 2 months ago

Environment A react website using the signMessage api in the MyNearWallet/Web Wallet flow on mainnet.

Problem Gas fee charges occur on the wallet

Expected Behaviour No charges should happen as this function just verifies the owner of the wallet with a message. on other wallets/blockchains this does not cost gas

Steps to reproduce

  1. setup the https://www.npmjs.com/package/@near-wallet-selector/my-near-wallet in a react app
  2. set it to use network: 'mainnet', - this is the only change from this flow: https://github.com/near/wallet-selector/tree/main/examples/react
  3. and this is the second change we did: export const NEAR_CONTRACT_ID = 'lavanetxyz.near' //'guest-book.testnet'
  4. then execute this after wallet login from the react website:
    localStorage.setItem(
      'message',
      JSON.stringify({
        message,
        nonce: [...Array.from(message)],
        recipient,
        callbackUrl: GetConnectionProgressUrlNearWallet(),
      }),
    )
    signedMessage = await wallet.signMessage({
      message,
      nonce,
      recipient,
    })
oneeuroquestion commented 2 months ago

ok just tested again this behaviour happens when logging in with sender wallet - could not reproduce it with the webwallet. So this happens after the log in - without even using the signMessage api. same flow using the connect your wallet as done in the example on the github.

Picture before login: image

Picture after logging in: image

The add key Txn which cost money: https://nearblocks.io/address/8b868c694970076635394ce22f719b7f8eef3e18396d31c30ad7d85f26cc7b55

oneeuroquestion commented 2 months ago

Ok I managed to reproduce the same issue in the web wallet with a new wallet (new account) before doing the login flow / signMessage flow - the wallet had these funds

0.1927 NEAR
$1.42

and this is an after picture: image and again near was spent on an add key txn: https://nearblocks.io/address/b7ecfa3320cc3e6588ee32c2cbbb519ced657faf5233d255fd7a5ad9938e35ef

oneeuroquestion commented 2 months ago

Link to conversation on the neardev telegram: https://t.me/neardev/43748