Skip to content

fix(keys): accept uppercase 0X prefix in isHexString - #198

Open
kutluhaneth46 wants to merge 1 commit into
agentcommercekit:mainfrom
kutluhaneth46:fix/is-hex-string-uppercase-0x-prefix
Open

fix(keys): accept uppercase 0X prefix in isHexString#198
kutluhaneth46 wants to merge 1 commit into
agentcommercekit:mainfrom
kutluhaneth46:fix/is-hex-string-uppercase-0x-prefix

Conversation

@kutluhaneth46

@kutluhaneth46 kutluhaneth46 commented Sep 4, 2026

Copy link
Copy Markdown

Summary

  • isHexString only stripped a lowercase 0x prefix, while hexStringToBytes already accepts 0X….
  • Make the guard strip the prefix case-insensitively so values the decoder accepts also pass the type guard.
  • Add a regression test for 0XABCDEF.

This is distinct from #161 (bare 0x / empty body); that PR does not make the prefix check case-insensitive.

Test plan

  • pnpm --filter @agentcommercekit/keys exec vitest run src/encoding/hex.test.ts
  • Confirm isHexString('0XABCDEF') === true
  • Confirm invalid hex still returns false

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes

    • Hex string validation now accepts both lowercase 0x and uppercase 0X prefixes, matching hex string conversion behavior.
  • Tests

    • Added coverage for valid hexadecimal strings using the uppercase 0X prefix.

Align the hex type guard with hexStringToBytes, which already strips a
case-insensitive 0x prefix. Values like 0XABCDEF decoded successfully
but failed isHexString.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: c1179500-0e65-4561-a238-1d13bb912a8f

📥 Commits

Reviewing files that changed from the base of the PR and between 7d23f83 and 72a7ce5.

📒 Files selected for processing (3)
  • .changeset/is-hex-string-uppercase-prefix.md
  • packages/keys/src/encoding/hex.test.ts
  • packages/keys/src/encoding/hex.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


Walkthrough

isHexString now accepts uppercase 0X prefixes by normalizing input before validation. A test covers this case, and a changeset declares a patch release for @agentcommercekit/keys.

Changes

Hex prefix validation

Layer / File(s) Summary
Accept uppercase hex prefixes
packages/keys/src/encoding/hex.ts, packages/keys/src/encoding/hex.test.ts, .changeset/is-hex-string-uppercase-prefix.md
isHexString now accepts 0X prefixes. The test verifies 0XABCDEF. The changeset documents the patch release.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 72a7c

This change makes uppercase 0X-prefixed hexadecimal strings valid in isHexString, matching existing decoder behavior. The new behavior is directly covered by a regression test, with no remaining current-head merge risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: isHexString now accepts an uppercase 0X prefix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant