Add modular_account auth delegation example - #407
Conversation
Adds a new modular_account example demonstrating the auth delegation APIs introduced in soroban-sdk v27 via CAP-71: - env.custom_account().get_delegated_signers() to read the delegate addresses the user attached to the auth entry. - env.custom_account().delegate_auth(&address) to forward the current __check_auth context to a verified delegate. ModularAccount performs its own ed25519 verification, then forwards the auth context to each registered delegate. The test exercises the full flow via env.set_auths with SorobanAddressCredentialsWithDelegates, covering both an unregistered-delegate rejection and a successful delegation to two registered signers. Claude-Session: https://claude.ai/code/session_01EgjfKqQ1RMvtwQUSx3iDzh
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
soroban-sdk 27.0.0-rc.1 requires rustc 1.91.0, so the example's rust-version must declare 1.91.0 for the CI msrv job to select a compatible toolchain. Claude-Session: https://claude.ai/code/session_01EgjfKqQ1RMvtwQUSx3iDzh
6b02fb1 to
9f42488
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new modular_account example contract intended to demonstrate CAP-71 auth delegation (soroban-sdk v27) and wires it into the top-level examples list.
Changes:
- Add
modular_accountcontract implementingCustomAccountInterfaceand delegating auth to user-supplied delegate signers. - Add a test fixture contract and integration-style test using
env.set_authsto exercise the delegation flow. - Update the repository README to list the new example; add crate build/test scaffolding (Makefile, Cargo.*).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds modular_account to the examples list. |
| modular_account/src/lib.rs | Implements a modular custom account that forwards auth to delegated signers. |
| modular_account/src/test.rs | Adds a delegation flow test using XDR auth entries and a delegate fixture account. |
| modular_account/Cargo.toml | New crate manifest targeting soroban-sdk v27 RC. |
| modular_account/Makefile | Standard build/test targets for the new example. |
| modular_account/Cargo.lock | Dependency lockfile for the new crate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update delegate-auth.mdx to match the canonical example in stellar/soroban-examples#407 rather than the SDK unit test: - type Signature = () — account carries no own signature, relies entirely on delegates - Per-signer persistent storage (Signer(Address) key) instead of a stored Vec<Address> - Constructor takes only signers, no public key - Two-pass __check_auth: validate all delegates first, then forward - Test section updated to match the simpler DelegateAccount fixture (Signature = (), always approves, stores ApprovedContexts) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GgpDVzaPCuCzUVUUyvdAke
* docs: add CAP-71 auth delegation section for soroban-sdk v27 * docs(soroban): add Modular Account example page for CAP-71 auth delegation - Add docs/build/smart-contracts/example-contracts/modular-account.mdx as a standalone example covering auth delegation (soroban-sdk v27+). - Remove the auth delegation section that was added to complex-account.mdx and replace it with a link to the new Modular Account page. - Source contract code is taken from the SDK test in soroban-sdk/src/tests/delegate_auth.rs. Claude-Session: https://claude.ai/code/session_01GgpDVzaPCuCzUVUUyvdAke * docs(soroban): fix CI and align Modular Account page with runnable example - Add the modular-account route to routes.txt (build job). - Remove the extra blank line in complex-account.mdx (mdx-format job). - Point the page at the new runnable modular_account example in soroban-examples, adding a "Run the Example" section and source-file titles on the code blocks. - Correct the DelegateAccount error type to soroban_sdk::Error and note it is defined as a test fixture (a single Wasm exports one __check_auth). - Explain the record_authorized_calls test-observability helper. Claude-Session: https://claude.ai/code/session_01EgjfKqQ1RMvtwQUSx3iDzh * docs(soroban): restructure Delegate Auth example to match soroban-examples PR #407 - Rename modular-account.mdx → delegate-auth.mdx (title: "Delegate Auth") - Rewrite code section to use the canonical lib.rs from soroban-examples PR #407: #![no_std], mod test; split, inline comments matching the example repo - Add Run the Example section pointing to soroban-examples/modular_account - Add Build the Contract section with expected wasm output path - Update complex-account.mdx Further Reading link to new filename Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GgpDVzaPCuCzUVUUyvdAke * regenerate routes.txt for delegate-auth page rename * align delegate-auth docs with example changes * align delegate-auth docs with rewritten example * Update delegate-auth.mdx * docs(soroban): align Delegate Auth example with soroban-examples PR #407 Update delegate-auth.mdx to match the canonical example in stellar/soroban-examples#407 rather than the SDK unit test: - type Signature = () — account carries no own signature, relies entirely on delegates - Per-signer persistent storage (Signer(Address) key) instead of a stored Vec<Address> - Constructor takes only signers, no public key - Two-pass __check_auth: validate all delegates first, then forward - Test section updated to match the simpler DelegateAccount fixture (Signature = (), always approves, stores ApprovedContexts) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GgpDVzaPCuCzUVUUyvdAke * add empty-delegate rejection to delegate-auth example * bump delegate-auth sidebar_position to 18 to avoid collision * use InsufficientDelegates error in delegate-auth example * align delegate-auth docs with merged example tests --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
What
Add a modular_account example demonstrating the CAP-71 auth delegation APIs introduced in soroban-sdk v27. The ModularAccount custom account verifies no signature of its own; in __check_auth it forwards the authorization context to user-selected delegate signers via env.custom_account().get_delegated_signers() and env.custom_account().delegate_auth(&address), after checking that each delegate is one it has registered.
Why
soroban-sdk v27 ships auth delegation and there should be an example.