Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 71 additions & 7 deletions src/constants/chainList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,62 @@ const chains = {
1: {
name: "Ethereum",
chain_id: 1,
rpc_url: "https://rpc.ankr.com/eth",
rpc_url:
"https://eth-mainnet.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
blockchain: "eth",
currency: "ETH",
explorer: "https://etherscan.io",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_ethereum.jpg",
},
137: {
name: "Polygon",
chain_id: 137,
rpc_url: "https://rpc.ankr.com/polygon",
rpc_url:
"https://polygon-mainnet.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
blockchain: "polygon",
currency: "MATIC",
explorer: "https://polygonscan.com",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_polygon.jpg",
},
80001: {
name: "Polygon Mumbai",
chain_id: 80001,
rpc_url: "https://rpc.ankr.com/polygon_mumbai",
rpc_url:
"https://polygon-testnet.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
blockchain: "polygon_mumbai",
currency: "MATIC",
explorer: "https://mumbai.polygonscan.com",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_polygon.jpg",
},
42161: {
name: "Arbitrum One",
blockchain: "arbitrum",
chain_id: 42161,
rpc_url: "https://rpc.ankr.com/arbitrum",
rpc_url:
"https://arbitrum-one.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
currency: "ETH",
explorer: "https://arbiscan.io",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_arbitrum.jpg",
},
56: {
name: "BNB Smart Chain",
blockchain: "bsc",
chain_id: 56,
rpc_url: "https://rpc.ankr.com/bsc",
rpc_url:
"https://bsc-mainnet.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
currency: "BNB",
explorer: "https://bscscan.com",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_binance.jpg",
},
97: {
name: "BNB Smart Chain Testnet",
blockchain: "bsc_testnet_chapel",
chain_id: 97,
rpc_url: "https://rpc.ankr.com/bsc_testnet_chapel",
currency: "tBNB",
rpc_url:
"https://bsc-testnet.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
currency: "BNB",
explorer: "https://testnet.bscscan.com",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_binance.jpg",
},
204: {
name: "opBNB Mainnet",
Expand All @@ -54,6 +66,27 @@ const chains = {
rpc_url: "https://1rpc.io/opbnb",
currency: "BNB",
explorer: "https://opbnbscan.com/",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_binance.jpg",
},
59144: {
name: "Linea",
chain_id: 59144,
rpc_url:
"https://linea-mainnet.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
blockchain: "linea",
currency: "ETH",
explorer: "https://lineascan.build",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_linea.jpg",
},
59140: {
name: "Linea Goerli",
chain_id: 59140,
rpc_url:
"https://linea-goerli.blastapi.io/7c12fa10-4e46-4810-bf66-6b3148119501",
blockchain: "linea_testnet",
currency: "ETH",
explorer: "https://goerli.lineascan.build",
icon_url: "https://icons.llamao.fi/icons/chains/rsz_linea.jpg",
},
};

Expand All @@ -64,4 +97,35 @@ export const testnetChainFaucets = {
80001: "https://mumbaifaucet.com",
};

export const gaslessChains = [137];

export enum ChainNames {
"eth" = "Ethereum",
"polygon" = "Polygon PoS",
"polygon_mumbai" = "Polygon Mumbai",
"arbitrum" = "Arbitrum One",
"bsc" = "BNB Smart Chain",
"bsc_testnet_chapel" = "BNB Smart Chain Testnet",
"opbnb" = "opBNB Mainnet",
"linea" = "Linea",
"linea_testnet" = "Linea Goerli",
}

export enum ChainIds {
"eth" = 1,
"polygon" = 137,
"polygon_mumbai" = 80001,
"arbitrum" = 42161,
"bsc" = 56,
"bsc_testnet_chapel" = 97,
"opbnb" = 204,
"linea" = 59144,
"linea_testnet" = 59140,
}

export const SupportedChainIdsForAccounts = {
eoa: [1, 137, 80001, 42161, 56, 97, 204],
scw: [137, 80001],
};

export default chains;
24 changes: 24 additions & 0 deletions src/services/ankr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ async function getNativeTokenBalances(walletAddress: string) {
axios.post(chains[56].rpc_url, payload),
axios.post(chains[97].rpc_url, payload),
axios.post(chains[204].rpc_url, payload),
axios.post(chains[59144].rpc_url, payload),
axios.post(chains[59140].rpc_url, payload),
];
const [
eth,
Expand All @@ -84,6 +86,8 @@ async function getNativeTokenBalances(walletAddress: string) {
bsc,
bsc_testnet_chapel,
opbnb_mainnet,
linea,
linea_goerli,
] = await Promise.all(ankrPromises);
return [
{
Expand Down Expand Up @@ -142,6 +146,26 @@ async function getNativeTokenBalances(walletAddress: string) {
.mul(Decimal.pow(10, -18))
.toString(),
},
{
tokenType: "NATIVE",
tokenSymbol: "ETH",
blockchain: "linea",
balance: linea.data.result
? new Decimal(linea.data.result).mul(Decimal.pow(10, -18)).toString()
: 0,
thumbnail: chains[59144].icon_url,
},
{
tokenType: "NATIVE",
tokenSymbol: "ETH",
blockchain: "linea_testnet",
balance: linea_goerli.data.result
? new Decimal(linea_goerli.data.result)
.mul(Decimal.pow(10, -18))
.toString()
: 0,
thumbnail: chains[59140].icon_url,
},
];
}

Expand Down
1 change: 1 addition & 0 deletions src/use/switchChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function switchChain(chainId) {
},
rpcUrls: [chainDetails.rpc_url],
blockExplorerUrls: [chainDetails.explorer],
iconUrls: [chainDetails.icon_url],
},
],
});
Expand Down