Skip to content

feat(soroban): make registry optional in example-compliant-token#64

Open
alex-predicate wants to merge 1 commit into
mainfrom
alex-predicate/stellar-testnet-compliant-token
Open

feat(soroban): make registry optional in example-compliant-token#64
alex-predicate wants to merge 1 commit into
mainfrom
alex-predicate/stellar-testnet-compliant-token

Conversation

@alex-predicate

Copy link
Copy Markdown
Contributor

What

Make the registry optional in example-compliant-token so the token can be deployed on a network that has no PredicateRegistry yet (e.g. Stellar mainnet today), while keeping the compliance guarantee that the token never performs an unchecked transfer.

Changes (soroban/example-compliant-token/src/lib.rs)

  • __constructor registry is now Option<Address> — omit --registry on the CLI to deploy without one.
  • New admin-only set_registry(registry) to attach (or replace) a registry later.
  • New TokenError::RegistryNotConfigured. register_policy (now returns Result) and transfer return it when no registry is set. transfer checks before moving any tokens — fail-safe, never an unchecked transfer.
  • registry() getter now returns Option<Address>.
  • Added test_no_registry_placeholder covering the deploy-without-registry → mint/balance → attach-registry flow.

Behavior with no registry

mint / balance / policy_id / deploy all work. The policy_id string is stored but inert until a registry is attached and register_policy succeeds. transfer and register_policy return RegistryNotConfigured.

Testing

  • cargo test -p example-compliant-token — 3/3 pass (watched the new test fail first).
  • cargo clippy -p example-compliant-token — clean.
  • stellar contract build --package example-compliant-token — builds for wasm32v1-none.

Deployed

Deployed to Stellar mainnet as a registry-less placeholder with policy x-managed-policy-2f0e79710e5254bdf4a978c49907b114:
CAYXGYBS2EZROB6MEA6EO7BOP4JDD7R6W3HW3VIFPDYODRUXI4EMXER7

🤖 Generated with Claude Code

Allow deploying the example compliant token without a PredicateRegistry
(e.g. on a network that has none yet, like Stellar mainnet today) while
preserving the compliance guarantee: the token never performs an
unchecked transfer.

- __constructor `registry` is now `Option<Address>` (omit `--registry`)
- add admin-only `set_registry` to attach a registry later
- add `TokenError::RegistryNotConfigured`; `register_policy` (now returns
  `Result`) and `transfer` return it when no registry is set — `transfer`
  checks before moving any tokens (fail-safe)
- `registry()` getter now returns `Option<Address>`
- add `test_no_registry_placeholder` covering deploy/mint/attach flow

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

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