-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Metamask connection option (#788)
Resolves #771 ### What Add Metamask to supported wallets 🦊 🥲 Metamask is visible only if you don't have Taho wallet installed. ![image](https://github.com/tahowallet/dapp/assets/20949277/f75f55a4-70ca-432f-a6a9-eeb7dad99ff3) ### Testing 1. Testing Taho **without** Metamask installed - [x] make sure you are able to connect to Taho - [x] make sure you are able to do transactions (stake, unstake) using Taho - [x] make sure you are able to disconnect and reconnect using Taho 2. Testing Taho **with** Metamask installed - [x] make sure you are able to connect to Taho - [x] make sure you are able to do transactions (stake, unstake) using Taho - [x] make sure you are able to disconnect and reconnect using Taho 3. Testing Metamask **without** Taho installed - [x] make sure you are able to connect to Metamask - [x] make sure you are able to do transactions (stake, unstake) using Metamask - [x] make sure you are able to disconnect and reconnect using Metamask - [x] make sure selecting Taho as connection option fails gracefully
- Loading branch information
Showing
6 changed files
with
746 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,60 @@ | ||
import tahoWalletModule from "@web3-onboard/taho" | ||
import trezorModule from "@web3-onboard/trezor" | ||
import walletConnectModule from "@web3-onboard/walletconnect" | ||
import metamaskSDK from "@web3-onboard/metamask" | ||
import { init } from "@web3-onboard/react" | ||
import { ARBITRUM_SEPOLIA } from "shared/constants" | ||
import favicon from "shared/assets/favicon.svg" | ||
|
||
const SUBSACAPE_NAME = "Subscape" | ||
const SUBSACAPE_URL = "https://app.taho.xyz" | ||
const SUBSACAPE_ICON = favicon | ||
const chains = [ARBITRUM_SEPOLIA] | ||
|
||
const appMetadata = { | ||
name: SUBSACAPE_NAME, | ||
description: "Subscape dapp", | ||
icon: SUBSACAPE_ICON, | ||
} | ||
|
||
const walletsSetup = { | ||
taho: tahoWalletModule(), | ||
trezor: trezorModule({ | ||
// TODO: use proper email and url | ||
email: "[email protected]", | ||
appUrl: "https://taho.xyz", | ||
appUrl: SUBSACAPE_URL, | ||
}), | ||
walletConnect: walletConnectModule({ | ||
projectId: process.env.WALLET_CONNECT_ID ?? "", | ||
requiredChains: [parseInt(ARBITRUM_SEPOLIA.id, 16)], | ||
}), | ||
metamask: metamaskSDK({ | ||
options: { | ||
extensionOnly: false, | ||
dappMetadata: { | ||
name: SUBSACAPE_NAME, | ||
url: SUBSACAPE_URL, | ||
}, | ||
}, | ||
}), | ||
} | ||
|
||
const wallets = [walletsSetup.taho] | ||
|
||
const chains = [ARBITRUM_SEPOLIA] | ||
// TODO: decide what metadata should look like | ||
const appMetadata = { | ||
name: "Taho Dapp", | ||
description: "Taho Dapp", | ||
icon: "https://raw.githubusercontent.com/tahowallet/taho.xyz/29a091abf919b5cfcf511fd10c41d73490ce4f23/src/shared/favicon.svg", | ||
} | ||
const hasTaho = "taho" in window | ||
const wallets = hasTaho | ||
? [walletsSetup.taho] | ||
: [walletsSetup.taho, walletsSetup.metamask] | ||
|
||
const web3Onboard = init({ | ||
wallets, | ||
chains, | ||
appMetadata, | ||
connect: { | ||
autoConnectLastWallet: true, | ||
// TODO: web3onboard remembers last wallet that was used. If it was MM but MM becomes | ||
// unavailable then web3onboard will try to auto connect to MM and will fail. | ||
// So to avoid problem with attempting auto connection to the wallet | ||
// that is not available on the wallet lists let's just disable autoConnect | ||
// feature for Metamask for now. | ||
autoConnectLastWallet: hasTaho, | ||
iDontHaveAWalletLink: | ||
"https://chrome.google.com/webstore/detail/taho/eajafomhmkipbjmfmhebemolkcicgfmd", | ||
removeWhereIsMyWalletWarning: true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.