clients: allow custom block range for relayer status (#3188)
This commit is contained in:
parent
8120772e95
commit
70dd001ba3
|
@ -315,14 +315,16 @@ Options:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
Positionals:
|
Positionals:
|
||||||
network Network [choices: "mainnet", "testnet", "devnet"]
|
network Network [choices: "mainnet", "testnet", "devnet"]
|
||||||
chain Source chain
|
chain Source chain
|
||||||
[choices: "unset", "solana", "ethereum", "terra", "bsc", "polygon",
|
[choices: "unset", "solana", "ethereum", "terra", "bsc", "polygon",
|
||||||
"avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala",
|
"avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala",
|
||||||
"klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective",
|
"klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective",
|
||||||
"osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet",
|
"osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet",
|
||||||
"xpla", "btc", "base", "sei", "wormchain", "sepolia"]
|
"xpla", "btc", "base", "sei", "wormchain", "sepolia"]
|
||||||
tx Source transaction hash [string]
|
tx Source transaction hash [string]
|
||||||
|
block-start Starting Block Range, i.e. -2048 [string]
|
||||||
|
block-end Ending Block Range, i.e. latest [string]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Show help [boolean]
|
--help Show help [boolean]
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
assertChain,
|
assertChain,
|
||||||
} from "@certusone/wormhole-sdk/lib/esm/utils/consts";
|
} from "@certusone/wormhole-sdk/lib/esm/utils/consts";
|
||||||
import { relayer, Network } from "@certusone/wormhole-sdk";
|
import { relayer, Network } from "@certusone/wormhole-sdk";
|
||||||
import yargs from "yargs";
|
import yargs, { string } from "yargs";
|
||||||
import { CONTRACTS, NETWORKS } from "../consts";
|
import { CONTRACTS, NETWORKS } from "../consts";
|
||||||
import { assertNetwork } from "../utils";
|
import { assertNetwork } from "../utils";
|
||||||
import { impossible } from "../vaa";
|
import { impossible } from "../vaa";
|
||||||
|
@ -29,6 +29,14 @@ export const builder = (y: typeof yargs) =>
|
||||||
describe: "Source transaction hash",
|
describe: "Source transaction hash",
|
||||||
type: "string",
|
type: "string",
|
||||||
demandOption: true,
|
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);
|
} as const);
|
||||||
export const handler = async (
|
export const handler = async (
|
||||||
argv: Awaited<ReturnType<typeof builder>["argv"]>
|
argv: Awaited<ReturnType<typeof builder>["argv"]>
|
||||||
|
@ -55,12 +63,35 @@ export const handler = async (
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
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, {
|
const info = await relayer.getWormholeRelayerInfo(chain, argv.tx, {
|
||||||
environment: network,
|
environment: network,
|
||||||
sourceChainProvider,
|
sourceChainProvider,
|
||||||
targetChainProviders,
|
targetChainProviders,
|
||||||
|
targetChainBlockRanges,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(relayer.stringifyWormholeRelayerInfo(info));
|
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"
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue