Improve `stellar tx edit` by including contract spec spec param names in JSON comments
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start from the implementation of stellar tx edit and its XDR-JSON rendering and editor round trip; trace how contract invocation arguments are obtained and how $schema is injected and removed. Determine how contract spec parameter names can be rendered as JSONC comments without breaking parsing, then verify that edited JSONC still converts back to XDR correctly.
Written by the indexing model from the issue text.
Description
I think we should improve stellar tx edit command by including contract spec spec param names in JSON comments, making the output JSONC.
The stellar tx edit command today takes a tx from stdin and renders it as XDR-JSON.
It makes some modification to the XDR-JSON, inserting the $schema key so that IDEs supporting JSON LSP can offer auto completion and documentation validation. The command then removes that key after the editor closes and before processing the JSON back into XDR.
{
"$schema": "https://stellar.org/schema/xdr-json/v23.0.0-rc.2/TransactionEnvelope.json",
"tx": {
"tx": {
// ...
When viewing txs that invoke contracts, details about the invocation are visible, including the contract address and the parameters. For example:
// ...
"invoke_contract": {
"contract_address": "CAG5LRYQ5JVEUI5TEID72EYOVX44TTUJT5BQR2J6J77FH65PCCFAJDDH",
"function_name": "add_liquidity",
"args": [
{ "address": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75" },
{ "address": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA" },
{ "i128": "1000000000" },
{ "i128": "2791736460" },
{ "i128": "1000000000" },
{ "i128": "2791736460" },
{ "u64": "0" }
]
// ...
While this is really easy to read in JSON, the parameters only show the values, and not the parameter names, making it a little hard to reason about what the values mean, and potentially leading to mistakes if a developer edits the tx and sets a value in the wrong field.
Most IDEs support JSONC, a form of JSON that allows for comments to appear within the JSON.
The stellar tx edit command could, in much the same way that it injects the $schema, render JSONC and to inject comments after or before each parameter so that it is unambiguous to the user what each parameter is.
For example:
// ...
"invoke_contract": {
"contract_address": "CAG5LRYQ5JVEUI5TEID72EYOVX44TTUJT5BQR2J6J77FH65PCCFAJDDH",
"function_name": "add_liquidity",
"args": [
{ "address": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75" }, // token_a
{ "address": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA" }, // token_b
{ "i128": "1000000000" }, // amount_a_desired
{ "i128": "2791736460" }, // amount_b_desired
{ "i128": "1000000000" }, // amount_a_min
{ "i128": "2791736460" }, // amount_b_min
{ "u64": "0" } // deadline
]
// ...
- Dominant language
- Rust
- Stars
- 123
- Forks
- 141
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 17
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stellar/stellar-cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stellar/stellar-cli#2384 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stellar/stellar-cli#2347 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
stellar/stellar-cli#2723 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
stellar/stellar-cli#2722 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
stellar/stellar-cli#2703 ·
All issues in stellar/stellar-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100