Skip to content

Commit 2f6b95e

Browse files
ifropcelizabethengelmanjanewangleighmcculloch
authored
Add ledger entry fetch implementation (#2012)
--------- Co-authored-by: elizabethengelman <4752801+elizabethengelman@users.noreply.github.com> Co-authored-by: Jane Wang <jane.wang@stellar.org> Co-authored-by: Leigh <351529+leighmcculloch@users.noreply.github.com>
1 parent 4c6f0d9 commit 2f6b95e

File tree

18 files changed

+1715
-75
lines changed

18 files changed

+1715
-75
lines changed

Cargo.lock

Lines changed: 77 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FULL_HELP_DOCS.md

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4230,9 +4230,251 @@ Fetch ledger information
42304230

42314231
###### **Subcommands:**
42324232

4233+
- `entry` — Work with ledger entries
42334234
- `latest` — Get the latest ledger sequence and information from the network
42344235
- `fetch`
42354236

4237+
## `stellar ledger entry`
4238+
4239+
Work with ledger entries
4240+
4241+
**Usage:** `stellar ledger entry <COMMAND>`
4242+
4243+
###### **Subcommands:**
4244+
4245+
- `fetch` — Fetch ledger entries. This command supports all types of ledger entries supported by the RPC. Read more about the RPC command here: [https://developers.stellar.org/docs/data/apis/rpc/api-reference/methods/getLedgerEntries#types-of-ledgerkeys](https://developers.stellar.org/docs/data/apis/rpc/api-reference/methods/getLedgerEntries#types-of-ledgerkeys)
4246+
4247+
## `stellar ledger entry fetch`
4248+
4249+
Fetch ledger entries. This command supports all types of ledger entries supported by the RPC. Read more about the RPC command here: [https://developers.stellar.org/docs/data/apis/rpc/api-reference/methods/getLedgerEntries#types-of-ledgerkeys](https://developers.stellar.org/docs/data/apis/rpc/api-reference/methods/getLedgerEntries#types-of-ledgerkeys)
4250+
4251+
**Usage:** `stellar ledger entry fetch <COMMAND>`
4252+
4253+
###### **Subcommands:**
4254+
4255+
- `account` — Fetch account entry by public key or alias
4256+
- `contract-data` — Fetch contract ledger entry by address or alias and storage key
4257+
- `claimable-balance` — Fetch a claimable balance ledger entry by id
4258+
- `liquidity-pool` — Fetch a liquidity pool ledger entry by id
4259+
- `contract-code` — Fetch a Contract's WASM bytecode by WASM hash
4260+
- `trustline` — Fetch a trustline by account and asset
4261+
- `data` — Fetch key-value data entries attached to an account (see manageDataOp)
4262+
- `offer` — Fetch an offer by account and offer id
4263+
4264+
## `stellar ledger entry fetch account`
4265+
4266+
Fetch account entry by public key or alias
4267+
4268+
**Usage:** `stellar ledger entry fetch account [OPTIONS] --account <ACCOUNT>`
4269+
4270+
###### **Options:**
4271+
4272+
- `--account <ACCOUNT>` — Account alias or address to lookup
4273+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4274+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4275+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4276+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4277+
- `--global` — ⚠️ Deprecated: global config is always on
4278+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4279+
- `--output <OUTPUT>` — Format of the output
4280+
4281+
Default value: `json`
4282+
4283+
Possible values:
4284+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4285+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4286+
- `xdr`: Original RPC output (containing XDRs)
4287+
4288+
- `--hd-path <HD_PATH>` — If identity is a seed phrase use this hd path, default is 0
4289+
4290+
## `stellar ledger entry fetch contract-data`
4291+
4292+
Fetch contract ledger entry by address or alias and storage key
4293+
4294+
**Usage:** `stellar ledger entry fetch contract-data [OPTIONS] --contract <CONTRACT>`
4295+
4296+
###### **Options:**
4297+
4298+
- `--contract <CONTRACT>` — Contract alias or address to fetch
4299+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4300+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4301+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4302+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4303+
- `--global` — ⚠️ Deprecated: global config is always on
4304+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4305+
- `--output <OUTPUT>` — Format of the output
4306+
4307+
Default value: `json`
4308+
4309+
Possible values:
4310+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4311+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4312+
- `xdr`: Original RPC output (containing XDRs)
4313+
4314+
- `--durability <DURABILITY>` — Storage entry durability
4315+
4316+
Default value: `persistent`
4317+
4318+
Possible values:
4319+
- `persistent`: Persistent
4320+
- `temporary`: Temporary
4321+
4322+
- `--key <KEY>` — Storage key (symbols only)
4323+
- `--key-xdr <KEY_XDR>` — Storage key (base64-encoded XDR)
4324+
4325+
## `stellar ledger entry fetch claimable-balance`
4326+
4327+
Fetch a claimable balance ledger entry by id
4328+
4329+
**Usage:** `stellar ledger entry fetch claimable-balance [OPTIONS]`
4330+
4331+
###### **Options:**
4332+
4333+
- `--id <ID>` — Claimable Balance Ids to fetch an entry for
4334+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4335+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4336+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4337+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4338+
- `--global` — ⚠️ Deprecated: global config is always on
4339+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4340+
- `--output <OUTPUT>` — Format of the output
4341+
4342+
Default value: `json`
4343+
4344+
Possible values:
4345+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4346+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4347+
- `xdr`: Original RPC output (containing XDRs)
4348+
4349+
## `stellar ledger entry fetch liquidity-pool`
4350+
4351+
Fetch a liquidity pool ledger entry by id
4352+
4353+
**Usage:** `stellar ledger entry fetch liquidity-pool [OPTIONS]`
4354+
4355+
###### **Options:**
4356+
4357+
- `--id <ID>` — Liquidity pool ids
4358+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4359+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4360+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4361+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4362+
- `--global` — ⚠️ Deprecated: global config is always on
4363+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4364+
- `--output <OUTPUT>` — Format of the output
4365+
4366+
Default value: `json`
4367+
4368+
Possible values:
4369+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4370+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4371+
- `xdr`: Original RPC output (containing XDRs)
4372+
4373+
## `stellar ledger entry fetch contract-code`
4374+
4375+
Fetch a Contract's WASM bytecode by WASM hash
4376+
4377+
**Usage:** `stellar ledger entry fetch contract-code [OPTIONS]`
4378+
4379+
###### **Options:**
4380+
4381+
- `--wasm-hash <WASM_HASH>` — Get WASM bytecode by hash
4382+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4383+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4384+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4385+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4386+
- `--global` — ⚠️ Deprecated: global config is always on
4387+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4388+
- `--output <OUTPUT>` — Format of the output
4389+
4390+
Default value: `json`
4391+
4392+
Possible values:
4393+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4394+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4395+
- `xdr`: Original RPC output (containing XDRs)
4396+
4397+
## `stellar ledger entry fetch trustline`
4398+
4399+
Fetch a trustline by account and asset
4400+
4401+
**Usage:** `stellar ledger entry fetch trustline [OPTIONS] --account <ACCOUNT> --asset <ASSET>`
4402+
4403+
###### **Options:**
4404+
4405+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4406+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4407+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4408+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4409+
- `--global` — ⚠️ Deprecated: global config is always on
4410+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4411+
- `--output <OUTPUT>` — Format of the output
4412+
4413+
Default value: `json`
4414+
4415+
Possible values:
4416+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4417+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4418+
- `xdr`: Original RPC output (containing XDRs)
4419+
4420+
- `--account <ACCOUNT>` — Account alias or address to lookup
4421+
- `--asset <ASSET>` — Assets to get trustline info for
4422+
- `--hd-path <HD_PATH>` — If account is a seed phrase use this hd path, default is 0
4423+
4424+
## `stellar ledger entry fetch data`
4425+
4426+
Fetch key-value data entries attached to an account (see manageDataOp)
4427+
4428+
**Usage:** `stellar ledger entry fetch data [OPTIONS] --account <ACCOUNT> --data-name <DATA_NAME>`
4429+
4430+
###### **Options:**
4431+
4432+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4433+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4434+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4435+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4436+
- `--global` — ⚠️ Deprecated: global config is always on
4437+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4438+
- `--output <OUTPUT>` — Format of the output
4439+
4440+
Default value: `json`
4441+
4442+
Possible values:
4443+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4444+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4445+
- `xdr`: Original RPC output (containing XDRs)
4446+
4447+
- `--account <ACCOUNT>` — Account alias or address to lookup
4448+
- `--data-name <DATA_NAME>` — Fetch key-value data entries attached to an account (see manageDataOp)
4449+
- `--hd-path <HD_PATH>` — If identity is a seed phrase use this hd path, default is 0
4450+
4451+
## `stellar ledger entry fetch offer`
4452+
4453+
Fetch an offer by account and offer id
4454+
4455+
**Usage:** `stellar ledger entry fetch offer [OPTIONS] --account <ACCOUNT> --offer <OFFER>`
4456+
4457+
###### **Options:**
4458+
4459+
- `--rpc-url <RPC_URL>` — RPC server endpoint
4460+
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
4461+
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
4462+
- `-n`, `--network <NETWORK>` — Name of network to use from config
4463+
- `--global` — ⚠️ Deprecated: global config is always on
4464+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
4465+
- `--output <OUTPUT>` — Format of the output
4466+
4467+
Default value: `json`
4468+
4469+
Possible values:
4470+
- `json`: JSON output of the ledger entry with parsed XDRs (one line, not formatted)
4471+
- `json-formatted`: Formatted (multiline) JSON output of the ledger entry with parsed XDRs
4472+
- `xdr`: Original RPC output (containing XDRs)
4473+
4474+
- `--account <ACCOUNT>` — Account alias or address to lookup
4475+
- `--offer <OFFER>` — ID of an offer made on the Stellar DEX
4476+
- `--hd-path <HD_PATH>` — If identity is a seed phrase use this hd path, default is 0
4477+
42364478
## `stellar ledger latest`
42374479

42384480
Get the latest ledger sequence and information from the network

cmd/crates/soroban-test/tests/it/integration/ledger.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use soroban_rpc::{GetLatestLedgerResponse, GetLedgersResponse};
22
use soroban_test::{AssertExt, TestEnv};
3+
mod entry;
34

45
#[tokio::test]
56
async fn ledger_latest() {

0 commit comments

Comments
 (0)