feat: initial contracts setup - #45
Conversation
d06d2ad to
ac9645c
Compare
Permissive compliance dispatcher (bind/unbind token, add/remove modules, admin-gated) with no policy modules registered, and an allowlist identity verifier whose verify_identity reverts with error 304 for non-listed accounts. Minimal RWA wiring for M1: the share-token constructor requires both, and mint calls verify_identity. Closes #63
Add the RWAToken surface (mint/burn/forced_transfer/recover/freeze/…), each gated on the manager role and delegating to the audited RWA internals, plus AccessControl and an admin-gated Pausable brake. All contractimpl blocks live in one module: soroban's contracttrait client generation can't be split across files without breaking the test build on the client's private testutils fields. A test asserts the manager mints to an allowlisted holder. Closes #62
Declare compliance, identity-verifier and share-token under [development.contracts] with client generation and constructor args. Account and contract names resolve to deployed addresses, so the share-token constructor receives the compliance and identity-verifier addresses at deploy time. Lets stellar-scaffold deploy the three and generate their TS clients. Closes #66
8f6329b to
fbc9c6a
Compare
Add a //! header and a contractmeta entry (stub=testnet-only; prod=external ERC-3643 ...) to the compliance and identity-verifier stubs, so the deployed wasm advertises they are placeholders, not part of the product.
There was a problem hiding this comment.
Pull request overview
This PR lands the first slice of the reference Soroban contracts and the wiring so CI can build the wasms and generate TS clients. It introduces a two-crate shared library layer (pricing, bindings), an RWA (SEP-57 / ERC-3643-style) share-token with RBAC-gated privileged operations, permissive compliance and identity-verifier testnet stubs, and the deploy/client-generation configuration in environments.toml. It also sets up the local toolchain/dev environment (Nix flake, pre-commit hooks, README development docs) and re-establishes the Cargo workspace with a committed Cargo.lock.
Changes:
- Add the RWA
share-token(ContractType = RWA, 7-decimal metadata,managerrole, compliance + identity wiring) pluscomplianceandidentity-verifierstubs, and sharedpricing/bindingscrates. - Wire deployment: declare the three contracts with constructor args in
environments.tomland populate the workspace/lockfile. - Set up developer tooling: Nix flake devshell,
prek/gitleaks pre-commit hooks, README build instructions, and toolchain/gitignore updates.
Reviewed changes
Copilot reviewed 20 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Re-establishes the workspace (crates/*, contracts/*), edition 2021, pinned deps, release profile. |
Cargo.lock |
Newly committed generated lockfile for the workspace. |
rust-toolchain.toml |
Switches channel to stable and adds components — removes the version pin (flagged). |
flake.nix / flake.lock |
Nix devshell pinning stellar-cli 27.0.0 plus Rust/TLA+/hook tooling. |
README.md |
Adds a Development section (Nix and non-Nix toolchain setup). |
.pre-commit-config.yaml |
Adds cargo-fmt and gitleaks hooks via prek. |
.gitignore |
Adds .stellar, TLA+ artifacts; consolidates agent-tooling entries. |
environments.toml |
Declares compliance, identity_verifier, share_token with constructor args. |
crates/pricing/* |
Deposit/redeem conversion math with par/round-trip/overflow tests. |
crates/bindings/* |
Cross-contract OracleFeed/Share client trait bindings. |
contracts/share-token/* |
RWA share token: constructor wiring, RBAC-gated RWA surface, Pausable, tests (Spanish comments flagged). |
contracts/compliance/* |
Permissive compliance dispatcher stub with token binder. |
contracts/identity-verifier/* |
Allowlist identity-verifier stub gating verify_identity. |
contracts/.gitkeep |
Placeholder removed/retained for the contracts directory. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -1,3 +1,4 @@ | |||
| [toolchain] | |||
| channel = "1.93.0" | |||
| channel = "stable" | |||
| compliance.bind_token(&token.address, &admin); // el token debe estar bound | ||
| identity.allow(&receiver, &true, &admin); // allowlist del receptor | ||
|
|
||
| token.mint(&receiver, &100, &manager); // ← no existe todavía → ROJO |
Restore an explicit rust toolchain pin (1.97.0); the PR had loosened it to stable, which breaks reproducibility and risks the experimental spec_shaking_v2 feature. In the mint test, translate the one load-bearing comment to English and drop two slop/stale ones.
Summary
First slice of the reference contracts, plus the deploy wiring so CI can
build the wasms and generate the TS clients.
What's here
pricing(deposit/redeem conversion,round-trip and overflow invariants) and cross-contract
bindings.metadata, admin, the
managerrole and the two compliance components.The privileged surface is RBAC-gated on
managerand delegates to theaudited RWA internals;
Pausableis the token's own admin brake.an allowlist verifier: the minimal RWA wiring M1 needs.
environments.tomldeclares the threecontracts with constructor args, so stellar-scaffold deploys them and
emits TS clients.
Design notes
ContractType = RWA; theasync vault lands in Port the async vault #65. A contract can pick only one ContractType, so
the split is forced, not stylistic.
client generation can't be split across files —
cargo testbreaks onthe generated client's private testutils fields.
does not, so a de-listed holder can always be redeemed out.
Verification
cargo test: share-token 2/2, pricing 4/4.stellar contract build: three wasms (share_token 35 KB).runs in CI (needs the local-network container).
Closes #62, #63, #66.