Skip to content

Comments

Make contract invoke auto-convert values when type is string.#2410

Open
fnando wants to merge 3 commits intomainfrom
contract-invoke-autoconvert-numbers-to-string
Open

Make contract invoke auto-convert values when type is string.#2410
fnando wants to merge 3 commits intomainfrom
contract-invoke-autoconvert-numbers-to-string

Conversation

@fnando
Copy link
Member

@fnando fnando commented Feb 20, 2026

What

Before:

# Before
$ stellar contract invoke --id hello-world --send yes -- hello --to 5
❌ error: Failed to parse argument 'to': invalid type: integer `5`, expected string or map

Context: Expected type string, but received: '5'

After:

$ stellar contract invoke --id hello-world --send yes -- hello --to 5
ℹ️ Simulating transaction…
ℹ️ Signing transaction: 5e9c45b7a4003f110f10c703e4033a890566ba30d15f7a1644294b3abbe02f92
🌎 Sending transaction…
✅ Transaction submitted successfully!
📅 CBO5PAY52ACVZMWQFLJV3L7FD67LFHC6QA6WFRXS2IHRBVMDNLZ6557D - Success - Event: [{"string":"hello"}] = {"string":"5"}
["Hello","5"]

[fnando] in Projects/stellar/hello on  main !? +471 -139  v22.15.0  v1.93.0  25.1.0
$ stellar contract invoke --id hello-world --send yes -- hello --to '"5"'
ℹ️ Simulating transaction…
ℹ️ Signing transaction: f901a379dd7164c00475db8c3ac579645f7a27336180e4cfd289a767b7188b0a
🌎 Sending transaction…
✅ Transaction submitted successfully!
📅 CBO5PAY52ACVZMWQFLJV3L7FD67LFHC6QA6WFRXS2IHRBVMDNLZ6557D - Success - Event: [{"string":"hello"}] = {"string":"5"}
["Hello","5"]

Why

Fix #2334.

Known limitations

N/A

Copilot AI review requested due to automatic review settings February 20, 2026 22:26
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Feb 20, 2026
@fnando fnando self-assigned this Feb 20, 2026
@fnando fnando added bug Something isn't working cli Related to Soroban CLI labels Feb 20, 2026
@fnando fnando moved this from Backlog (Not Ready) to Needs Review in DevX Feb 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves stellar contract invoke argument parsing by coercing non-quoted numeric inputs into String contract parameters, aligning CLI behavior with the contract function’s declared type (fixes #2334).

Changes:

  • Coerce non-string JSON primitives into Value::String when the expected ScType is String.
  • Add unit tests covering String parsing from numeric, boolean, bare-word, and JSON-quoted inputs.

@fnando fnando force-pushed the contract-invoke-autoconvert-numbers-to-string branch from cb2cea5 to fdaa853 Compare February 20, 2026 22:31
@fnando fnando changed the title Auto-convert numbers to strings when type is string while using contract invoke. Auto-convert values to string when type is string while using contract invoke. Feb 20, 2026
@fnando fnando changed the title Auto-convert values to string when type is string while using contract invoke. Make contract invoke auto-convert values when type is string. Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli Related to Soroban CLI

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

contract invoke should auto-convert numbers to strings when parameter type is String

1 participant