Skip to content

Conversation

@homura
Copy link
Collaborator

@homura homura commented Mar 5, 2024

Description

This PR is a part implementation of #597. There are some breaking changes in this PR because all Buffer in parameters and returns of methods are replaced with Uint8Array for browser compatibility.

This PR targets the browser-compatibility branch instead of the develop branch because the feature may be released at 0.23.0

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Unit test

@homura homura changed the title feat!: replace Buffer with Uint8Array feat!: replace Buffer with Uint8Array Mar 5, 2024
@vercel
Copy link

vercel bot commented Mar 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 Mar 5, 2024 11:25am

@codecov
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 90.60403% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 84.28%. Comparing base (e34daa1) to head (f8fcd99).

Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                    @@
##           browser-compatibility     #645      +/-   ##
=========================================================
- Coverage                  87.19%   84.28%   -2.91%     
=========================================================
  Files                        120      120              
  Lines                      24357    24352       -5     
  Branches                    2508     2342     -166     
=========================================================
- Hits                       21238    20525     -713     
- Misses                      3076     3786     +710     
+ Partials                      43       41       -2     
Files Coverage Δ
packages/common-scripts/src/common.ts 89.44% <100.00%> (ø)
packages/hd/src/extended_key.ts 97.70% <100.00%> (+0.01%) ⬆️
packages/hd/src/helper.ts 75.00% <100.00%> (+8.33%) ⬆️
packages/hd/src/key.ts 96.77% <100.00%> (+0.03%) ⬆️
packages/hd/src/keychain.ts 100.00% <100.00%> (ø)
packages/hd/src/keystore.ts 91.76% <100.00%> (-0.04%) ⬇️
packages/base/src/values.ts 84.28% <0.00%> (ø)
packages/base/src/utils.ts 80.51% <33.33%> (+7.11%) ⬆️
packages/hd/src/mnemonic/index.ts 35.29% <52.63%> (+0.53%) ⬆️

... and 9 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 e34daa1...f8fcd99. Read the comment docs.

@homura homura changed the title feat!: replace Buffer with Uint8Array BREAKING CHANGE: replace Buffer with Uint8Array May 22, 2024
}
}

export function hexifyWithout0x(value: BytesLike): string {
Copy link
Member

Choose a reason for hiding this comment

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

Why not extend the bytes.hexify to accept hex string without 0x

@twhy
Copy link
Contributor

twhy commented May 30, 2024

@Keith-CY @homura After checking the related code last night, I suggest we postpone this PR.

Reasons

  1. The browser-compatibility branch is 27 commits behind develop
  2. This PR still contains Buffer.from() , e.g.
    https://github.com/ckb-js/lumos/pull/645/files#diff-a9e7dac36ed4d2aa4efe20eec63d01ded13115251c933f0dcfce2284d6e7024bR238
  3. Replace Buffer with Uint8Array should be put behind replacing node crypto becuase it's a breaking change.

Our goal here is to make Lumos run in browsers without extra configs.
I want to achieve this with a few PRs based on develop branch.

  1. [NON BREAKING] Replace Node crypto.randomBytes with Lumos crypto.randomBytes Code PR
  2. [NON BREAKING] Replace Node crypto createHash createHmac etc with noble-curves methods
  3. [BREAKING] Replace Buffer with Uint8Array fully, based on existing work in this PR.
  4. Maybe one more PR to make things fully work.

When all these done, we release it with version 0.30.0
That means, starting from 0.30.0, Lumos can run in browsers without extra configs.
People still want to use Buffer can stay at version 0.2x.x

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