Skip to content

Commit 6bb6247

Browse files
authored
fix: Replace deprecated #[clap] attributes with #[arg]/#[command] (#3128)
Closes #3127 ## Introduced changes This PR updates deprecated `#[clap(...)]` attributes to their modern equivalents in `clap` 4.x. The current codebase still uses outdated syntax that has been deprecated since version 4.0. By making this update, we ensure compatibility with future versions and maintain code quality. ## Tests `cargo check --features clap/deprecated `fixed now. ![Pasted Graphic 74](https://github.com/user-attachments/assets/f70d703d-7d30-432e-b74b-cc94c62d71dc) ## Checklist <!-- Make sure all of these are complete --> - [X] Linked relevant issue - [ ] Updated relevant documentation - [ ] Added relevant tests - [X] Performed self-review of the code - [ ] Added changes to `CHANGELOG.md`
1 parent 4c4a867 commit 6bb6247

File tree

21 files changed

+87
-87
lines changed

21 files changed

+87
-87
lines changed

crates/forge/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Report bugs: https://github.com/foundry-rs/starknet-foundry/issues/new/choose\
7171
"
7272
)]
7373
#[command(about = "snforge - a testing tool for Starknet contracts", long_about = None)]
74-
#[clap(name = "snforge")]
74+
#[command(name = "snforge")]
7575
pub struct Cli {
7676
#[command(subcommand)]
7777
subcommand: ForgeSubcommand,
@@ -205,7 +205,7 @@ pub struct TestArgs {
205205
tracked_resource: ForgeTrackedResource,
206206

207207
/// Additional arguments for cairo-coverage or cairo-profiler
208-
#[clap(last = true)]
208+
#[arg(last = true)]
209209
additional_args: Vec<OsString>,
210210
}
211211

crates/sncast/src/helpers/fee.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ use std::num::{NonZeroU64, NonZeroU128};
99
#[derive(Args, Debug, Clone)]
1010
pub struct FeeArgs {
1111
/// Max fee for the transaction. If not provided, will be automatically estimated.
12-
#[clap(value_parser = parse_non_zero_felt, short, long)]
12+
#[arg(value_parser = parse_non_zero_felt, short, long)]
1313
pub max_fee: Option<NonZeroFelt>,
1414

1515
/// Max gas amount. If not provided, will be automatically estimated.
16-
#[clap(value_parser = parse_non_zero_felt, long)]
16+
#[arg(value_parser = parse_non_zero_felt, long)]
1717
pub max_gas: Option<NonZeroFelt>,
1818

1919
/// Max gas price in Fri. If not provided, will be automatically estimated.
20-
#[clap(value_parser = parse_non_zero_felt, long)]
20+
#[arg(value_parser = parse_non_zero_felt, long)]
2121
pub max_gas_unit_price: Option<NonZeroFelt>,
2222
}
2323

crates/sncast/src/helpers/rpc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use std::time::UNIX_EPOCH;
1212
#[group(required = false, multiple = false)]
1313
pub struct RpcArgs {
1414
/// RPC provider url address; overrides url from snfoundry.toml
15-
#[clap(short, long)]
15+
#[arg(short, long)]
1616
pub url: Option<String>,
1717

1818
/// Use predefined network with a public provider. Note that this option may result in rate limits or other unexpected behavior
19-
#[clap(long)]
19+
#[arg(long)]
2020
pub network: Option<Network>,
2121
}
2222

crates/sncast/src/main.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,49 +71,49 @@ Report bugs: https://github.com/foundry-rs/starknet-foundry/issues/new/choose\
7171
"
7272
)]
7373
#[command(about = "sncast - All-in-one tool for interacting with Starknet smart contracts", long_about = None)]
74-
#[clap(name = "sncast")]
74+
#[command(name = "sncast")]
7575
#[expect(clippy::struct_excessive_bools)]
7676
struct Cli {
7777
/// Profile name in snfoundry.toml config file
78-
#[clap(short, long)]
78+
#[arg(short, long)]
7979
profile: Option<String>,
8080

8181
/// Account to be used for contract declaration;
8282
/// When using keystore (`--keystore`), this should be a path to account file
8383
/// When using accounts file, this should be an account name
84-
#[clap(short = 'a', long)]
84+
#[arg(short = 'a', long)]
8585
account: Option<String>,
8686

8787
/// Path to the file holding accounts info
88-
#[clap(long = "accounts-file")]
88+
#[arg(long = "accounts-file")]
8989
accounts_file_path: Option<Utf8PathBuf>,
9090

9191
/// Path to keystore file; if specified, --account should be a path to starkli JSON account file
92-
#[clap(short, long)]
92+
#[arg(short, long)]
9393
keystore: Option<Utf8PathBuf>,
9494

9595
/// If passed, values will be displayed as integers
96-
#[clap(long, conflicts_with = "hex_format")]
96+
#[arg(long, conflicts_with = "hex_format")]
9797
int_format: bool,
9898

9999
/// If passed, values will be displayed as hex
100-
#[clap(long, conflicts_with = "int_format")]
100+
#[arg(long, conflicts_with = "int_format")]
101101
hex_format: bool,
102102

103103
/// If passed, output will be displayed in json format
104-
#[clap(short, long)]
104+
#[arg(short, long)]
105105
json: bool,
106106

107107
/// If passed, command will wait until transaction is accepted or rejected
108-
#[clap(short = 'w', long)]
108+
#[arg(short = 'w', long)]
109109
wait: bool,
110110

111111
/// Adjusts the time after which --wait assumes transaction was not received or rejected
112-
#[clap(long)]
112+
#[arg(long)]
113113
wait_timeout: Option<u16>,
114114

115115
/// Adjusts the time between consecutive attempts to fetch transaction by --wait flag
116-
#[clap(long)]
116+
#[arg(long)]
117117
wait_retry_interval: Option<u8>,
118118

119119
#[command(subcommand)]
@@ -160,11 +160,11 @@ enum Commands {
160160
#[group(multiple = false)]
161161
pub struct Arguments {
162162
/// Arguments of the called function serialized as a series of felts
163-
#[clap(short, long, value_delimiter = ' ', num_args = 1..)]
163+
#[arg(short, long, value_delimiter = ' ', num_args = 1..)]
164164
pub calldata: Option<Vec<String>>,
165165

166166
// Arguments of the called function as a comma-separated string of Cairo expressions
167-
#[clap(long)]
167+
#[arg(long)]
168168
pub arguments: Option<String>,
169169
}
170170

crates/sncast/src/starknet_commands/account/create.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@ use std::str::FromStr;
3232
#[command(about = "Create an account with all important secrets")]
3333
pub struct Create {
3434
/// Type of the account
35-
#[clap(value_enum, short = 't', long = "type", value_parser = AccountType::from_str, default_value_t = AccountType::OpenZeppelin)]
35+
#[arg(value_enum, short = 't', long = "type", value_parser = AccountType::from_str, default_value_t = AccountType::OpenZeppelin)]
3636
pub account_type: AccountType,
3737

3838
/// Account name under which account information is going to be saved
39-
#[clap(short, long)]
39+
#[arg(short, long)]
4040
pub name: Option<String>,
4141

4242
/// Salt for the address
43-
#[clap(short, long)]
43+
#[arg(short, long)]
4444
pub salt: Option<Felt>,
4545

4646
/// If passed, a profile with provided name and corresponding data will be created in snfoundry.toml
47-
#[clap(long, conflicts_with = "network")]
47+
#[arg(long, conflicts_with = "network")]
4848
pub add_profile: Option<String>,
4949

5050
/// Custom contract class hash of declared contract
51-
#[clap(short, long, requires = "account_type")]
51+
#[arg(short, long, requires = "account_type")]
5252
pub class_hash: Option<Felt>,
5353

54-
#[clap(flatten)]
54+
#[command(flatten)]
5555
pub rpc: RpcArgs,
5656

5757
/// If passed, the command will not trigger an interactive prompt to add an account as a default
58-
#[clap(long)]
58+
#[arg(long)]
5959
pub silent: bool,
6060
}
6161

crates/sncast/src/starknet_commands/account/delete.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ use sncast::{chain_id_to_network_name, get_chain_id};
1616
.multiple(false)))]
1717
pub struct Delete {
1818
/// Name of the account to be deleted
19-
#[clap(short, long)]
19+
#[arg(short, long)]
2020
pub name: String,
2121

2222
/// Assume "yes" as answer to confirmation prompt and run non-interactively
23-
#[clap(long, default_value = "false")]
23+
#[arg(long, default_value = "false")]
2424
pub yes: bool,
2525

26-
#[clap(flatten)]
26+
#[command(flatten)]
2727
pub rpc: RpcArgs,
2828

2929
/// Literal name of the network used in accounts file
30-
#[clap(long)]
30+
#[arg(long)]
3131
pub network_name: Option<String>,
3232
}
3333

