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

Update sncast scripts #3076

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 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
f452e23
Restore previous test content
franciszekjob Mar 19, 2025
b95a793
Restore previous test content
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
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
a9452b6
Update changelog
franciszekjob Mar 19, 2025
1faa439
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 21, 2025
219080c
Remove `pub` from `FeeSettings` fields; Update docs
franciszekjob Mar 21, 2025
393c20a
Update todos
franciszekjob Mar 24, 2025
41feb72
Fix linting
franciszekjob Mar 24, 2025
13dd39a
Remove changes from last two commits; Update todos
franciszekjob Mar 24, 2025
8444414
Fix typos
franciszekjob Mar 24, 2025
6995ec7
Apply code review suggestions
franciszekjob Mar 24, 2025
da9c4a4
Fix docs
franciszekjob Mar 24, 2025
c80ec6d
Remove print
franciszekjob Mar 24, 2025
044e8fa
Apply code review suggestions
franciszekjob Mar 24, 2025
bafd15a
Update docs
franciszekjob Mar 24, 2025
bfae5e6
Update changelog
franciszekjob Mar 24, 2025
b5c6063
Update changelog
franciszekjob Mar 24, 2025
6dfd37f
Apply code review suggestion
franciszekjob Mar 25, 2025
00aab06
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 25, 2025
ead34c9
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 25, 2025
d606788
Update changelog
franciszekjob Mar 25, 2025
119b677
Merge branch 'franciszekjob/2490-rpc-0.8.0' of https://github.com/fou…
franciszekjob Mar 25, 2025
feca05b
Fix `FeeSettingsTrait` in sncast_std
franciszekjob Mar 25, 2025
88c10ab
Apply code review sugestion
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#### Added

- `--l1-gas`, `--l1-gas-price`, `--l2-gas`, `--l2-gas-price`, `--l1-data-gas`, `--l1-data-gas-price` flags
- methods for fee settings creation, in `FeeSettingsTrait`: `max_fee()`, `resource_bounds()` and `estimate()` (in `sncast_std`)

#### Changed

Expand All @@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#### Removed

- `--max-gas` and `--max-gas-unit-price` flags
- `max_gas`, `max_gas_unit_price` fields in `FeeSettings` (in `sncast_std`)

## [0.39.0] - 2025-03-19

Expand Down
1 change: 0 additions & 1 deletion crates/sncast/src/helpers/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ impl FeeArgs {
}
}

// TODO(#3102): Refactor to be enum with max fee and triplet variants
/// Struct used in `sncast script` for deserializing from cairo, `FeeSettings` can't be
/// used as it missing `max_fee`
#[derive(Debug, PartialEq, CairoDeserialize)]
Expand Down
17 changes: 6 additions & 11 deletions crates/sncast/tests/data/scripts/declare/src/fee_settings.cairo
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
use sncast_std::{
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait
};

fn main() {
let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let declare_nonce = get_nonce('latest');
declare(
"Mapa",
FeeSettings {
max_gas: Option::Some(99999),
max_gas_unit_price: Option::Some(999999999999),
max_fee: Option::None
},
Option::Some(declare_nonce)
)
.expect('declare failed');
declare("Mapa", fee_settings, Option::Some(declare_nonce)).expect('declare failed');
println!("success");
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use sncast_std::{
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettings,
FeeSettingsTrait,
};

fn main() {
let fee_settings = FeeSettingsTrait::resource_bounds(
9999999999999999999,
99999999999999999999999999999999999999,
9999999999999999999,
99999999999999999999999999999999999999,
9999999999999999999,
99999999999999999999999999999999999999
);
let declare_nonce = get_nonce('latest');
let declare_result = declare(
"Mapa",
FeeSettings {
max_fee: Option::None,
max_gas: Option::Some(9999999999999999999),
max_gas_unit_price: Option::Some(99999999999999999999999999999999999999)
},
Option::Some(declare_nonce)
)
.unwrap_err();
let declare_result = declare("Mapa", fee_settings, Option::Some(declare_nonce)).unwrap_err();
println!("{:?}", declare_result);

assert(
Expand Down
12 changes: 3 additions & 9 deletions crates/sncast/tests/data/scripts/declare/src/no_contract.cairo
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use sncast_std::{
declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings,
declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, FeeSettingsTrait,
};

fn main() {
let declare_result = declare(
"Mapaaaa",
FeeSettings {
max_fee: Option::None, max_gas: Option::None, max_gas_unit_price: Option::None
},
Option::None
)
.unwrap_err();
let fee_settings = FeeSettingsTrait::estimate();
let declare_result = declare("Mapaaaa", fee_settings, Option::None).unwrap_err();
println!("{:?}", declare_result);
}

Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
use sncast_std::{
get_nonce, declare, DeclareResult, DeclareResultTrait, ScriptCommandError, ProviderError,
StarknetError, FeeSettings
StarknetError, FeeSettingsTrait
};

fn main() {
let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let declare_nonce = get_nonce('latest');
let first_declare_result = declare(
"Mapa",
FeeSettings {
max_fee: Option::None,
max_gas: Option::Some(999999),
max_gas_unit_price: Option::Some(100000000000)
},
Option::Some(declare_nonce)
)
let first_declare_result = declare("Mapa", fee_settings, Option::Some(declare_nonce))
.expect('declare failed');
println!("success");

Expand All @@ -27,15 +22,7 @@ fn main() {
assert(*first_declare_result.class_hash() == class_hash, 'Class hashes must be equal');

let declare_nonce = get_nonce('latest');
let second_declare_result = declare(
"Mapa",
FeeSettings {
max_fee: Option::None,
max_gas: Option::Some(999999),
max_gas_unit_price: Option::Some(100000000000)
},
Option::Some(declare_nonce)
)
let second_declare_result = declare("Mapa", fee_settings, Option::Some(declare_nonce))
.expect('second declare failed');

// Check if already declared contract was handled correctly
Expand Down
17 changes: 6 additions & 11 deletions crates/sncast/tests/data/scripts/declare/src/time_out.cairo
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
use sncast_std::{
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait
};

fn main() {
let max_fee = 99999999999999999;

let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let declare_nonce = get_nonce('latest');
let declare_result = declare(
"Mapa",
FeeSettings {
max_fee: Option::Some(max_fee), max_gas: Option::None, max_gas_unit_price: Option::None
},
Option::Some(declare_nonce)
)
.unwrap_err();
let declare_result = declare("Mapa", fee_settings, Option::Some(declare_nonce)).unwrap_err();

println!("{:?}", declare_result);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
use sncast_std::{
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait
};

fn main() {
let fee_settings = FeeSettingsTrait::resource_bounds(1, 1, 1, 1, 1, 1,);
let declare_nonce = get_nonce('latest');
let declare_result = declare(
"Mapa",
FeeSettings {
max_fee: Option::None, max_gas: Option::Some(1), max_gas_unit_price: Option::Some(1)
},
Option::Some(declare_nonce)
)
.unwrap_err();
let declare_result = declare("Mapa", fee_settings, Option::Some(declare_nonce)).unwrap_err();
println!("{:?}", declare_result);

assert(
ScriptCommandError::ProviderError(
ProviderError::StarknetError(StarknetError::InsufficientMaxFee)
ProviderError::StarknetError(StarknetError::InsufficientResourcesForValidate)
) == declare_result,
'ohno'
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
use sncast_std::{
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings
get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait
};

fn main() {
let max_fee = 99999999999999999;

let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let declare_nonce = get_nonce('pending') + 100;
let declare_result = declare(
"Mapa",
FeeSettings {
max_fee: Option::Some(max_fee), max_gas: Option::None, max_gas_unit_price: Option::None
},
Option::Some(declare_nonce)
)
.unwrap_err();
let declare_result = declare("Mapa", fee_settings, Option::Some(declare_nonce)).unwrap_err();
println!("{:?}", declare_result);

assert(
Expand Down
16 changes: 5 additions & 11 deletions crates/sncast/tests/data/scripts/deploy/src/fee_settings.cairo
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
use sncast_std::{deploy, DeployResult, FeeSettings};
use sncast_std::{deploy, DeployResult, FeeSettingsTrait};
use starknet::{ClassHash, Felt252TryIntoClassHash};
use traits::Into;

fn main() {
let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let salt = 0x3;
let class_hash: ClassHash = 0x059426c817fb8103edebdbf1712fa084c6744b2829db9c62d1ea4dce14ee6ded
.try_into()
.expect('Invalid class hash value');

let deploy_result = deploy(
class_hash,
array![0x2, 0x2, 0x0],
Option::Some(salt),
true,
FeeSettings {
max_gas: Option::Some(999),
max_gas_unit_price: Option::Some(999999999999),
max_fee: Option::None
},
Option::None
class_hash, array![0x2, 0x2, 0x0], Option::Some(salt), true, fee_settings, Option::None
)
.expect('deploy failed');

Expand Down
16 changes: 6 additions & 10 deletions crates/sncast/tests/data/scripts/deploy/src/invalid_calldata.cairo
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use sncast_std::{
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings,
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait,
};
use starknet::{ClassHash, Felt252TryIntoClassHash};
use traits::Into;

fn main() {
let max_fee = 99999999999999999;
let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let salt = 0x3;

let class_hash: ClassHash = 0x059426c817fb8103edebdbf1712fa084c6744b2829db9c62d1ea4dce14ee6ded
Expand All @@ -14,14 +17,7 @@ fn main() {

let deploy_nonce = get_nonce('pending');
let deploy_result = deploy(
class_hash,
array![0x2],
Option::Some(salt),
true,
FeeSettings {
max_fee: Option::Some(max_fee), max_gas: Option::None, max_gas_unit_price: Option::None
},
Option::Some(deploy_nonce)
class_hash, array![0x2], Option::Some(salt), true, fee_settings, Option::Some(deploy_nonce)
)
.unwrap_err();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use sncast_std::{
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings,
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait,
};
use starknet::{ClassHash, Felt252TryIntoClassHash};
use traits::Into;

fn main() {
let max_fee = 99999999999999999;
let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let salt = 0x3;

let class_hash: ClassHash = 0xdddd.try_into().expect('Invalid class hash value');
Expand All @@ -16,9 +19,7 @@ fn main() {
array![0x2, 0x2, 0x0],
Option::Some(salt),
true,
FeeSettings {
max_fee: Option::Some(max_fee), max_gas: Option::None, max_gas_unit_price: Option::None
},
fee_settings,
Option::Some(deploy_nonce)
)
.unwrap_err();
Expand Down
12 changes: 6 additions & 6 deletions crates/sncast/tests/data/scripts/deploy/src/invalid_nonce.cairo
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use sncast_std::{
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings,
TransactionExecutionErrorData
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait, TransactionExecutionErrorData
};

use starknet::{ClassHash, Felt252TryIntoClassHash};
use traits::Into;

fn main() {
let max_fee = 99999999999999999;
let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let salt = 0x3;

let class_hash: ClassHash = 0x059426c817fb8103edebdbf1712fa084c6744b2829db9c62d1ea4dce14ee6ded
Expand All @@ -20,9 +22,7 @@ fn main() {
array![0x2, 0x2, 0x0],
Option::Some(salt),
true,
FeeSettings {
max_fee: Option::Some(max_fee), max_gas: Option::None, max_gas_unit_price: Option::None
},
fee_settings,
Option::Some(deploy_nonce)
)
.unwrap_err();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use sncast_std::{
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError, FeeSettings,
get_nonce, deploy, DeployResult, ScriptCommandError, ProviderError, StarknetError,
FeeSettingsTrait,
};
use starknet::{ClassHash, Felt252TryIntoClassHash};
use traits::Into;

fn main() {
let max_fee = 99999999999999999;
let fee_settings = FeeSettingsTrait::resource_bounds(
100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000,
);
let salt = 0x34542;

let class_hash: ClassHash = 0x059426c817fb8103edebdbf1712fa084c6744b2829db9c62d1ea4dce14ee6ded
Expand All @@ -18,9 +21,7 @@ fn main() {
array![0x2, 0x2, 0x0],
Option::Some(salt),
true,
FeeSettings {
max_fee: Option::Some(max_fee), max_gas: Option::None, max_gas_unit_price: Option::None
},
fee_settings,
Option::Some(deploy_nonce)
)
.expect('1st deploy failed');
Expand All @@ -35,9 +36,7 @@ fn main() {
array![0x2, 0x2, 0x0],
Option::Some(salt),
true,
FeeSettings {
max_fee: Option::Some(max_fee), max_gas: Option::None, max_gas_unit_price: Option::None
},
fee_settings,
Option::Some(deploy_nonce)
)
.unwrap_err();
Expand Down
Loading
Loading