Skip to content

fix(authors): align author name resolution with pkc-js#53

Merged
tomcasaburi merged 4 commits intomasterfrom
fix/resolved-author-address-types
Apr 20, 2026
Merged

fix(authors): align author name resolution with pkc-js#53
tomcasaburi merged 4 commits intomasterfrom
fix/resolved-author-address-types

Conversation

@tomcasaburi
Copy link
Copy Markdown
Member

@tomcasaburi tomcasaburi commented Apr 20, 2026

Summary

  • Align author name resolution with the current pkc-js resolveAuthorName({ name }) contract.
  • Add pkc-js-derived types so future resolver contract drift is caught by TypeScript.
  • Update local pkc-js mocks and author hook tests to return { resolvedAuthorName } instead of masking the old bare-string/address shape.

Root Cause

useResolvedAuthorAddress still passed an address-shaped payload into author-name resolution while the current pkc-js API expects a name-shaped payload. The local mocks mirrored the stale shape, so the mismatch did not fail tests or type-checking.

Verification

  • yarn type-check
  • yarn build
  • yarn test src/hooks/authors/authors.test.ts
  • yarn prettier
  • Manual 5chan verification using a local package tarball built from this branch: imported the plebeius account backup, opened the settings modal, clicked the crypto address check button, and confirmed the status resolved as belonging to the account.

Full hook/store coverage still could not complete locally because the existing accounts hook suite runs out of memory before finishing.


Note

Medium Risk
Touches author address/name resolution and its caching/compat layer; incorrect normalization or fallback selection could break crypto-name display/resolution paths. Changes are type-backed and covered by updated unit tests, reducing risk.

Overview
Aligns author-name resolution with the current pkc-js contract by passing { name } to resolveAuthorName and normalizing the newer { resolvedAuthorName } return shape (while keeping a legacy fallback to resolveAuthorAddress).

Updates the local pkc mocks and authors hook tests to use the typed resolveAuthorName API, and introduces pkc-js-derived types in pkc-types.ts to catch future contract drift at compile time. Also tightens internal PR-creation docs to require ready-for-review PRs (no drafts).

Reviewed by Cursor Bugbot for commit 2c0ad35. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Refactor

    • Enhanced author address resolution to align with updated protocol client API contracts, improving type safety and compatibility.
  • Tests

    • Updated test coverage for author resolution functionality to reflect API contract changes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

The changes refactor author name resolution across the codebase. A new type definitions file introduces PKC type aliases. Mock implementations and the compatibility layer update resolveAuthorName to accept { name: string } instead of { address: string }, returning a typed object with resolvedAuthorName. Hook invocations and tests are updated to match.

Changes

Cohort / File(s) Summary
Type Definitions
src/lib/pkc-types.ts
New file adding strongly-typed type aliases for PKC client, resolveAuthorName function, its options ({ name: string }), and return result ({ resolvedAuthorName: string }).
Protocol Compatibility Layer
src/lib/pkc-compat.ts
Updated resolveAuthorNameWithProtocol to async with typed signature. Refactored to prefer resolveAuthorName when available (with result normalization), otherwise fallback to resolveAuthorAddress called with { address: options.name }.
PKC Mock Implementations
src/lib/pkc-js/pkc-js-mock.ts, src/lib/pkc-js/pkc-js-mock-content.ts
Updated resolveAuthorName method signatures to typed and async. Changed internal resolution from passing options directly to resolveAuthorAddress to constructing { address: options.name } argument and wrapping result as { resolvedAuthorName }.
Hook Implementation
src/hooks/authors/authors.ts
Updated two hook invocations to pass { name: addr } or { name: author?.address } to resolveAuthorNameWithProtocol instead of using address property.
Hook Tests
src/hooks/authors/authors.test.ts
Refactored test mocks to target resolveAuthorName (with { name: string } argument shape) instead of resolveAuthorAddress. Added typed result helper and comprehensive test cases for contract validation, caching, rejection handling, and promise reuse scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A name by any protocol bound,
With types now strong and clearly found,
We trade our address for a name,
The flow remains, refined the same!
Mock calls adapt with wrapping neat,
Our author resolution now complete! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(authors): align author name resolution with pkc-js' accurately describes the main change: aligning the author name resolution API with the pkc-js contract by updating inputs from address-shaped to name-shaped payloads and introducing proper typing.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/resolved-author-address-types

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 and usage tips.

@tomcasaburi tomcasaburi marked this pull request as ready for review April 20, 2026 08:08
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/hooks/authors/authors.ts (1)

322-340: Log payload key still uses address for a crypto name.

Lines 326 and 461 label the log as "...protocol.resolveAuthorName" but pass { address: addr } / { address: author?.address }. Now that the resolver argument is semantically a name, consider { name: addr } for consistency with the updated call below and with anyone grepping logs.

♻️ Proposed log-key alignment
-      log("useAuthorAddress protocol.resolveAuthorName", { address: addr });
+      log("useAuthorAddress protocol.resolveAuthorName", { name: addr });
       return cacheResolveAuthorAddressPromise(
         addr,
         resolveAuthorNameWithProtocol(protocolClient, { name: addr }),
       );

And equivalently around line 461:

-    log("useResolvedAuthorAddress protocol.resolveAuthorName", { address: author?.address });
+    log("useResolvedAuthorAddress protocol.resolveAuthorName", { name: author?.address });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/authors/authors.ts` around lines 322 - 340, The log payload is
using the key address for a crypto name; update the payload key to name in the
log calls so they match the resolver semantics: change the log(...) invocation
inside resolveAuthorAddressNoCache (currently passing { address: addr }) to pass
{ name: addr }, and do the same for the other log call that uses { address:
author?.address } (change to { name: author?.address }); these touches are in
the functions/blocks named resolveAuthorAddressNoCache and the surrounding
resolveAuthorAddress / caller that reference addr and author?.address and the
shared log(...) helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/hooks/authors/authors.ts`:
- Around line 322-340: The log payload is using the key address for a crypto
name; update the payload key to name in the log calls so they match the resolver
semantics: change the log(...) invocation inside resolveAuthorAddressNoCache
(currently passing { address: addr }) to pass { name: addr }, and do the same
for the other log call that uses { address: author?.address } (change to { name:
author?.address }); these touches are in the functions/blocks named
resolveAuthorAddressNoCache and the surrounding resolveAuthorAddress / caller
that reference addr and author?.address and the shared log(...) helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2ffdad9-a8df-4783-b63c-a3fb7eb96773

📥 Commits

Reviewing files that changed from the base of the PR and between 9f4614f and 62f614b.

📒 Files selected for processing (6)
  • src/hooks/authors/authors.test.ts
  • src/hooks/authors/authors.ts
  • src/lib/pkc-compat.ts
  • src/lib/pkc-js/pkc-js-mock-content.ts
  • src/lib/pkc-js/pkc-js-mock.ts
  • src/lib/pkc-types.ts

@tomcasaburi
Copy link
Copy Markdown
Member Author

Addressed the valid CodeRabbit nitpick in the latest commit by aligning the author resolver debug log payload keys with the new { name } resolver semantics.

Locally verified after the change with yarn build, yarn test src/hooks/authors/authors.test.ts, yarn prettier, and git diff --check.

@tomcasaburi tomcasaburi merged commit 3294f39 into master Apr 20, 2026
8 checks passed
@tomcasaburi tomcasaburi deleted the fix/resolved-author-address-types branch April 20, 2026 08:46
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