-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(website): update wallet setup docs #14209
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,67 @@ | ||
import { | ||
ELDFELL_ADD_ETHEREUM_CHAIN, | ||
ELDFELL_CONFIG, | ||
GRIMSVOTN_ADD_ETHEREUM_CHAIN, | ||
GRIMSVOTN_CONFIG, | ||
SEPOLIA_ADD_ETHEREUM_CHAIN, | ||
SEPOLIA_CONFIG, | ||
} from "../../domain/chain"; | ||
|
||
import { ethereumRequest } from "../../utils/ethereumRequest"; | ||
|
||
type ConnectButtonProps = { | ||
network: | ||
| typeof SEPOLIA_CONFIG.names.shortName | ||
| typeof ELDFELL_CONFIG.names.shortName | ||
| typeof GRIMSVOTN_CONFIG.names.shortName; | ||
}; | ||
|
||
const chainMap = { | ||
Eldfell: ELDFELL_CONFIG.chainId.hex, // 167005 | ||
Grimsvotn: GRIMSVOTN_CONFIG.chainId.hex, // 167005 | ||
Sepolia: SEPOLIA_CONFIG.chainId.hex, // 11155111 | ||
}; | ||
|
||
const configMap = { | ||
Eldfell: ELDFELL_ADD_ETHEREUM_CHAIN, | ||
Grimsvotn: GRIMSVOTN_ADD_ETHEREUM_CHAIN, | ||
Sepolia: SEPOLIA_ADD_ETHEREUM_CHAIN, | ||
}; | ||
|
||
interface AddTokenButtonProps { | ||
address: string; | ||
symbol: string; | ||
decimals: number; | ||
image: string; | ||
network: ConnectButtonProps["network"]; | ||
} | ||
|
||
const addTokenToWallet = async (token: AddTokenButtonProps) => { | ||
const options = { ...token, type: "ERC20" }; | ||
await ethereumRequest("wallet_watchAsset", options); | ||
const { ethereum } = window as any; | ||
|
||
if (ethereum.chainId != chainMap[token.network]) { | ||
await ethereumRequest("wallet_addEthereumChain", [configMap[token.network]]); | ||
} | ||
|
||
const params = { options: { address: token.address, symbol: token.symbol, decimals: token.decimals, image: token.image }, type: "ERC20" }; | ||
|
||
await ethereumRequest("wallet_watchAsset", params); | ||
|
||
}; | ||
|
||
export function AddTokenButton({ | ||
address, | ||
symbol, | ||
decimals, | ||
image, | ||
network, | ||
}: AddTokenButtonProps) { | ||
return ( | ||
<div | ||
onClick={() => addTokenToWallet({ address, symbol, decimals, image })} | ||
onClick={() => addTokenToWallet({ address, symbol, decimals, image, network })} | ||
className="hover:cursor-pointer text-neutral-100 bg-[#E81899] hover:bg-[#d1168a] border-solid border-neutral-200 focus:ring-4 focus:outline-none focus:ring-neutral-100 font-medium rounded-lg text-sm px-3 py-2 text-center inline-flex items-center" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we should consider refactoring out a button class now that we are using it so frequently: ecosystem page, homepage, here, and add wallet. this could be a good first issue as well i think for community. |
||
> | ||
Add {symbol} to wallet | ||
Add {symbol} ({network}) | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
import { Steps } from "nextra-theme-docs"; | ||
import { AddTokenButton } from "components/Button/AddTokenButton"; | ||
import { ConnectToMetamaskButton } from "components/Button/ConnectToMetamaskButton"; | ||
|
||
import { | ||
ELDFELL_CONFIG, | ||
GRIMSVOTN_CONFIG, | ||
SEPOLIA_CONFIG, | ||
} from "domain/chain"; | ||
|
||
# Setup your wallet | ||
|
||
|
@@ -11,11 +19,45 @@ This guide helps you connect your wallet to Taiko's networks. | |
## Steps | ||
|
||
<Steps> | ||
### Visit RPC configuration | ||
Visit the [RPC configuration page](/docs/reference/rpc-configuration) and click the buttons to add the networks. Or, add them manually in your wallet with the provided configuration. | ||
### Add chains to your wallet | ||
<ConnectToMetamaskButton network={SEPOLIA_CONFIG.names.shortName} /> | ||
<br /> | ||
<ConnectToMetamaskButton network={GRIMSVOTN_CONFIG.names.shortName} /> | ||
<br /> | ||
<ConnectToMetamaskButton network={ELDFELL_CONFIG.names.shortName} /> | ||
|
||
### Add tokens to your wallet | ||
Use your wallet (e.g., Metamask) to [import the tokens](https://support.ledger.com/hc/en-us/articles/6375103346077-Add-custom-tokens-to-MetaMask?docs=true). You can find all deployed tokens contract addresses [here](/docs/reference/contract-addresses). | ||
<AddTokenButton address={SEPOLIA_CONFIG.basedContracts.erc20Contracts.taikoToken.address.proxy} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
symbol={SEPOLIA_CONFIG.basedContracts.erc20Contracts.taikoToken.symbol} | ||
decimals={SEPOLIA_CONFIG.basedContracts.erc20Contracts.taikoToken.decimals} | ||
image="https://raw.githubusercontent.com/taikoxyz/taiko-mono/main/packages/branding/testnet-token-images/ttko.svg" | ||
network="Sepolia"/> | ||
<AddTokenButton address={SEPOLIA_CONFIG.basedContracts.erc20Contracts.bullToken.address.impl} | ||
symbol={SEPOLIA_CONFIG.basedContracts.erc20Contracts.bullToken.symbol} | ||
decimals={SEPOLIA_CONFIG.basedContracts.erc20Contracts.bullToken.decimals} | ||
image="https://raw.githubusercontent.com/taikoxyz/taiko-mono/main/packages/branding/testnet-token-images/bull_32x32.svg" | ||
network="Sepolia"/> | ||
<AddTokenButton address={SEPOLIA_CONFIG.basedContracts.erc20Contracts.horseToken.address.impl} | ||
symbol={SEPOLIA_CONFIG.basedContracts.erc20Contracts.horseToken.symbol} | ||
decimals={SEPOLIA_CONFIG.basedContracts.erc20Contracts.horseToken.decimals} | ||
image="https://raw.githubusercontent.com/taikoxyz/taiko-mono/main/packages/branding/testnet-token-images/horse.svg" | ||
network="Sepolia"/> | ||
<br /> | ||
<AddTokenButton address={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedTaikoToken.address.impl} | ||
symbol={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedTaikoToken.symbol} | ||
decimals={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedTaikoToken.decimals} | ||
image="https://raw.githubusercontent.com/taikoxyz/taiko-mono/main/packages/branding/testnet-token-images/ttko.svg" | ||
network="Grimsvotn"/> | ||
<AddTokenButton address={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedBullToken.address.impl} | ||
symbol={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedBullToken.symbol} | ||
decimals={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedBullToken.decimals} | ||
image="https://raw.githubusercontent.com/taikoxyz/taiko-mono/main/packages/branding/testnet-token-images/bull_32x32.svg" | ||
network="Grimsvotn"/> | ||
<AddTokenButton address={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedHorseToken.address.impl} | ||
symbol={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedHorseToken.symbol} | ||
decimals={GRIMSVOTN_CONFIG.rollupContracts.erc20Contracts.bridgedHorseToken.decimals} | ||
image="https://raw.githubusercontent.com/taikoxyz/taiko-mono/main/packages/branding/testnet-token-images/horse.svg" | ||
network="Grimsvotn"/> | ||
|
||
</Steps> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't initialize constants here if we need this mapping we should expose it out of the domain folder