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

1113 fixed point number #1227

Merged
merged 63 commits into from
Sep 4, 2024
Merged

1113 fixed point number #1227

merged 63 commits into from
Sep 4, 2024

Conversation

lucanicoladebiasi
Copy link
Contributor

@lucanicoladebiasi lucanicoladebiasi commented Sep 3, 2024

Description

The class packages/core/tests/vcdm/FPN.unit.test.ts implements the simplest possibile Fixed Point Number math to provide the (minimal, so far) functionalities to express currencies included the ETH and Gas quantities as part of the VeChain Data Model.
The class aims to replace dependencies from bignumber.js, bn.js, bigdecimal.js and from the fixed precision math of ethers.js.

The class use bignumber.js as reference and benchmark, albeit it differs for numerical algorithms, FPN uses bigint math to limit algorithms to the functionalities strictly available on all JS runtimes, bignmber.js represents numbers as an array of UInt8Array integer representations, the ratio among elements of the array lead to the represented value, hence FPN is way simpler.

The class packages/core/tests/vcdm/FPN.unit.test.ts checks the compatibility with bignumber.js.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • yarn test:solo
  • yarn test:unit

Test Configuration:

  • Node.js Version: v20.14.0
  • Yarn Version: 1.22.22

Checklist:

  • My code follows the coding standards of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing integration tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have not added any vulnerable dependencies to my code

# Conflicts:
#	packages/core/src/vcdm/Hex.ts
#	packages/core/src/vcdm/HexInt.ts
#	packages/core/src/vcdm/index.ts
…pressions

# Conflicts:
#	docs/diagrams/architecture/vcdm.md
#	packages/core/src/hash/Sha256.ts
#	packages/core/src/hash/index.ts
#	packages/core/src/hdnode/hdnode.ts
#	packages/core/src/vcdm/Hex.ts
#	packages/core/tests/hash/Sha256.unit.test.ts
#	packages/core/tests/hash/fixture.ts
#	packages/core/tests/hash/hash.unit.test.ts
@lucanicoladebiasi lucanicoladebiasi added this to the RC milestone Sep 3, 2024
@lucanicoladebiasi lucanicoladebiasi self-assigned this Sep 3, 2024
Copy link

github-actions bot commented Sep 3, 2024

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 99%
99.5% (4031/4051) 98.27% (1254/1276) 99.87% (804/805)
Title Tests Skipped Failures Errors Time
core 799 0 💤 0 ❌ 0 🔥 1m 33s ⏱️
network 686 0 💤 0 ❌ 0 🔥 4m 11s ⏱️
errors 43 0 💤 0 ❌ 0 🔥 15.173s ⏱️

@lucanicoladebiasi lucanicoladebiasi marked this pull request as ready for review September 3, 2024 11:23
@lucanicoladebiasi lucanicoladebiasi requested a review from a team as a code owner September 3, 2024 11:23
@lucanicoladebiasi lucanicoladebiasi marked this pull request as draft September 3, 2024 13:43
@lucanicoladebiasi lucanicoladebiasi marked this pull request as ready for review September 4, 2024 09:48
@fabiorigam fabiorigam merged commit 0ffa75a into main Sep 4, 2024
10 checks passed
@fabiorigam fabiorigam deleted the 1113-FixedPointNumber branch September 4, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants