Skip to content

Add stellar token approve subcommand - #2714

Open
fnando wants to merge 2 commits into
token-decimalsfrom
token-approve
Open

Add stellar token approve subcommand#2714
fnando wants to merge 2 commits into
token-decimalsfrom
token-approve

Conversation

@fnando

@fnando fnando commented Sep 4, 2026

Copy link
Copy Markdown
Member

What

Adds stellar token approve, a write subcommand that sets a SEP-41 allowance. --from grants and authorizes the allowance, --spender is the delegate, --amount is the allowance in smallest units, and --expiration-ledger is the ledger after which it expires. Returns a JSON receipt with the tx hash.

Why

Part of #2620 (typed SEP-41 + SAC client), first of the write commands after the read-metadata group. A thin wrapper over contract invoke reusing args::invoke_by_position and args::not_deployed_error, mirroring transfer. Landing approve before allowance lets the allowance command's tests do a clean approve→read round-trip.

Known limitations

Muxed (M…) source accounts are rejected with a clear error (same constraint as transfer, see #2645).

Copilot AI balanced review requested due to automatic review settings September 4, 2026 17:09
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Sep 4, 2026

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 stellar token approve for setting SEP-41 allowances and returning JSON transaction receipts.

Changes:

  • Implements approval invocation, validation, signing, and structured errors.
  • Registers command routing and updates help documentation.
  • Adds integration coverage for approval behavior and failures.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
FULL_HELP_DOCS.md Documents the command and options.
cmd/soroban-cli/src/commands/token/mod.rs Registers and dispatches approve.
cmd/soroban-cli/src/commands/token/approve.rs Implements approvals; muxed-source coverage is missing and its guard explanation is inaccurate.
cmd/soroban-cli/src/cli.rs Enables JSON error formatting.
cmd/crates/soroban-test/tests/it/integration/token/mod.rs Registers approval integration tests.
cmd/crates/soroban-test/tests/it/integration/token/approve.rs Tests approval behavior and key failures.
Suppressed comments (1)

cmd/soroban-cli/src/commands/token/approve.rs:158

  • This explanation contradicts #2645: positional parsing and simulation accept the muxed address; the failure occurs later when the sequence-number lookup passes the M… strkey to a G-only account parser. Please keep the guard but describe the actual failure point so future work on #2645 does not remove or relocate it for the wrong reason.
        // The invoke pipeline can't source a transaction from a muxed account
        // yet (see #2645), and a muxed strkey in the `from` arg is rejected
        // mid-simulation with an opaque host error; reject it up front with a
        // clear message instead.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/soroban-cli/src/commands/token/approve.rs
@fnando fnando moved this from Backlog (Not Ready) to Needs Review in DevX Sep 4, 2026
@fnando fnando self-assigned this Sep 4, 2026
Copilot AI review requested due to automatic review settings September 4, 2026 18:35

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

#[arg(long, value_parser = parse_nonneg_i128)]
pub amount: i128,

/// Ledger sequence after which the allowance expires. Must be at or beyond

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The CLI validates --amount is non-negative (via parse_nonneg_i128, see the Error::Args/args::Error layer) to avoid an opaque HostError, but this doc comment states the same trap condition applies to --expiration-ledger — a positive amount with an expiration ledger already in the past — yet there's no equivalent validation.


/// The machine-readable receipt of a token approval.
#[derive(Debug, serde::Serialize)]
struct Receipt {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fwiw receipt is not a common term in the Stellar vocab. I'd call this Result rather than introduce a new concept. It's not a blocker though, as it appears to just be a term being used internal to the cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

3 participants