Wallet auto-connect
#
How to implement the wallet auto-connectWeb3 browser in 1inch Wallet injects JavaScript code/objects when opening a webpage.
So first it is necessary to find out if the provider has been injected:
export function isOneInchWalletProviderInjected(): boolean { return Boolean(ethereum?.isOneInchIOSWallet || ethereum?.isOneInchAndroidWallet);}
The next step is to retrieve the net/address, thus it would be classified as a connection.
// Retrieving accounts: eth_requestAccounts returns the current one, it gives an array containing single addressconst accounts = await ethereum.request({ method: 'eth_requestAccounts' });
// returns id of the network in hex-formatconst currentChain = await ethereum.request({ method: 'eth_chainId' });