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

feat: implement bigint support #728

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

glevco
Copy link
Contributor

@glevco glevco commented Aug 1, 2024

Depends on #720

Motivation

See https://github.com/HathorNetwork/internal-issues/issues/363.

This PR adds the necessary structures to support bigint fields, however it does not yet change the OutputValueType to bigint.

Acceptance Criteria

  • Implement bigIntToBytes() and remove signedIntToBytes() support for 8 bytes.
  • Implement unpackToBigInt() and remove unpackToInt() support for 8 bytes.
  • Update bytesToOutputValue() to use unpackToBigInt().
  • Dependencies:
    • Added json-bigint and zod.
    • level-transcoder was added explicitly but was already an indirect dependency.
    • Removed long.
  • Create api/txApi and api/wallet Zod schemas, updating requests to use transformJsonBigIntResponse().
  • Update Output.valueToBytes() to use bigIntToBytes() instead of signedIntToBytes().
  • Create Zod schemas for some necessary interfaces.
  • Use Zod parsing in WS history txs.
  • Update LevelDB sublevels to use jsonBigIntEncoding() where necessary.
  • Implement utils/bigint.ts.
  • Change WS handler to use JSONBigInt.parse() instead of JSON.parse().
  • Change TS target to es2020 instead of es2018, adding support for bigint.

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@glevco glevco self-assigned this Aug 1, 2024
@glevco glevco force-pushed the feat/bigint-functions branch 3 times, most recently from acb3f0f to badafe5 Compare August 1, 2024 16:46
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 89.61039% with 8 lines in your changes missing coverage. Please review.

Project coverage is 80.56%. Comparing base (1b31680) to head (6c44af7).

Files Patch % Lines
src/api/wallet.ts 50.00% 3 Missing ⚠️
src/utils/bigint.ts 88.23% 2 Missing ⚠️
src/utils/storage.ts 33.33% 2 Missing ⚠️
src/utils/buffer.ts 95.65% 1 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                        @@
##           refactor/typing-improvements     #728       +/-   ##
=================================================================
+ Coverage                         66.52%   80.56%   +14.04%     
=================================================================
  Files                                78       82        +4     
  Lines                              6156     6209       +53     
  Branches                           1337     1353       +16     
=================================================================
+ Hits                               4095     5002      +907     
+ Misses                             1985     1195      -790     
+ Partials                             76       12       -64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

.github/workflows/integration-test.yml Outdated Show resolved Hide resolved
.github/workflows/main.yml Outdated Show resolved Hide resolved
@glevco glevco changed the title wip feat: implement bigint support Aug 2, 2024
@glevco glevco force-pushed the refactor/typing-improvements branch from efe15e4 to c744d46 Compare August 2, 2024 20:27
@glevco glevco force-pushed the refactor/typing-improvements branch from c744d46 to 1b31680 Compare August 2, 2024 20:45
@glevco glevco force-pushed the refactor/typing-improvements branch from 1b31680 to 8cecc72 Compare August 2, 2024 21:40
@glevco glevco marked this pull request as ready for review August 5, 2024 18:25
@glevco glevco requested a review from r4mmer August 5, 2024 19:53
@glevco glevco force-pushed the refactor/typing-improvements branch from 8cecc72 to 59e0572 Compare August 13, 2024 21:11
Base automatically changed from refactor/typing-improvements to master August 15, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant