Skip to content

fix(branta): align brantaService with Branta SDK v3 types#409

Closed
spe1020 wants to merge 1 commit into
mainfrom
fix/branta-sdk-v3
Closed

fix(branta): align brantaService with Branta SDK v3 types#409
spe1020 wants to merge 1 commit into
mainfrom
fix/branta-sdk-v3

Conversation

@spe1020
Copy link
Copy Markdown
Contributor

@spe1020 spe1020 commented May 30, 2026

What

The Branta SDK v3 upgrade (#401) left src/lib/brantaService.server.ts using v2 field/method shapes that no longer match the installed @branta-ops/branta@3.x types, producing 9 svelte-check errors on main (cascading into api/branta/register). This aligns the code to the SDK's actual v3 type surface.

Key correction

In v3 (3.0.2 installed), the service class and Payment/Destination/DestinationType types are still exported from the /v2 entry point — only the client-options classes (BrantaClientOptions, BrantaServerBaseUrl) live at the package root. So this keeps the split import and fixes the type mismatches, rather than moving everything to the root.

Fixes (verified against the installed .d.ts)

Issue Fix
DestinationType imported from root (not exported there) import from @branta-ops/branta/v2 (both files)
BrantaServerBaseUrl used as a type it's a value whose members carry the resolved URL → map BRANTA_ENVIRONMENT to the matching member; don't annotate with it
Destination.isZk renamed to zk
Payment.metadata = JSON.stringify(...) v3 type is Record<string, string> → coerce object values to strings
result.verifyUrl on addPayment ZKPaymentResult has no verifyUrl → use result.verifyLink
getPayments/getPaymentsByQRCode treated as { payments, verifyUrl } v3 return Payment[] directly → index the array; verifyUrl lives on each Payment
getPaymentsByQrCode getPaymentsByQRCode (capital QR)

Scope / safety

  • Two files: src/lib/brantaService.server.ts and src/routes/api/branta/register/+server.ts (import path only).
  • No other files reference the changed shapes.
  • Behavior preserved: same registration/lookup flow, same graceful degradation when unconfigured.

Verification

  • pnpm check0 errors (was 9); 128 pre-existing warnings unchanged.
  • pnpm test151/151 pass.

🤖 Generated with Claude Code

The v3 SDK upgrade left brantaService.server.ts straddling the deprecated
`@branta-ops/branta/v2` entry point and the v3 root, producing 9 svelte-check
errors. Consolidate entirely onto the v3 root (per the SDK's own guidance;
`/v2` is removed in v4) and align to its types:

- Import BrantaService + all types from the package root, not `/v2`.
- baseUrl: v3 types it as the resolved URL string, so map the environment
  name through the BrantaServerBaseUrl const instead of passing 'Production'.
  (Import it as a value, not a type.)
- Destination: v2 `isZk` -> v3 `zk`.
- Payment.metadata: v3 is Record<string, string> (was a stringified blob);
  coerce the metadata object's values to strings.
- addPayment result: v3 moved `verifyUrl` off ZKPaymentResult onto the
  returned Payment -> use result.payment.verifyUrl.
- getPayments / getPaymentsByQRCode: v3 returns { payments, verifyUrl }
  (v2 was { data, url }); the existing reads now match, and the QR method
  is getPaymentsByQRCode (capital QR).

api/branta/register's root import of DestinationType now resolves cleanly
(it was cascading off the broken v2 import). No other files reference the
changed shapes. svelte-check: 0 errors (was 9); tests 151/151.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
zapcooking-frontend 67cc2b4 May 30 2026, 01:58 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
frontend 67cc2b4 May 30 2026, 01:59 PM

@spe1020 spe1020 closed this May 30, 2026
@spe1020 spe1020 changed the title fix(branta): migrate brantaService to Branta SDK v3 surface fix(branta): align brantaService with Branta SDK v3 types May 30, 2026
@spe1020
Copy link
Copy Markdown
Contributor Author

spe1020 commented May 30, 2026

Superseded by #410 — the fix was force-pushed to the same branch and this PR couldn't be reopened, so a fresh PR was created. Please review #410 instead.

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.

1 participant