Skip to content

Commit

Permalink
Add Ink chain support (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinoConti authored Feb 26, 2025
1 parent 9a54bb5 commit dcb5a7d
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/icons/blockchains/colorless/ink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/icons/blockchains/ink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 31 additions & 11 deletions src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,53 +35,55 @@ const MAINNET_RPCS = {
arbitrum: "https://arb1.arbitrum.io/rpc",
avalanche: "https://api.avax.network/ext/bc/C/rpc",
base: "https://mainnet.base.org",
berachain: "https://rpc.berachain.com",
blast: "https://rpc.ankr.com/blast",
bsc: process.env.BSC_RPC || "https://bsc-dataseed2.defibit.io",
celo: "https://forno.celo.org",
ethereum: process.env.ETH_RPC || "https://ethereum-rpc.publicnode.com",
fantom: "https://rpc.ankr.com/fantom",
injective: "https://api.injective.network",
ink: "https://ink.drpc.org",
karura: "https://eth-rpc-karura.aca-api.network",
klaytn: "https://klaytn-mainnet-rpc.allthatnode.com:8551",
moonbeam: "https://rpc.ankr.com/moonbeam",
mantle: "https://rpc.mantle.xyz",
moonbeam: "https://rpc.ankr.com/moonbeam",
near: "https://rpc.mainnet.near.org",
oasis: "https://emerald.oasis.dev",
optimism: "https://1rpc.io/op",
polygon: "https://1rpc.io/matic",
scroll: "https://rpc.ankr.com/scroll",
snaxchain: "https://mainnet.snaxchain.io/",
solana: process.env.SOLANA_RPC ?? "https://api.mainnet-beta.solana.com",
sui: "https://rpc.mainnet.sui.io",
terra: "https://terra-classic-fcd.publicnode.com",
terra2: "https://lcd-terra.tfl.foundation",
xpla: "https://dimension-lcd.xpla.dev",
xlayer: "https://xlayerrpc.okx.com",
snaxchain: "https://mainnet.snaxchain.io/",
unichain: "https://mainnet.unichain.org/",
berachain: "https://rpc.berachain.com",
xlayer: "https://xlayerrpc.okx.com",
xpla: "https://dimension-lcd.xpla.dev",
};

const TESTNET_RPCS = {
arbitrum_sepolia: "https://sepolia-rollup.arbitrum.io/rpc",
avalanche: "https://api.avax-test.network/ext/bc/C/rpc",
base_sepolia: "https://sepolia.base.org",
berachain: "https://berachain-testnet-rpc.publicnode.com",
blast: "https://sepolia.blast.io",
bsc: "https://data-seed-prebsc-2-s3.binance.org:8545",
celo: "https://alfajores-forno.celo-testnet.org",
ethereum: "https://rpc.ankr.com/eth_goerli",
fantom: "https://rpc.testnet.fantom.network",
ink: "https://ink-sepolia.drpc.org",
mantle: "https://rpc.testnet.mantle.xyz",
monad_devnet: `${process.env.WORMSCAN_BFF_URL}/monadRpcCall`,
moonbeam: "https://rpc.api.moonbase.moonbeam.network",
sepolia: "https://ethereum-sepolia.publicnode.com",
optimism_sepolia: "https://sepolia.optimism.io",
polygon: "https://rpc.ankr.com/polygon_mumbai",
polygon_sepolia: "https://rpc.ankr.com/polygon_amoy",
polygon: "https://rpc.ankr.com/polygon_mumbai",
scroll: "https://rpc.ankr.com/scroll_sepolia_testnet",
blast: "https://sepolia.blast.io",
xlayer: "https://xlayertestrpc.okx.com",
sepolia: "https://ethereum-sepolia.publicnode.com",
snaxchain: "https://testnet.snaxchain.io/",
monad_devnet: `${process.env.WORMSCAN_BFF_URL}/monadRpcCall`,
unichain: "https://sepolia.unichain.org/",
berachain: "https://berachain-testnet-rpc.publicnode.com",
xlayer: "https://xlayertestrpc.okx.com",
};

export type Environment = {
Expand Down Expand Up @@ -138,6 +140,7 @@ export const testnetNativeCurrencies: { [key: string]: string } = {
[chainIdToChain(43)]: "ETH",
[chainIdToChain(44)]: "ETH",
[chainIdToChain(45)]: "ETH",
[chainIdToChain(46)]: "ETH",
[chainIdToChain(48)]: "MON",
[chainIdToChain(10002)]: "ETH",
[chainIdToChain(10003)]: "ETH",
Expand Down Expand Up @@ -186,6 +189,7 @@ export const mainnetNativeCurrencies: { [key: string]: string } = {
[chainIdToChain(43)]: "ETH",
[chainIdToChain(44)]: "ETH",
[chainIdToChain(45)]: "ETH",
[chainIdToChain(46)]: "ETH",
[chainIdToChain(48)]: "MON",
};

Expand Down Expand Up @@ -346,6 +350,14 @@ export const testnetEnv: Environment = {
nativeCurrencyDecimals: 18,
rpcUrl: TESTNET_RPCS.unichain || "",
},
{
chainId: 46 as ChainId,
chainName: "Ink Sepolia",
defaultDeliveryProviderContractAddress: testnetDefaultDeliveryProviderContractAddress,
evmNetworkId: 763373,
nativeCurrencyDecimals: 18,
rpcUrl: TESTNET_RPCS.ink || "",
},
{
chainId: 48 as ChainId,
chainName: "Monad Testnet",
Expand Down Expand Up @@ -516,6 +528,14 @@ export const mainnetEnv: Environment = {
nativeCurrencyDecimals: 18,
rpcUrl: MAINNET_RPCS.unichain || "",
},
{
chainId: 46 as ChainId,
chainName: "Ink",
defaultDeliveryProviderContractAddress: mainnetDefaultDeliveryProviderContractAddress,
evmNetworkId: 57073,
nativeCurrencyDecimals: 18,
rpcUrl: MAINNET_RPCS.ink || "",
},
{
chainId: 48 as ChainId,
chainName: "Monad",
Expand Down
2 changes: 2 additions & 0 deletions src/utils/filterUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const ChainFilterMainnet = [
chainToChainId("Ethereum"),
chainToChainId("Fantom"),
chainToChainId("Injective"),
// chainToChainId("Ink"),
chainToChainId("Karura"),
chainToChainId("Klaytn"),
chainToChainId("Mantle"),
Expand Down Expand Up @@ -123,6 +124,7 @@ export const ChainFilterTestnet = [
chainToChainId("Ethereum"), // Goerli
chainToChainId("Holesky"),
chainToChainId("Injective"),
// chainToChainId("Ink"),
chainToChainId("Karura"),
chainToChainId("Klaytn"),
chainToChainId("Mantle"),
Expand Down
16 changes: 16 additions & 0 deletions src/utils/metaMaskUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,20 @@ export const METAMASK_CHAIN_PARAMETERS: {
rpcUrls: ["https://endpoints.omniatech.io/v1/op/sepolia/public"],
blockExplorerUrls: ["https://sepolia-optimism.etherscan.io/"],
},
57073: {
chainId: "0xDEF1",
chainName: "Ink",
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
rpcUrls: ["https://ink.drpc.org"],
blockExplorerUrls: ["https://explorer.inkonchain.com"],
},
763373: {
chainId: "0xBA5ED",
chainName: "Ink Sepolia",
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
rpcUrls: ["https://ink-sepolia.drpc.org"],
blockExplorerUrls: ["https://explorer-sepolia.inkonchain.com"],
},
};

export const CHAIN_IDS: ChainIds = {
Expand Down Expand Up @@ -399,6 +413,7 @@ export const CHAIN_IDS: ChainIds = {
SEPOLIA_NETWORK_CHAIN_ID: { Mainnet: 0, Testnet: 11155111, Devnet: 11155111 },
SNAXCHAIN_NETWORK_CHAIN_ID: { Mainnet: 2192, Testnet: 13001, Devnet: 13001 },
XLAYER_NETWORK_CHAIN_ID: { Mainnet: 196, Testnet: 195, Devnet: 195 },
INK_NETWORK_CHAIN_ID: { Mainnet: 57073, Testnet: 763373, Devnet: 763373 },
};

export const getEvmChainId = (chainId: ChainId, currentNetwork: Network): number | undefined => {
Expand Down Expand Up @@ -429,6 +444,7 @@ export const getEvmChainId = (chainId: ChainId, currentNetwork: Network): number
[chainToChainId("Sepolia")]: CHAIN_IDS.SEPOLIA_NETWORK_CHAIN_ID[currentNetwork],
[chainToChainId("Snaxchain")]: CHAIN_IDS.SNAXCHAIN_NETWORK_CHAIN_ID[currentNetwork],
[chainToChainId("Xlayer")]: CHAIN_IDS.XLAYER_NETWORK_CHAIN_ID[currentNetwork],
[chainToChainId("Ink")]: CHAIN_IDS.INK_NETWORK_CHAIN_ID[currentNetwork],
};

const evmChainId = chainNetworks[chainId as keyof typeof chainNetworks];
Expand Down
18 changes: 18 additions & 0 deletions src/utils/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import EvmosIcon from "src/icons/blockchains/evmos.svg";
import FantomIcon from "src/icons/blockchains/fantom.svg";
import HederaIcon from "src/icons/blockchains/hedera.svg";
import InjectiveIcon from "src/icons/blockchains/injective.svg";
import InkIcon from "src/icons/blockchains/ink.svg";
import KaruraIcon from "src/icons/blockchains/karura.svg";
import KlaytnIcon from "src/icons/blockchains/klaytn.svg";
import KujiraIcon from "src/icons/blockchains/kujira.svg";
Expand Down Expand Up @@ -70,6 +71,7 @@ import EvmosColorlessIcon from "src/icons/blockchains/colorless/evmos.svg";
import FantomColorlessIcon from "src/icons/blockchains/colorless/fantom.svg";
import HederaColorlessIcon from "src/icons/blockchains/colorless/hedera.svg";
import InjectiveColorlessIcon from "src/icons/blockchains/colorless/injective.svg";
import InkColorlessIcon from "src/icons/blockchains/colorless/ink.svg";
import KaruraColorlessIcon from "src/icons/blockchains/colorless/karura.svg";
import KlaytnColorlessIcon from "src/icons/blockchains/colorless/klaytn.svg";
import KujiraColorlessIcon from "src/icons/blockchains/colorless/kujira.svg";
Expand Down Expand Up @@ -483,6 +485,22 @@ const WORMHOLE_CHAINS: any = {
return this.explorer?.[network] + "/transaction/" + value;
},
},
[chainToChainId("Ink")]: {
name: "Ink",
icon: InkIcon,
colorlessIcon: InkColorlessIcon,
explorer: {
Testnet: "https://explorer-sepolia.inkonchain.com",
Devnet: "https://explorer-sepolia.inkonchain.com",
Mainnet: "https://explorer.inkonchain.com",
},
getExplorerBaseURL: function ({ network = "Mainnet", value, base }: ExplorerBaseURLInput) {
if (base === "address") return this.explorer?.[network] + "/address/" + value;
if (base === "token") return this.explorer?.[network] + "/token/" + value;
if (base === "block") return this.explorer?.[network] + "/block/" + value;
return this.explorer?.[network] + "/tx/" + value;
},
},
[chainToChainId("Karura")]: {
name: "Karura",
icon: KaruraIcon,
Expand Down

0 comments on commit dcb5a7d

Please sign in to comment.