Skip to content

refactor: use the SDK custody client - #1243

Draft
TaprootFreak wants to merge 2 commits into
developfrom
feat/use-packages-custody
Draft

refactor: use the SDK custody client#1243
TaprootFreak wants to merge 2 commits into
developfrom
feat/use-packages-custody

Conversation

@TaprootFreak

Copy link
Copy Markdown
Contributor

Consumer side of step 4 of DFXswiss/packages#198: use the custody client from @dfx.swiss/react
and drop the local copies.

Depends on DFXswiss/packages#202.

Changes

  • src/dto/safe.dto.ts and src/dto/order.dto.ts keep only what is local: the screen's operation
    enums (SafeOperationType, TransactionMode, TransactionType, FiatCurrency), the staff
    CustodyOrderListEntry, and ExchangeRate. Every wire type now comes from the package;
    OrderPaymentData and OrderPaymentInfo are CustodyOrderPaymentInfo and CustodyOrder there.
  • useSafe calls useCustody() instead of building URLs by hand. The screen state — loading flags,
    request generations, account selection, asset pairing, the PDF download to disk — stays here.
  • accountPath() is gone: toCustodyAccountId(account) from the package resolves the legacy
    account's null id.

What the corrected types surfaced

Three requests that the API would have rejected are now impossible to build:

  • Orders sent the session token when the custody token was missing. The package requires the
    custody token, so custodyToken() fails here instead of the request failing there.
  • Swap, withdrawal and send passed both amounts as number | undefined. The API prices from one
    side or the other and rejects a request carrying both or neither. orderAmount() decides which one
    goes out and refuses when there is none.
  • A withdrawal passed data.bankAccount?.iban, which the API requires. It is now checked before
    the request.

isOwnAccount reads account.isOwner instead of inferring ownership from the presence of an owner
relation — the comment there asked for exactly that once the API exposed the flag. It does.

Before this can go green

The package pin in package.json still points at the published @dfx.swiss/react. CI stays red
until DFXswiss/packages#202 is merged and published and the pin is raised here.
Verified locally
against a build of that branch: tsc clean, npm run lint clean, full suite at 673 passing with no
new failures (the two suites failing on develop today still fail, unchanged).

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

🤖 PR Review Bot

❌ TypeScript: 40 errors


This is an automated review. Please address the issues above.

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