Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for decoding variable length arrays to cli #366

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented May 9, 2024

What

Add support for decoding variable length arrays to the CLI.

Why

Stellar-core returns a variable length array of diagnostic events from it's submission endpoint. It'd be convenient to be able to decode it on the command line with the CLI.

A symmetrical encode op would be ideal to add, but the effort to add it is significantly higher than simply plopping this additional decode format in, so I'm trading off symmetrical feature support for getting something that's a win today and deferring something that to my knowledge we haven't identified a need for yet.

Example

$ curl -vG 'http://localhost:11826/tx' --data-urlencode "blob=AAAAAg..." | jq
{
  "diagnostic_events": "AAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAFom2gAAAAUAAAAAAo+hhQ==",
  "error": "AAAAAABaJz7////vAAAAAA==",
  "status": "ERROR"
}
$ echo -n 'AAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAA8AAAAFZXJyb3IAAAAAAAACAAAAAwAAAAUAAAAQAAAAAQAAAAMAAAAOAAAAU3RyYW5zYWN0aW9uIGBzb3JvYmFuRGF0YS5yZXNvdXJjZUZlZWAgaXMgbG93ZXIgdGhhbiB0aGUgYWN0dWFsIFNvcm9iYW4gcmVzb3VyY2UgZmVlAAAAAAUAAAAAAFom2gAAAAUAAAAAAo+hhQ==' \
    | stellar-xdr d --type DiagnosticEvent --input var-array-base64 | jq
{
  "in_successful_contract_call": false,
  "event": {
    "ext": "v0",
    "contract_id": null,
    "type_": "diagnostic",
    "body": {
      "v0": {
        "topics": [
          {
            "symbol": "error"
          },
          {
            "error": {
              "storage": "exceeded_limit"
            }
          }
        ],
        "data": {
          "vec": [
            {
              "string": "transaction `sorobanData.resourceFee` is lower than the actual Soroban resource fee"
            },
            {
              "u64": 5908186
            },
            {
              "u64": 42967429
            }
          ]
        }
      }
    }
  }
}

Close #323

@leighmcculloch leighmcculloch deleted the cli-var-array branch May 9, 2024 06:32
@leighmcculloch leighmcculloch restored the cli-var-array branch July 12, 2024 05:54
@leighmcculloch
Copy link
Member Author

The main immediate problem being solve by this PR was solved with stellar/stellar-xdr#187, but it's still a useful feature that I'll finish and merge.

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.

Support encoding/decoding of vararrays of any type
1 participant