Skip to content

Commit

Permalink
improve: Support slow fill requests in SpokePool script (#1802)
Browse files Browse the repository at this point in the history
Has been used to initiate a slow fill for a user in Discord.
  • Loading branch information
pxrl authored Sep 6, 2024
1 parent 1596ada commit 2225c03
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/spokepool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async function deposit(args: Record<string, number | string>, signer: Signer): P
}

async function fillDeposit(args: Record<string, number | string | boolean>, signer: Signer): Promise<boolean> {
const { txnHash, depositId: depositIdArg, execute } = args;
const { txnHash, depositId: depositIdArg, execute, slow } = args;
const originChainId = Number(args.chainId);

if (txnHash === undefined || typeof txnHash !== "string" || txnHash.length != 66 || !txnHash.startsWith("0x")) {
Expand Down Expand Up @@ -295,7 +295,9 @@ async function fillDeposit(args: Record<string, number | string | boolean>, sign
fromLiteChain: false, // Not relevant
toLiteChain: false, // Not relevant
};
const fill = await sdkUtils.populateV3Relay(destSpokePool, deposit, relayer);
const fill = isDefined(slow)
? await destSpokePool.populateTransaction.requestV3SlowFill(deposit)
: await sdkUtils.populateV3Relay(destSpokePool, deposit, relayer);

console.group("Fill Txn Info");
console.log(`to: ${fill.to}`);
Expand Down Expand Up @@ -459,7 +461,7 @@ function usage(badInput?: string): boolean {

const dumpConfigArgs = "--chainId";
const fetchArgs = "--chainId <chainId> [--depositId <depositId> | --txnHash <txnHash>]";
const fillArgs = "--chainId <originChainId> --txnHash <depositHash> [--depositId <depositId>] [--execute]";
const fillArgs = "--chainId <originChainId> --txnHash <depositHash> [--depositId <depositId>] [--slow] [--execute]";

const pad = "deposit".length;
usageStr += `
Expand Down Expand Up @@ -491,7 +493,7 @@ async function run(argv: string[]): Promise<number> {
const fetchDepositOpts = ["chainId", "depositId"];
const opts = {
string: ["wallet", ...configOpts, ...depositOpts, ...fetchOpts, ...fillOpts, ...fetchDepositOpts],
boolean: ["decimals", "execute"], // @dev tbd whether this is good UX or not...may need to change.
boolean: ["decimals", "execute", "slow"], // @dev tbd whether this is good UX or not...may need to change.
default: {
wallet: "secret",
decimals: false,
Expand Down

0 comments on commit 2225c03

Please sign in to comment.