Skip to content

Commit fc26db6

Browse files
committed
Revert "Reimplement speculos-client communication"
This reverts commit 3509f73.
1 parent 3509f73 commit fc26db6

7 files changed

Lines changed: 64 additions & 236 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ serde_path_to_error = "0.1.20"
122122
serde_with = "3.18.0"
123123
wiremock = "0.6.3"
124124
coins-ledger = "0.13.0"
125+
speculos-client = { git = "https://github.com/MKowalski8/speculos-client", rev = "58d9523" }
125126
const-hex = "1.18.1"
126127
indicatif = "0.18.3"
127128
shell-words = "1.1.0"

crates/sncast/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ wiremock.workspace = true
8282
docs = { workspace = true, features = ["testing"] }
8383
shared = { path = "../shared", features = ["testing"] }
8484
packages_validation = { path = "../testing/packages_validation" }
85+
speculos-client.workspace = true
8586

8687
[features]
8788
default = []

crates/sncast/tests/docs_snippets/ledger.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ use tempfile::TempDir;
1212

1313
const DOCS_SNIPPETS_PORT_BASE: u16 = 4006;
1414

15-
async fn setup_speculos_automation(
16-
client: &Arc<crate::e2e::ledger::speculos::SpeculosClient>,
17-
args: &[&str],
18-
) {
15+
async fn setup_speculos_automation(client: &Arc<speculos_client::SpeculosClient>, args: &[&str]) {
1916
if args.contains(&"get-public-key") && !args.contains(&"--no-display") {
2017
set_automation(client, &[automation::APPROVE_PUBLIC_KEY]).await;
2118
} else if args.contains(&"sign-hash") {

crates/sncast/tests/e2e/ledger/account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::fs;
22

3-
use super::speculos::AutomationRule;
43
use crate::e2e::ledger::{
54
BRAAVOS_LEDGER_PATH, LEDGER_ACCOUNT_NAME, LEDGER_PUBLIC_KEY, OZ_LEDGER_PATH, READY_LEDGER_PATH,
65
TEST_LEDGER_PATH, TEST_LEDGER_PATH_STORED, automation, set_automation, setup_speculos,
@@ -17,6 +16,7 @@ use shared::test_utils::output_assert::{assert_stderr_contains, assert_stdout_co
1716
use snapbox::assert_data_eq;
1817
use sncast::helpers::account::load_accounts;
1918
use sncast::helpers::constants::{BRAAVOS_CLASS_HASH, OZ_CLASS_HASH, READY_CLASS_HASH};
19+
use speculos_client::AutomationRule;
2020
use tempfile::tempdir;
2121
use test_case::test_case;
2222

@@ -41,7 +41,7 @@ async fn test_create_ledger_account(
4141
saved_type: &str,
4242
class_hash: String,
4343
port: u16,
44-
automations: &[AutomationRule<'static>],
44+
automations: &[speculos_client::AutomationRule<'static>],
4545
) {
4646
let (client, url) = setup_speculos(port);
4747
let tempdir = tempdir().unwrap();

crates/sncast/tests/e2e/ledger/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use sncast::helpers::constants::{
1414
};
1515
use sncast::helpers::ledger::{DerivationPathParser, SncastLedgerTransport};
1616
use sncast::response::ui::UI;
17-
use speculos::{AutomationAction, AutomationCondition, AutomationRule, Button, SpeculosClient};
17+
use speculos_client::{
18+
AutomationAction, AutomationCondition, AutomationRule, Button, DeviceModel, SpeculosClient,
19+
};
1820
use starknet_rust::accounts::{AccountFactory, ArgentAccountFactory, OpenZeppelinAccountFactory};
1921
use starknet_rust::core::types::{BlockId, BlockTag};
2022
use starknet_rust::providers::Provider;
@@ -28,7 +30,6 @@ use url::Url;
2830
mod account;
2931
mod basic;
3032
mod network;
31-
pub(crate) mod speculos;
3233

3334
pub(crate) const OZ_LEDGER_PATH: &str = "m//starknet'/sncast'/0'/0'/0";
3435
pub(crate) const READY_LEDGER_PATH: &str = "m//starknet'/sncast'/0'/1'/0";
@@ -45,19 +46,21 @@ pub(crate) const LEDGER_PUBLIC_KEY: &str =
4546
pub(crate) const LEDGER_ACCOUNT_NAME: &str = "my_ledger";
4647

4748
pub(crate) fn setup_speculos(port: u16) -> (Arc<SpeculosClient>, String) {
48-
let client = Arc::new(SpeculosClient::new(port, APP_PATH).unwrap());
49+
let client = Arc::new(SpeculosClient::new(DeviceModel::Nanox, port, APP_PATH).unwrap());
4950
let url = format!("http://127.0.0.1:{port}");
5051
(client, url)
5152
}
5253

53-
/// Sets automation rules and, when `ENABLE_BLIND_SIGN` is among them, presses RIGHT so the
54-
/// blind-sign flow advances immediately.
54+
/// Sets automation rules and, when `ENABLE_BLIND_SIGN` is among them, presses RIGHT to
55+
/// navigate from the home screen to "App settings" so the rule triggers immediately.
5556
pub(crate) async fn set_automation(
5657
client: &SpeculosClient,
57-
rules: &[speculos::AutomationRule<'static>],
58+
rules: &[speculos_client::AutomationRule<'static>],
5859
) {
5960
client.automation(rules).await.unwrap();
60-
let needs_blind_sign = rules.iter().any(|r| r == &automation::ENABLE_BLIND_SIGN);
61+
let needs_blind_sign = rules
62+
.iter()
63+
.any(|r| r.text.as_deref() == Some("App settings"));
6164
if needs_blind_sign {
6265
client.click_button(Button::Right).await.unwrap();
6366
}

0 commit comments

Comments
 (0)