Skip to content

Conversation

@feruzm
Copy link
Member

@feruzm feruzm commented Jan 12, 2026

Summary by CodeRabbit

  • New Features

    • Added support for claiming Hive Engine rewards through the wallet interface.
    • Asset information now displays a detailed breakdown of balance types (liquid, staked, savings).
  • Chores

    • Released package version 1.5.15.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

This PR refactors authentication prioritization logic for Hive Engine reward claims, giving HiveAuth precedence when applicable, restructures SDK auth broadcasting to check HiveAuth first, adds support for Claim operations in wallet mutations, extends asset info with component breakdown, and bumps the wallets package version.

Changes

Cohort / File(s) Summary
Authentication Logic
apps/web/src/app/(dynamicPages)/profile/[username]/wallet/(token)/[token]/_components/hive-engine-claim-rewards-button.tsx, apps/web/src/utils/sdk-auth.ts
Reworked signType selection priority in claim rewards flow: HiveAuth takes precedence when shouldUseHiveAuth() is true, falls back to keychain for keychain loginType, defaults to hivesigner otherwise. Reordered SDK auth broadcast logic to check HiveAuth (user.loginType or shouldUseHiveAuth()) first, configure for "active"/"posting" authorities, and skip setup for hivesigner/privateKey/undefined types.
Wallet Operation Support
packages/wallets/src/modules/wallets/mutations/wallet-operation.ts
Added AssetOperation.Claim mapping to engineOperationToFunctionMap that constructs a payload from claim operation data and calls claimHiveEngineRewards with proper auth integration.
Asset Info Extension
packages/wallets/src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts
Extended GeneralAssetInfo interface with new parts field containing an array of asset components (liquid, staked, savings) built from portfolio v2 fields.
Version Bump
packages/wallets/package.json
Updated package version from 1.5.14 to 1.5.15.

Sequence Diagram

sequenceDiagram
    actor User
    participant Button as Claim Rewards Button
    participant Auth as Auth Context (SDK)
    participant HiveAuth as HiveAuth
    participant Keychain as Keychain
    participant Engine as Hive Engine

    User->>Button: Click Claim Rewards
    Button->>Button: Evaluate signType priority
    alt shouldUseHiveAuth() == true
        Button->>Auth: Use HiveAuth
        Auth->>HiveAuth: Configure broadcast for active/posting
        HiveAuth->>Engine: Sign & execute claim
    else loginType == "keychain"
        Button->>Auth: Use Keychain
        Auth->>Keychain: Configure broadcast with authority mapping
        Keychain->>Engine: Sign & execute claim
    else
        Button->>Auth: Use HiveSigner (default)
        Auth->>Engine: Execute claim
    end
    Engine-->>User: Return claim result
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • Fix wallet actions #611: Modifies the same asset-info transformation in get-account-wallet-asset-info-query-options.ts and updates GeneralAssetInfo shape with parts extension.
  • Engine/SPK to SDK #608: Introduces getSdkAuthContext and claimHiveEngineRewards functions that form the foundation for this PR's auth and claim logic.
  • Convert op, optimistic commenting fixes #613: Extends engineOperationToFunctionMap in wallet-operation.ts with asset operation handlers; this PR adds AssetOperation.Claim mapping to the same structure.

Poem

🐰 Hop along the auth trail so bright,
HiveAuth first, then Keychain's might,
Claims now flow with perfect grace,
Parts aligned in their rightful place!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and uses abbreviated, non-descriptive terms ('sdk', 'broadcaster', 'wallet parts', 'claim') that don't clearly convey what the main changes accomplish. Revise the title to be more descriptive of the primary changes, such as: 'Prioritize HiveAuth in SDK authentication flow and add wallet asset parts breakdown' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
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

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.

Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/wallets/src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts (1)

80-93: Inconsistent handling of zero balances between liquid and staked/savings.

The liquid field is included in parts even when its value is 0 (only checks for undefined/null), while staked and savings require > 0 to be included. This asymmetry may be intentional (liquid balance of 0 is meaningful context), but verify this is the desired behavior.

If consistency is preferred:

