Skip to content

Add stellar token mint subcommand - #2716

Open
fnando wants to merge 1 commit into
token-allowancefrom
token-mint
Open

Add stellar token mint subcommand#2716
fnando wants to merge 1 commit into
token-allowancefrom
token-mint

Conversation

@fnando

@fnando fnando commented Sep 4, 2026

Copy link
Copy Markdown
Member

What

Adds stellar token mint, a SAC-admin write subcommand that mints new tokens. --admin signs and authorizes the mint (the asset issuer for a Stellar Asset Contract), --to is the recipient, and --amount is the quantity in smallest units. Returns a JSON receipt with the tx hash.

Why

Part of #2620 (typed SEP-41 + SAC client), first of the SAC-admin commands. A thin wrapper over contract invoke reusing args::invoke_by_position and args::not_deployed_error. Unlike transfer/approve, the admin only authorizes — it is not a mint argument — so only [to, amount] are passed positionally.

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:56
@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 mint, a typed SAC-admin command for minting tokens and returning JSON transaction receipts.

Changes:

  • Adds mint validation, authorization, invocation, and receipt handling.
  • Registers the command, JSON errors, help documentation, and integration tests.
  • Native SAC targets must be rejected because they have no administrator.

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 token mint.
cmd/soroban-cli/src/commands/token/mod.rs Registers and dispatches the command.
cmd/soroban-cli/src/commands/token/mint.rs Implements mint behavior and validation.
cmd/soroban-cli/src/cli.rs Enables JSON error formatting.
cmd/crates/soroban-test/tests/it/integration/token/mod.rs Registers mint integration tests.
cmd/crates/soroban-test/tests/it/integration/token/mint.rs Tests mint success and failure cases.
Suppressed comments (1)

cmd/soroban-cli/src/commands/token/mint.rs:152

  • Add an integration test for the muxed-admin guard. This is a behavior explicitly called out in the PR's known limitations, but the new mint tests never execute this branch; the equivalent transfer constraint is protected by transfer_rejects_muxed_source_with_clear_error in cmd/crates/soroban-test/tests/it/integration/token/transfer.rs:221-241. Without matching coverage, this command can regress to the raw invoke-pipeline decode error described in #2645.
        let source_account = config.source_account()?;
        if matches!(source_account, crate::xdr::MuxedAccount::MuxedEd25519(_)) {
            return Err(Error::MuxedSourceNotSupported);

💡 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/mint.rs
@fnando fnando moved this from Backlog (Not Ready) to In Progress 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:45

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 7 out of 7 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

cmd/crates/soroban-test/tests/it/integration/token/mint.rs:115

  • The new muxed-admin rejection path is not exercised by this suite, so a regression would fall back to the raw invoke-pipeline failure described in #2645. The equivalent guards in transfer.rs:222-242 and approve.rs:116-145 have integration tests; add one here using a non-native asset, since native returns through the earlier native-admin guard.
}

cmd/soroban-cli/src/commands/token/mint.rs:155

  • Add an integration test for this documented muxed-admin rejection. The equivalent source-account guards are explicitly covered for transfer and approve, but token/mint.rs currently tests success, native, undeployed SAC, and negative amount only; without an M-address case, a regression can fall back to the raw invoke-pipeline decode failure described in #2645.
        if matches!(source_account, crate::xdr::MuxedAccount::MuxedEd25519(_)) {
            return Err(Error::MuxedSourceNotSupported);

Comment thread cmd/soroban-cli/src/commands/token/args.rs Outdated
Copilot AI review requested due to automatic review settings September 4, 2026 19:10

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.

Suppressed comments (2)

cmd/soroban-cli/src/commands/token/mint.rs:152

  • Add an integration test for this new muxed-admin rejection. The PR explicitly exposes this as a known limitation, and the equivalent guards are covered for transfer and approve (integration/token/transfer.rs:221-241, approve.rs:116-144); without a mint case, a regression to the raw invoke-pipeline decode error would go unnoticed.
        if matches!(source_account, crate::xdr::MuxedAccount::MuxedEd25519(_)) {
            return Err(Error::MuxedSourceNotSupported);

cmd/soroban-cli/src/commands/token/mint.rs:145

  • The current patch still accepts --id native, but the native SAC has no Admin contract data (commands/contract/deploy/asset.rs:234-243), so this invocation cannot mint successfully. Reject native immediately after resolution with a typed native_not_administered error, remove native from this command’s help, and add the corresponding integration test.
        let token = self
            .id
            .resolve(&config.locator, &network.network_passphrase)?;

/// an identity or secret key you control (the asset issuer for a Stellar
/// Asset Contract).
#[arg(long)]
pub admin: UnresolvedMuxedAccount,

@leighmcculloch leighmcculloch Sep 5, 2026

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.

It's surprising that admin is a parameter here. The SAC's mint fn doesn't require it as an input. And I'm not aware of other contracts that provide mint fns requiring it either.

So I think it should be removed, and rely on the standard --source for specifying the signer.

Note that the mint fn is not part of SEP-41, it is a SAC fn, so these token commands are a mix of SEP-41 and SAC fns.

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.

Hmm, I guess --admin makes it more explicit. I'm on the fence, approving as is and defer to you but worth considering.

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants