Skip to content

SDK mutation hooks and adapters - #648

Merged
feruzm merged 8 commits into
developfrom
mutation
Feb 9, 2026
Merged

SDK mutation hooks and adapters#648
feruzm merged 8 commits into
developfrom
mutation

Conversation

@feruzm

@feruzmferuzm commented Feb 9, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Improved, user-friendly chain error messages and auth-fallback behavior for broadcasts.
    • Multi-method signing/broadcast fallback with platform adapter support for smoother signing flows.
    • Many new operation builders enabling account, content, community, governance, market, social, wallet, and platform-specific actions.
    • New mutation hooks for voting, commenting, reblogging, transfers, and proposal voting with post-broadcast UI updates.
  • Tests

    • Comprehensive tests validating chain error parsing and related utilities.
  • Chores

    • Package version updates and changelog entries for the SDK and wallets.

@coderabbitai

coderabbitaiBot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds structured chain error parsing and tests, a PlatformAdapter and AuthContextV2 with multi-method broadcast fallback, many operation builders, new React Query mutation hooks using the fallback and adapter side-effects, plus re-exports and a changelog/version bump.

Changes

Cohort / File(s)Summary
Error utilities & tests
packages/sdk/src/modules/core/errors/chain-errors.ts, packages/sdk/src/modules/core/errors/index.ts, packages/sdk/src/modules/core/errors/chain-errors.spec.ts
New ErrorType enum and ParsedChainError; parseChainError, formatError, and predicate helpers (shouldTriggerAuthFallback, isResourceCreditsError, isInfoError, isNetworkError); extensive unit tests covering many error shapes and edge cases.
Auth types & adapter
packages/sdk/src/modules/core/types/platform-adapter.ts, packages/sdk/src/modules/core/types/auth.ts, packages/sdk/src/modules/core/types/index.ts
Introduces PlatformAdapter, User, AuthMethod, AuthContextV2 (adapter, enableFallback, fallbackChain) and re-exports platform-adapter types.
Broadcast core & mutation update
packages/sdk/src/modules/core/mutations/use-broadcast-mutation.ts, packages/sdk/src/modules/core/index.ts
Adds internal broadcastWithFallback and updates useBroadcastMutation to accept AuthContextV2 + authority; uses adapter fallback chain, aggregates per-method errors, preserves legacy paths for backward compatibility; core re-export updated.
Operation builders (many)
packages/sdk/src/modules/operations/builders/...
content.ts, wallet.ts, social.ts, governance.ts, market.ts, account.ts, community.ts, ecency.ts, index.ts
New builder modules providing typed operation constructors (content, wallet, social, governance, market, account, community, Ecency); input validation and DHive-style Operation returns; builders barrel added.
Operations re-export
packages/sdk/src/modules/operations/index.ts
Re-exports the new builders via export * from "./builders".
Post mutations
packages/sdk/src/modules/posts/mutations/use-comment.ts, use-reblog.ts, use-vote.ts, packages/sdk/src/modules/posts/mutations/index.ts
New hooks useComment, useReblog, useVote with payload types; integrate with useBroadcastMutation and adapter side-effects (recordActivity, invalidateQueries); re-exports added.
Wallet transfer mutation
packages/sdk/src/modules/wallet/mutations/use-transfer.ts, packages/sdk/src/modules/wallet/mutations/index.ts, packages/sdk/src/modules/wallet/index.ts
New useTransfer hook with TransferPayload, internal broadcastTransferWithFallback implementing per-method attempts, aggregated error reporting, and adapter post-success hooks; re-exports added.
Proposals mutation
packages/sdk/src/modules/proposals/mutations/use-proposal-vote.ts, packages/sdk/src/modules/proposals/mutations/index.ts, packages/sdk/src/modules/proposals/index.ts
New useProposalVote hook and ProposalVotePayload; records activity and invalidates proposal caches on success; re-exports added.
Re-exports & indexes
multiple index files
packages/sdk/src/modules/core/index.ts, packages/sdk/src/modules/operations/index.ts, packages/sdk/src/modules/posts/mutations/index.ts, packages/sdk/src/modules/wallet/index.ts, packages/sdk/src/modules/wallet/mutations/index.ts, packages/sdk/src/modules/proposals/index.ts
Updated to re-export new modules, builders, and mutation hooks to the public API surface.
Changelog & versions
packages/sdk/CHANGELOG.md, packages/sdk/package.json, packages/wallets/CHANGELOG.md, packages/wallets/package.json
Bumped SDK and wallets package versions to 1.5.28 and added changelog entries.

Sequence Diagram(s)

sequenceDiagram
participant Client
participant Hook as useBroadcastMutation
participant Fallback as broadcastWithFallback
participant Adapter as PlatformAdapter
participant Method as AuthMethod
participant Chain as Blockchain
Client->>Hook: request broadcast(ops, auth:AuthContextV2, authority)
Hook->>Fallback: broadcastWithFallback(ops, auth, authority)
Fallback->>Adapter: adapter? / adapter.broadcast methods
loop attempt methods in fallbackChain
Fallback->>Method: try method (key / hiveauth / hivesigner / keychain / custom)
Method->>Chain: send transaction
alt success
Chain-->>Method: tx result
Method-->>Adapter: return result
Adapter-->>Fallback: success -> stop attempts
else failure
Method-->>Adapter: error
Adapter-->>Fallback: error -> check shouldTriggerAuthFallback
alt continue
Fallback->>Method: try next method
else all failed
Fallback-->>Hook: throw aggregated error
end
end
end
Fallback-->>Hook: return tx result
Hook-->>Client: resolve mutation (optionally adapter.recordActivity / invalidateQueries)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Poem

🐇 I hopped through logs and regex art,
I nibbled errors, tore them apart.
Adapters lined, fallbacks standing by,
I chased failed ops across the sky.
Tiny rabbit cheers: "Send that tx high!"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately summarizes the primary changes: comprehensive SDK mutation hooks (useVote, useReblog, useComment, useTransfer, useProposalVote) and platform adapters (PlatformAdapter interface, AuthContextV2 with fallback support) that form the main focus of this substantial changeset.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mutation

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
packages/sdk/src/modules/core/errors/chain-errors.ts (1)

278-293: Nit: Missing truncation for non-string error_description on Line 283.

Line 283 uses String(error.error_description) without .substring(0, 150), unlike every other branch in the fallback chain. If error_description were a large non-string value, the message would be unbounded.

Proposed fix
 if (error.error_description) {
- message = String(error.error_description);+ message = String(error.error_description).substring(0, 150);
} else if (error.code) {

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.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@feruzmferuzm changed the title SDK mutations/expansionSDK mutation hooks and adaptersFeb 9, 2026
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@feruzmferuzm added patch Bug fixes and patches (1.0.0 → 1.0.1) and removed patch Bug fixes and patches (1.0.0 → 1.0.1) labels Feb 9, 2026
@feruzm
feruzm merged commit fbabee8 into developFeb 9, 2026
1 check passed
@feruzm
feruzm deleted the mutation branch February 9, 2026 19:26
This was referenced Feb 10, 2026
@coderabbitaicoderabbitaiBot mentioned this pull request Feb 22, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patchBug fixes and patches (1.0.0 → 1.0.1)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@feruzm