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

refactor: Align /suggested-fees inputs w/ SpokePool names #890

Merged
merged 2 commits into from
Oct 30, 2023
Merged
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
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
Loading