Skip to content

Commit

Permalink
fix: metamask chainid bug (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
rongquan1 authored Apr 8, 2024
1 parent a2a6ebb commit 49aa8ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/utils/chain-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const walletSwitchChain = async (chainId: ChainId): Promise<void> => {
try {
await ethereum.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: `0x${chainId.toString(16)}` }],
params: [{ chainId: `0x${(+chainId).toString(16)}` }],
});
} catch (e: any) {
if (e.code === -32601) {
Expand Down Expand Up @@ -83,7 +83,7 @@ export const walletAddChain = async (chainId: ChainId): Promise<void> => {
method: "wallet_addEthereumChain",
params: [
{
chainId: `0x${chainId.toString(16)}`,
chainId: `0x${(+chainId).toString(16)}`,
chainName: chainInfo.networkLabel,
nativeCurrency: chainInfo.nativeCurrency,
blockExplorerUrls: [chainInfo.explorerUrl],
Expand Down

0 comments on commit 49aa8ec

Please sign in to comment.