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

chore: fix usdc send precision #3385

Merged
merged 7 commits into from
Dec 5, 2024
Merged

chore: fix usdc send precision #3385

merged 7 commits into from
Dec 5, 2024

Conversation

tomiir
Copy link
Collaborator

@tomiir tomiir commented Dec 3, 2024

Description

  • Number(4.1) * 1_000_000 = 4100000 (right?)
  • A former PM of mine would say: haha, computers
image
  • Adds Math.round and parseFloat to handle USDC amount parsing

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • [] Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

vercel bot commented Dec 3, 2024

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

Name Status Preview Comments Updated (UTC)
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 6:16pm
appkit-vue-solana ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 6:16pm
appkit-wagmi-cdn-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 6:16pm
vue-wagmi-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 6:16pm

Copy link

changeset-bot bot commented Dec 3, 2024

⚠️ No Changeset found

Latest commit: 50015aa

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

Copy link
Contributor

github-actions bot commented Dec 3, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 47.69% 12267 / 25720
🔵 Statements 47.69% 12267 / 25720
🔵 Functions 34.26% 832 / 2428
🔵 Branches 76.89% 1308 / 1701
File CoverageNo changed files found.
Generated in workflow #7876 for commit 50015aa by the Vitest Coverage Report Action

Copy link
Contributor

@zoruka zoruka left a comment

Choose a reason for hiding this comment

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

Could we have tests here?

@@ -46,7 +46,7 @@ function AvailableTestContent({ chain, config }: IProps) {
const toast = useChakraToast()

async function onSendTransaction(wagmiConfig: Config) {
const usdcAmount = BigInt(Number(amount) * 1000000)
const usdcAmount = BigInt(Math.round(parseFloat(amount) * 1_000_000))
Copy link
Contributor

Choose a reason for hiding this comment

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

We are using bignumber.js in AppKit for these kind of calculations (heavily used for swaps) - maybe we could have the same utility in lab for these calculations too? Or expose that utility from AppKit if it's helpful enough?

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.

3 participants