Option A: Include liquid only when > 0 (like staked/savings)
-      if (assetInfo.liquid !== undefined && assetInfo.liquid !== null) {
+      if (assetInfo.liquid !== undefined && assetInfo.liquid !== null && assetInfo.liquid > 0) {
         parts.push({ name: "liquid", balance: assetInfo.liquid });
       }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a1639a and bcec2b2.

⛔ Files ignored due to path filters (6)
  • packages/wallets/dist/browser/index.js is excluded by !**/dist/**
  • packages/wallets/dist/browser/index.js.map is excluded by !**/dist/**, !**/*.map
  • packages/wallets/dist/node/index.cjs is excluded by !**/dist/**
  • packages/wallets/dist/node/index.cjs.map is excluded by !**/dist/**, !**/*.map
  • packages/wallets/dist/node/index.mjs is excluded by !**/dist/**
  • packages/wallets/dist/node/index.mjs.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (5)
  • apps/web/src/app/(dynamicPages)/profile/[username]/wallet/(token)/[token]/_components/hive-engine-claim-rewards-button.tsx
  • apps/web/src/utils/sdk-auth.ts
  • packages/wallets/package.json
  • packages/wallets/src/modules/wallets/mutations/wallet-operation.ts
  • packages/wallets/src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts
🧰 Additional context used
🧬 Code graph analysis (4)
packages/wallets/src/modules/wallets/mutations/wallet-operation.ts (4)
packages/wallets/dist/browser/index.d.ts (2)
  • AssetOperation (2031-2031)
  • claimHiveEngineRewards (2031-2031)
packages/wallets/dist/node/index.mjs (11)
  • payload (1320-1320)
  • payload (1373-1373)
  • payload (1398-1398)
  • payload (1538-1538)
  • payload (1625-1625)
  • payload (1672-1672)
  • payload (1715-1715)
  • payload (1762-1762)
  • payload (2801-2801)
  • payload (3045-3045)
  • auth (373-373)
packages/wallets/dist/node/index.cjs (7)
  • payload (1347-1347)
  • payload (1400-1400)
  • payload (1425-1425)
  • payload (1565-1565)
  • payload (1652-1652)
  • payload (1699-1699)
  • auth (400-400)
packages/wallets/dist/browser/index.js (1)
  • auth (375-375)
apps/web/src/app/(dynamicPages)/profile/[username]/wallet/(token)/[token]/_components/hive-engine-claim-rewards-button.tsx (1)
apps/web/src/utils/hive-auth.ts (1)
  • shouldUseHiveAuth (1351-1363)
packages/wallets/src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts (2)
packages/wallets/dist/node/index.mjs (4)
  • parts (2201-2204)
  • parts (3596-3596)
  • assetInfo (3592-3594)
  • assetInfo (3627-3627)
packages/wallets/dist/node/index.cjs (4)
  • parts (2228-2231)
  • parts (3623-3623)
  • assetInfo (3619-3621)
  • assetInfo (3654-3654)
apps/web/src/utils/sdk-auth.ts (1)
apps/web/src/utils/hive-auth.ts (2)
  • shouldUseHiveAuth (1351-1363)
  • broadcastWithHiveAuth (1374-1381)
🔇 Additional comments (7)
packages/wallets/package.json (1)

4-4: LGTM!

The patch version bump is appropriate for the bug fixes and new Claim operation support added in this PR.

packages/wallets/src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts (1)

95-104: LGTM!

The GeneralAssetInfo object is well-constructed with the new parts field providing useful balance breakdown information for UI components.

packages/wallets/src/modules/wallets/mutations/wallet-operation.ts (1)

73-84: LGTM!

The Claim operation handler correctly transforms the generic wallet operation payload into the format expected by claimHiveEngineRewards:

  • Maps payload.fromaccount
  • Wraps payload.asset in an array for tokens
  • Conditionally includes the key only when type is "key"

This aligns well with the claim flow in hive-engine-claim-rewards-button.tsx.

apps/web/src/utils/sdk-auth.ts (2)

26-41: LGTM!

The keychain broadcast setup is now properly guarded with an explicit else if check, ensuring it only applies when the user explicitly logged in with keychain. The authority mapping logic is unchanged and correct.


17-25: No action needed—shouldUseHiveAuth properly respects explicit keychain login.

The function checks the stored loginType first via getLoginType(username) and returns false if loginType === "keychain" (since it only returns true when loginType === "hiveauth"). Browser detection only applies as a fallback when no stored login type exists. The edge case is safely handled—explicit keychain login will not be overridden by HiveAuth.

apps/web/src/app/(dynamicPages)/profile/[username]/wallet/(token)/[token]/_components/hive-engine-claim-rewards-button.tsx (2)

161-168: LGTM!

The signType selection logic now correctly aligns with the prioritization in sdk-auth.ts:

  1. HiveAuth takes precedence via shouldUseHiveAuth()
  2. Keychain only when explicitly loginType === "keychain"
  3. Defaults to hivesigner otherwise

This ensures consistent authentication behavior across the claim workflow.


170-182: LGTM!

The claim mutation correctly handles both authentication paths:

  • Direct key signing for privateKey login type
  • Delegated signing via signType and auth context for other login types

The flow properly leverages the claimHiveEngineRewards function from the wallets package.

@feruzm feruzm merged commit 4ce1b16 into develop Jan 12, 2026
1 check passed
@feruzm feruzm deleted the auth branch January 12, 2026 11:34
This was referenced Jan 13, 2026
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