Skip to content

Add Must variants and named Identity constructors#36

Merged
0xluk merged 2 commits into
mainfrom
identity-helpers
Jun 10, 2026
Merged

Add Must variants and named Identity constructors#36
0xluk merged 2 commits into
mainfrom
identity-helpers

Conversation

@0xluk

@0xluk 0xluk commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Transaction.MustDigest() and Transaction.MustID() — panic-on-error variants of Digest / ID for callers that hold a well-formed transaction.
  • Add package-level NewTxID(digest) / NewAddress(pubKey) constructors and their MustNewTxID / MustNewAddress variants. These wrap Identity.FromPubKey and replace the semantic boolean (isLowerCase=true → tx ID, false → address) with named intent at call sites.
  • Refactor Transaction.ID / MustID to delegate to the new helpers.

Existing Identity.FromPubKey / ToPubKey remain for back-compat; this PR is additive.

Test plan

  • go test ./types/... — all tests pass (including new TDD-first tests: TestTransaction_MustDigest_MatchesDigest, TestTransaction_MustID_MatchesID, TestNewAddress_MatchesFromPubKeyUppercase, TestNewTxID_MatchesFromPubKeyLowercase, TestMustNewAddress_MatchesNewAddress, TestMustNewTxID_MatchesNewTxID)
  • go vet ./types/... clean
  • go build ./types/... clean

🤖 Generated with Claude Code

0xluk and others added 2 commits June 3, 2026 10:02
Convenience helpers for callers that hold a well-formed transaction and
don't want to thread errors from the unreachable failure paths in
Digest/ID. MustID reuses MustDigest internally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The isLowerCase boolean on Identity.FromPubKey is a semantic flag, not
a real parameter: lowercase=true means tx ID, lowercase=false means
address. Named constructors make intent explicit at call sites and
remove the misuse risk of passing the wrong bool.

Transaction.ID/MustID now delegate to the new helpers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@LINCKODE LINCKODE left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@0xluk 0xluk merged commit ab754da into main Jun 10, 2026
4 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