()
| 163 | * once before and Metamask within browser saves this. |
| 164 | */ |
| 165 | export const getCurrentWalletConnected = async () => { |
| 166 | if (window.ethereum) { |
| 167 | try { |
| 168 | const addressArray = await window.ethereum.request({ |
| 169 | method: "eth_accounts", |
| 170 | }); |
| 171 | |
| 172 | // --- If wallet is already connected --- |
| 173 | if (addressArray.length > 0) { |
| 174 | return { |
| 175 | address: addressArray[0], |
| 176 | status: "Your wallet has been connected!", |
| 177 | } |
| 178 | |
| 179 | // --- Otherwise, prompt user to connect --- |
| 180 | } else { |
| 181 | return { |
| 182 | address: null, |
| 183 | status: "Connect to MetaMask using the top right button.", |
| 184 | } |
| 185 | } |
| 186 | } catch (error: any) { |
| 187 | return { |
| 188 | address: null, |
| 189 | status: error.message, |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // --- Similarly, on user needing to install Metamask with eth --- |
| 194 | } else { |
| 195 | return { |
| 196 | address: "", |
| 197 | status: "You must install MetaMask, a virtual Ethereum wallet, in your browser." |
| 198 | } |
| 199 | } |
| 200 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected