-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat: Add redesigned ERC20 Approve confirmation and SpendingCap section #26606
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
fd15e88
to
e0713a6
Compare
ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.ts
Outdated
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/hooks/use-is-nft.ts
Outdated
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/hooks/use-is-nft.ts
Outdated
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/hooks/use-is-nft.ts
Outdated
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/hooks/use-received-token.ts
Outdated
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/approve.tsx
Outdated
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.ts
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/approve.tsx
Outdated
Show resolved
Hide resolved
ui/pages/confirmations/components/confirm/info/approve/approve.tsx
Outdated
Show resolved
Hide resolved
test/e2e/tests/confirmations/transactions/erc20-increase-allowance-redesign.spec.ts
Outdated
Show resolved
Hide resolved
d3260a4
to
8c3d68e
Compare
@pedronfigueiredo for the erc20 approve and increaseAllowance, can we update the subtitle copy and the copy within the estimated changes to match the one here? Ty 💛 Subtitle Estimated changes Key row within Estimated changes |
8afe36c
to
f86909d
Compare
Builds ready [f86909d]
Page Load Metrics (81 ± 12 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #26606 +/- ##
===========================================
- Coverage 70.08% 70.06% -0.02%
===========================================
Files 1414 1417 +3
Lines 49328 49407 +79
Branches 13781 13811 +30
===========================================
+ Hits 34568 34615 +47
- Misses 14760 14792 +32 ☔ View full report in Codecov by Sentry. |
c72ec54
to
07b3a7d
Compare
07b3a7d
to
1eb241f
Compare
Quality Gate passedIssues Measures |
Builds ready [50a7441]
Page Load Metrics (1793 ± 80 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
} | ||
editIconClassName="edit-spending-cap" | ||
/> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting JSX in variable is INHO not great idea, any reason for not including it inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the idea is to reduce code duplication in the following code block
<ConfirmInfoRow
label={t('spendingCap')}
tooltip={t('spendingCapTooltipDesc')}
>
{tokenAmount === UNLIMITED_MSG ? (
<Tooltip title={formattedTokenNum}>{SpendingCapElement}</Tooltip>
) : (
SpendingCapElement
)}
</ConfirmInfoRow>
This was changed to address feedback on this comment #26606 (comment)
symbol: string; | ||
}; | ||
|
||
export const useReceivedToken = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this file now be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be removed in the next PR
switch (confirmation?.type) { | ||
case TransactionType.contractInteraction: | ||
return t('confirmTitleTransaction'); | ||
case TransactionType.tokenMethodApprove: | ||
return t('confirmTitleApproveTransaction'); | ||
if (isNFT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, ternary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keeping it as is for now since it's the pattern in use in this file
); | ||
}, [transactionMeta]); | ||
|
||
const isNFT = value?.standard !== TokenStandard.ERC20; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, I appreciate we're only using this for labels currently, but one to keep an eye on as some wouldn't consider an ERC-1155 an NFT if it supported multiple of a token ID.
|
||
const decodedSpendingCap = value | ||
? new BigNumber(value.data[0].params[1].value) | ||
.dividedBy(new BigNumber(10).pow(Number(decimals))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, not the problem of this PR but we do this math a lot so a applyDecimals
util or similar would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be addressed in a later PR
Description
Introduces support for ERC20 token transactions with the
approve
type. This includes a new spending cap section and bespoke logic in the "static simulation" section. Above a certain threshold, spending caps are represented as "Unlimited".Related issues
Fixes: #2924
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist