Skip to content

[SDK] fix: Requery allowances on quote screen return #6187

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

Merged

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Feb 7, 2025


PR-Codex overview

This PR focuses on enhancing the handling of approval amounts in the thirdweb package, specifically in the Buy flow. It introduces changes to manage approval data more effectively, ensuring that allowance checks are performed correctly before transactions.

Detailed summary

  • Added approvalAmount property in various components.
  • Replaced approval with approvalData in BuyWithCryptoTransfer and BuyWithCryptoQuote types.
  • Implemented allowance checks in PostOnRampSwap, TransferConfirmationScreen, and SwapConfirmationScreen.
  • Updated logic to determine if approval is needed based on approvalData.
  • Adjusted transaction handling to include approval transactions when necessary.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Feb 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 3:10am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 3:10am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 3:10am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 3:10am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 3:10am

Copy link

changeset-bot bot commented Feb 7, 2025

🦋 Changeset detected

Latest commit: edaaef5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter Patch
thirdweb-login Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Feb 7, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 46.23 KB (-0.98% 🔽) 925 ms (-0.98% 🔽) 2.8 s (+45.2% 🔺) 3.8 s
thirdweb (cjs) 121.93 KB (-0.52% 🔽) 2.5 s (-0.52% 🔽) 6.2 s (+8.23% 🔺) 8.6 s
thirdweb (minimal + tree-shaking) 5.58 KB (0%) 112 ms (0%) 394 ms (+59.9% 🔺) 506 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 35 ms (-0.95% 🔽) 45 ms
thirdweb/react (minimal + tree-shaking) 19.29 KB (0%) 386 ms (0%) 695 ms (+10.73% 🔺) 1.1 s

props.quote.approvalData &&
props.preApprovedAmount !== undefined &&
props.preApprovedAmount < BigInt(props.quote.approvalData.amountWei);
console.log("needsApproval", needsApproval);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this console.log statement as it appears to be debugging code that shouldn't be committed to production.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 9.44882% with 115 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@18f0e57). Learn more about missing BASE report.
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...et/screens/Buy/swap/TransferConfirmationScreen.tsx 7.69% 36 Missing ⚠️
...act/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx 11.76% 30 Missing ⚠️
.../ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx 9.37% 29 Missing ⚠️
...nectWallet/screens/Buy/swap/ConfirmationScreen.tsx 10.52% 17 Missing ⚠️
...ackages/thirdweb/src/pay/buyWithCrypto/getQuote.ts 0.00% 1 Missing ⚠️
...ages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts 0.00% 1 Missing ⚠️
...web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.tsx 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (9.44%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6187   +/-   ##
=======================================
  Coverage        ?   56.87%           
=======================================
  Files           ?     1155           
  Lines           ?    63988           
  Branches        ?     5200           
=======================================
  Hits            ?    36395           
  Misses          ?    26865           
  Partials        ?      728           
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (?) Carriedforward from dfd64d2
packages 55.07% <9.44%> (?)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...ackages/thirdweb/src/pay/buyWithCrypto/getQuote.ts 5.40% <0.00%> (ø)
...ages/thirdweb/src/pay/buyWithCrypto/getTransfer.ts 7.27% <0.00%> (ø)
...web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.tsx 8.64% <0.00%> (ø)
...nectWallet/screens/Buy/swap/ConfirmationScreen.tsx 8.80% <10.52%> (ø)
.../ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx 11.02% <9.37%> (ø)
...act/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx 4.24% <11.76%> (ø)
...et/screens/Buy/swap/TransferConfirmationScreen.tsx 10.60% <7.69%> (ø)

@joaquim-verges joaquim-verges merged commit ee57ded into main Feb 7, 2025
31 of 33 checks passed
@joaquim-verges joaquim-verges deleted the _SDK_fix_Requery_allowances_on_quote_screen_return branch February 7, 2025 05:00
@joaquim-verges joaquim-verges mentioned this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants