Skip to content

refactor(sdk-core): unify sysio contracts behind a generated proxy#50

Open
joshglogau wants to merge 3 commits into
masterfrom
refactor/sysio-contract-proxy
Open

refactor(sdk-core): unify sysio contracts behind a generated proxy#50
joshglogau wants to merge 3 commits into
masterfrom
refactor/sysio-contract-proxy

Conversation

@joshglogau

Copy link
Copy Markdown
Contributor

Summary

Refactors the SDK’s system-contract integration around a single generated, strongly typed sysio proxy modeled after Wire Tools’ getSysioContract design.

The proxy now exposes every contract defined in SysioContractDefinitions through one consistent interface:

  • actions.<name>.prepare(...)
  • actions.<name>.invoke(...)
  • tables.<name>.query(...)
  • tables.<name>.rows(...)
  • tables.<name>.first(...)
  • tables.<name>.scopes(...)

What changed

  • Added a root proxy through contracts.sysio.createClient({ client }).
  • Added direct dynamic lookup through getSysioContract(name).
  • Derives contract, action, table, request, and response types from the generated SysioContractMapping.
  • Validates contract members against generated definitions at runtime.
  • Lazily creates and caches contract, action, and table clients.
  • Supports contract account overrides for nonstandard deployments.
  • Uses local codecs only where synchronous Action encoding is required.
  • Falls back to a typed AnyAction when local encoding is unavailable so APIClient can resolve the deployed ABI.
  • Requires explicit authorization instead of guessing a write authority.
  • Forwards transaction options directly to APIClient.pushTransaction.
  • Keeps AuthEx, multisig, and reserve clients as focused domain facades built on top of the shared proxy.

Cleanup

  • Removed duplicated AuthEx, multisig, and reserve descriptors.
  • Removed the legacy named createClient({ name }) factory.
  • Removed callable action aliases in favor of the consistent prepare/invoke interface.
  • Removed redundant facade wrappers and unused runtime serializers.
  • Centralized the remaining synchronous codecs in one typed registry.
  • Separated generic descriptor-client tests from generated sysio-proxy tests.

Example

import { contracts, SysioContracts } from "@wireio/sdk-core"

const sysio = contracts.sysio.createClient({ client: api })

const msig = sysio.msig
const epoch = sysio.getSysioContract(
  SysioContracts.SysioContractName.epoch
)

const action = msig.actions.approve.prepare(
  {
    proposer: "alice",
    proposal_name: "upgrade1",
    level: {
      actor: "bob",
      permission: "active"
    },
    proposal_hash: null
  },
  {
    authorization: ["bob@active"]
  }
)

await epoch.actions.advance.invoke(
  {},
  {
    authorization: ["operator@active"]
  }
)

const proposals = await msig.tables.proposal.query({
  scope: "alice"
})

Verification

  • SDK TypeScript compilation passes.
  • Strict-null typecheck passes.
  • Repository-wide ESLint passes.
  • All 527 SDK tests pass across 48 test suites.

@joshglogau
joshglogau requested review from a team, bearcubsvet and jglanz July 21, 2026 18:59
@bearcubsvet
bearcubsvet requested review from a team and removed request for a team, bearcubsvet and jglanz July 21, 2026 20:23
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