Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable braavos integration #3122

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2d56362
Refactor `FeeSettings` in `sncast_std`
franciszekjob Mar 11, 2025
c837366
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 11, 2025
a8d115e
Add rpc changes to sncast_std
franciszekjob Mar 11, 2025
cce8b24
Update script tests
franciszekjob Mar 11, 2025
4f9ee06
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 12, 2025
35ee0b0
Fix some script tests
franciszekjob Mar 12, 2025
755b27c
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 12, 2025
c4daa26
Fix linting
franciszekjob Mar 12, 2025
8321f05
Add todos and fix tests
franciszekjob Mar 12, 2025
8a69532
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 12, 2025
caadc34
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 12, 2025
3b3c2a9
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 12, 2025
ce77091
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 13, 2025
f0467b0
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 13, 2025
c3d6a4a
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 13, 2025
470116e
Add todos
franciszekjob Mar 13, 2025
f6d479b
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 13, 2025
bf482bc
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 13, 2025
210421b
Update changelog
franciszekjob Mar 13, 2025
f840464
Fix `test_wrong_calldata`
franciszekjob Mar 13, 2025
f2e3a8e
Fix `test_wrong_function_name`
franciszekjob Mar 13, 2025
5324b2a
Add todo
franciszekjob Mar 13, 2025
11b9877
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 13, 2025
515995a
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 14, 2025
f7188ec
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 14, 2025
4f08b2c
Remove docs snippets fix
franciszekjob Mar 14, 2025
47b68e1
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 14, 2025
7b7500b
Merge branch 'franciszekjob/2490-rpc-0.8.0' into franciszekjob/2490-2…
franciszekjob Mar 14, 2025
da757eb
Fix cast script errors (#3099)
cptartur Mar 14, 2025
e4e3093
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 17, 2025
4a55e31
Merge branch 'franciszekjob/2490-2-fix-sncast-scripts' of https://git…
franciszekjob Mar 17, 2025
77ee07f
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 17, 2025
a9bb361
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 18, 2025
fc0f8cf
Add todo
franciszekjob Mar 18, 2025
ee1c151
Merge branch 'franciszekjob/2490-rpc-0.8.0' into franciszekjob/2490-2…
franciszekjob Mar 18, 2025
53ae32a
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 19, 2025
30f26ad
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 19, 2025
325ee9e
Merge branch 'franciszekjob/2490-2-fix-sncast-scripts' of https://git…
franciszekjob Mar 19, 2025
17d78db
Fix sncast docs snippets tests (#3101)
franciszekjob Mar 19, 2025
44c63a3
Merge branch 'franciszekjob/2490-2-fix-sncast-scripts' of https://git…
franciszekjob Mar 19, 2025
f476f34
Add todos
franciszekjob Mar 19, 2025
f2de231
Fix todos
franciszekjob Mar 19, 2025
05a7399
Disable braavos integration
franciszekjob Mar 19, 2025
5488acf
Update account import docs
franciszekjob Mar 19, 2025
4d8c2a9
Add tests for disabled braavos integration
franciszekjob Mar 19, 2025
9c3faa9
Fix devnet path
franciszekjob Mar 19, 2025
f452e23
Restore previous test content
franciszekjob Mar 19, 2025
b95a793
Restore previous test content
franciszekjob Mar 19, 2025
b3e9933
Merge branch 'franciszekjob/2490-2-fix-sncast-scripts' of https://git…
franciszekjob Mar 19, 2025
607e62e
Restore `invalid_calldata` script content
franciszekjob Mar 19, 2025
30cc127
Fix asserted stdout content in `test_call_invalid_calldata` script test
franciszekjob Mar 19, 2025
eef7cfd
Merge branch 'franciszekjob/2490-2-fix-sncast-scripts' into francisze…
franciszekjob Mar 19, 2025
de6b195
Add todo
franciszekjob Mar 19, 2025
617e956
Merge branch 'franciszekjob/2490-disable-braavos' of https://github.c…
franciszekjob Mar 19, 2025
5f5d7ea
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 19, 2025
9e0533d
Add `FeeSettingsImpl`; Adjust script tests
franciszekjob Mar 19, 2025
29eb163
Add fee settings section in docs
franciszekjob Mar 19, 2025
c7d8bdc
Merge branch 'franciszekjob/2490-2-fix-sncast-scripts' of https://git…
franciszekjob Mar 19, 2025
4f30606
Use helper function
franciszekjob Mar 19, 2025
7c14e39
Fix linting
franciszekjob Mar 20, 2025
b28ca96
Apply code review suggestions
franciszekjob Mar 20, 2025
1e6b407
Fix devnet path
franciszekjob Mar 20, 2025
87b6a78
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 25, 2025
4804f01
Update changelog [skip ci]
franciszekjob Mar 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#### Changed

- Updated argent class hash used in account creation to v0.4.0
- Using Braavos accounts with `sncast` is currently disabled

#### Removed

Expand Down
10 changes: 10 additions & 0 deletions crates/sncast/src/helpers/braavos.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::{Error, bail};
use async_trait::async_trait;
use starknet::{
accounts::{AccountFactory, PreparedAccountDeploymentV3, RawAccountDeploymentV3},
Expand All @@ -8,6 +9,8 @@ use starknet::{
use starknet_crypto::poseidon_hash_many;
use starknet_types_core::felt::Felt;

use crate::AccountType;

// Adapted from strakli as there is currently no implementation of braavos account factory in starknet-rs
pub struct BraavosAccountFactory<S, P> {
class_hash: Felt,
Expand Down Expand Up @@ -140,3 +143,10 @@ where
.is_interactive(SignerInteractivityContext::Other)
}
}

pub fn assert_non_braavos_account_type(account_type: AccountType) -> Result<(), Error> {
if let AccountType::Braavos = account_type {
bail!("Using Braavos accounts with `sncast` is currently disabled")
}
Ok(())
}
6 changes: 6 additions & 0 deletions crates/sncast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::{Context, Error, Result, anyhow, bail};
use camino::Utf8PathBuf;
use clap::ValueEnum;
use conversions::serde::serialize::CairoSerialize;
use helpers::braavos::assert_non_braavos_account_type;
use helpers::constants::{KEYSTORE_PASSWORD_ENV_VAR, UDC_ADDRESS};
use rand::RngCore;
use rand::rngs::OsRng;
Expand Down Expand Up @@ -278,6 +279,11 @@ pub async fn get_account<'a>(
get_account_data_from_accounts_file(account, chain_id, accounts_file)?
};

// TODO(#3118): Remove this check once braavos integration is restored
if let Some(account_type) = account_data.account_type {
assert_non_braavos_account_type(account_type)?;
}

let account = build_account(account_data, chain_id, provider).await?;

Ok(account)
Expand Down
5 changes: 4 additions & 1 deletion crates/sncast/src/starknet_commands/account/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use camino::Utf8PathBuf;
use clap::Args;
use conversions::IntoConv;
use serde_json::json;
use sncast::helpers::braavos::BraavosAccountFactory;
use sncast::helpers::braavos::{BraavosAccountFactory, assert_non_braavos_account_type};
use sncast::helpers::configuration::CastConfig;
use sncast::helpers::constants::{
ARGENT_CLASS_HASH, BRAAVOS_BASE_ACCOUNT_CLASS_HASH, BRAAVOS_CLASS_HASH,
Expand Down Expand Up @@ -67,6 +67,9 @@ pub async fn create(
chain_id: Felt,
create: &Create,
) -> Result<AccountCreateResponse> {
// TODO(#3118): Remove this check once braavos integration is restored
assert_non_braavos_account_type(create.account_type)?;

let add_profile = create.add_profile.clone();
let salt = extract_or_generate_salt(create.salt);
let class_hash = create.class_hash.unwrap_or(match create.account_type {
Expand Down
4 changes: 4 additions & 0 deletions crates/sncast/src/starknet_commands/account/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use clap::Args;
use conversions::string::{TryFromDecStr, TryFromHexStr};
use sncast::check_if_legacy_contract;
use sncast::helpers::account::generate_account_name;
use sncast::helpers::braavos::assert_non_braavos_account_type;
use sncast::helpers::configuration::CastConfig;
use sncast::helpers::rpc::RpcArgs;
use sncast::response::structs::AccountImportResponse;
Expand Down Expand Up @@ -69,6 +70,9 @@ pub async fn import(
provider: &JsonRpcClient<HttpTransport>,
import: &Import,
) -> Result<AccountImportResponse> {
// TODO(#3118): Remove this check once braavos integration is restored
assert_non_braavos_account_type(import.account_type)?;

let private_key = if let Some(passed_private_key) = &import.private_key {
passed_private_key
} else if let Some(passed_private_key_file_path) = &import.private_key_file_path {
Expand Down
37 changes: 35 additions & 2 deletions crates/sncast/tests/e2e/account/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use test_case::test_case;

#[test_case("oz"; "oz_account_type")]
#[test_case("argent"; "argent_account_type")]
#[test_case("braavos"; "braavos_account_type")]
// TODO(#3118): Re-enable this test once braavos integration is restored
// #[test_case("braavos"; "braavos_account_type")]
#[tokio::test]
pub async fn test_happy_case(account_type: &str) {
let temp_dir = tempdir().expect("Unable to create a temporary directory");
Expand Down Expand Up @@ -331,7 +332,8 @@ pub async fn test_account_already_exists() {

#[test_case("oz"; "oz_account_type")]
#[test_case("argent"; "argent_account_type")]
#[test_case("braavos"; "braavos_account_type")]
// TODO(#3118)
// #[test_case("braavos"; "braavos_account_type")]
#[tokio::test]
pub async fn test_happy_case_keystore(account_type: &str) {
let temp_dir = tempdir().expect("Unable to create a temporary directory");
Expand Down Expand Up @@ -819,3 +821,34 @@ fn get_keystore_account_pattern(account_type: AccountType, class_hash: Option<&s

to_string_pretty(&account_json).unwrap()
}

#[test]
fn test_braavos_disabled() {
let temp_dir = tempdir().expect("Unable to create a temporary directory");
let accounts_file = "accounts.json";

let args = vec![
"--accounts-file",
accounts_file,
"account",
"create",
"--url",
URL,
"--name",
"my_account",
"--salt",
"0x1",
"--type",
"braavos",
];

let snapbox = runner(&args).current_dir(temp_dir.path());
let output = snapbox.assert().success();

assert_stderr_contains(
output,
indoc! {r"
error: Using Braavos accounts with `sncast` is currently disabled
"},
);
}
7 changes: 3 additions & 4 deletions crates/sncast/tests/e2e/account/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use indoc::indoc;
use serde_json::Value;
use shared::test_utils::output_assert::{AsOutput, assert_stderr_contains};
use sncast::AccountType;
use sncast::helpers::constants::{
ARGENT_CLASS_HASH, BRAAVOS_CLASS_HASH, KEYSTORE_PASSWORD_ENV_VAR, OZ_CLASS_HASH,
};
use sncast::helpers::constants::{ARGENT_CLASS_HASH, KEYSTORE_PASSWORD_ENV_VAR, OZ_CLASS_HASH};
use starknet::core::types::TransactionReceipt::DeployAccount;
use std::fs;
use tempfile::{TempDir, tempdir};
Expand All @@ -23,7 +21,8 @@ use test_case::test_case;
#[test_case(DEVNET_OZ_CLASS_HASH_CAIRO_0, "oz"; "cairo_0_class_hash")]
#[test_case(&OZ_CLASS_HASH.into_hex_string(), "oz"; "cairo_1_class_hash")]
#[test_case(&ARGENT_CLASS_HASH.into_hex_string(), "argent"; "argent_class_hash")]
#[test_case(&BRAAVOS_CLASS_HASH.into_hex_string(), "braavos"; "braavos_class_hash")]
// TODO(#3118)
// #[test_case(&BRAAVOS_CLASS_HASH.into_hex_string(), "braavos"; "braavos_class_hash")]
#[tokio::test]
pub async fn test_happy_case(class_hash: &str, account_type: &str) {
let tempdir = create_account(false, class_hash, account_type).await;
Expand Down
33 changes: 32 additions & 1 deletion crates/sncast/tests/e2e/account/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use test_case::test_case;

#[test_case("oz", "open_zeppelin"; "oz_account_type")]
#[test_case("argent", "argent"; "argent_account_type")]
#[test_case("braavos", "braavos"; "braavos_account_type")]
// TODO(#3118)
// #[test_case("braavos", "braavos"; "braavos_account_type")]
#[tokio::test]
pub async fn test_happy_case(input_account_type: &str, saved_type: &str) {
let tempdir = tempdir().expect("Unable to create a temporary directory");
Expand Down Expand Up @@ -819,3 +820,33 @@ pub async fn test_happy_case_default_name_generation() {

assert_eq!(contents_json, all_accounts_content);
}

#[tokio::test]
pub async fn test_braavos_disabled() {
let tempdir = tempdir().expect("Unable to create a temporary directory");
let accounts_file = "accounts.json";

let args = vec![
"--accounts-file",
accounts_file,
"account",
"import",
"--url",
URL,
"--name",
"my_account_import",
"--address",
"0x123",
"--private-key",
"0x456",
"--type",
"braavos",
];

let snapbox = runner(&args).current_dir(tempdir.path());

snapbox.assert().stderr_matches(indoc! {r"
command: account import
error: Using Braavos accounts with `sncast` is currently disabled
"});
}
42 changes: 40 additions & 2 deletions crates/sncast/tests/e2e/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ use indoc::indoc;
use shared::test_utils::output_assert::{assert_stderr_contains, assert_stdout_contains};
use sncast::AccountType;
use sncast::helpers::constants::ARGENT_CLASS_HASH;
use sncast::helpers::constants::{BRAAVOS_CLASS_HASH, OZ_CLASS_HASH};
use sncast::helpers::constants::OZ_CLASS_HASH;
use sncast::helpers::fee::FeeArgs;
use starknet::core::types::TransactionReceipt::Declare;
use starknet_types_core::felt::Felt;
use std::fs;
use tempfile::tempdir;
use test_case::test_case;

#[tokio::test]
Expand Down Expand Up @@ -62,7 +63,8 @@ async fn test_happy_case_human_readable() {
)]
#[test_case(OZ_CLASS_HASH, AccountType::OpenZeppelin; "cairo_1_class_hash")]
#[test_case(ARGENT_CLASS_HASH, AccountType::Argent; "argent_class_hash")]
#[test_case(BRAAVOS_CLASS_HASH, AccountType::Braavos; "braavos_class_hash")]
// TODO(#3118)
// #[test_case(BRAAVOS_CLASS_HASH, AccountType::Braavos; "braavos_class_hash")]
#[tokio::test]
async fn test_happy_case(class_hash: Felt, account_type: AccountType) {
let contract_path = duplicate_contract_directory_with_salt(
Expand Down Expand Up @@ -616,3 +618,39 @@ async fn test_no_scarb_profile() {
"},
);
}

// TODO(#3118: Remove this test, once integration with braavos is restored
#[tokio::test]
async fn test_braavos_disabled() {
let contract_path = duplicate_contract_directory_with_salt(
CONTRACTS_DIR.to_string() + "/map",
"put",
"human_readable",
);
let tempdir = tempdir().expect("Failed to create a temporary directory");
let accounts_json_path = get_accounts_path("tests/data/accounts/accounts.json");
join_tempdirs(&contract_path, &tempdir);

let args = vec![
"--accounts-file",
&accounts_json_path,
"--account",
"braavos",
"declare",
"--url",
URL,
"--contract-name",
"Map",
];
let args = apply_test_resource_bounds_flags(args);

let snapbox = runner(&args).current_dir(tempdir.path());
let output = snapbox.assert().failure();

assert_stderr_contains(
output,
indoc! {r"
Error: Using Braavos accounts with `sncast` is currently disabled
"},
);
}
34 changes: 32 additions & 2 deletions crates/sncast/tests/e2e/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::helpers::constants::{
};
use crate::helpers::fee::apply_test_resource_bounds_flags;
use crate::helpers::fixtures::{
create_and_deploy_account, create_and_deploy_oz_account, get_transaction_hash,
get_transaction_receipt,
create_and_deploy_account, create_and_deploy_oz_account, get_accounts_path,
get_transaction_hash, get_transaction_receipt,
};
use crate::helpers::runner::runner;
use indoc::indoc;
Expand All @@ -17,6 +17,7 @@ use sncast::helpers::fee::FeeArgs;
use starknet::core::types::TransactionReceipt::Deploy;
use starknet_types_core::felt::Felt;
use std::path::PathBuf;
use tempfile::tempdir;
use test_case::test_case;

#[tokio::test]
Expand Down Expand Up @@ -374,3 +375,32 @@ async fn test_happy_case_shell() {
.arg(CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA);
snapbox.assert().success();
}

// TODO(#3118: Remove this test, once integration with braavos is restored
#[tokio::test]
async fn test_braavos_disabled() {
let tempdir = tempdir().expect("Failed to create a temporary directory");
let accounts_json_path = get_accounts_path("tests/data/accounts/accounts.json");

let args = vec![
"--accounts-file",
&accounts_json_path,
"--account",
"braavos",
"deploy",
"--url",
URL,
"--class-hash",
MAP_CONTRACT_CLASS_HASH_SEPOLIA,
];

let snapbox = runner(&args).current_dir(tempdir.path());
let output = snapbox.assert().failure();

assert_stderr_contains(
output,
indoc! {r"
Error: Using Braavos accounts with `sncast` is currently disabled
"},
);
}
38 changes: 36 additions & 2 deletions crates/sncast/tests/e2e/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::helpers::constants::{
};
use crate::helpers::fee::apply_test_resource_bounds_flags;
use crate::helpers::fixtures::{
create_and_deploy_account, create_and_deploy_oz_account, get_transaction_hash,
get_transaction_receipt,
create_and_deploy_account, create_and_deploy_oz_account, get_accounts_path,
get_transaction_hash, get_transaction_receipt,
};
use crate::helpers::runner::runner;
use indoc::indoc;
Expand All @@ -17,6 +17,7 @@ use sncast::helpers::fee::FeeArgs;
use starknet::core::types::TransactionReceipt::Invoke;
use starknet_types_core::felt::Felt;
use std::path::PathBuf;
use tempfile::tempdir;
use test_case::test_case;

#[tokio::test]
Expand Down Expand Up @@ -362,3 +363,36 @@ async fn test_happy_case_shell() {
.arg(DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA);
snapbox.assert().success();
}

// TODO(#3118): Remove this test, once integration with braavos is restored
#[tokio::test]
async fn test_braavos_disabled() {
let tempdir = tempdir().expect("Failed to create a temporary directory");
let accounts_json_path = get_accounts_path("tests/data/accounts/accounts.json");

let args = vec![
"--accounts-file",
&accounts_json_path,
"--account",
"braavos",
"invoke",
"--url",
URL,
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--function",
"put",
"--calldata",
"0x1 0x2",
];

let snapbox = runner(&args).current_dir(tempdir.path());
let output = snapbox.assert().failure();

assert_stderr_contains(
output,
indoc! {r"
Error: Using Braavos accounts with `sncast` is currently disabled
"},
);
}
Loading