Skip to content

Conversation

@kamleshmugdiya
Copy link
Contributor

@kamleshmugdiya kamleshmugdiya commented Nov 22, 2025

Ticket: COIN-0000

This PR fixes a critical issue in VET transaction processing where large numeric values lost precision due to JavaScript's Number type limitations.
When handling transactions with values exceeding ~15-17 significant digits, the values were converted to scientific notation (e.g., 2.332734928448876e+22 instead of 23327349284488761096413).

The issue was in Transaction.fromDeserializedSignedTransaction() which used Number(clause.value).toString(), converting large values to scientific notation. This caused transaction output parsing to fail when comparing the expected amount with the actual amount.

The fix:

  • Replaces Number(clause.value).toString() with new BigNumber(clause.value).toFixed().
  • Ensures exact precision is maintained throughout transaction processing.
  • Adds test to verify precision handling of large numbers.

This change ensures accurate value representation in VET transactions, particularly important for exchanges and applications handling large value transfers.

@kamleshmugdiya kamleshmugdiya self-assigned this Nov 22, 2025
@kamleshmugdiya kamleshmugdiya marked this pull request as ready for review November 22, 2025 08:07
@kamleshmugdiya kamleshmugdiya requested a review from a team as a code owner November 22, 2025 08:07
@kamleshmugdiya kamleshmugdiya changed the title fix(vet): preserve precision for large value transactions fix(sdk-coin-vet): preserve precision for large value transactions Nov 22, 2025
Copy link
Contributor

@prithvishet2503 prithvishet2503 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Vijay-Jagannathan Vijay-Jagannathan left a comment

Choose a reason for hiding this comment

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

good catch, we should never be using Number for amount

@kamleshmugdiya kamleshmugdiya merged commit 0385049 into master Nov 22, 2025
25 of 26 checks passed
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.

4 participants