Skip to content

SPIKE: Protocol 28 (CAP-0084)#1499

Draft
sisuresh wants to merge 2 commits into
stellar:masterfrom
sisuresh:p28-cap-0084
Draft

SPIKE: Protocol 28 (CAP-0084)#1499
sisuresh wants to merge 2 commits into
stellar:masterfrom
sisuresh:p28-cap-0084

Conversation

@sisuresh

Copy link
Copy Markdown

SPIKE porting CAP-0084 (muxed contract addresses) into the SDK. v16 vendored the
former @stellar/stellar-base into src/base/ and now owns XDR generation
(xdr/*.xsrc/base/generated via the Makefile/xdrgen), so this work lives
here rather than in a pinned base dependency.

Changes

  • xdr/{curr,next}/Stellar-contract.x: SC_ADDRESS_TYPE_MUXED_CONTRACT arm, MuxedContract struct, SCAddress union case.
  • Regenerated src/base/generated/{curr,next}_generated.js + .d.ts — targeted muxed-contract additions only; preserved existing xdrgen/dts-xdr shape (incl. the xdrgen#152 SCSYMBOL_LIMIT/SC_SPEC_DOC_LIMIT workaround) to keep the diff reviewable and avoid regressing the type API.
  • src/base/address.ts: Address.muxedContract() factory, contractId()/muxedId() accessors, and fromScAddress/toScAddress/toString arms. Display-only <C-strkey>:<id> (not constructor-parseable; round-trips via ScAddress/ScVal).
  • Tests (vitest) + CHANGELOG.

pnpm run build:prod and the base unit suite (1594 tests) pass.

Deferred

  • Canonical StrKey for muxed-contract — no upstream version byte yet; draft until CAP-0084 lands in canonical stellar-xdr, after which regenerate via the Makefile XDR_BASE_URL bump instead of the manual .x patch.
  • Makefile unchanged (manual .x patch; pinned stellar-xdr commit predates the arm).

Cross-links

js-stellar-sdk v16 vendors the former stellar-base into src/base and owns
XDR generation (xdr/*.x -> src/base/generated via Makefile/xdrgen). Ports
the CAP-0084 changes from stellar/js-stellar-base#980 (head d79a2b7):

- xdr/{curr,next}/Stellar-contract.x: SC_ADDRESS_TYPE_MUXED_CONTRACT arm,
  MuxedContract struct, SCAddress union case.
- Regenerated src/base/generated/{curr,next}_generated.js + .d.ts (targeted
  muxed-contract additions only; preserved existing dts-xdr/xdrgen shape).
- Address.muxedContract() + contractId()/muxedId() accessors and
  fromScAddress/toScAddress/toString arms.
- Tests + CHANGELOG.

Canonical XDR: stellar/stellar-xdr CAP-0084 SCAddress MuxedContract arm.
The SC_ADDRESS_TYPE_MUXED_CONTRACT arm was leaking into the released
`curr` codec. Per the feature-flag contract a gated CAP def must be
`next`-only until the protocol is enabled. Mirrors the fix on
stellar/js-stellar-base#980.

- xdr/curr/Stellar-contract.x + src/base/generated/curr{,_generated}.{js,d.ts}:
  drop the muxed-contract arm (next-channel files keep it).
- src/base/address.ts: guard the fromScAddress case label with optional
  chaining and reach the gated members via a cast so the curr-bound
  Address codec no longer fails to type-check or throws when the arm is
  absent (the write path stays dormant until the arm lands in curr).
- test/unit/base/address.test.ts: codec round-trip cases run only when
  the active codec defines the arm; Address-level assertions stay
  codec-agnostic.
@sisuresh

Copy link
Copy Markdown
Author

Downstream lab PR (CAP-0084 SPIKE): stellar/laboratory#2131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

1 participant