Skip to content

Upgrade branta sdk to v3.1.2 - #622

Closed
kylemccullen wants to merge 5 commits into
arkade-os:masterfrom
BrantaOps:upgrade-branta-sdk
Closed

kylemccullen wants to merge 5 commits into
arkade-os:masterfrom
BrantaOps:upgrade-branta-sdk

Conversation

@kylemccullen

@kylemccullen kylemccullen commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Dependencies

    • Updated Branta library to v3.1.3.
  • Improvements

    • Send screen now uses the newer verification SDK with stricter privacy mode.
    • Payment verification shows HTTPS-only verify links, theme-aware platform logos, and a clearer verified badge link.
    • Improved recipient lookup: unified behavior when scanning QR codes or typing, with more robust loading/error handling.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 522c4a89-7381-4c63-a6ac-0d027c6cd606

📥 Commits

Reviewing files that changed from the base of the PR and between f97f465 and 4a3782d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json
  • src/screens/Wallet/Send/Form.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • src/screens/Wallet/Send/Form.tsx

Walkthrough

SendForm is refactored to use the Branta v2 SDK (dependency bumped to 3.1.3). It instantiates a module-level BrantaService (PrivacyMode.Strict) with env-based baseUrl, replaces legacy client imports/types with the SDK's Payment, consolidates QR/typed lookup into one effect that normalizes HTTPS logo/verify URLs, and updates the verified-by-Branta UI to use brantaVerifyUrl and theme-appropriate logos.

Changes

Branta v2 SDK Migration

Layer / File(s) Summary
SDK imports, dependency bump, and client initialization
package.json, src/screens/Wallet/Send/Form.tsx
Dependency @branta-ops/branta updated to 3.1.3; imports switched to v2 SDK exports (BrantaServerBaseUrl, PrivacyMode, BrantaService, Payment); Themes added to shared types; isProductionEnv derived and module-level BrantaService instantiated with PrivacyMode.Strict and conditional baseUrl.
Component state, unified lookup effect, and UI wiring
src/screens/Wallet/Send/Form.tsx
Component state now uses `Payment

Sequence Diagram(s)

sequenceDiagram
  participant SendForm
  participant BrantaService
  participant BrantaAPI
  SendForm->>BrantaService: getPaymentsByQrCode(rawScanData) / getPayments(typed)
  BrantaService->>BrantaAPI: HTTP request to Branta endpoints
  BrantaAPI-->>BrantaService: return Payment[] (SDK Payment objects)
  BrantaService-->>SendForm: return first Payment with platformLogoUrl/platformLogoLightUrl/verifyUrl
  SendForm->>SendForm: set brantaPayment and brantaVerifyUrl (HTTPS-only)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • arkade-os/wallet#568: Both PRs modify src/screens/Wallet/Send/Form.tsx’s Branta integration—specifically the brantaPayment/Branta payment typing and related fields.
  • arkade-os/wallet#490: Both PRs modify src/screens/Wallet/Send/Form.tsx to implement Branta QR verification and verification UI; this PR upgrades the integration to the v2 SDK.

Suggested reviewers

  • bordalix
  • arkanaai
  • louisinger
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title states 'Upgrade branta sdk to v3.1.2' but the actual dependency version updated in package.json is '3.1.3', not '3.1.2'. This is a factual mismatch between the stated version and the actual change. Update the PR title to accurately reflect the version being upgraded to: 'Upgrade branta sdk to v3.1.3' or verify that the dependency version in package.json should be 3.1.2 instead.
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.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/screens/Wallet/Send/Form.tsx`:
- Around line 286-302: Add a lightweight local pre-check for Branta/ZK scans
inside the useEffect that reads rawScanData before setting loading or calling
brantaClient.getPaymentsByQrCode: implement an isBrantaQr(rawScanData) helper
(or inline check) that only returns true for the known Branta/ZK QR
patterns/markers you expect, and if it returns false immediately call
setBrantaPayment(null), setBrantaVerifyUrl(undefined), setBrantaLoading(false)
and return; only when isBrantaQr(rawScanData) is true should you
setBrantaLoading(true) and invoke brantaClient.getPaymentsByQrCode(rawScanData).
Reference symbols: rawScanData, useEffect block,
brantaClient.getPaymentsByQrCode, setBrantaPayment, setBrantaVerifyUrl,
setBrantaLoading, and the new isBrantaQr helper.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aeac6f3a-4278-4dfe-9161-d1551f9d2d3e

📥 Commits

Reviewing files that changed from the base of the PR and between 98f2ef0 and ddd39b8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json
  • src/screens/Wallet/Send/Form.tsx

