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

refactor: allow Transaction.pack(unpacked) #599

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

doitian
Copy link
Contributor

@doitian doitian commented Jan 5, 2024

Description

The function can pack its unpacked result, but the function signature
does not allow it. This is very annoying, for example, I cannot set
version to number 0 to call pack.

Type of change

Please delete options that are not relevant.

  • Refactor (non-breaking change)

How Has This Been Tested?

  • added a test case in packages/base/tests/serialize.test.ts
  • pnpm --filter base lint && pnpm --filter base test

The function can pack its unpacked result, but the function signature
does not allow it. This is very annoying, for example, I cannot set
version to number 0 to call `pack`.
Copy link

vercel bot commented Jan 5, 2024

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

Name Status Preview Updated (UTC)
lumos-website ✅ Ready (Inspect) Visit Preview Jan 5, 2024 1:34pm

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ccd8213) 83.84% compared to head (be98ce6) 84.81%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #599      +/-   ##
===========================================
+ Coverage    83.84%   84.81%   +0.96%     
===========================================
  Files          116      116              
  Lines        23583    23587       +4     
  Branches      2223     2289      +66     
===========================================
+ Hits         19773    20005     +232     
+ Misses        3770     3538     -232     
- Partials        40       44       +4     
Files Coverage Δ
packages/base/src/blockchain.ts 99.08% <100.00%> (+0.69%) ⬆️

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ccd8213...be98ce6. Read the comment docs.

@homura
Copy link
Collaborator

homura commented Jan 5, 2024

Thanks for your PR. However, I have noticed that the blockchain.Transaction.unpack function behaves differently from api.Transaction. The blockchain module directly uses number codecs, which results in the unpacked output being either a number or a BI. Ideally, any type of number should be in string(hex formatted). This inconsistency was not caused by your PR, but by your comment "cannot set number 0 to call pack", which drew my attention to it. To address this issue, Lumos may have to modify the blockchain.*.unpack function to output a string(hex format) instead of a number.

@homura
Copy link
Collaborator

homura commented Jan 6, 2024

@doitian Hi, I've opened a new PR that should solve this issue at #601, please let me know if you think it helps

@doitian
Copy link
Contributor Author

doitian commented Jan 7, 2024

@doitian Hi, I've opened a new PR that should solve this issue at #601, please let me know if you think it helps

Not sure whether it worthes a breaking change.

@homura
Copy link
Collaborator

homura commented Jan 8, 2024

Not sure whether it worthes a breaking change.

This breaking change is not just a fix for this PR, it is also a bug since 0.20

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.

2 participants