Skip to content

feat: add SDA protocol support (getSdaProtocol) - #73

Merged
jonathunne merged 7 commits into
mainfrom
feat/sda-protocol
Jul 29, 2026
Merged

feat: add SDA protocol support (getSdaProtocol)#73
jonathunne merged 7 commits into
mainfrom
feat/sda-protocol

Conversation

@AlonzoRicardo

@AlonzoRicardo AlonzoRicardo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Wires the new SdaProtocol category into the WDK so SDA (Smart Deposit Address) providers can be registered and retrieved alongside swap / bridge / lending / fiat / swidge, and makes SDA operations governable by the policy engine. Part 2 of 3.

Depends on the published @tetherto/wdk-wallet@^1.0.0-beta.15, which ships the SdaProtocol interface from tetherto/wdk-wallet#46 (merged and released). No branch pin remains.

What's in it

Protocol wiring (mirrors the existing swidge wiring exactly)

  • getSdaProtocol(label) on IWalletAccountWithProtocols, and typeof SdaProtocol added to the registerProtocol template union.
  • wdk.js: an sda bucket in both protocol registries, the instanceof SdaProtocol dispatch branch in registerProtocol / _registerProtocols, and the per-account account.getSdaProtocol getter.
  • getSdaProtocol → 'sda' mapping in the policy account proxy.

Policy governance

  • Adds PROTOCOL_METHODS.sda and the SDA operation names to OPERATIONS (the policy-rule allow-list) so SDA write methods can be targeted and enforced. Without this, getSdaProtocol on a policy-governed account threw TypeError: opsToWrap is not iterable (the proxy referenced an sda bucket that did not exist in PROTOCOL_METHODS).
  • Governed methods are the mutating operations: createDepositAddress, renewDepositAddress, recoverDepositAddress, disableDepositAddress. Read methods (getSupportedRoutes, quoteDeposit, ...) stay unwrapped. Also reflected in the PolicyOperation type.

Tests

  • getSdaProtocol coverage under getAccount / getAccountByPath in wdk.test.js, mirroring the sibling protocol suites.
  • Policy tests: an SDA write method blocks on DENY while a read method stays unwrapped, plus the simulate.getSdaProtocol(...) DENY path.

Validation

  • Unit tests only: 140 passing, standard lint clean, tsc --noEmit clean.
  • Coverage is the wiring and the policy governance, with the wallet boundary and protocol methods mocked (the established pattern in these suites). The policy tests are genuine regressions: removing PROTOCOL_METHODS.sda reproduces the opsToWrap is not iterable crash.
  • No real-provider or testnet testing. There is no concrete SDA provider module yet (that lands via the create-wdk-module template, chore: public release, bump version #14), so only the interface wiring and policy integration can be exercised here.

Notes

  • Imports SdaProtocol / ISdaProtocol from @tetherto/wdk-wallet/protocols.
  • Includes the generated .d.ts declarations, kept in sync with the source.
  • Open for review. One design point for sign-off: the set of SDA methods placed under policy governance (the four mutating ones above).

Related PRs

Part of a 3-PR set:

@socket-security

socket-security Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​tetherto/​wdk-wallet@​1.0.0-beta.13 ⏵ 1.0.0-beta.1579 +110083 +195 +1100

View full report

Wire the new `SdaProtocol` category into the WDK so SDA providers can be
registered and retrieved alongside swap/bridge/lending/fiat/swidge.

- `getSdaProtocol(label)` on `IWalletAccountWithProtocols`.
- `registerProtocol` dispatch and per-account getter in `wdk.js`
  (an `sda` bucket in both protocol registries, plus the
  `instanceof SdaProtocol` branch).
- `getSdaProtocol` -> `sda` mapping in the policy account proxy.

Part 2 of 3. Depends on the `SdaProtocol` interface in
tetherto/wdk-wallet.

Generated `.d.ts` are produced by `npm run build:types`.
…te types

The SDA interface (wdk-wallet#46) shipped in v1.0.0-beta.15, so depend on the
released version instead of the git branch. Regenerate the .d.ts (getSdaProtocol /
SdaProtocolCtor / registerProtocol overload), which the original SDA commit omitted.
Replace the standalone wdk-sda.smoke.test.js with getSdaProtocol describe
blocks under getAccount and getAccountByPath, mirroring the getSwapProtocol /
getSwidgeProtocol siblings (registration, dispatch, missing-label) for
coverage parity.
…ned accounts

PROTOCOL_GETTERS listed 'sda' but PROTOCOL_METHODS had no matching entry, so
getSdaProtocol (and simulate.getSdaProtocol) on a policy-governed account threw
'opsToWrap is not iterable'. Add the SDA state-changing methods
(createDepositAddress, renewDepositAddress, recoverDepositAddress,
disableDepositAddress) to OPERATIONS and PROTOCOL_METHODS.sda so policies can
target and enforce them, extend the PolicyOperation typedef, sync the
hand-maintained .d.ts, and add regression tests for the wrapped-DENY and
simulate paths.
@AlonzoRicardo
AlonzoRicardo marked this pull request as ready for review July 27, 2026 14:26
@AlonzoRicardo AlonzoRicardo self-assigned this Jul 27, 2026
Comment thread src/wallet-account-with-protocols.js Outdated
Comment thread src/wdk.js
…constraint

Address review feedback: the *ProtocolCtor aliases were part of the public type
surface but never exported. Rather than export them, revert to a typeof-based
constraint (the original approach). Inline the qualified
typeof import('@tetherto/wdk-wallet/protocols').X form in the registerProtocol
@template so it still resolves for strict-mode consumers without a value import
of the protocol classes — a bare 'typeof SwapProtocol' re-triggers TS2304 in
this interface file, which is what the ctor typedefs originally worked around.
wdk.js keeps its short 'typeof X' (it imports the classes for instanceof), so
both are now typeof-based with no ad-hoc ctor types.
Comment thread src/wallet-account-with-protocols.js Outdated
@Davi0kProgramsThings Davi0kProgramsThings self-assigned this Jul 29, 2026

@Davi0kProgramsThings Davi0kProgramsThings 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.

LGTM.

@jonathunne
jonathunne merged commit a10425b into main Jul 29, 2026
7 checks passed
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