Skip to content

Commit

Permalink
refactor: Align /suggested-fees inputs w/ SpokePool names (#890)
Browse files Browse the repository at this point in the history
To reduce misalignment between the SpokePool deposit() input parameters
and the parameter names supplied to /suggested-fees, rename the
following:

 recipientAddress -> recipient
 relayerAddress -> relayer

This leaves only `token` as the variable name that differs.
  • Loading branch information
pxrl authored Oct 30, 2023
1 parent 2643dab commit 85c8621
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions api/suggested-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const SuggestedFeesQueryParamsSchema = type({
timestamp: optional(positiveIntStr()),
skipAmountLimit: optional(boolStr()),
message: optional(string()),
recipientAddress: optional(validAddress()),
relayerAddress: optional(validAddress()),
recipient: optional(validAddress()),
relayer: optional(validAddress()),
});

type SuggestedFeesQueryParams = Infer<typeof SuggestedFeesQueryParamsSchema>;
Expand Down Expand Up @@ -72,8 +72,8 @@ const handler = async (
originChainId,
timestamp,
skipAmountLimit,
recipientAddress,
relayerAddress,
recipient,
relayer,
message,
} = query;

Expand All @@ -82,8 +82,8 @@ const handler = async (
}
const destinationChainId = Number(_destinationChainId);

relayerAddress ??= sdk.constants.DEFAULT_SIMULATED_RELAYER_ADDRESS;
recipientAddress ??= DEFAULT_SIMULATED_RECIPIENT_ADDRESS;
relayer ??= sdk.constants.DEFAULT_SIMULATED_RELAYER_ADDRESS;
recipient ??= DEFAULT_SIMULATED_RECIPIENT_ADDRESS;
token = ethers.utils.getAddress(token);

const [latestBlock, tokenDetails] = await Promise.all([
Expand All @@ -101,7 +101,7 @@ const handler = async (
throw new InputError("Message must be an even hex string");
}
const isRecipientAContract = await sdk.utils.isContractDeployedToAddress(
recipientAddress,
recipient,
getProvider(destinationChainId)
);
if (!isRecipientAContract) {
Expand All @@ -124,12 +124,13 @@ const handler = async (
}
const balanceOfToken = await getCachedTokenBalance(
destinationChainId,
relayerAddress,
relayer,
destinationToken
);
if (balanceOfToken.lt(amountInput)) {
throw new InputError(
`Relayer Address (${relayerAddress}) doesn't have enough funds to support this deposit. For help, please reach out to https://discord.across.to`
`Relayer Address (${relayer}) doesn't have enough funds to support this deposit;` +
` for help, please reach out to https://discord.across.to`
);
}
}
Expand Down Expand Up @@ -208,10 +209,10 @@ const handler = async (
amount,
computedOriginChainId,
destinationChainId,
recipientAddress,
recipient,
tokenPrice,
message,
relayerAddress
relayer
);

const skipAmountLimitEnabled = skipAmountLimit === "true";
Expand Down

2 comments on commit 85c8621

@vercel
Copy link

@vercel vercel bot commented on 85c8621 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

goerli-frontend-v2 – ./

goerli-frontend-v2-git-master-uma.vercel.app
goerli-frontend-v2-uma.vercel.app
goerli-frontend-v2.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 85c8621 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.