Skip to content

feat: add getProjectWalletsByTag and normalize wallet shape#127

Merged
jinglescode merged 3 commits into
mainfrom
feat/get-wallets-by-tag
Apr 26, 2026
Merged

feat: add getProjectWalletsByTag and normalize wallet shape#127
jinglescode merged 3 commits into
mainfrom
feat/get-wallets-by-tag

Conversation

@jinglescode
Copy link
Copy Markdown
Contributor

Summary

  • Adds sdk.wallet.getProjectWalletsByTag(tag) to WalletDeveloperControlled, consuming the existing GET /api/project-wallet/:projectId/tag/:tag backend endpoint.
  • Fixes a latent shape-cast bug in getProjectWallet and getProjectWalletsByTag: the backend returns a flat Web3ProjectWallet (pubKeyHash, stakeCredentialHash at top level) but the SDK was casting it as the nested MultiChainWalletInfo (chains.cardano.*). Any caller reading wallet.chains.cardano.pubKeyHash previously got undefined. A normalizeWalletInfo helper now maps flat → nested at the SDK boundary. Spark is intentionally omitted because the backend doesn't persist Spark public keys.
  • Removes a dead walletInfo.chains.spark gate in getWallet. Spark wallets derive entirely from the mnemonic; the gate prevented the spark branch from ever running in production.
  • Bumps version 0.2.00.2.1.

API

const wallets = await sdk.wallet.getProjectWalletsByTag("treasury");
console.log(`Found ${wallets.length} treasury wallets`);
  • URL-encodes the tag (team/alpha betateam%2Falpha%20beta)
  • Throws on empty/whitespace tag
  • Returns MultiChainWalletInfo[] with chains.cardano populated

Out of scope (deferred)

  • getProjectWallets (paginated list) has a separate envelope-shape bug — SDK expects {data, pagination} but the backend returns a flat array. Not touched here.
  • POST /api/project-wallet silently drops chains.spark — would require a Prisma schema migration.

Test plan

  • pnpm jest src/sdk/wallet-developer-controlled/index.test.ts — 40/40 passing
  • Type-check passes for changed files (pre-existing errors elsewhere)
  • QA review (code review + cross-check against backend handlers and Prisma schema) — verdict PASS-WITH-CONCERNS, zero blockers
  • Smoke test against staging API (reviewer)

🤖 Generated with Claude Code

jinglescode and others added 3 commits April 26, 2026 21:52
- Add `getProjectWalletsByTag(tag)` on `WalletDeveloperControlled`,
  consuming the existing `GET /api/project-wallet/:projectId/tag/:tag`
  endpoint. URL-encodes the tag and rejects empty/whitespace input.

- Add `normalizeWalletInfo` helper that maps the backend's flat
  `Web3ProjectWallet` response (top-level `pubKeyHash`,
  `stakeCredentialHash`) into the SDK's nested `MultiChainWalletInfo`
  shape. Apply it in `getProjectWallet` and `getProjectWalletsByTag`,
  replacing the unsafe `data as MultiChainWalletInfo` casts that
  previously left `walletInfo.chains.cardano.*` undefined for callers.
  Spark is intentionally omitted because the backend doesn't persist
  Spark public keys.

- Drop the dead `walletInfo.chains.spark` gate in `getWallet`. Spark
  wallets are derived entirely from the mnemonic; the gate previously
  prevented the spark branch from ever running in production.

- Update tests to mock the actual flat backend shape and assert the
  normalized output. 40/40 passing.

Bumps version 0.2.0 -> 0.2.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Main shipped 0.2.1 in #126; this branch's 0.2.1 collides, so bump to 0.2.2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jinglescode jinglescode merged commit bb4966e into main Apr 26, 2026
1 check passed
@jinglescode jinglescode deleted the feat/get-wallets-by-tag branch April 26, 2026 13:55
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