Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds authority-aware broadcasting with a smarter fallback flow, a new AuthorityLevel mapping and helpers, extended PlatformAdapter methods for key/authorization management and auth-upgrade UI, a web broadcast adapter, and web-facing SDK mutation wrapper hooks that delegate broadcasting to the SDK. Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(200,230,255,0.5)
participant Client
end
rect rgba(220,255,220,0.5)
participant Adapter
end
rect rgba(255,240,200,0.5)
participant KeyStore
end
rect rgba(255,220,220,0.5)
participant ExternalAuth as "HiveSigner/Keychain/HiveAuth"
end
rect rgba(240,240,240,0.5)
participant Node as "Blockchain Node"
end
Client->>Adapter: broadcastWithMethod(username, ops, authority)
Adapter->>Adapter: adapter.getLoginType(username)?
alt loginType available
Adapter->>Client: select preferred method
end
alt method == "key"
Adapter->>KeyStore: get key for authority (getPostingKey/getActiveKey/getOwnerKey)
KeyStore-->>Adapter: key
Adapter->>Node: sign & broadcast tx
else method == "hivesigner" or "hiveauth" or "keychain"
Adapter->>ExternalAuth: request token/key & send broadcast
ExternalAuth-->>Node: submit broadcast
else method == "custom"
Client->>Adapter: invoke custom broadcast handler
end
Node-->>Client: tx confirmation or error
alt auth failure
Client->>Adapter: showAuthUpgradeUI(requiredAuthority, operation)
Adapter->>Client: user selects alternate method -> retry via fallback chain
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/web/src/providers/sdk/web-broadcast-adapter.ts`:
- Around line 63-74: getUser currently returns user.loginType directly causing
inconsistency with getLoginType; update getUser to map loginType the same way
getLoginType does (i.e. map 'privateKey' to 'key' and pass through other values)
before returning authType. Locate the getUser function and either apply the same
conditional/mapping logic used in getLoginType or call
getLoginType(user.loginType) to set authType = mapped value instead of
user.loginType so both methods produce the same authType for private-key
sessions.
🧹 Nitpick comments (3)
apps/web/src/providers/sdk/web-broadcast-adapter.ts (2)
163-173: Consider wiring UI feedback to your toast system.Console-only feedback can hide errors in production. Hooking into the app’s existing toast/notification utilities would improve UX.
191-213: Use browser-safe timeout typing.The
apps/web/tsconfig.jsonis DOM-focused and doesn't explicitly include Node types (only DOM, DOM.Iterable, and ES targets). WhileNodeJS.Timeoutworks via the base config's"types": ["node"], usingReturnType<typeof setTimeout>is more appropriate for this web-only module and avoids unnecessary dependency on Node types.♻️ Suggested typing tweak
- let timeoutId: NodeJS.Timeout | undefined; + let timeoutId: ReturnType<typeof setTimeout> | undefined;apps/web/src/api/mutations/create-reply.ts (1)
62-97: Only set beneficiaries when non-empty—follow the SDK's pattern.The SDK's own
useCommentimplementation explicitly guards against empty beneficiaries by checkingif (beneficiaries.length > 0)before including the extension. Your code setsbeneficiariesunconditionally, which can result in an empty array being sent and potentially rejected by builders/ops that treat it as an explicit extension.♻️ Suggested tweak
- commentPayload.options = { + const beneficiaries = extractBeneficiaries(options.extensions); + commentPayload.options = { maxAcceptedPayout: options.max_accepted_payout, percentHbd: options.percent_hbd, allowVotes: options.allow_votes, allowCurationRewards: options.allow_curation_rewards, - beneficiaries: extractBeneficiaries(options.extensions), + ...(beneficiaries.length ? { beneficiaries } : {}), };
| async getUser(username: string) { | ||
| // Use existing user-token helper for consistent localStorage access | ||
| const user = getUser(username); | ||
| if (!user) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return { | ||
| name: user.username, | ||
| authType: user.loginType, // 'hivesigner' | 'keychain' | 'hiveauth' | 'privateKey' | ||
| }; | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
rg -n "interface User|authType|broadcastWithMethod" --type ts -C3 packages/sdkRepository: ecency/vision-next
Length of output: 11132
🏁 Script executed:
rg -A 20 "export interface User" packages/sdk/src/modules/core/types/platform-adapter.tsRepository: ecency/vision-next
Length of output: 268
🏁 Script executed:
rg -n "loginType|privateKey|keychain|hivesigner|hiveauth" apps/web/src/providers/sdk/web-broadcast-adapter.ts -B2 -A2Repository: ecency/vision-next
Length of output: 3296
🏁 Script executed:
rg -n "export.*loginType|type.*LoginType|enum.*LoginType" --type ts apps/webRepository: ecency/vision-next
Length of output: 174
Consistency: getUser should map loginType like getLoginType does.
The getLoginType method explicitly maps 'privateKey' → 'key' (line 153), but getUser returns loginType without mapping. This creates an inconsistency: the same private-key session will report different authType values depending on which method is called. Apply the mapping in getUser to match getLoginType behavior.
Suggested mapping
- return {
- name: user.username,
- authType: user.loginType, // 'hivesigner' | 'keychain' | 'hiveauth' | 'privateKey'
- };
+ const authType =
+ user.loginType === 'privateKey' ? 'key' : user.loginType;
+ return {
+ name: user.username,
+ authType,
+ };🤖 Prompt for AI Agents
In `@apps/web/src/providers/sdk/web-broadcast-adapter.ts` around lines 63 - 74,
getUser currently returns user.loginType directly causing inconsistency with
getLoginType; update getUser to map loginType the same way getLoginType does
(i.e. map 'privateKey' to 'key' and pass through other values) before returning
authType. Locate the getUser function and either apply the same
conditional/mapping logic used in getLoginType or call
getLoginType(user.loginType) to set authType = mapped value instead of
user.loginType so both methods produce the same authType for private-key
sessions.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores