diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 191b604fa..3757f94f3 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -42,7 +42,7 @@ jobs: - run: rustup update - run: rustup target add ${{ matrix.sys.target }} - if: matrix.sys.target == 'aarch64-unknown-linux-gnu' - run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libudev-dev - name: Setup vars run: | version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stellar-cli") | .version')" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 744dc76b2..ac0f6ca20 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,5 +12,7 @@ jobs: publish: uses: stellar/actions/.github/workflows/rust-publish.yml@main + with: + additional-deb-packages: libudev-dev secrets: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index c539264f5..275cadfbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2983,6 +2983,25 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -3461,6 +3480,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "open" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a877bf6abd716642a53ef1b89fb498923a4afca5c754f9050b4d081c05c4b3" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "openssl" version = "0.10.55" @@ -4733,7 +4763,7 @@ dependencies = [ [[package]] name = "soroban-cli" -version = "21.4.1" +version = "21.5.0" dependencies = [ "assert_cmd", "assert_fs", @@ -4771,6 +4801,7 @@ dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", "num-bigint", + "open", "openssl", "pathdiff", "phf", @@ -4813,6 +4844,7 @@ dependencies = [ "tracing-subscriber", "ulid", "ureq", + "url", "walkdir", "wasm-opt", "wasmparser 0.90.0", @@ -4898,7 +4930,7 @@ dependencies = [ [[package]] name = "soroban-hello" -version = "21.4.1" +version = "21.5.0" [[package]] name = "soroban-ledger-snapshot" @@ -4968,7 +5000,7 @@ dependencies = [ [[package]] name = "soroban-spec-json" -version = "21.4.1" +version = "21.5.0" dependencies = [ "pretty_assertions", "serde", @@ -4998,7 +5030,7 @@ dependencies = [ [[package]] name = "soroban-spec-tools" -version = "21.4.1" +version = "21.5.0" dependencies = [ "base64 0.21.7", "ethnum", @@ -5017,7 +5049,7 @@ dependencies = [ [[package]] name = "soroban-spec-typescript" -version = "21.4.1" +version = "21.5.0" dependencies = [ "base64 0.21.7", "heck 0.4.1", @@ -5038,7 +5070,7 @@ dependencies = [ [[package]] name = "soroban-test" -version = "21.4.1" +version = "21.5.0" dependencies = [ "assert_cmd", "assert_fs", @@ -5110,14 +5142,14 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-cli" -version = "21.4.1" +version = "21.5.0" dependencies = [ "soroban-cli", ] [[package]] name = "stellar-ledger" -version = "21.4.1" +version = "21.5.0" dependencies = [ "async-trait", "bollard", @@ -5423,35 +5455,35 @@ dependencies = [ [[package]] name = "test_custom_account" -version = "21.4.1" +version = "21.5.0" dependencies = [ "soroban-sdk", ] [[package]] name = "test_custom_types" -version = "21.4.1" +version = "21.5.0" dependencies = [ "soroban-sdk", ] [[package]] name = "test_hello_world" -version = "21.4.1" +version = "21.5.0" dependencies = [ "soroban-sdk", ] [[package]] name = "test_swap" -version = "21.4.1" +version = "21.5.0" dependencies = [ "soroban-sdk", ] [[package]] name = "test_token" -version = "21.4.1" +version = "21.5.0" dependencies = [ "soroban-sdk", "soroban-token-sdk", @@ -5459,7 +5491,7 @@ dependencies = [ [[package]] name = "test_udt" -version = "21.4.1" +version = "21.5.0" dependencies = [ "soroban-sdk", ] diff --git a/Cargo.toml b/Cargo.toml index d58335a21..c3108dc78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ default-members = ["cmd/soroban-cli", "cmd/crates/soroban-spec-tools", "cmd/crat exclude = ["cmd/crates/soroban-test/tests/fixtures/hello"] [workspace.package] -version = "21.4.1" +version = "21.5.0" rust-version = "1.79.0" [workspace.dependencies.soroban-env-host] @@ -27,15 +27,15 @@ version = "=21.5.0" version = "=21.5.0" [workspace.dependencies.soroban-spec-json] -version = "=21.4.1" +version = "=21.5.0" path = "./cmd/crates/soroban-spec-json" [workspace.dependencies.soroban-spec-typescript] -version = "21.4.1" +version = "21.5.0" path = "./cmd/crates/soroban-spec-typescript" [workspace.dependencies.soroban-spec-tools] -version = "21.4.1" +version = "21.5.0" path = "./cmd/crates/soroban-spec-tools" [workspace.dependencies.soroban-sdk] @@ -48,7 +48,7 @@ version = "=21.2.0" version = "=21.2.0" [workspace.dependencies.soroban-cli] -version = "=21.4.1" +version = "=21.5.0" path = "cmd/soroban-cli" [workspace.dependencies.soroban-rpc] diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index 99577b5d6..9097637e7 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -118,6 +118,10 @@ 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" * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -139,6 +143,10 @@ Deploy builtin Soroban Asset Contract * `--asset ` — ID of the Stellar classic asset to wrap, e.g. "USDC:G...5" * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -366,6 +374,10 @@ If no keys are specified the contract itself is extended. * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -396,6 +408,10 @@ Deploy a wasm contract * `--salt ` — Custom salt 32-byte salt for the token id * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -459,6 +475,10 @@ Deploy builtin Soroban Asset Contract * `--asset ` — ID of the Stellar classic asset to wrap, e.g. "USDC:G...5" * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -480,6 +500,10 @@ Deploy normal Wasm Contract * `--salt ` — ID of the Soroban contract * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -680,6 +704,10 @@ Install a WASM file to the ledger without creating a contract instance * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -721,6 +749,10 @@ stellar contract invoke ... -- --help * `--is-view` — View the result simulating and do not sign and submit transaction. Deprecated use `--send=no` * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -804,6 +836,10 @@ Print the current value of a contract-data ledger entry * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -843,6 +879,10 @@ If no keys are specificed the contract itself is restored. * `--ttl-ledger-only` — Only print the new Time To Live ledger * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -1315,7 +1355,7 @@ Sign, Simulate, and Send transactions * `simulate` — Simulate a transaction envelope from stdin * `hash` — Calculate the hash of a transaction envelope from stdin -* `sign` — Sign a transaction envolope appending the signature to the envelope +* `sign` — Sign a transaction envelope appending the signature to the envelope * `send` — Send a transaction envelope to the network @@ -1330,6 +1370,10 @@ Simulate a transaction envelope from stdin * `--source-account ` — Account where the final transaction originates from. If no `--sign-with-*` flag is passed, passed key will also be used to sign the transaction. Can be an identity (`--source alice`), a secret key (`--source SC36…`), or a seed phrase (`--source "kite urban…"`) * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint @@ -1356,13 +1400,17 @@ Calculate the hash of a transaction envelope from stdin ## `stellar tx sign` -Sign a transaction envolope appending the signature to the envelope +Sign a transaction envelope appending the signature to the envelope **Usage:** `stellar tx sign [OPTIONS]` ###### **Options:** * `--sign-with-key ` — Sign with a local key. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path +* `--sign-with-lab` — Sign with laboratory +* `--lab-url ` — Lab URL for `sign_with_lab` + + Default value: `https://lab.stellar.org/transaction/cli-sign` * `--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` * `--yes` — If one of `--sign-with-*` flags is provided, don't ask to confirm to sign a transaction * `--rpc-url ` — RPC server endpoint diff --git a/README.md b/README.md index a3632af92..46c6d6816 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Stellar CLI (stellar-cli) ![Apache 2.0 licensed](https://img.shields.io/badge/license-apache%202.0-blue.svg) +[![Crates.io Version](https://img.shields.io/crates/v/stellar-cli?label=version&color=04ac5b)](https://crates.io/crates/stellar-cli) This repo is home to the Stellar CLI, the command-line multi-tool for running and deploying Stellar contracts on the Stellar network. diff --git a/cmd/crates/soroban-test/Cargo.toml b/cmd/crates/soroban-test/Cargo.toml index 643db6ec3..09126adcf 100644 --- a/cmd/crates/soroban-test/Cargo.toml +++ b/cmd/crates/soroban-test/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/soroban-test" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "21.4.1" +version = "21.5.0" edition = "2021" rust-version.workspace = true autobins = false diff --git a/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml index 64d861184..0c3b1512f 100644 --- a/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soroban-hello" -version = "21.4.1" +version = "21.5.0" edition = "2021" publish = false diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml index db31464f2..d4405c512 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_custom_account" -version = "21.4.1" +version = "21.5.0" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml index 61b1cd4c6..17e618805 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_custom_types" -version = "21.4.1" +version = "21.5.0" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml index c2bb8ce80..9ad83fd1c 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_hello_world" -version = "21.4.1" +version = "21.5.0" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/crates/stellar-ledger/Cargo.toml b/cmd/crates/stellar-ledger/Cargo.toml index 24d2e8a74..d8847c7d7 100644 --- a/cmd/crates/stellar-ledger/Cargo.toml +++ b/cmd/crates/stellar-ledger/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stellar-ledger" -description = "" +description = "Handle Stellar signing with Ledger device" homepage = "https://github.com/stellar/soroban-tools" repository = "https://github.com/stellar/soroban-tools" authors = ["Stellar Development Foundation "] diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index d6ef5d90c..95e1c99c0 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/stellar-cli" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "21.4.1" +version = "21.5.0" edition = "2021" rust-version.workspace = true autobins = false @@ -125,7 +125,8 @@ phf = { version = "0.11.2", features = ["macros"] } crossterm = "0.27.0" semver = "1.0.0" glob = "0.3.1" - +open = "5.3.0" +url = "2.5.2" # For hyper-tls [target.'cfg(unix)'.dependencies] openssl = { version = "=0.10.55", features = ["vendored"] } diff --git a/cmd/soroban-cli/src/commands/tx/mod.rs b/cmd/soroban-cli/src/commands/tx/mod.rs index d5d36ead6..a4fb97bb6 100644 --- a/cmd/soroban-cli/src/commands/tx/mod.rs +++ b/cmd/soroban-cli/src/commands/tx/mod.rs @@ -15,7 +15,7 @@ pub enum Cmd { Simulate(simulate::Cmd), /// Calculate the hash of a transaction envelope from stdin Hash(hash::Cmd), - /// Sign a transaction envolope appending the signature to the envelope + /// Sign a transaction envelope appending the signature to the envelope Sign(sign::Cmd), /// Send a transaction envelope to the network Send(send::Cmd), diff --git a/cmd/soroban-cli/src/commands/tx/sign.rs b/cmd/soroban-cli/src/commands/tx/sign.rs index 3f0b90139..ca91eae3f 100644 --- a/cmd/soroban-cli/src/commands/tx/sign.rs +++ b/cmd/soroban-cli/src/commands/tx/sign.rs @@ -1,6 +1,6 @@ use crate::{ config::sign_with, - xdr::{self, Limits, TransactionEnvelope, WriteXdr}, + xdr::{self, Limits, WriteXdr}, }; #[derive(thiserror::Error, Debug)] @@ -24,12 +24,12 @@ impl Cmd { #[allow(clippy::unused_async)] pub async fn run(&self) -> Result<(), Error> { let txn_env = super::xdr::tx_envelope_from_stdin()?; - let envelope = self.sign_tx_env(txn_env).await?; + if self.sign_with.sign_with_lab { + return Ok(self.sign_with.sign_tx_env_with_lab(&txn_env)?); + } + + let envelope = self.sign_with.sign_txn_env(txn_env).await?; println!("{}", envelope.to_xdr_base64(Limits::none())?.trim()); Ok(()) } - - pub async fn sign_tx_env(&self, tx: TransactionEnvelope) -> Result { - Ok(self.sign_with.sign_txn_env(tx).await?) - } } diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index c31580eef..294e0bbc5 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -1,10 +1,13 @@ -use std::path::PathBuf; - use crate::{ signer::{self, sign_txn_env, Stellar}, xdr::TransactionEnvelope, }; use clap::arg; +use crossterm::event::{read, Event, KeyCode}; +use soroban_env_host::xdr::WriteXdr; +use soroban_sdk::xdr::Limits; +use std::path::PathBuf; +use url::Url; use super::{ locator, @@ -26,6 +29,15 @@ pub enum Error { Rpc(#[from] soroban_rpc::Error), #[error("No sign with key provided")] NoSignWithKey, + #[error(transparent)] + Xdr(#[from] soroban_env_host::xdr::Error), + #[error(transparent)] + Url(#[from] url::ParseError), + #[error(transparent)] + Open(#[from] std::io::Error), + #[error("User cancelled signing, perhaps need to remove --check")] + //todo pull this error into a common module instead of duplicating it here + UserCancelledSigning, } #[derive(Debug, clap::Args, Clone, Default)] @@ -38,14 +50,17 @@ pub struct Args { env = "STELLAR_SIGN_WITH_SECRET" )] pub sign_with_key: Option, - /// Sign with labratory + /// Sign with laboratory + #[arg(long, conflicts_with = "sign_with_key", env = "STELLAR_SIGN_WITH_LAB")] + pub sign_with_lab: bool, + /// Lab URL for `sign_with_lab` #[arg( long, conflicts_with = "sign_with_key", - env = "STELLAR_SIGN_WITH_LABRATORY", - hide = true + env = "STELLAR_SIGN_WITH_LAB_URL", + default_value = "https://lab.stellar.org/transaction/cli-sign" )] - pub sign_with_lab: bool, + pub lab_url: String, #[arg(long, conflicts_with = "sign_with_lab")] /// 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` @@ -88,6 +103,34 @@ impl Args { Ok(sign_txn_env(signer, tx_env, &network).await?) } + pub fn sign_tx_env_with_lab(&self, tx_env: &TransactionEnvelope) -> Result<(), Error> { + if !self.yes { + //todo: bring this into a common mod instead of duplicating it here + eprintln!("Press 'y' or 'Y' for yes, any other key for no:"); + match read_key() { + 'y' | 'Y' => { + eprintln!("Signing now..."); + } + _ => return Err(Error::UserCancelledSigning), + }; + } + + let passphrase = self.get_network()?.network_passphrase; + let xdr_buffer = tx_env.to_xdr_base64(Limits::none())?; + + let mut url = Url::parse(&self.lab_url)?; + url.query_pairs_mut() + .append_pair("networkPassphrase", &passphrase) + .append_pair("xdr", &xdr_buffer); + + let txn_sign_url = url.to_string(); + + println!("Opening lab to sign transaction: {}", &txn_sign_url); + open::that(txn_sign_url)?; + + Ok(()) + } + pub fn get_network(&self) -> Result { Ok(self.network.get(&self.locator)?) } @@ -96,3 +139,15 @@ impl Args { Ok(self.locator.config_dir()?) } } + +pub fn read_key() -> char { + loop { + if let Event::Key(key) = read().unwrap() { + match key.code { + KeyCode::Char(c) => return c, + KeyCode::Esc => return '\x1b', // escape key + _ => (), + } + } + } +} diff --git a/cmd/stellar-cli/Cargo.toml b/cmd/stellar-cli/Cargo.toml index 40fa29dcf..2a388b4de 100644 --- a/cmd/stellar-cli/Cargo.toml +++ b/cmd/stellar-cli/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/stellar-cli" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "21.4.1" +version = "21.5.0" edition = "2021" rust-version.workspace = true autobins = false