Skip to content

Add modular_account auth delegation example - #407

Merged
leighmcculloch merged 16 commits into
mainfrom
claude/pensive-noether-mifqn1
Jul 16, 2026
Merged

leighmcculloch merged 16 commits into
mainfrom
claude/pensive-noether-mifqn1

Conversation

@leighmcculloch

@leighmcculloch leighmcculloch commented Jun 17, 2026

Copy link
Copy Markdown
Member

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.

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
@socket-security

socket-security Bot commented Jun 17, 2026

Copy link
Copy Markdown

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.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: cargo libc is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?cargo/stellar-xdr@27.0.0cargo/soroban-sdk@27.0.0cargo/soroban-ledger-snapshot@27.0.0cargo/ed25519-dalek@1.0.1cargo/sha2@0.10.9cargo/rand@0.8.5cargo/proptest@1.5.0cargo/ark-std@0.5.0cargo/alloy-sol-types@1.3.1cargo/libc@0.2.186

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/libc@0.2.186. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: cargo zerocopy is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?cargo/soroban-sdk@27.0.0cargo/soroban-ledger-snapshot@27.0.0cargo/rand@0.8.5cargo/rand@0.7.3cargo/ark-ec@0.4.2cargo/proptest@1.5.0cargo/ark-ec@0.5.0cargo/ark-std@0.5.0cargo/alloy-sol-types@1.3.1cargo/zerocopy@0.8.52

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/zerocopy@0.8.52. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

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
@leighmcculloch
leighmcculloch force-pushed the claude/pensive-noether-mifqn1 branch from 6b02fb1 to 9f42488 Compare June 17, 2026 21:48
@leighmcculloch
leighmcculloch marked this pull request as ready for review June 18, 2026 04:40
Copilot AI review requested due to automatic review settings June 18, 2026 04:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_account contract implementing CustomAccountInterface and delegating auth to user-supplied delegate signers.
  • Add a test fixture contract and integration-style test using env.set_auths to 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.

Comment thread modular_account/src/lib.rs
Comment thread modular_account/src/lib.rs
Comment thread modular_account/src/lib.rs
Comment thread modular_account/src/test.rs
Comment thread modular_account/Cargo.toml
leighmcculloch added a commit to stellar/stellar-docs that referenced this pull request Jun 18, 2026


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
@leighmcculloch
leighmcculloch requested a review from dmkozh July 15, 2026 02:12
@leighmcculloch
leighmcculloch enabled auto-merge (squash) July 15, 2026 02:43
Comment thread modular_account/src/lib.rs Outdated
@leighmcculloch
leighmcculloch merged commit 14c069c into main Jul 16, 2026
134 checks passed
@leighmcculloch
leighmcculloch deleted the claude/pensive-noether-mifqn1 branch July 16, 2026 07:21
ElliotFriend pushed a commit to stellar/stellar-docs that referenced this pull request Jul 16, 2026
* 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>
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.

3 participants