feat(soroban): make registry optional in example-compliant-token#64
Open
alex-predicate wants to merge 1 commit into
Open
feat(soroban): make registry optional in example-compliant-token#64alex-predicate wants to merge 1 commit into
alex-predicate wants to merge 1 commit into
Conversation
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>
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make the
registryoptional inexample-compliant-tokenso 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)__constructorregistryis nowOption<Address>— omit--registryon the CLI to deploy without one.set_registry(registry)to attach (or replace) a registry later.TokenError::RegistryNotConfigured.register_policy(now returnsResult) andtransferreturn it when no registry is set.transferchecks before moving any tokens — fail-safe, never an unchecked transfer.registry()getter now returnsOption<Address>.test_no_registry_placeholdercovering the deploy-without-registry → mint/balance → attach-registry flow.Behavior with no registry
mint/balance/policy_id/ deploy all work. Thepolicy_idstring is stored but inert until a registry is attached andregister_policysucceeds.transferandregister_policyreturnRegistryNotConfigured.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 forwasm32v1-none.Deployed
Deployed to Stellar mainnet as a registry-less placeholder with policy
x-managed-policy-2f0e79710e5254bdf4a978c49907b114:CAYXGYBS2EZROB6MEA6EO7BOP4JDD7R6W3HW3VIFPDYODRUXI4EMXER7🤖 Generated with Claude Code