Skip to content

Commit 56d6df2

Browse files
authored
Add chain to the Metamask if it does not exist (#69)
Signed-off-by: OjusWiZard <[email protected]>
1 parent 3b5135a commit 56d6df2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/shared/src/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ export const chainInfos: Record<string | number, ChainInfo> = {
6161
id: "xdai",
6262
color: "#48a900",
6363
chainId: 100,
64-
name: "xDAI Chain",
65-
rpcUrls: ["https://gnosischain-rpc.gateway.pokt.network/"],
64+
name: "Gnosis",
65+
rpcUrls: ["https://rpc.gnosischain.com/"],
6666
nativeCurrency: {
6767
name: "xDAI",
68-
symbol: "xDAI",
68+
symbol: "XDAI",
6969
decimals: 18,
7070
},
71-
blockExplorerUrls: ["https://gnosischain.io/"],
71+
blockExplorerUrls: ["https://gnosisscan.io/"],
7272
},
7373
matic: {
7474
id: "matic",
@@ -96,7 +96,7 @@ export const chainInfos: Record<string | number, ChainInfo> = {
9696
},
9797
};
9898

99-
export const addEthereumChain = (
99+
export const addEthereumChain = async (
100100
chain: string | number,
101101
library?: providers.Web3Provider
102102
) => {
@@ -108,16 +108,16 @@ export const addEthereumChain = (
108108

109109
// first attempt to switch to that chain
110110
try {
111-
return library.send("wallet_switchEthereumChain", [
111+
return await library.send("wallet_switchEthereumChain", [
112112
{ chainId: utils.hexValue(chainId) },
113113
]);
114-
} catch {}
114+
} catch { }
115115

116116
if (!rpcUrls || rpcUrls.length === 0) {
117117
return null;
118118
}
119119

120-
return library.send("wallet_addEthereumChain", [
120+
return await library.send("wallet_addEthereumChain", [
121121
{
122122
chainId: utils.hexValue(chainId),
123123
chainName: name,

0 commit comments

Comments
 (0)