web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

Different Events in mobile and desktop

Open mostafa-rio opened this issue 1 year ago • 4 comments

Describe the bug If we try to write our logic based on this equality our logic will only work if this runs only on dekstop: web3ModalEvents.event === "CONNECT_SUCCESS"

and in mobile version SELECT_WALLET will be fired

To Reproduce Create a simple react app with walletconnect/ethers5 and add useWeb3ModalEvents and check the event on mobile and desktop

mostafa-rio avatar Feb 21 '24 13:02 mostafa-rio

hi, what's the expected behavior you're looking for?

glitch-txs avatar Feb 26 '24 20:02 glitch-txs

The expected behavior is to have the same behavior as the desktop and the web3ModalEvents.event === "CONNECT_SUCCESS" must be evaluated to true whenever we successfully connect to a mobile wallet. If there is a limitation on mobile there should be a section in the document to explain this behavior.

mostafa-rio avatar Feb 28 '24 05:02 mostafa-rio

got it, in the meantime you can use these getters, you can also subscribe to them: https://docs.walletconnect.com/web3modal/javascript/actions?platform=ethers5#ethereum-library

const isConnected = modal.getIsConnected()

// or

function handleChange({ isConnected }) {
  //...
}

modal.subscribeProvider(handleChange)

glitch-txs avatar Feb 28 '24 05:02 glitch-txs

Awesome that would solve my issue. You also may tag this issue for future pull requests.

mostafa-rio avatar Feb 28 '24 06:02 mostafa-rio