Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clients sdk update #3416

Closed
wants to merge 9 commits into from
Closed
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
20 changes: 11 additions & 9 deletions clients/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ 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", "wormchain", "sepolia"]
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "sepolia"]
-n, --network Network
[required] [choices: "mainnet", "testnet", "devnet"]
-a, --contract-address Contract to submit VAA to (override config) [string]
Expand Down Expand Up @@ -310,13 +311,15 @@ 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", "wormchain", "sepolia"]
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "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", "wormchain", "sepolia"]
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "sepolia"]
--dst-addr destination address [string] [required]
--token-addr token address [string] [default: native token]
--amount token amount [string] [required]
Expand All @@ -342,16 +345,15 @@ Options:

```sh
Positionals:
network Network [choices: "mainnet", "testnet", "devnet"]
chain Source chain
network Network [choices: "mainnet", "testnet", "devnet"]
chain Source chain
[choices: "unset", "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", "wormchain", "sepolia"]
tx Source transaction hash [string]
block-start Starting Block Range, i.e. -2048 [string]
block-end Ending Block Range, i.e. latest [string]
"xpla", "btc", "base", "sei", "rootstock", "wormchain", "cosmoshub", "evmos",
"kujira", "sepolia"]
tx Source transaction hash [string]

Options:
--help Show help [boolean]
Expand Down
81 changes: 27 additions & 54 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.9.24-beta.0",
"@certusone/wormhole-sdk": "^0.10.5-beta.3",
"@cosmjs/encoding": "^0.26.2",
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
"@injectivelabs/networks": "^1.10.7",
Expand Down
4 changes: 4 additions & 0 deletions clients/js/src/chains/generic/getOriginalAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export const getOriginalAsset = async (
case "osmosis":
case "pythnet":
case "wormchain":
case "cosmoshub":
case "evmos":
case "kujira":
case "rootstock":
throw new Error(`${chainName} not supported`);
default:
impossible(chainName);
Expand Down
4 changes: 4 additions & 0 deletions clients/js/src/chains/generic/getWrappedAssetAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ export const getWrappedAssetAddress = async (
case "osmosis":
case "pythnet":
case "wormchain":
case "cosmoshub":
case "evmos":
case "kujira":
case "rootstock":
throw new Error(`${chainName} not supported`);
default:
impossible(chainName);
Expand Down
4 changes: 4 additions & 0 deletions clients/js/src/chains/generic/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export const getProviderForChain = <T extends ChainId | ChainName>(
case "osmosis":
case "pythnet":
case "wormchain":
case "cosmoshub":
case "evmos":
case "kujira":
case "rootstock":
throw new Error(`${chainName} not supported`);
default:
impossible(chainName);
Expand Down
12 changes: 8 additions & 4 deletions clients/js/src/cmds/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@ function parseAddress(chain: ChainName, address: string): string {
return "0x" + evm_address(address);
} else if (chain === "near") {
return "0x" + evm_address(address);
} else if (chain === "osmosis") {
throw Error("OSMOSIS is not supported yet");
} else if (chain === "sui") {
return "0x" + evm_address(address);
} else if (chain === "aptos") {
Expand All @@ -321,10 +319,16 @@ function parseAddress(chain: ChainName, address: string): string {
}

return sha3_256(Buffer.from(address)); // address is hash of fully qualified type
} else if (chain === "wormchain") {
return "0x" + tryNativeToHexString(address, chain);
} else if (chain === "btc") {
throw Error("btc is not supported yet");
} else if (chain === "cosmoshub") {
throw Error("cosmoshub is not supported yet");
} else if (chain === "evmos") {
throw Error("evmos is not supported yet");
} else if (chain === "kujira") {
throw Error("kujira is not supported yet");
} else if (chain === "rootstock") {
throw Error("rootstock is not supported yet");
} else {
impossible(chain);
}
Expand Down
33 changes: 1 addition & 32 deletions clients/js/src/cmds/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ export const builder = (y: typeof yargs) =>
describe: "Source transaction hash",
type: "string",
demandOption: true,
} as const)
.positional("block-start", {
describe: "Starting Block Range, i.e. -2048",
type: "string",
} as const)
.positional("block-end", {
describe: "Ending Block Range, i.e. latest",
type: "string",
} as const);
export const handler = async (
argv: Awaited<ReturnType<typeof builder>["argv"]>
Expand All @@ -59,39 +51,16 @@ export const handler = async (
targetChainProviders.set(
key as ChainName,
new ethers.providers.JsonRpcProvider(
NETWORKS[network][key as ChainName].rpc
NETWORKS[network as Network][key as ChainName].rpc
)
);
}
const targetChainBlockRanges = new Map<
ChainName,
[ethers.providers.BlockTag, ethers.providers.BlockTag]
>();
const getBlockTag = (tagString: string): ethers.providers.BlockTag => {
if (+tagString) return parseInt(tagString);
return tagString;
};
for (const key in NETWORKS[network]) {
targetChainBlockRanges.set(key as ChainName, [
getBlockTag(argv["block-start"] || "-2048"),
getBlockTag(argv["block-end"] || "latest"),
]);
}

const info = await relayer.getWormholeRelayerInfo(chain, argv.tx, {
environment: network,
sourceChainProvider,
targetChainProviders,
targetChainBlockRanges,
});

console.log(relayer.stringifyWormholeRelayerInfo(info));
if (
info.targetChainStatus.events[0].status ===
relayer.DeliveryStatus.DeliveryDidntHappenWithinRange
) {
console.log(
"Try using the '--block-start' and '--block-end' flags to specify a different block range"
);
}
};
8 changes: 8 additions & 0 deletions clients/js/src/cmds/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ async function executeSubmit(
throw Error("Wormchain is not supported yet");
} else if (chain === "btc") {
throw Error("btc is not supported yet");
} else if (chain === "cosmoshub") {
throw Error("Cosmoshub is not supported yet");
} else if (chain === "evmos") {
throw Error("Evmos is not supported yet");
} else if (chain === "kujira") {
throw Error("kujira is not supported yet");
} else if (chain === "rootstock") {
throw Error("rootstock is not supported yet");
} else {
// If you get a type error here, hover over `chain`'s type and it tells you
// which cases are not handled
Expand Down
8 changes: 8 additions & 0 deletions clients/js/src/cmds/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ export const handler = async (
throw Error("Wormchain is not supported yet");
} else if (srcChain === "btc") {
throw Error("btc is not supported yet");
} else if (srcChain === "cosmoshub") {
throw Error("cosmoshub is not supported yet");
} else if (srcChain === "evmos") {
throw Error("evmos is not supported yet");
} else if (srcChain === "kujira") {
throw Error("kujira is not supported yet");
} else if (srcChain === "rootstock") {
throw Error("rootstock is not supported yet");
} else {
// If you get a type error here, hover over `chain`'s type and it tells you
// which cases are not handled
Expand Down
Loading