wallet-sdk PR2: core (Money, errors+classify, events, Sdk shell + wiring)#1120
wallet-sdk PR2: core (Money, errors+classify, events, Sdk shell + wiring)#1120orveth wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
…nnection wiring Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| "exclude": ["node_modules"], | ||
| "compilerOptions": { | ||
| "lib": ["ES2022"], | ||
| "lib": ["ES2022", "DOM"], |
| "dependencies": { | ||
| "@agicash/opensecret": "catalog:", | ||
| "@cashu/cashu-ts": "3.6.1", | ||
| "@supabase/supabase-js": "2.95.2", |
There was a problem hiding this comment.
I think the idea is to put all libs that are shared by multiple packages/apps in our monorepo to the catalog (@pmilic021 correct me if wrong)
There was a problem hiding this comment.
I don't think money needs to be part of sdk. I think we should add antoher package in packgas folder just for the money lib so sdk and whoever else needs it can use it. it's a standalone lib
|
Superseded by the reactive design-B stack (SDK #1129-#1138 + lib-extract #1140-#1143). This no-cache stack was the reference substrate the reactive PRs were built from (~90% reused, reads adapted to Query); it was never reviewed/merged, so nothing is lost. Closing as superseded — branch retained for reference. |
PR2 of the
@agicash/wallet-sdkbuild (no-cache contract). Stacked on PR1 (#1119) — base issdk/pr1-contract. Lands Slice 0 / core on top of PR1's contract types: no domain business logic (those are PR3+).What this implements (Slice 0)
declare classplaceholder.Moneyis now a real value export, re-exporting the liveMoney(+Currency/CurrencyUnit) fromapps/web-wallet/app/lib/moneyvia a relative path (single source of truth, zero web churn).lib: ["DOM"]added to the package tsconfig formoney.ts's dev-only devtools formatter.classify— kept the realSdkError/ConcurrencyError/DomainError/NotFoundError; addedNotImplementedError(thrown by the stubs).classify(err) → 'transient' | 'permanent' | 'already-resolved' | 'unhandled'is a pure fn (§12, the locked 4-bucket seam): SDK-native errors + cashu-tsMintOperationError/NetworkError/HttpResponseError, mapping NUT codes (11004/11002/20005 → transient per fix(cashu): stop transient outputs-pending (11004) from crashing swap tasks #1115; already-spent/issued/paid/signed → already-resolved; other mint rejections → permanent). TheCashuErrorCodesenum is lifted verbatim intosrc/internal/.TypedEventEmitter<M>(on/once/emit/off/removeAllListeners) backing PR1's publicEventEmitter<M>interface (theSdkexposes the subscribe-only surface;emit/offare internal).Sdk.create+Sdkclass — validates config; instantiates the OpenSecret client (configure({apiUrl,clientId})), the SDK-owned Supabase client (schema pinned'wallet', RLS access token = the OpenSecret JWT via an internal cached/auto-refreshing token provider), threads thestorageadapter, builds the event emitter, and wires each domain accessor (auth/user/accounts/cashu/spark/transactions/contacts/transfers/scan/exchangeRate/background) to a stub whose methods throwNotImplementedError.destroy()closes Supabase realtime, clears the token cache + all subscribers (mint-WS/Breez/orchestrator teardown hooks land in S3/S5).clientIdauto-generated viacrypto.randomUUID()when omitted.Placeholders resolved vs deferred
Money(→ realapp/lib/money),StorageAdapter(kept structural — see note below), the error classes + classifier, the event emitter.ExtendedCashuWallet/BreezSdk(S3),SparkNetwork/Bolt11Invoice/ParsedToken/cashuProofsub-types (S2/S3), the DBDatabasetypes (Supabase client typed loosely now, narrowed when DB types are lifted).Stubbed for later slices
executeQuoteorchestrator + relocating theclassifyconsumer) · S4 transactions + contacts + transfers · S5 background (leader-election) + realtime→event forwarding. Each stub is a typed seam insrc/internal/stub-domains.ts.Connection-wiring note (needs a decision)
The contract's
storage: StorageAdapter+ "session-resume via storage adapter" assumed@agicash/opensecret-sdk's pluggable storage. The installed package is@agicash/opensecret, which configures via a module-globalconfigure({apiUrl,clientId})(no storage param) and persists its own tokens inlocalStorage(browser-only). So: session resume comes "for free" from the OpenSecret client rehydrating, and the SDK still holdsconfig.storagefor the auth slice / future use — but there is no storage-injection seam in the installed package, which means non-browser (MCP/fs) use is not yet possible without the@agicash/opensecret-sdkpluggable-storage work. TheStorageAdaptertype is kept as PR1's structural shape. Flagged for a follow-up call.CI (local, package-scoped)
biome format --write packages/wallet-sdkclean;format:check+lint:check+tsc --noEmitall pass. Whole-workspaceweb-wallettypecheck also passes (Money re-export + tsconfig change cause no regression). A runtime smoke test confirmed: real Money, all 7 classify buckets,Sdk.createwiring, event delivery, stubs throwingNotImplementedError,destroy(), and config validation.🤖 Generated with Claude Code