crates/sncast/src/starknet_commands/account/deploy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ use starknet_types_core::felt::Felt;
2828
#[command(about = "Deploy an account to the Starknet")]
2929
pub struct Deploy {
3030
/// Name of the account to be deployed
31-
#[clap(short, long)]
31+
#[arg(short, long)]
3232
pub name: Option<String>,
3333

34-
#[clap(flatten)]
34+
#[command(flatten)]
3535
pub fee_args: FeeArgs,
3636

37-
#[clap(flatten)]
37+
#[command(flatten)]
3838
pub rpc: RpcArgs,
3939
}
4040

crates/sncast/src/starknet_commands/account/import.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,42 @@ use starknet_types_core::felt::Felt;
2424
#[command(about = "Add an account to the accounts file")]
2525
pub struct Import {
2626
/// Name of the account to be imported
27-
#[clap(short, long)]
27+
#[arg(short, long)]
2828
pub name: Option<String>,
2929

3030
/// Address of the account
31-
#[clap(short, long)]
31+
#[arg(short, long)]
3232
pub address: Felt,
3333

3434
/// Type of the account
35-
#[clap(short = 't', long = "type", value_parser = AccountType::from_str)]
35+
#[arg(short = 't', long = "type", value_parser = AccountType::from_str)]
3636
pub account_type: AccountType,
3737

3838
/// Class hash of the account
39-
#[clap(short, long)]
39+
#[arg(short, long)]
4040
pub class_hash: Option<Felt>,
4141

4242
/// Account private key
43-
#[clap(long, group = "private_key_input")]
43+
#[arg(long, group = "private_key_input")]
4444
pub private_key: Option<Felt>,
4545

4646
/// Path to the file holding account private key
47-
#[clap(long = "private-key-file", group = "private_key_input")]
47+
#[arg(long = "private-key-file", group = "private_key_input")]
4848
pub private_key_file_path: Option<Utf8PathBuf>,
4949

5050
/// Salt for the address
51-
#[clap(short, long)]
51+
#[arg(short, long)]
5252
pub salt: Option<Felt>,
5353

5454
/// If passed, a profile with the provided name and corresponding data will be created in snfoundry.toml
55-
#[clap(long, conflicts_with = "network")]
55+
#[arg(long, conflicts_with = "network")]
5656
pub add_profile: Option<String>,
5757

58-
#[clap(flatten)]
58+
#[command(flatten)]
5959
pub rpc: RpcArgs,
6060

6161
/// If passed, the command will not trigger an interactive prompt to add an account as a default
62-
#[clap(long)]
62+
#[arg(long)]
6363
pub silent: bool,
6464
}
6565

