From 9cc8fcd99b6c2fa2a9c34e43439b3d13ce4ea0e5 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Mon, 14 Oct 2024 02:19:14 -0400 Subject: [PATCH] Feat/add rpc header arg (#1618) --- Cargo.lock | 2 +- FULL_HELP_DOCS.md | 35 ++++ cmd/crates/soroban-test/src/lib.rs | 1 + .../src/commands/contract/deploy/asset.rs | 4 +- .../src/commands/contract/deploy/wasm.rs | 5 +- .../src/commands/contract/extend.rs | 6 +- .../src/commands/contract/fetch.rs | 12 +- .../src/commands/contract/info/shared.rs | 15 +- .../src/commands/contract/install.rs | 25 ++- .../src/commands/contract/invoke.rs | 35 ++-- cmd/soroban-cli/src/commands/contract/read.rs | 4 +- .../src/commands/contract/restore.rs | 6 +- cmd/soroban-cli/src/commands/events.rs | 8 +- cmd/soroban-cli/src/commands/tx/send.rs | 8 +- cmd/soroban-cli/src/commands/tx/simulate.rs | 4 +- cmd/soroban-cli/src/config/mod.rs | 6 +- cmd/soroban-cli/src/config/network.rs | 171 ++++++++++++++++++ cmd/soroban-cli/src/wasm.rs | 19 +- 18 files changed, 292 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71ca2b35f..55ebf62a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5022,7 +5022,7 @@ dependencies = [ [[package]] name = "stellar-rpc-client" version = "21.4.0" -source = "git+https://github.com/stellar/rs-stellar-rpc-client?branch=main#9f748334fffb2762db01b566dee455eea3095c79" +source = "git+https://github.com/stellar/rs-stellar-rpc-client?branch=main#7554d4c87c026313a1f5b3c7ae66a92b5ff7e091" dependencies = [ "clap", "hex", diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index c52636226..41575aea0 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -117,6 +117,7 @@ Get Id of builtin Soroban Asset Contract. Deprecated, use `stellar contract id a * `--asset ` — ID of the Stellar classic asset to wrap, e.g. "USDC:G...5" * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -134,6 +135,7 @@ Deploy builtin Soroban Asset Contract * `--asset ` — ID of the Stellar classic asset to wrap, e.g. "USDC:G...5" * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -180,6 +182,7 @@ Remove contract alias * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config @@ -200,6 +203,7 @@ Add contract alias * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--overwrite` — Overwrite the contract alias if it already exists @@ -222,6 +226,7 @@ Show the contract id associated with a given alias * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config @@ -293,6 +298,7 @@ Generate a TypeScript / JavaScript package * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config @@ -359,6 +365,7 @@ If no keys are specified the contract itself is extended. Temporary * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -387,6 +394,7 @@ Deploy a wasm contract * `--wasm-hash ` — Hash of the already installed/deployed WASM file * `--salt ` — Custom salt 32-byte salt for the token id * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -420,6 +428,7 @@ Fetch a contract's Wasm binary * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config @@ -448,6 +457,7 @@ Deploy builtin Soroban Asset Contract * `--asset ` — ID of the Stellar classic asset to wrap, e.g. "USDC:G...5" * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -465,6 +475,7 @@ Deploy normal Wasm Contract * `--salt ` — ID of the Soroban contract * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -506,6 +517,7 @@ Outputs no data when no data is present in the contract. * `--wasm-hash ` — Wasm hash to get the data for * `--id ` — Contract id to get the data for * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -545,6 +557,7 @@ Outputs no data when no data is present in the contract. * `--wasm-hash ` — Wasm hash to get the data for * `--id ` — Contract id to get the data for * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -584,6 +597,7 @@ Outputs no data when no data is present in the contract. * `--wasm-hash ` — Wasm hash to get the data for * `--id ` — Contract id to get the data for * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -661,6 +675,7 @@ Install a WASM file to the ledger without creating a contract instance ###### **Options:** * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -700,6 +715,7 @@ stellar contract invoke ... -- --help * `--id ` — Contract ID to invoke * `--is-view` — View the result simulating and do not sign and submit transaction. Deprecated use `--send=no` * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -777,6 +793,7 @@ Print the current value of a contract-data ledger entry Temporary * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -812,6 +829,7 @@ If no keys are specificed the contract itself is restored. * `--ledgers-to-extend ` — Number of ledgers to extend the entry * `--ttl-ledger-only` — Only print the new Time To Live ledger * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -872,6 +890,7 @@ Watch the network for contract events * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config @@ -945,6 +964,7 @@ Fund an identity on a test network ###### **Options:** * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 @@ -973,6 +993,7 @@ Generate a new identity with a seed phrase, currently 12 words * `--hd-path ` — When generating a secret key, which `hd_path` should be used from the original `seed_phrase` * `-d`, `--default-seed` — Generate the default seed phrase. Useful for testing. Equivalent to --seed 0000000000000000 * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--fund` — Fund generated key pair @@ -1060,6 +1081,7 @@ Add a new network ###### **Options:** * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — Optional header (e.g. API Key) to include in requests to the RPC * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1272,6 +1294,7 @@ Any invalid contract id passed as `--address` will be ignored. * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--archive-url ` — Archive URL @@ -1303,6 +1326,7 @@ Simulate a transaction envelope from stdin ###### **Options:** * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1321,6 +1345,7 @@ Calculate the hash of a transaction envelope from stdin ###### **Options:** * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config @@ -1338,6 +1363,7 @@ Sign a transaction envelope appending the signature to the envelope * `--hd-path ` — If using a seed phrase to sign, sets which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--sign-with-lab` — Sign with https://lab.stellar.org * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -1354,6 +1380,7 @@ Send a transaction envelope to the network ###### **Options:** * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--global` — Use global config @@ -1396,6 +1423,7 @@ Transfers the XLM balance of an account to another account and removes the sourc * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1422,6 +1450,7 @@ Bumps forward the sequence number of the source account to the given sequence nu * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1448,6 +1477,7 @@ Creates, updates, or deletes a trustline Learn more about trustlines https://dev * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1477,6 +1507,7 @@ Creates and funds a new account with the specified starting balance * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1506,6 +1537,7 @@ Sets, modifies, or deletes a data entry (name/value pair) that is attached to an * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1533,6 +1565,7 @@ Sends an amount in a specific asset to a destination account * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1563,6 +1596,7 @@ Set option for an account such as flags, inflation destination, signers, home do * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail @@ -1604,6 +1638,7 @@ Allows issuing account to configure authorization and trustline flags to an asse * `--build-only` — Build the transaction and only write the base64 xdr to stdout * `--sim-only` — (Deprecated) simulate the transaction and only write the base64 xdr to stdout * `--rpc-url ` — RPC server endpoint +* `--rpc-header ` — RPC Header(s) to include in requests to the RPC provider * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail diff --git a/cmd/crates/soroban-test/src/lib.rs b/cmd/crates/soroban-test/src/lib.rs index 849b78796..2c62578ef 100644 --- a/cmd/crates/soroban-test/src/lib.rs +++ b/cmd/crates/soroban-test/src/lib.rs @@ -235,6 +235,7 @@ impl TestEnv { config::Args { network: network::Args { rpc_url: Some(self.rpc_url.clone()), + rpc_headers: [].to_vec(), network_passphrase: Some(LOCAL_NETWORK_PASSPHRASE.to_string()), network: None, }, diff --git a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs index ad0afce5e..263908521 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs @@ -16,7 +16,7 @@ use crate::{ NetworkRunnable, }, config::{self, data, network}, - rpc::{Client, Error as SorobanRpcError}, + rpc::Error as SorobanRpcError, tx::builder, utils::contract_id_hash_from_asset, }; @@ -88,7 +88,7 @@ impl NetworkRunnable for Cmd { let asset = &self.asset; let network = config.get_network()?; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; client .verify_network_passphrase(Some(&network.network_passphrase)) .await?; diff --git a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs index 03ed3f438..21c685b93 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs @@ -16,8 +16,7 @@ use crate::{ assembled::simulate_and_assemble_transaction, commands::{contract::install, HEADING_RPC}, config::{self, data, locator, network}, - rpc::{self, Client}, - utils, wasm, + rpc, utils, wasm, }; use crate::{ commands::{ @@ -208,7 +207,7 @@ impl NetworkRunnable for Cmd { None => rand::thread_rng().gen::<[u8; 32]>(), }; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; client .verify_network_passphrase(Some(&network.network_passphrase)) .await?; diff --git a/cmd/soroban-cli/src/commands/contract/extend.rs b/cmd/soroban-cli/src/commands/contract/extend.rs index 92b986a22..24aac54c5 100644 --- a/cmd/soroban-cli/src/commands/contract/extend.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -16,9 +16,7 @@ use crate::{ NetworkRunnable, }, config::{self, data, locator, network}, - key, - rpc::{self, Client}, - wasm, Pwd, + key, rpc, wasm, Pwd, }; const MAX_LEDGERS_TO_EXTEND: u32 = 535_679; @@ -132,7 +130,7 @@ impl NetworkRunnable for Cmd { let network = config.get_network()?; tracing::trace!(?network); let keys = self.key.parse_keys(&config.locator, &network)?; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; let source_account = config.source_account()?; let extend_to = self.ledgers_to_extend(); diff --git a/cmd/soroban-cli/src/commands/contract/fetch.rs b/cmd/soroban-cli/src/commands/contract/fetch.rs index fd8070898..2714b1f07 100644 --- a/cmd/soroban-cli/src/commands/contract/fetch.rs +++ b/cmd/soroban-cli/src/commands/contract/fetch.rs @@ -7,12 +7,14 @@ use std::{fmt::Debug, fs, io}; use clap::{arg, command, Parser}; -use crate::commands::{global, NetworkRunnable}; -use crate::config::{ - self, locator, - network::{self, Network}, +use crate::{ + commands::{global, NetworkRunnable}, + config::{ + self, locator, + network::{self, Network}, + }, + wasm, Pwd, }; -use crate::{wasm, Pwd}; #[derive(Parser, Debug, Default, Clone)] #[allow(clippy::struct_excessive_bools)] diff --git a/cmd/soroban-cli/src/commands/contract/info/shared.rs b/cmd/soroban-cli/src/commands/contract/info/shared.rs index 4113f7d5b..0974632ae 100644 --- a/cmd/soroban-cli/src/commands/contract/info/shared.rs +++ b/cmd/soroban-cli/src/commands/contract/info/shared.rs @@ -2,13 +2,13 @@ use std::path::PathBuf; use crate::xdr; use clap::arg; -use soroban_rpc::Client; -use crate::commands::contract::info::shared::Error::InvalidWasmHash; -use crate::config::{locator, network}; -use crate::utils::rpc::get_remote_wasm_from_hash; -use crate::wasm; -use crate::wasm::Error::ContractIsStellarAsset; +use crate::{ + commands::contract::info::shared::Error::InvalidWasmHash, + config::{locator, network}, + utils::rpc::get_remote_wasm_from_hash, + wasm::{self, Error::ContractIsStellarAsset}, +}; #[derive(Debug, clap::Args, Clone, Default)] #[command(group( @@ -71,7 +71,8 @@ pub async fn fetch_wasm(args: &Args) -> Result>, Error> { let hash = xdr::Hash(hash); - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; + client .verify_network_passphrase(Some(&network.network_passphrase)) .await?; diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index d51158ec3..cd6e93b24 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -10,15 +10,20 @@ use crate::xdr::{ use clap::{command, Parser}; use super::restore; -use crate::assembled::simulate_and_assemble_transaction; -use crate::commands::txn_result::{TxnEnvelopeResult, TxnResult}; -use crate::commands::{global, NetworkRunnable}; -use crate::config::{self, data, network}; -use crate::key; -use crate::print::Print; -use crate::rpc::{self, Client}; -use crate::tx::builder::{self, TxExt}; -use crate::{utils, wasm}; +use crate::{ + assembled::simulate_and_assemble_transaction, + commands::{ + global, + txn_result::{TxnEnvelopeResult, TxnResult}, + NetworkRunnable, + }, + config::{self, data, network}, + key, + print::Print, + rpc, + tx::builder::{self, TxExt}, + utils, wasm, +}; const CONTRACT_META_SDK_KEY: &str = "rssdkver"; const PUBLIC_NETWORK_PASSPHRASE: &str = "Public Global Stellar Network ; September 2015"; @@ -103,7 +108,7 @@ impl NetworkRunnable for Cmd { let config = config.unwrap_or(&self.config); let contract = self.wasm.read()?; let network = config.get_network()?; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; client .verify_network_passphrase(Some(&network.network_passphrase)) .await?; diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index e32d5d5a6..5d43f9bfa 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -7,29 +7,30 @@ use std::{fmt::Debug, fs, io}; use clap::{arg, command, Parser, ValueEnum}; -use crate::xdr::{ - self, AccountEntry, AccountEntryExt, AccountId, ContractEvent, ContractEventType, - DiagnosticEvent, HostFunction, InvokeContractArgs, InvokeHostFunctionOp, LedgerEntryData, - Limits, Memo, MuxedAccount, Operation, OperationBody, Preconditions, PublicKey, ScSpecEntry, - SequenceNumber, String32, StringM, Thresholds, Transaction, TransactionExt, Uint256, VecM, - WriteXdr, -}; - use soroban_rpc::{SimulateHostFunctionResult, SimulateTransactionResponse}; use soroban_spec::read::FromWasmError; use super::super::events; use super::arg_parsing; -use crate::assembled::simulate_and_assemble_transaction; -use crate::commands::contract::arg_parsing::{build_host_function_parameters, output_to_string}; -use crate::commands::txn_result::{TxnEnvelopeResult, TxnResult}; -use crate::commands::NetworkRunnable; -use crate::get_spec::{self, get_remote_contract_spec}; -use crate::print; use crate::{ - commands::global, + assembled::simulate_and_assemble_transaction, + commands::{ + contract::arg_parsing::{build_host_function_parameters, output_to_string}, + global, + txn_result::{TxnEnvelopeResult, TxnResult}, + NetworkRunnable, + }, config::{self, data, locator, network}, - rpc, Pwd, + get_spec::{self, get_remote_contract_spec}, + print, rpc, + xdr::{ + self, AccountEntry, AccountEntryExt, AccountId, ContractEvent, ContractEventType, + DiagnosticEvent, HostFunction, InvokeContractArgs, InvokeHostFunctionOp, LedgerEntryData, + Limits, Memo, MuxedAccount, Operation, OperationBody, Preconditions, PublicKey, + ScSpecEntry, SequenceNumber, String32, StringM, Thresholds, Transaction, TransactionExt, + Uint256, VecM, WriteXdr, + }, + Pwd, }; use soroban_spec_tools::contract; @@ -203,7 +204,7 @@ impl NetworkRunnable for Cmd { // For testing wasm arg parsing let _ = build_host_function_parameters(&contract_id, &self.slop, spec_entries, config)?; } - let client = rpc::Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; let account_details = if self.is_view { default_account_entry() } else { diff --git a/cmd/soroban-cli/src/commands/contract/read.rs b/cmd/soroban-cli/src/commands/contract/read.rs index 4e013a1f4..58efc93b7 100644 --- a/cmd/soroban-cli/src/commands/contract/read.rs +++ b/cmd/soroban-cli/src/commands/contract/read.rs @@ -13,7 +13,7 @@ use crate::{ commands::{global, NetworkRunnable}, config::{self, locator}, key, - rpc::{self, Client, FullLedgerEntries, FullLedgerEntry}, + rpc::{self, FullLedgerEntries, FullLedgerEntry}, }; #[derive(Parser, Debug, Clone)] @@ -181,7 +181,7 @@ impl NetworkRunnable for Cmd { let network = self.config.network.get(&locator)?; tracing::trace!(?network); - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; let keys = self.key.parse_keys(&locator, &network)?; Ok(client.get_full_ledger_entries(&keys).await?) } diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index 627fd3eee..87a52a9f6 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -17,9 +17,7 @@ use crate::{ NetworkRunnable, }, config::{self, data, locator, network}, - key, - rpc::{self, Client}, - wasm, Pwd, + key, rpc, wasm, Pwd, }; #[derive(Parser, Debug, Clone)] @@ -134,7 +132,7 @@ impl NetworkRunnable for Cmd { let network = config.get_network()?; tracing::trace!(?network); let entry_keys = self.key.parse_keys(&config.locator, &network)?; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; let source_account = config.source_account()?; // Get the account sequence number diff --git a/cmd/soroban-cli/src/commands/events.rs b/cmd/soroban-cli/src/commands/events.rs index 0c4cfcc0e..a1f5de921 100644 --- a/cmd/soroban-cli/src/commands/events.rs +++ b/cmd/soroban-cli/src/commands/events.rs @@ -4,8 +4,10 @@ use std::io; use crate::xdr::{self, Limits, ReadXdr}; use super::{global, NetworkRunnable}; -use crate::config::{self, locator, network}; -use crate::rpc; +use crate::{ + config::{self, locator, network}, + rpc, +}; #[derive(Parser, Debug, Clone)] #[group(skip)] @@ -207,7 +209,7 @@ impl NetworkRunnable for Cmd { self.network.get(&self.locator) }?; - let client = rpc::Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; client .verify_network_passphrase(Some(&network.network_passphrase)) .await?; diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index c3856114d..22fbc860a 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -1,8 +1,10 @@ use async_trait::async_trait; use soroban_rpc::GetTransactionResponse; -use crate::commands::{global, NetworkRunnable}; -use crate::config::{self, locator, network}; +use crate::{ + commands::{global, NetworkRunnable}, + config::{self, locator, network}, +}; #[derive(thiserror::Error, Debug)] pub enum Error { @@ -52,7 +54,7 @@ impl NetworkRunnable for Cmd { } else { self.network.get(&self.locator)? }; - let client = crate::rpc::Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; let tx_env = super::xdr::tx_envelope_from_stdin()?; Ok(client.send_transaction_polling(&tx_env).await?) } diff --git a/cmd/soroban-cli/src/commands/tx/simulate.rs b/cmd/soroban-cli/src/commands/tx/simulate.rs index 1f534884d..cb2ed7c69 100644 --- a/cmd/soroban-cli/src/commands/tx/simulate.rs +++ b/cmd/soroban-cli/src/commands/tx/simulate.rs @@ -16,6 +16,8 @@ pub enum Error { Rpc(#[from] crate::rpc::Error), #[error(transparent)] Xdr(#[from] xdr::Error), + #[error(transparent)] + Network(#[from] config::network::Error), } /// Command to simulate a transaction envelope via rpc @@ -50,7 +52,7 @@ impl NetworkRunnable for Cmd { ) -> Result { let config = config.unwrap_or(&self.config); let network = config.get_network()?; - let client = crate::rpc::Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; let tx = super::xdr::unwrap_envelope_v1(super::xdr::tx_envelope_from_stdin()?)?; let tx = simulate_and_assemble_transaction(&client, &tx).await?; Ok(tx) diff --git a/cmd/soroban-cli/src/config/mod.rs b/cmd/soroban-cli/src/config/mod.rs index 12f571a50..b961f0f67 100644 --- a/cmd/soroban-cli/src/config/mod.rs +++ b/cmd/soroban-cli/src/config/mod.rs @@ -2,8 +2,6 @@ use address::Address; use clap::{arg, command}; use serde::{Deserialize, Serialize}; -use soroban_rpc::Client; - use crate::{ print::Print, signer::{self, LocalKey, Signer, SignerKind}, @@ -98,7 +96,7 @@ impl Args { ) -> Result, Error> { let network = self.get_network()?; let source_key = self.key_pair()?; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; let latest_ledger = client.get_latest_ledger().await?.sequence; let seq_num = latest_ledger + 60; // ~ 5 min Ok(signer::sign_soroban_authorizations( @@ -116,7 +114,7 @@ impl Args { pub async fn next_sequence_number(&self, account_str: &str) -> Result { let network = self.get_network()?; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; Ok((client.get_account(account_str).await?.seq_num.0 + 1).into()) } } diff --git a/cmd/soroban-cli/src/config/network.rs b/cmd/soroban-cli/src/config/network.rs index b6f6d8c1d..ac7dc04bc 100644 --- a/cmd/soroban-cli/src/config/network.rs +++ b/cmd/soroban-cli/src/config/network.rs @@ -1,7 +1,11 @@ use clap::arg; +use itertools::Itertools; +use jsonrpsee_http_client::HeaderMap; use phf::phf_map; +use reqwest::header::{HeaderName, HeaderValue, InvalidHeaderName, InvalidHeaderValue}; use serde::{Deserialize, Serialize}; use serde_json::Value; +use std::collections::HashMap; use std::str::FromStr; use stellar_strkey::ed25519::PublicKey; use url::Url; @@ -30,6 +34,12 @@ pub enum Error { InvalidUrl(String), #[error("funding failed: {0}")] FundingFailed(String), + #[error(transparent)] + InvalidHeaderName(#[from] InvalidHeaderName), + #[error(transparent)] + InvalidHeaderValue(#[from] InvalidHeaderValue), + #[error("invalid HTTP header: must be in the form 'key:value'")] + InvalidHeader, } #[derive(Debug, clap::Args, Clone, Default)] @@ -44,6 +54,17 @@ pub struct Args { help_heading = HEADING_RPC, )] pub rpc_url: Option, + /// RPC Header(s) to include in requests to the RPC provider + #[arg( + long = "rpc-header", + env = "STELLAR_RPC_HEADERS", + help_heading = HEADING_RPC, + num_args = 1, + action = clap::ArgAction::Append, + value_delimiter = '\n', + value_parser = parse_http_header, + )] + pub rpc_headers: Vec<(String, String)>, /// Network passphrase to sign the transaction sent to the rpc server #[arg( long = "network-passphrase", @@ -76,6 +97,7 @@ impl Args { { Ok(Network { rpc_url, + rpc_headers: self.rpc_headers.clone(), network_passphrase, }) } else { @@ -94,6 +116,17 @@ pub struct Network { help_heading = HEADING_RPC, )] pub rpc_url: String, + /// Optional header (e.g. API Key) to include in requests to the RPC + #[arg( + long = "rpc-header", + env = "STELLAR_RPC_HEADERS", + help_heading = HEADING_RPC, + num_args = 1, + action = clap::ArgAction::Append, + value_delimiter = '\n', + value_parser = parse_http_header, + )] + pub rpc_headers: Vec<(String, String)>, /// Network passphrase to sign the transaction sent to the rpc server #[arg( long, @@ -103,6 +136,21 @@ pub struct Network { pub network_passphrase: String, } +fn parse_http_header(header: &str) -> Result<(String, String), Error> { + let header_components = header.splitn(2, ':'); + + let (key, value) = header_components + .map(str::trim) + .next_tuple() + .ok_or_else(|| Error::InvalidHeader)?; + + // Check that the headers are properly formatted + HeaderName::from_str(key)?; + HeaderValue::from_str(value)?; + + Ok((key.to_string(), value.to_string())) +} + impl Network { pub async fn helper_url(&self, addr: &str) -> Result { tracing::debug!("address {addr:?}"); @@ -160,6 +208,19 @@ impl Network { pub fn rpc_uri(&self) -> Result { Url::from_str(&self.rpc_url).map_err(|_| Error::InvalidUrl(self.rpc_url.to_string())) } + + pub fn rpc_client(&self) -> Result { + let mut header_hash_map = HashMap::new(); + for (header_name, header_value) in &self.rpc_headers { + header_hash_map.insert(header_name.to_string(), header_value.to_string()); + } + + let header_map: HeaderMap = (&header_hash_map) + .try_into() + .map_err(|_| Error::InvalidHeader)?; + + Ok(rpc::Client::new_with_headers(&self.rpc_url, header_map)?) + } } pub static DEFAULTS: phf::Map<&'static str, (&'static str, &'static str)> = phf_map! { @@ -186,6 +247,7 @@ impl From<&(&str, &str)> for Network { fn from(n: &(&str, &str)) -> Self { Self { rpc_url: n.0.to_string(), + rpc_headers: Vec::new(), network_passphrase: n.1.to_string(), } } @@ -197,11 +259,15 @@ mod tests { use mockito::Server; use serde_json::json; + const INVALID_HEADER_NAME: &str = "api key"; + const INVALID_HEADER_VALUE: &str = "cannot include a carriage return \r in the value"; + #[tokio::test] async fn test_helper_url_local_network() { let network = Network { rpc_url: "http://localhost:8000".to_string(), network_passphrase: passphrase::LOCAL.to_string(), + rpc_headers: Vec::new(), }; let result = network @@ -239,6 +305,7 @@ mod tests { let network = Network { rpc_url: server.url(), network_passphrase: passphrase::TESTNET.to_string(), + rpc_headers: Vec::new(), }; let url = network .helper_url("GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI") @@ -269,6 +336,7 @@ mod tests { let network = Network { rpc_url: server.url(), network_passphrase: passphrase::TESTNET.to_string(), + rpc_headers: Vec::new(), }; let url = network .helper_url("GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI") @@ -276,4 +344,107 @@ mod tests { .unwrap(); assert_eq!(url.as_str(), "https://friendbot.stellar.org/secret?api_key=123456&user=demo&addr=GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"); } + + // testing parse_header function + #[tokio::test] + async fn test_parse_http_header_ok() { + let result = parse_http_header("Authorization: Bearer 1234"); + assert!(result.is_ok()); + } + + #[tokio::test] + async fn test_parse_http_header_error_with_invalid_name() { + let invalid_header = format!("{INVALID_HEADER_NAME}: Bearer 1234"); + let result = parse_http_header(&invalid_header); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + format!("invalid HTTP header name") + ); + } + + #[tokio::test] + async fn test_parse_http_header_error_with_invalid_value() { + let invalid_header = format!("Authorization: {INVALID_HEADER_VALUE}"); + let result = parse_http_header(&invalid_header); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + format!("failed to parse header value") + ); + } + + // testing rpc_client function - we're testing this and the parse_http_header function separately because when a user has their network already configured in a toml file, the parse_http_header function is not called and we want to make sure that if the toml file is correctly formatted, the rpc_client function will work as expected + + #[tokio::test] + async fn test_rpc_client_is_ok_when_there_are_no_headers() { + let network = Network { + rpc_url: "http://localhost:1234".to_string(), + network_passphrase: "Network passphrase".to_string(), + rpc_headers: [].to_vec(), + }; + + let result = network.rpc_client(); + assert!(result.is_ok()); + } + + #[tokio::test] + async fn test_rpc_client_is_ok_with_correctly_formatted_headers() { + let network = Network { + rpc_url: "http://localhost:1234".to_string(), + network_passphrase: "Network passphrase".to_string(), + rpc_headers: [("Authorization".to_string(), "Bearer 1234".to_string())].to_vec(), + }; + + let result = network.rpc_client(); + assert!(result.is_ok()); + } + + #[tokio::test] + async fn test_rpc_client_is_ok_with_multiple_headers() { + let network = Network { + rpc_url: "http://localhost:1234".to_string(), + network_passphrase: "Network passphrase".to_string(), + rpc_headers: [ + ("Authorization".to_string(), "Bearer 1234".to_string()), + ("api-key".to_string(), "5678".to_string()), + ] + .to_vec(), + }; + + let result = network.rpc_client(); + assert!(result.is_ok()); + } + + #[tokio::test] + async fn test_rpc_client_returns_err_with_invalid_header_name() { + let network = Network { + rpc_url: "http://localhost:8000".to_string(), + network_passphrase: passphrase::LOCAL.to_string(), + rpc_headers: [(INVALID_HEADER_NAME.to_string(), "Bearer".to_string())].to_vec(), + }; + + let result = network.rpc_client(); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + format!("invalid HTTP header: must be in the form 'key:value'") + ); + } + + #[tokio::test] + async fn test_rpc_client_returns_err_with_invalid_header_value() { + let network = Network { + rpc_url: "http://localhost:8000".to_string(), + network_passphrase: passphrase::LOCAL.to_string(), + rpc_headers: [("api-key".to_string(), INVALID_HEADER_VALUE.to_string())].to_vec(), + }; + + let result = network.rpc_client(); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + format!("invalid HTTP header: must be in the form 'key:value'") + ); + } } diff --git a/cmd/soroban-cli/src/wasm.rs b/cmd/soroban-cli/src/wasm.rs index bc202a4b3..5f0ed3b5c 100644 --- a/cmd/soroban-cli/src/wasm.rs +++ b/cmd/soroban-cli/src/wasm.rs @@ -1,9 +1,6 @@ -use crate::config::locator; -use crate::config::network::Network; use crate::xdr::{self, Hash, LedgerKey, LedgerKeyContractCode}; use clap::arg; use sha2::{Digest, Sha256}; -use soroban_rpc::Client; use soroban_spec_tools::contract::{self, Spec}; use std::{ fs, io, @@ -11,10 +8,14 @@ use std::{ }; use stellar_xdr::curr::{ContractDataEntry, ContractExecutable, ScVal}; -use crate::utils::rpc::get_remote_wasm_from_hash; -use crate::utils::{self}; - -use crate::wasm::Error::{ContractIsStellarAsset, UnexpectedContractToken}; +use crate::{ + config::{ + locator, + network::{Error as NetworkError, Network}, + }, + utils::{self, rpc::get_remote_wasm_from_hash}, + wasm::Error::{ContractIsStellarAsset, UnexpectedContractToken}, +}; #[derive(thiserror::Error, Debug)] pub enum Error { @@ -47,6 +48,8 @@ pub enum Error { a network built-in asset contract that does not have a downloadable code binary" )] ContractIsStellarAsset, + #[error(transparent)] + Network(#[from] NetworkError), } #[derive(Debug, clap::Args, Clone)] @@ -128,7 +131,7 @@ pub async fn fetch_from_contract( .resolve_contract_id(contract_id, &network.network_passphrase)? .0; - let client = Client::new(&network.rpc_url)?; + let client = network.rpc_client()?; client .verify_network_passphrase(Some(&network.network_passphrase)) .await?;