Skip to content

Commit

Permalink
Client/JS: Add new chains (#3610)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley authored Dec 20, 2023
1 parent 818038e commit 14144c8
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 26 deletions.
20 changes: 12 additions & 8 deletions clients/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ Options:
"avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala",
"klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective",
"osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet",
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "sepolia"]
"xpla", "btc", "base", "sei", "rootstock", "scroll", "mantle", "wormchain",
"cosmoshub", "evmos", "kujira", "neutron", "celestia", "sepolia",
"arbitrum_sepolia", "base_sepolia", "optimism_sepolia"]
-n, --network Network
[required] [choices: "mainnet", "testnet", "devnet"]
-a, --contract-address Contract to submit VAA to (override config) [string]
Expand Down Expand Up @@ -311,15 +312,17 @@ Options:
"avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala",
"klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective",
"osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet",
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "sepolia"]
"xpla", "btc", "base", "sei", "rootstock", "scroll", "mantle", "wormchain",
"cosmoshub", "evmos", "kujira", "neutron", "celestia", "sepolia",
"arbitrum_sepolia", "base_sepolia", "optimism_sepolia"]
--dst-chain destination chain
[required] [choices: "solana", "ethereum", "terra", "bsc", "polygon",
"avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala",
"klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective",
"osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet",
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "sepolia"]
"xpla", "btc", "base", "sei", "rootstock", "scroll", "mantle", "wormchain",
"cosmoshub", "evmos", "kujira", "neutron", "celestia", "sepolia",
"arbitrum_sepolia", "base_sepolia", "optimism_sepolia"]
--dst-addr destination address [string] [required]
--token-addr token address [string] [default: native token]
--amount token amount [string] [required]
Expand Down Expand Up @@ -351,8 +354,9 @@ Positionals:
"avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala",
"klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective",
"osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet",
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "sepolia"]
"xpla", "btc", "base", "sei", "rootstock", "scroll", "mantle", "wormchain",
"cosmoshub", "evmos", "kujira", "neutron", "celestia", "sepolia",
"arbitrum_sepolia", "base_sepolia", "optimism_sepolia"]
tx Source transaction hash [string]

Options:
Expand Down
30 changes: 15 additions & 15 deletions clients/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"dependencies": {
"@celo-tools/celo-ethers-wrapper": "^0.1.0",
"@certusone/wormhole-sdk": "^0.10.5-beta.3",
"@certusone/wormhole-sdk": "^0.10.7",
"@cosmjs/encoding": "^0.26.2",
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
"@injectivelabs/networks": "^1.10.7",
Expand Down
9 changes: 8 additions & 1 deletion clients/js/src/chains/generic/getOriginalAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ export const getOriginalAsset = async (
case "optimism":
case "polygon":
// case "rootstock":
case "sepolia": {
case "scroll":
case "mantle":
case "sepolia":
case "arbitrum_sepolia":
case "base_sepolia":
case "optimism_sepolia": {
const provider = getProviderForChain(chainName, network, { rpc });
return getOriginalAssetEth(
tokenBridgeAddress,
Expand Down Expand Up @@ -113,6 +118,8 @@ export const getOriginalAsset = async (
case "cosmoshub":
case "evmos":
case "kujira":
case "neutron":
case "celestia":
case "rootstock":
throw new Error(`${chainName} not supported`);
default:
Expand Down
9 changes: 8 additions & 1 deletion clients/js/src/chains/generic/getWrappedAssetAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export const getWrappedAssetAddress = async (
case "optimism":
case "polygon":
// case "rootstock":
case "sepolia": {
case "scroll":
case "mantle":
case "sepolia":
case "arbitrum_sepolia":
case "base_sepolia":
case "optimism_sepolia": {
const provider = getProviderForChain(chainName, network, { rpc });
return getForeignAssetEth(
tokenBridgeAddress,
Expand Down Expand Up @@ -159,6 +164,8 @@ export const getWrappedAssetAddress = async (
case "cosmoshub":
case "evmos":
case "kujira":
case "neutron":
case "celestia":
case "rootstock":
throw new Error(`${chainName} not supported`);
default:
Expand Down
7 changes: 7 additions & 0 deletions clients/js/src/chains/generic/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export const getProviderForChain = <T extends ChainId | ChainName>(
case "optimism":
case "polygon":
// case "rootstock":
case "scroll":
case "mantle":
case "sepolia":
case "arbitrum_sepolia":
case "base_sepolia":
case "optimism_sepolia":
return new ethers.providers.JsonRpcProvider(rpc) as ChainProvider<T>;
case "terra":
case "terra2":
Expand Down Expand Up @@ -157,6 +162,8 @@ export const getProviderForChain = <T extends ChainId | ChainName>(
case "cosmoshub":
case "evmos":
case "kujira":
case "neutron":
case "celestia":
case "rootstock":
throw new Error(`${chainName} not supported`);
default:
Expand Down
4 changes: 4 additions & 0 deletions clients/js/src/cmds/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ async function executeSubmit(
throw Error("Evmos is not supported yet");
} else if (chain === "kujira") {
throw Error("kujira is not supported yet");
} else if (chain === "neutron") {
throw Error("neutron is not supported yet");
} else if (chain === "celestia") {
throw Error("celestia is not supported yet");
} else if (chain === "rootstock") {
throw Error("rootstock is not supported yet");
} else {
Expand Down
4 changes: 4 additions & 0 deletions clients/js/src/cmds/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ export const handler = async (
throw Error("evmos is not supported yet");
} else if (srcChain === "kujira") {
throw Error("kujira is not supported yet");
} else if (srcChain === "neutron") {
throw Error("neutron is not supported yet");
} else if (srcChain === "celestia") {
throw Error("celestia is not supported yet");
} else if (srcChain === "rootstock") {
throw Error("rootstock is not supported yet");
} else {
Expand Down
105 changes: 105 additions & 0 deletions clients/js/src/consts/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,41 @@ const MAINNET = {
key: undefined,
chain_id: undefined,
},
neutron: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
celestia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
scroll: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
mantle: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
arbitrum_sepolia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
base_sepolia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
optimism_sepolia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
};

const TESTNET = {
Expand Down Expand Up @@ -373,6 +408,41 @@ const TESTNET = {
key: undefined,
chain_id: undefined,
},
neutron: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
celestia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
scroll: {
rpc: "https://rpc.ankr.com/scroll_sepolia_testnet",
key: getEnvVar("ETH_KEY_TESTNET"),
chain_id: 534353,
},
mantle: {
rpc: "https://rpc.ankr.com/mantle_testnet",
key: getEnvVar("ETH_KEY_TESTNET"),
chain_id: 5001,
},
arbitrum_sepolia: {
rpc: "https://arbitrum-sepolia.publicnode.com",
key: getEnvVar("ETH_KEY_TESTNET"),
chain_id: 421614,
},
base_sepolia: {
rpc: "https://sepolia.base.org",
key: getEnvVar("ETH_KEY_TESTNET"),
chain_id: 84532,
},
optimism_sepolia: {
rpc: "https://rpc.ankr.com/optimism_sepolia",
key: getEnvVar("ETH_KEY_TESTNET"),
chain_id: 11155420,
},
};

const DEVNET = {
Expand Down Expand Up @@ -530,6 +600,41 @@ const DEVNET = {
rpc: undefined,
key: undefined,
},
neutron: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
celestia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
scroll: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
mantle: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
arbitrum_sepolia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
base_sepolia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
optimism_sepolia: {
rpc: undefined,
key: undefined,
chain_id: undefined,
},
};

/**
Expand Down

0 comments on commit 14144c8

Please sign in to comment.