Skip to content

feat(cli): fix issue with content hash handling#9

Merged
sphamjoli merged 8 commits intomainfrom
spha/pat_token
Feb 11, 2026
Merged

feat(cli): fix issue with content hash handling#9
sphamjoli merged 8 commits intomainfrom
spha/pat_token

Conversation

@sphamjoli
Copy link
Member

Description

Fix contenthash decoding in contentManagement.ts. The decodeContenthashToCid function passed 0x-prefixed hex directly to @ensdomains/content-hash which expects raw hex without the prefix. This caused getCodec to misparse the bytes, producing Invalid CID version 112 errors when reading existing on-chain contenthashes. The fix consolidates on the shared cid.ts utilities which already handle 0x stripping correctly.

Type

  • Bug fix
  • Feature
  • Breaking change
  • Documentation
  • Chore

Package

  • @dotns/cli
  • Root/monorepo
  • Documentation

Related Issues

Fixes

Checklist

Code

  • Follows project style
  • bun run lint passes
  • bun run format passes
  • bun run typecheck passes

Documentation

  • README updated if needed
  • Types updated if needed

Breaking Changes

  • No breaking changes
  • Breaking changes documented below

Testing

How to test:

  1. Set a contenthash on a domain: dotns content set <name> <cid>, the current field should now decode correctly on first run instead of showing Unable to decode
  2. View an existing contenthash: dotns content view <name>, should display the CID instead of erroring with Invalid CID version 112

Notes

Same root cause as the gateway slice(2) bug. The @ensdomains/content-hash library expects raw hex (e301017012...) but was receiving 0x-prefixed hex (0xe301017012...), causing byte offsets to shift. The cid.ts utility already handled this correctly, contentManagement.ts had a duplicate implementation that didn't.

@github-actions
Copy link

github-actions bot commented Feb 11, 2026

CI Summary

Check Result
Lint Passed
Typecheck Passed
Build Passed
Release Passed
PR Title Passed
Labels Passed

Release - Passed

Test this PR

Download artifact (GitHub CLI required):

gh run download 21921655089 -n cli-preview-0.0.0-pr.9 -R paritytech/dotns-sdk

Install globally:

Package Manager Command
npm npm install -g ./dotns-cli-0.0.0-pr.9.tgz
yarn yarn global add ./dotns-cli-0.0.0-pr.9.tgz
bun (macOS/Linux) bun add -g "$(pwd)/dotns-cli-0.0.0-pr.9.tgz"
bun (Windows) bun add -g "$PWD\dotns-cli-0.0.0-pr.9.tgz"

Verify:

dotns --help
Labels

pkg: cli

@sphamjoli sphamjoli changed the title bug(cli) fix issue with content hash handling fix(cli) fix issue with content hash handling Feb 11, 2026
Copy link

@waytwotall waytwotall left a comment

Choose a reason for hiding this comment

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

Nit : please comment on why you are changing code or what the code is doing

@sphamjoli
Copy link
Member Author

sphamjoli commented Feb 11, 2026

Fix contenthash decoding in contentManagement.ts. The decodeContenthashToCid function passed 0x-prefixed hex directly to @ensdomains/content-hash which expects raw hex without the prefix. This caused getCodec to misparse the bytes, producing Invalid CID version 112 errors when reading existing on-chain contenthashes. The fix consolidates on the shared cid.ts utilities which already handle 0x stripping correctly.

Right, please see the description, do i need to add more info @waytwotall

@sphamjoli sphamjoli changed the title fix(cli) fix issue with content hash handling feat(cli) fix issue with content hash handling Feb 11, 2026
@sphamjoli sphamjoli changed the title feat(cli) fix issue with content hash handling feat(cli): fix issue with content hash handling Feb 11, 2026
@sphamjoli sphamjoli merged commit 22f2706 into main Feb 11, 2026
11 of 14 checks passed
@sphamjoli sphamjoli deleted the spha/pat_token branch February 11, 2026 21:37
@waytwotall
Copy link

Fix contenthash decoding in contentManagement.ts. The decodeContenthashToCid function passed 0x-prefixed hex directly to @ensdomains/content-hash which expects raw hex without the prefix. This caused getCodec to misparse the bytes, producing Invalid CID version 112 errors when reading existing on-chain contenthashes. The fix consolidates on the shared cid.ts utilities which already handle 0x stripping correctly.

Right, please see the description, do i need to add more info @waytwotall

Hi Spha - the description and release notes are great - It is more of a nit - I think that often people are reading through code and looking at entry and exit points for functions and code flows - sometimes it can be obvious but often the code is the artefact and the issues and release notes are lost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants