Skip to content

Conversation

@kien-ngo
Copy link
Contributor

@kien-ngo kien-ngo commented Nov 4, 2024

Fix various issues with ERC20 claim conditions since we up'd it to v5 on the dashboard


PR-Codex overview

This PR focuses on enhancing the handling of tokenDecimals for ERC20 tokens in the ClaimConditionsForm and related components, ensuring proper validation and conversion of values based on token type.

Detailed summary

  • Modified isDisabled properties in MaxClaimableSupplyInput and MaxClaimablePerWalletInput to account for tokenDecimals.
  • Updated ClaimConditionsForm to handle tokenDecimals as number | undefined.
  • Added checks for loading and existence of tokenDecimals.
  • Introduced conversion functions for ERC20 values to and from display format.
  • Adjusted logic in setClaimPhasesTx and getClaimPhasesInLegacyFormat to use tokenDecimals for ERC20 claims.
  • Improved error handling and user feedback when tokenDecimals cannot be fetched.

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

@vercel
Copy link

vercel bot commented Nov 4, 2024

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

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 5:37am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Nov 6, 2024 5:37am
thirdweb_playground ⬜️ Skipped (Inspect) Nov 6, 2024 5:37am
wallet-ui ⬜️ Skipped (Inspect) Nov 6, 2024 5:37am

@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 4, 2024 17:16 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 4, 2024 17:16 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui November 4, 2024 17:16 Inactive
@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2024

⚠️ No Changeset found

Latest commit: d65387b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 4, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

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

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Nov 4, 2024
Copy link
Contributor Author

kien-ngo commented Nov 4, 2024

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

Join @kien-ngo and the rest of your teammates on Graphite Graphite

@kien-ngo kien-ngo marked this pull request as ready for review November 4, 2024 17:17
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 43 KB (0%) 861 ms (0%) 1.1 s (+112.19% 🔺) 1.9 s
thirdweb (cjs) 103 KB (0%) 2.1 s (0%) 1.2 s (+11.64% 🔺) 3.2 s
thirdweb (minimal + tree-shaking) 4.85 KB (0%) 97 ms (0%) 79 ms (+41.18% 🔺) 176 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 8 ms (-5.56% 🔽) 18 ms
thirdweb/react (minimal + tree-shaking) 17.51 KB (0%) 351 ms (0%) 143 ms (-3.02% 🔽) 493 ms

@kien-ngo kien-ngo self-assigned this Nov 4, 2024
@kien-ngo kien-ngo added the DO NOT MERGE This pull request is still in progress and is not ready to be merged. label Nov 4, 2024 — with Graphite App
@kien-ngo kien-ngo marked this pull request as draft November 4, 2024 18:32
@kien-ngo kien-ngo force-pushed the kien/fix-erc20-claim-condition branch from 7c07fda to 047c948 Compare November 5, 2024 01:01
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 5, 2024 01:02 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 5, 2024 01:02 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui November 5, 2024 01:02 Inactive
@kien-ngo kien-ngo force-pushed the kien/fix-erc20-claim-condition branch from 047c948 to 99c3a53 Compare November 5, 2024 01:03
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 5, 2024 01:03 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 5, 2024 01:03 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui November 5, 2024 01:03 Inactive
@codecov
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.61%. Comparing base (418e3e4) to head (d65387b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5284   +/-   ##
=======================================
  Coverage   45.61%   45.61%           
=======================================
  Files        1068     1068           
  Lines       55556    55556           
  Branches     4047     4047           
=======================================
  Hits        25341    25341           
  Misses      29525    29525           
  Partials      690      690           
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 418e3e4
packages 40.72% <ø> (ø)

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

@kien-ngo kien-ngo force-pushed the kien/fix-erc20-claim-condition branch from 99c3a53 to 867f277 Compare November 5, 2024 01:14
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 5, 2024 01:14 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 5, 2024 01:14 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui November 5, 2024 01:14 Inactive
@kien-ngo kien-ngo marked this pull request as ready for review November 5, 2024 01:21
@kien-ngo kien-ngo removed the DO NOT MERGE This pull request is still in progress and is not ready to be merged. label Nov 5, 2024
@kien-ngo kien-ngo force-pushed the kien/fix-erc20-claim-condition branch from 867f277 to 7f09c4b Compare November 5, 2024 01:41
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 5, 2024 01:41 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 5, 2024 01:41 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui November 5, 2024 01:41 Inactive
return "unlimited";
}
if (decimals) {
return toTokens(value, decimals);
Copy link
Member

Choose a reason for hiding this comment

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

why do you need this here? unlimited should be the same no matter the decimals no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is similar to toBigInt. While toBigInt converts the value to send it to the blockchain, toUnlimited converts the value from the blockchain to display it on the UI.

Without this new logic, a maxClaimableSupply of 100 tokens will be displayed on the frontend as: 100000000000000000000n

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code pattern to make it similar to toBigInt

// so we need to convert it using toUnits
maxClaimableSupply: toBigInt(
phase.maxClaimableSupply,
baseOptions.type === "erc20" ? baseOptions.decimals : undefined,
Copy link
Member

Choose a reason for hiding this comment

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

feels a bit confusing to bake this logic inside toBigInt - i think i would separate it at this level, and do an explicit to toUnits here instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated ^

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 6, 2024

Merge activity

Fix various issues with ERC20 claim conditions since we up'd it to v5 on the dashboard

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing the handling of `tokenDecimals` for ERC20 tokens in the claim conditions form, ensuring that the application correctly manages and displays the maximum claimable supply and per wallet limits based on the token's decimal precision.

### Detailed summary
- Updated `MaxClaimableSupplyInput` and `MaxClaimablePerWalletInput` to disable inputs if `tokenDecimals` is not available.
- Changed `tokenDecimals` type from `number` to `number | undefined`.
- Enhanced fetching logic for `tokenDecimals` in the claim conditions form.
- Added error handling for missing `tokenDecimals` when submitting forms.
- Introduced conversion functions for handling ERC20 values in wei and display format.
- Updated `toBigInt` function to return `bigint | undefined`.
- Adjusted `toUnlimited` function to maintain clarity on unlimited values.

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

<!-- end pr-codex -->
@kien-ngo kien-ngo force-pushed the kien/fix-erc20-claim-condition branch from 1f3ee9c to d65387b Compare November 6, 2024 05:26
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 6, 2024 05:27 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui November 6, 2024 05:27 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 6, 2024 05:27 Inactive
@graphite-app graphite-app bot merged commit d65387b into main Nov 6, 2024
32 checks passed
@graphite-app graphite-app bot deleted the kien/fix-erc20-claim-condition branch November 6, 2024 05:37
@vercel vercel bot temporarily deployed to Production – docs-v2 November 6, 2024 05:37 Inactive
@vercel vercel bot temporarily deployed to Production – wallet-ui November 6, 2024 05:37 Inactive
@vercel vercel bot temporarily deployed to Production – thirdweb_playground November 6, 2024 05:37 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dashboard Involves changes to the Dashboard.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants