Skip to content

Commit

Permalink
Support JSON output for XDR structures across all endpoints.
Browse files Browse the repository at this point in the history
Add support for base64-encoded XDR fields to be returned as unpacked JSON.

# Details
The following endpoints have a new, optional request parameter, 
`xdrFormat?: ""|"base64"|"json"`:
  * `getTransaction`
  * `getTransactions`
  * `getLedgerEntry`
  * `getLedgerEntries`
  * `getEvents`
  * `sendTransaction`
  * `simulateTransaction`

When omitted, the behavior does not change and we encode fields as base64.

# New Response Fields
There are new field names for the JSONified versions of XDR structures. Any
field with an `Xdr` suffix (e.g., `resultXdr` in `getTransaction()`) will be
replaced with one that has a `Json` suffix (e.g., `resultJson`) that is a JSON
object verbosely and completely describing the XDR structure.

Certain XDR-encoded fields do not have an `Xdr` suffix, but those also have a
`*Json` equivalent and are listed below:

* _getEvents_: `topic` -> `topicJson`, `value` -> `valueJson`
* _getLedgerEntries_: `key` -> `keyJson`, `xdr` -> `dataJson`
* _getLedgerEntry_: `xdr` -> `entryJson`
* _simulateTransaction_: `transactionData`, `events`, `results.auth`,
  `restorePreamble.transactionData`, `stateChanges.key|before|after` all have a
  `Json` suffix, and `results.xdr` is now `results.returnValueJson`

Closes #124.
  • Loading branch information
Shaptic authored Aug 12, 2024
1 parent 2d6faac commit b88b421
Show file tree
Hide file tree
Showing 35 changed files with 1,763 additions and 465 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
go-version: 1.22
- run: rustup update
- uses: stellar/actions/rust-cache@main
- run: make build-libpreflight
- run: make build-libs

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ jobs:
- name: Build libpreflight
run: |
rustup update
make build-libpreflight
make build-libs
- name: Run golangci-lint
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # version v6.0.1
with:
version: v1.59.1 # this is the golangci-lint version
github-token: ${{ secrets.GITHUB_TOKEN }}
only-new-issues: true




6 changes: 3 additions & 3 deletions .github/workflows/soroban-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: ./.github/actions/setup-go
- run: rustup update
- uses: stellar/actions/rust-cache@main
- run: make build-libpreflight
- run: make build-libs
- run: go test -race -timeout 25m ./cmd/soroban-rpc/...

build:
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
rustup target add ${{ matrix.rust_target }}
rustup update
- uses: stellar/actions/rust-cache@main
- run: make build-libpreflight
- run: make build-libs
env:
CARGO_BUILD_TARGET: ${{ matrix.rust_target }}

Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
- run: rustup update
- uses: stellar/actions/rust-cache@main
- run: make build-libpreflight
- run: make build-libs

- name: Run Soroban RPC Integration Tests
run: |
Expand Down
Loading

0 comments on commit b88b421

Please sign in to comment.