Comment thread src/screens/Wallet/Send/Form.tsx Outdated
Comment on lines +286 to +302
// fetch branta payment info for ZK QR-scanned addresses (SDK strict mode gates non-ZK)
useEffect(() => {
if (!rawScanData) {
setBrantaPayment(null)
setBrantaVerifyUrl(undefined)
setBrantaLoading(false)
return
}

setBrantaPayment(null)
setBrantaVerifyUrl(undefined)
setBrantaLoading(true)
let cancelled = false

let isValidZKCode = false
try {
const url = new URL(rawScanData.trim())
isValidZKCode = url.searchParams.has('branta_id') && url.searchParams.has('branta_secret')
} catch {
// Invalid URL, not a ZK code
}

if (!isValidZKCode) {
setBrantaLoading(false)
return
}

setBrantaLoading(true)
brantaClient
.getPaymentsByQRCode(rawScanData)
.then((payments: BrantaPayment[]) => {
.getPaymentsByQrCode(rawScanData)
.then(({ payments, verifyUrl }) => {

@coderabbitai coderabbitai Bot May 18, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Restore a local Branta/ZK pre-check before calling the SDK.

Line 301 now sends every non-empty scanned payload to getPaymentsByQrCode(rawScanData). That means plain invoices, BIP21 URIs, and addresses scanned in this screen get disclosed to Branta even when they are not Branta QR codes and no Branta UI is ultimately shown. Please reintroduce the lightweight local gate that existed before this migration and only call the SDK for Branta/ZK scans.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/screens/Wallet/Send/Form.tsx` around lines 286 - 302, Add a lightweight
local pre-check for Branta/ZK scans inside the useEffect that reads rawScanData
before setting loading or calling brantaClient.getPaymentsByQrCode: implement an
isBrantaQr(rawScanData) helper (or inline check) that only returns true for the
known Branta/ZK QR patterns/markers you expect, and if it returns false
immediately call setBrantaPayment(null), setBrantaVerifyUrl(undefined),
setBrantaLoading(false) and return; only when isBrantaQr(rawScanData) is true
should you setBrantaLoading(true) and invoke
brantaClient.getPaymentsByQrCode(rawScanData). Reference symbols: rawScanData,
useEffect block, brantaClient.getPaymentsByQrCode, setBrantaPayment,
setBrantaVerifyUrl, setBrantaLoading, and the new isBrantaQr helper.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Setting privacy: 'strict' in the BrantaClientOptions prevents this behavior within the SDK itself. When strict mode is enabled, the SDK will not transmit plain-text addresses, BIP21 URIs, or standard invoice formats to Branta servers—it performs local validation first and only makes network requests for data that matches the Branta/ZK format.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kylemccullen, thanks for the clarification! That makes sense — since the client is initialized with privacy: PrivacyMode.Strict, the SDK itself performs the local Branta/ZK format check before any network request, making the removed isValidZKCode pre-check redundant. The concern is no longer valid. I'll note this behavior for future reviews.

(ˆ · ˆ) 🐇


✏️ Learnings added
Learnt from: kylemccullen
Repo: arkade-os/wallet PR: 622
File: src/screens/Wallet/Send/Form.tsx:286-302
Timestamp: 2026-05-19T11:53:58.967Z
Learning: In `src/screens/Wallet/Send/Form.tsx` (React/TypeScript), the `BrantaService` client from `branta-ops/branta` v3.x is initialized with `privacy: PrivacyMode.Strict`. When `PrivacyMode.Strict` is set in `BrantaClientOptions`, the SDK performs local validation before any network request and will NOT transmit plain-text addresses, BIP21 URIs, or standard Lightning invoice formats to Branta servers — only data matching the Branta/ZK QR format triggers a network call. Therefore, no additional local pre-check (e.g. `isValidZKCode`) is needed in the component before calling `brantaClient.getPaymentsByQrCode(rawScanData)`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

const brantaClient = new V2BrantaClient({
const brantaClient = new BrantaService({
baseUrl: BrantaServerBaseUrl.Production,
privacy: PrivacyMode.Strict,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note - this SDK version enables Zero-Knowledge for lightning payments (in addition to onchain zero-knowledge)


setBrantaPayment(null)
setBrantaVerifyUrl(undefined)
setBrantaLoading(true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i dont see any code that sets this false again? what if something fails?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe a fail case is handled by the finally block

@Kukks

Kukks commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Superseded by #673, which re-creates this branch with master merged in (the trivial import conflict in Send/Form.tsx is resolved there). Re-created because this PR's fork has maintainer edits disabled, so the conflict resolution couldn't be pushed here. Your commit authorship is preserved in #673. Closing in favor of #673.

@Kukks Kukks closed this Jun 15, 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.

3 participants