Skip to content

SD-102: Fix allowance fee not shown in pending transaction#92

Merged
rAskVAL merged 5 commits intomainfrom
sd-102-fees-improvements
Jul 16, 2025
Merged

SD-102: Fix allowance fee not shown in pending transaction#92
rAskVAL merged 5 commits intomainfrom
sd-102-fees-improvements

Conversation

@rAskVAL
Copy link
Contributor

@rAskVAL rAskVAL commented Jun 30, 2025

No description provided.

@aws-amplify-eu-central-1
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-92.d1rxgx3w89g7ku.amplifyapp.com

Comment on lines -23 to -45
const { data: needsApproval } = useQuery({
queryKey: chainConfig && walletAddress && shouldCheckAllowance ?
getQueryKey.allowanceCheck(token.address, chainConfig.id.toString(), walletAddress, amount.toString()) : [],
queryFn: !publicClient || !chainConfig?.shielderConfig || !walletAddress || !shouldCheckAllowance ?
skipToken :
async (): Promise<boolean> => {
try {
const shielderConfig = chainConfig.shielderConfig;
if (!shielderConfig) return false;

const allowance = await publicClient.readContract({
address: token.address,
abi: erc20Abi,
functionName: 'allowance',
args: [walletAddress, shielderConfig.shielderContractAddress],
});
return allowance < amount;
} catch {
return false;
}
},
enabled: shouldCheckAllowance && !!publicClient && !!chainConfig?.shielderConfig && !!walletAddress,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously I was checking if the user actually needed allowance approval before calculating and showing the estimate. The issue with this approach is that if we want to display the estimate after the user already approved the allowance, this check returns false, so the fee estimate isn’t calculated or shown. This happened for example with pending transactions where the allowance fee wasn’t displayed.

I think it’s fine to always show the estimate, even in edge cases where the allowance check isn’t needed. We’re showing the maximum possible fees anyway, so if the allowance fee doesn’t apply, the actual fee will just be lower, which is acceptable in my opinion.

useEffect(() => {
const handleEsc = (e: KeyboardEvent) => {
if (e.key === 'Escape' && !nonDismissible) {
// Only handle ESC key if this is the top modal and it's not non-dismissible
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for this comment imo - the code explains that perfectly clearly.

@rAskVAL rAskVAL force-pushed the sd-102-fees-improvements branch from 88636b8 to 11d8898 Compare July 16, 2025 06:56
@rAskVAL rAskVAL merged commit f167cd9 into main Jul 16, 2025
6 checks passed
@rAskVAL rAskVAL deleted the sd-102-fees-improvements branch July 16, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants