From 17f0fa582ab2a00bd4551835a9f05ac7721d1745 Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Tue, 10 Sep 2024 10:40:45 -0700 Subject: [PATCH 01/18] Add libudev-dev as dep. (#1434) Co-authored-by: Willem Wyndham --- .github/workflows/binaries.yml | 2 +- .github/workflows/publish.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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 }} From b26394c71d96730e228b1293578eab1eeacea8b1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 09:24:42 -0700 Subject: [PATCH 02/18] Bump version to 21.5.0 (#1596) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- Cargo.lock | 28 +++++++++---------- Cargo.toml | 10 +++---- cmd/crates/soroban-test/Cargo.toml | 2 +- .../tests/fixtures/hello/Cargo.toml | 2 +- .../test-wasms/custom_account/Cargo.toml | 2 +- .../test-wasms/custom_type/Cargo.toml | 2 +- .../test-wasms/hello_world/Cargo.toml | 2 +- cmd/soroban-cli/Cargo.toml | 2 +- cmd/stellar-cli/Cargo.toml | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ae6408d09..788fc8e59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4675,7 +4675,7 @@ dependencies = [ [[package]] name = "soroban-cli" -version = "21.4.1" +version = "21.5.0" dependencies = [ "assert_cmd", "assert_fs", @@ -4839,7 +4839,7 @@ dependencies = [ [[package]] name = "soroban-hello" -version = "21.4.1" +version = "21.5.0" [[package]] name = "soroban-ledger-snapshot" @@ -4909,7 +4909,7 @@ dependencies = [ [[package]] name = "soroban-spec-json" -version = "21.4.1" +version = "21.5.0" dependencies = [ "pretty_assertions", "serde", @@ -4939,7 +4939,7 @@ dependencies = [ [[package]] name = "soroban-spec-tools" -version = "21.4.1" +version = "21.5.0" dependencies = [ "base64 0.21.7", "ethnum", @@ -4958,7 +4958,7 @@ dependencies = [ [[package]] name = "soroban-spec-typescript" -version = "21.4.1" +version = "21.5.0" dependencies = [ "base64 0.21.7", "heck 0.4.1", @@ -4979,7 +4979,7 @@ dependencies = [ [[package]] name = "soroban-test" -version = "21.4.1" +version = "21.5.0" dependencies = [ "assert_cmd", "assert_fs", @@ -5051,14 +5051,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", @@ -5364,35 +5364,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", @@ -5400,7 +5400,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/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/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index d9ced8aa2..1f381eb42 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 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 From 7f83ec04492054246c3832d1c2fa6c830f75a92d Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Wed, 11 Sep 2024 10:04:32 -0700 Subject: [PATCH 03/18] Add `stellar-ledger` crate description. (#1597) --- cmd/crates/stellar-ledger/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 "] From c79804502bde84364c589b353293596cd06a7448 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:11:42 -0400 Subject: [PATCH 04/18] Fix typo --- cmd/soroban-cli/src/commands/tx/mod.rs | 2 +- cmd/soroban-cli/src/config/sign_with.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index c31580eef..c78e32a59 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -38,11 +38,11 @@ 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_LABRATORY", + env = "STELLAR_SIGN_WITH_LABORATORY", hide = true )] pub sign_with_lab: bool, From 7f4b5860214209ab697a4123e4c27e7be28bde41 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:25:52 -0400 Subject: [PATCH 05/18] Start to add sign with lab functionality --- cmd/soroban-cli/src/commands/tx/sign.rs | 12 ++++++++++-- cmd/soroban-cli/src/config/sign_with.rs | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/sign.rs b/cmd/soroban-cli/src/commands/tx/sign.rs index 3f0b90139..4826909ea 100644 --- a/cmd/soroban-cli/src/commands/tx/sign.rs +++ b/cmd/soroban-cli/src/commands/tx/sign.rs @@ -24,12 +24,20 @@ 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?; - println!("{}", envelope.to_xdr_base64(Limits::none())?.trim()); + if self.sign_with.sign_with_lab { + return self.sign_tx_env_with_lab(txn_env).await; + } else { + let envelope = self.sign_tx_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?) } + + pub async fn sign_tx_env_with_lab(&self, tx: TransactionEnvelope) -> Result<(), Error> { + Ok(self.sign_with.sign_tx_env_with_lab().await?) + } } diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index c78e32a59..084c772a8 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -88,6 +88,12 @@ impl Args { Ok(sign_txn_env(signer, tx_env, &network).await?) } + pub async fn sign_tx_env_with_lab(&self) -> Result<(), Error> { + let network = self.get_network()?; + println!("signing with lab..."); + Ok(()) + } + pub fn get_network(&self) -> Result { Ok(self.network.get(&self.locator)?) } From 79e255b92b03621c75d61218864d85b13e3fe2e5 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:41:14 -0400 Subject: [PATCH 06/18] Open Lab on sign_with_lab --- Cargo.lock | 31 +++++++++++++++++++++++++ cmd/soroban-cli/Cargo.toml | 2 +- cmd/soroban-cli/src/commands/tx/sign.rs | 2 +- cmd/soroban-cli/src/config/sign_with.rs | 13 +++++++++-- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c539264f5..7fed48cf2 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" @@ -4771,6 +4801,7 @@ dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", "num-bigint", + "open", "openssl", "pathdiff", "phf", diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index d6ef5d90c..fb5705412 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -125,7 +125,7 @@ phf = { version = "0.11.2", features = ["macros"] } crossterm = "0.27.0" semver = "1.0.0" glob = "0.3.1" - +open = "5.3.0" # For hyper-tls [target.'cfg(unix)'.dependencies] openssl = { version = "=0.10.55", features = ["vendored"] } diff --git a/cmd/soroban-cli/src/commands/tx/sign.rs b/cmd/soroban-cli/src/commands/tx/sign.rs index 4826909ea..c5e18a85d 100644 --- a/cmd/soroban-cli/src/commands/tx/sign.rs +++ b/cmd/soroban-cli/src/commands/tx/sign.rs @@ -38,6 +38,6 @@ impl Cmd { } pub async fn sign_tx_env_with_lab(&self, tx: TransactionEnvelope) -> Result<(), Error> { - Ok(self.sign_with.sign_tx_env_with_lab().await?) + Ok(self.sign_with.sign_tx_env_with_lab(tx).await?) } } diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 084c772a8..484adaa92 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -88,9 +88,18 @@ impl Args { Ok(sign_txn_env(signer, tx_env, &network).await?) } - pub async fn sign_tx_env_with_lab(&self) -> Result<(), Error> { + pub async fn sign_tx_env_with_lab(&self, tx_env: TransactionEnvelope) -> Result<(), Error> { let network = self.get_network()?; - println!("signing with lab..."); + let passphrase = network.network_passphrase; + // fixme: this is not the correct way to encode url query strings, but this is how the version of zustand-querystring in lab is expecting it. zustand-querystring recently released an update, that _may_ fix this. + let encoded_passphrase = passphrase.replace(" ", "%20").replace(";", "/;"); + let xdr = "AAAAAgAAAAC3g0zwH+GTFKaencL9HEX62fg4A2jjirzHdBH9cPvjCQAAAGQAEb7FAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAALeDTPAf4ZMUpp6dwv0cRfrZ+DgDaOOKvMd0Ef1w++MJAAAAAAAAAADcOHnq5sGLOngOCEMyLqqn5CvFV2HGbOSjJAIzhqBdkAAAAAA7msoAAAAAAAAAAAFw++MJAAAAQGVOS50rimyFFTxO0loZZ24n3FPSttnVHqvQQNZWkSgeHYywX6IGUqR6mBDCi7VQwgfNiACpLK7eySx2//SAjYw0="; + let txn_sign_url = format!( + "http://localhost:3000/transaction/sign?$=network$&passphrase={encoded_passphrase};&transaction$sign$activeView=overview&importXdr={xdr}" + ); + + open::that(txn_sign_url).unwrap(); //todo: handle unwrap + Ok(()) } From d35c9bc1f655c54442d5691c946e3ada30f570f7 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:51:09 -0400 Subject: [PATCH 07/18] Properly encode the url query string --- Cargo.lock | 1 + cmd/soroban-cli/Cargo.toml | 1 + cmd/soroban-cli/src/config/sign_with.rs | 17 +++++++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fed48cf2..fd397ddbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4844,6 +4844,7 @@ dependencies = [ "tracing-subscriber", "ulid", "ureq", + "url", "walkdir", "wasm-opt", "wasmparser 0.90.0", diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index fb5705412..ff31f3bb0 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -126,6 +126,7 @@ 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/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 484adaa92..f3093ee25 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -5,6 +5,7 @@ use crate::{ xdr::TransactionEnvelope, }; use clap::arg; +use url::Url; use super::{ locator, @@ -91,13 +92,17 @@ impl Args { pub async fn sign_tx_env_with_lab(&self, tx_env: TransactionEnvelope) -> Result<(), Error> { let network = self.get_network()?; let passphrase = network.network_passphrase; - // fixme: this is not the correct way to encode url query strings, but this is how the version of zustand-querystring in lab is expecting it. zustand-querystring recently released an update, that _may_ fix this. - let encoded_passphrase = passphrase.replace(" ", "%20").replace(";", "/;"); - let xdr = "AAAAAgAAAAC3g0zwH+GTFKaencL9HEX62fg4A2jjirzHdBH9cPvjCQAAAGQAEb7FAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAALeDTPAf4ZMUpp6dwv0cRfrZ+DgDaOOKvMd0Ef1w++MJAAAAAAAAAADcOHnq5sGLOngOCEMyLqqn5CvFV2HGbOSjJAIzhqBdkAAAAAA7msoAAAAAAAAAAAFw++MJAAAAQGVOS50rimyFFTxO0loZZ24n3FPSttnVHqvQQNZWkSgeHYywX6IGUqR6mBDCi7VQwgfNiACpLK7eySx2//SAjYw0="; - let txn_sign_url = format!( - "http://localhost:3000/transaction/sign?$=network$&passphrase={encoded_passphrase};&transaction$sign$activeView=overview&importXdr={xdr}" - ); + let xdr = "AAAAAgAAAAC3g0zwH+GTFKaencL9HEX62fg4A2jjirzHdBH9cPvjCQAAAGQAEb7FAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAALeDTPAf4ZMUpp6dwv0cRfrZ+DgDaOOKvMd0Ef1w++MJAAAAAAAAAADcOHnq5sGLOngOCEMyLqqn5CvFV2HGbOSjJAIzhqBdkAAAAAA7msoAAAAAAAAAAAFw++MJAAAAQGVOS50rimyFFTxO0loZZ24n3FPSttnVHqvQQNZWkSgeHYywX6IGUqR6mBDCi7VQwgfNiACpLK7eySx2/SAjYw0="; + let base_url = "http://localhost:3000/transaction/sign?"; + let mut url = Url::parse(base_url).unwrap(); + url.query_pairs_mut() + .append_pair("networkPassphrase", &passphrase) + .append_pair("xdr", xdr); + + let txn_sign_url = url.to_string(); + + println!("Opening lab to sign transaction: {}", &txn_sign_url); open::that(txn_sign_url).unwrap(); //todo: handle unwrap Ok(()) From 79ff339391ea787348339ee35a3a686f39c87d04 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:10:32 -0400 Subject: [PATCH 08/18] Actually use the tx env passed in --- cmd/soroban-cli/src/config/sign_with.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index f3093ee25..97ad3f2f2 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -5,6 +5,8 @@ use crate::{ xdr::TransactionEnvelope, }; use clap::arg; +use soroban_env_host::xdr::WriteXdr; +use soroban_sdk::xdr::{self, Limits}; use url::Url; use super::{ @@ -92,13 +94,15 @@ impl Args { pub async fn sign_tx_env_with_lab(&self, tx_env: TransactionEnvelope) -> Result<(), Error> { let network = self.get_network()?; let passphrase = network.network_passphrase; - let xdr = "AAAAAgAAAAC3g0zwH+GTFKaencL9HEX62fg4A2jjirzHdBH9cPvjCQAAAGQAEb7FAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAALeDTPAf4ZMUpp6dwv0cRfrZ+DgDaOOKvMd0Ef1w++MJAAAAAAAAAADcOHnq5sGLOngOCEMyLqqn5CvFV2HGbOSjJAIzhqBdkAAAAAA7msoAAAAAAAAAAAFw++MJAAAAQGVOS50rimyFFTxO0loZZ24n3FPSttnVHqvQQNZWkSgeHYywX6IGUqR6mBDCi7VQwgfNiACpLK7eySx2/SAjYw0="; + let xdr_buffer = tx_env + .to_xdr_base64(Limits::none()) + .expect("Failed to write XDR"); let base_url = "http://localhost:3000/transaction/sign?"; let mut url = Url::parse(base_url).unwrap(); url.query_pairs_mut() .append_pair("networkPassphrase", &passphrase) - .append_pair("xdr", xdr); + .append_pair("xdr", &xdr_buffer); let txn_sign_url = url.to_string(); From f57cca64391cf1eb7b9b7154f90e2e02ee427c32 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:08:06 -0400 Subject: [PATCH 09/18] Add lab_url arg --- cmd/soroban-cli/src/config/sign_with.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 97ad3f2f2..7d2ed071f 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -49,6 +49,14 @@ pub struct Args { hide = true )] pub sign_with_lab: bool, + /// Lab URL for sign_with_lab + #[arg( + long, + env = "STELLAR_SIGN_WITH_LAB_URL", + hide = true, + default_value = "https://lab.stellar.org/transaction/sign?" + )] + 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` @@ -98,8 +106,7 @@ impl Args { .to_xdr_base64(Limits::none()) .expect("Failed to write XDR"); - let base_url = "http://localhost:3000/transaction/sign?"; - let mut url = Url::parse(base_url).unwrap(); + let mut url = Url::parse(&self.lab_url).unwrap(); url.query_pairs_mut() .append_pair("networkPassphrase", &passphrase) .append_pair("xdr", &xdr_buffer); From a122be309e8855f2aa6fa0ca2d1c25c357a06704 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:10:50 -0400 Subject: [PATCH 10/18] Handle unwraps --- cmd/soroban-cli/src/config/sign_with.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 7d2ed071f..305c9bd38 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -6,7 +6,7 @@ use crate::{ }; use clap::arg; use soroban_env_host::xdr::WriteXdr; -use soroban_sdk::xdr::{self, Limits}; +use soroban_sdk::xdr::Limits; use url::Url; use super::{ @@ -29,6 +29,12 @@ 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), } #[derive(Debug, clap::Args, Clone, Default)] @@ -100,13 +106,10 @@ impl Args { } pub async fn sign_tx_env_with_lab(&self, tx_env: TransactionEnvelope) -> Result<(), Error> { - let network = self.get_network()?; - let passphrase = network.network_passphrase; - let xdr_buffer = tx_env - .to_xdr_base64(Limits::none()) - .expect("Failed to write XDR"); + 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).unwrap(); + let mut url = Url::parse(&self.lab_url)?; url.query_pairs_mut() .append_pair("networkPassphrase", &passphrase) .append_pair("xdr", &xdr_buffer); @@ -114,7 +117,7 @@ impl Args { let txn_sign_url = url.to_string(); println!("Opening lab to sign transaction: {}", &txn_sign_url); - open::that(txn_sign_url).unwrap(); //todo: handle unwrap + open::that(txn_sign_url)?; Ok(()) } From 6d4ad614b3616ac014de6ee19094c3aa27081f5c Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:35:01 -0400 Subject: [PATCH 11/18] Refactor/cleanup --- cmd/soroban-cli/src/commands/tx/sign.rs | 18 +++++------------- cmd/soroban-cli/src/config/sign_with.rs | 4 ++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/sign.rs b/cmd/soroban-cli/src/commands/tx/sign.rs index c5e18a85d..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)] @@ -25,19 +25,11 @@ impl Cmd { pub async fn run(&self) -> Result<(), Error> { let txn_env = super::xdr::tx_envelope_from_stdin()?; if self.sign_with.sign_with_lab { - return self.sign_tx_env_with_lab(txn_env).await; - } else { - let envelope = self.sign_tx_env(txn_env).await?; - println!("{}", envelope.to_xdr_base64(Limits::none())?.trim()); + return Ok(self.sign_with.sign_tx_env_with_lab(&txn_env)?); } - Ok(()) - } - pub async fn sign_tx_env(&self, tx: TransactionEnvelope) -> Result { - Ok(self.sign_with.sign_txn_env(tx).await?) - } - - pub async fn sign_tx_env_with_lab(&self, tx: TransactionEnvelope) -> Result<(), Error> { - Ok(self.sign_with.sign_tx_env_with_lab(tx).await?) + let envelope = self.sign_with.sign_txn_env(txn_env).await?; + println!("{}", envelope.to_xdr_base64(Limits::none())?.trim()); + Ok(()) } } diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 305c9bd38..b5e7dc0f0 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -55,7 +55,7 @@ pub struct Args { hide = true )] pub sign_with_lab: bool, - /// Lab URL for sign_with_lab + /// Lab URL for `sign_with_lab` #[arg( long, env = "STELLAR_SIGN_WITH_LAB_URL", @@ -105,7 +105,7 @@ impl Args { Ok(sign_txn_env(signer, tx_env, &network).await?) } - pub async fn sign_tx_env_with_lab(&self, tx_env: TransactionEnvelope) -> Result<(), Error> { + pub fn sign_tx_env_with_lab(&self, tx_env: &TransactionEnvelope) -> Result<(), Error> { let passphrase = self.get_network()?.network_passphrase; let xdr_buffer = tx_env.to_xdr_base64(Limits::none())?; From a13e4b42c9aa83be29cb1b0eee70d338a92c6fa3 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:44:50 -0400 Subject: [PATCH 12/18] Small fix to default lab url --- cmd/soroban-cli/src/config/sign_with.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index b5e7dc0f0..e0040e134 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -51,16 +51,14 @@ pub struct Args { #[arg( long, conflicts_with = "sign_with_key", - env = "STELLAR_SIGN_WITH_LABORATORY", - hide = true + env = "STELLAR_SIGN_WITH_LABORATORY" )] pub sign_with_lab: bool, /// Lab URL for `sign_with_lab` #[arg( long, env = "STELLAR_SIGN_WITH_LAB_URL", - hide = true, - default_value = "https://lab.stellar.org/transaction/sign?" + default_value = "https://lab.stellar.org/transaction/sign" )] pub lab_url: String, From a79192b26dac99eb4c022d7bf3a5b1c9c848244f Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:49:32 -0400 Subject: [PATCH 13/18] Update generated docs --- FULL_HELP_DOCS.md | 48 +++++++++++++++++++++++++ cmd/soroban-cli/src/config/sign_with.rs | 6 +--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index 99577b5d6..ab348886b 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/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/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/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/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/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/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/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/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/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/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 @@ -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/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 @@ -1363,6 +1407,10 @@ Sign a transaction envolope appending the signature to the envelope ###### **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/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/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index e0040e134..71f62e56d 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -48,11 +48,7 @@ pub struct Args { )] pub sign_with_key: Option, /// Sign with laboratory - #[arg( - long, - conflicts_with = "sign_with_key", - env = "STELLAR_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( From 0b070bb7b7aa3439bc41297f952f5ff34aeee724 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:48:54 -0400 Subject: [PATCH 14/18] Update default sign with lab url --- FULL_HELP_DOCS.md | 24 ++++++++++++------------ cmd/soroban-cli/src/config/sign_with.rs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index ab348886b..fe9a3ac8a 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -121,7 +121,7 @@ Get Id of builtin Soroban Asset Contract. Deprecated, use `stellar contract id a * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -146,7 +146,7 @@ Deploy builtin Soroban Asset Contract * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -377,7 +377,7 @@ If no keys are specified the contract itself is extended. * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -411,7 +411,7 @@ Deploy a wasm contract * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -478,7 +478,7 @@ Deploy builtin Soroban Asset Contract * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -503,7 +503,7 @@ Deploy normal Wasm Contract * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -707,7 +707,7 @@ Install a WASM file to the ledger without creating a contract instance * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -752,7 +752,7 @@ stellar contract invoke ... -- --help * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -839,7 +839,7 @@ Print the current value of a contract-data ledger entry * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -882,7 +882,7 @@ If no keys are specificed the contract itself is restored. * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -1373,7 +1373,7 @@ Simulate a transaction envelope from stdin * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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 @@ -1410,7 +1410,7 @@ Sign a transaction envolope appending the signature to the envelope * `--sign-with-lab` — Sign with laboratory * `--lab-url ` — Lab URL for `sign_with_lab` - Default value: `https://lab.stellar.org/transaction/sign` + 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/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 71f62e56d..748882801 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -54,7 +54,7 @@ pub struct Args { #[arg( long, env = "STELLAR_SIGN_WITH_LAB_URL", - default_value = "https://lab.stellar.org/transaction/sign" + default_value = "https://lab.stellar.org/transaction/cli-sign" )] pub lab_url: String, From b6a18788377386493d9df455a7a1db58d0868c7e Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Wed, 11 Sep 2024 09:50:00 -0400 Subject: [PATCH 15/18] Address PR feedback --- cmd/soroban-cli/src/config/sign_with.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 748882801..2717cefdd 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -53,6 +53,7 @@ pub struct Args { /// Lab URL for `sign_with_lab` #[arg( long, + conflicts_with = "sign_with_key", env = "STELLAR_SIGN_WITH_LAB_URL", default_value = "https://lab.stellar.org/transaction/cli-sign" )] From 0e71259b8d972fa940978239cbc8f00e915e103d Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:57:11 -0400 Subject: [PATCH 16/18] WIP: check yes flag --- cmd/soroban-cli/src/config/sign_with.rs | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/config/sign_with.rs b/cmd/soroban-cli/src/config/sign_with.rs index 2717cefdd..294e0bbc5 100644 --- a/cmd/soroban-cli/src/config/sign_with.rs +++ b/cmd/soroban-cli/src/config/sign_with.rs @@ -1,12 +1,12 @@ -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::{ @@ -35,6 +35,9 @@ pub enum Error { 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)] @@ -101,6 +104,17 @@ impl Args { } 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())?; @@ -125,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 + _ => (), + } + } + } +} From dd14b52fda743b6b6f8397e33a4da190b126d4e6 Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Wed, 11 Sep 2024 13:28:04 -0700 Subject: [PATCH 17/18] Add crate version badge. (#1598) --- README.md | 1 + 1 file changed, 1 insertion(+) 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. From 0e5c81b9b8e3750cebe17b1ad8bd1c30ddc341c3 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 13 Sep 2024 08:52:17 -0400 Subject: [PATCH 18/18] Update generated help docs --- FULL_HELP_DOCS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index fe9a3ac8a..9097637e7 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -1355,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 @@ -1400,7 +1400,7 @@ 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]`