crates/sncast/src/starknet_commands/account/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub mod list;
2727
#[derive(Args)]
2828
#[command(about = "Creates and deploys an account to the Starknet")]
2929
pub struct Account {
30-
#[clap(subcommand)]
30+
#[command(subcommand)]
3131
pub command: Commands,
3232
}
3333

crates/sncast/src/starknet_commands/call.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ use starknet_types_core::felt::Felt;
1313
#[command(about = "Call a contract instance on Starknet", long_about = None)]
1414
pub struct Call {
1515
/// Address of the called contract (hex)
16-
#[clap(short = 'd', long)]
16+
#[arg(short = 'd', long)]
1717
pub contract_address: Felt,
1818

1919
/// Name of the contract function to be called
20-
#[clap(short, long)]
20+
#[arg(short, long)]
2121
pub function: String,
2222

23-
#[clap(flatten)]
23+
#[command(flatten)]
2424
pub arguments: Arguments,
2525

2626
/// Block identifier on which call should be performed.
2727
/// Possible values: pending, latest, block hash (0x prefixed string)
2828
/// and block number (u64)
29-
#[clap(short, long, default_value = "pending")]
29+
#[arg(short, long, default_value = "pending")]
3030
pub block_id: String,
3131

32-
#[clap(flatten)]
32+
#[command(flatten)]
3333
pub rpc: RpcArgs,
3434
}
3535

0 commit comments

Comments
 (0)