Skip to content

Conversation

@phroi
Copy link
Contributor

@phroi phroi commented Jan 10, 2026

Added the utilities for calculating the byte len of a HexLike / Hex

Phroi

@changeset-bot
Copy link

changeset-bot bot commented Jan 10, 2026

🦋 Changeset detected

Latest commit: bb381c1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@ckb-ccc/core Minor
@ckb-ccc/eip6963 Patch
@ckb-ccc/joy-id Patch
@ckb-ccc/lumos-patches Patch
@ckb-ccc/nip07 Patch
@ckb-ccc/okx Patch
@ckb-ccc/rei Patch
@ckb-ccc/shell Patch
@ckb-ccc/spore Patch
@ckb-ccc/ssri Patch
@ckb-ccc/udt Patch
@ckb-ccc/uni-sat Patch
@ckb-ccc/utxo-global Patch
@ckb-ccc/xverse Patch
@ckb-ccc/ccc Patch
ckb-ccc Patch
@ckb-ccc/connector Patch
@ckb-ccc/connector-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Jan 10, 2026

Deploy Preview for docsccc ready!

Name Link
🔨 Latest commit bb381c1
🔍 Latest deploy log https://app.netlify.com/projects/docsccc/deploys/696398a6b22d540008aa4001
😎 Deploy Preview https://deploy-preview-353--docsccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 71 (🟢 up 3 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Jan 10, 2026

Deploy Preview for appccc ready!

Name Link
🔨 Latest commit bb381c1
🔍 Latest deploy log https://app.netlify.com/projects/appccc/deploys/696398a6b596190008a2c532
😎 Deploy Preview https://deploy-preview-353--appccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 65 (🔴 down 22 from production)
Accessibility: 89 (🟢 up 1 from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @phroi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the core utility library by adding two new functions, bytesLen and bytesLenUnsafe, which are designed to accurately and efficiently determine the byte length of hexadecimal representations. These additions provide developers with more robust tools for handling data sizes, particularly when working with hex-encoded values, by offering both a general-purpose and an optimized, unsafe variant for specific use cases.

Highlights

  • New Utility Functions: Introduced bytesLen and bytesLenUnsafe functions to efficiently calculate the byte length of hexadecimal-like values and hexadecimal strings, respectively.
  • Optimized Byte Length Calculation: The bytesLen function provides a unified way to get the byte length for various HexLike types, leveraging a fast-path bytesLenUnsafe for validated hex strings and falling back to bytesFrom().length for other types.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@netlify
Copy link

netlify bot commented Jan 10, 2026

Deploy Preview for apiccc ready!

Name Link
🔨 Latest commit bb381c1
🔍 Latest deploy log https://app.netlify.com/projects/apiccc/deploys/696398a69c024d0008fd0d4f
😎 Deploy Preview https://deploy-preview-353--apiccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 81 (🔴 down 13 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 94 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces bytesLen and bytesLenUnsafe utility functions for calculating the byte length of hex-like values. The changes are well-documented and include examples. I've provided a couple of suggestions: one to optimize performance by handling ArrayBuffer more efficiently, and another to improve the clarity of the documentation for bytesLenUnsafe regarding its handling of non-standard odd-length hex strings.

@netlify
Copy link

netlify bot commented Jan 10, 2026

Deploy Preview for liveccc ready!

Name Link
🔨 Latest commit bb381c1
🔍 Latest deploy log https://app.netlify.com/projects/liveccc/deploys/696398a6f3e96100085dfb4e
😎 Deploy Preview https://deploy-preview-353--liveccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 42 (🟢 up 1 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@phroi
Copy link
Contributor Author

phroi commented Jan 10, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces bytesLen and bytesLenUnsafe utilities for calculating the byte length of hex-like values. The implementation is well-documented and the logic for the unsafe version is clever and correct. I've suggested a performance optimization for the bytesLen function to more efficiently handle Uint8Array and ArrayBuffer inputs by adding fast paths for them.

@phroi
Copy link
Contributor Author

phroi commented Jan 10, 2026

@Hanssen0 feel free to review 🤗

Phroi %93

Copy link
Member

@Hanssen0 Hanssen0 left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for your contribution!

It's kinda weird to see bytes from HexLike, but I think it's a reasonable decision for the performance.

Please change the base of this commit to the releases/next branch.

@phroi
Copy link
Contributor Author

phroi commented Jan 11, 2026

It's kinda weird to see bytes from HexLike, but I think it's a reasonable decision for the performance.

Agreed, then again it's mostly Hex-related logic. Sure most also Bytes-related, but I wanted to avoid any possible form of circular dependency 🤣

Please change the base of this commit to the releases/next branch.

bytesLen depends on isHex being defined, but seems that the PR cointaining isHex definition is not merged in releases/next, see: https://github.com/ckb-devrel/ccc/blob/releases/next/packages/core/src/hex/index.ts

Let me know how you want to proceed,
Phroi

P.S.: if it can help, I'm aware that Github is working on implementing support for interpendent PRs like these ones

@Hanssen0
Copy link
Member

bytesLen depends on isHex being defined, but seems that the PR cointaining isHex definition is not merged in releases/next, see: https://github.com/ckb-devrel/ccc/blob/releases/next/packages/core/src/hex/index.ts

You're right! I didn't realize this before. I think there are two ways:

  1. Include the isHex code in this PR. In this way, I will deal with conflicts when merging master and release (shouldn't be hard).
  2. Merge this into master, which means we need to wait for the major version for this feature.

@phroi
Copy link
Contributor Author

phroi commented Jan 11, 2026

Your merge conflicts are my merge conflicts!!! 🤣 (local unstable CCC)

Merging to master is fine (already fixed the patch to minor thing), let me know if you have any other feedback 🤗

BTW approx how far away would you estimate the next major release? (weeks, months, half a year)

Phroi

Copy link
Member

@Hanssen0 Hanssen0 left a comment

Choose a reason for hiding this comment

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

LGTM

@Hanssen0
Copy link
Member

BTW approx how far away would you estimate the next major release? (weeks, months, half a year)

About a month ago.

I desperately want to finish it this month. There are still two PRs I want to release before that (#328 and #349), and we might also want to merge releases/UDT (for minor or major release). I want to reduce the gap caused by breaking changes in major versions between people and new features.

@Hanssen0 Hanssen0 merged commit 66ae81b into ckb-devrel:master Jan 12, 2026
17 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.

2 participants