Skip to content

SPIKE: Protocol 28 (CAP-0084)#980

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

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

Conversation

@sisuresh

Copy link
Copy Markdown

SPIKE for Protocol 28 / CAP-0084 (muxed contract addresses). Re-pins XDR to the current stellar-xdr#306 head and adds Address-level support.

Changes

  • Re-pin XDR (curr+next) to stellar/stellar-xdr@7b56181 (PR TS Errors trying to build envelope from xdr string #306 head); rename feature gate CAP_0084CAP_0084_MUXED_CONTRACT, drop now-ungated CAP_0071. Generated JS + .x are byte-identical to the prior pin.
  • New XDR: SCAddressType.SC_ADDRESS_TYPE_MUXED_CONTRACT=5, struct MuxedContract, SCAddress muxedContract arm.
  • Address decodes/encodes the muxed-contract arm: Address.muxedContract(contractId, id), fromScAddress/toScAddress round-trip (uint64 kept as xdr.Uint64), contractId()/muxedId() accessors, <C-strkey>:<id> display, toBuffer() throws.
  • scripts/post-process-generated.py inlines bare const use-sites (terser-safe const-inlining), wired as a post-xdrgen Makefile step.

Deferred

  • Canonical muxed-contract strkey — no upstream version byte yet; string form is display-only <C-strkey>:<id>, round-trip via ScAddress/ScVal.

Cross-links

Bump XDR pin to stellar-xdr#306 (7b56181) and regen for CAP-0084
muxed contract addresses. Add Address-level encode/decode for the
SC_ADDRESS_TYPE_MUXED_CONTRACT arm (muxedContract factory,
contractId()/muxedId(), <C-strkey>:<id> display). Canonical strkey
deferred — no upstream version byte yet.
@sisuresh

Copy link
Copy Markdown
Author

Downstream: the same CAP-0084 muxed-contract changes are ported into js-stellar-sdk v16 (which vendored stellar-base into src/base/) in stellar/js-stellar-sdk#1499.

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.

- Makefile: split XDR_FEATURES into XDR_FEATURES_CURR (CAP_0083) and
  XDR_FEATURES_NEXT (CAP_0083,CAP_0084_MUXED_CONTRACT); regen curr.
- curr_generated.js + types/curr.d.ts: drop the muxed-contract arm.
- address.js: guard the fromScAddress case label with optional chaining
  so the curr-bound Address codec no longer throws when the arm is
  absent (the write path stays dormant until the arm lands in curr).
- address_test.js: codec round-trip cases run only when the active codec
  defines the arm; Address-level assertions stay codec-agnostic.
sisuresh added a commit to sisuresh/js-stellar-sdk that referenced this pull request Jun 27, 2026
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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant