Skip to content

Commit 4cdf2bd

Browse files
authored
fix: Speed up startup time from 5s -> 10ms (500x faster) (#557)
1 parent 23094a9 commit 4cdf2bd

File tree

18 files changed

+92
-92
lines changed

18 files changed

+92
-92
lines changed

Cargo.lock

Lines changed: 23 additions & 23 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ name = "near"
2424
path = "src/main.rs"
2525

2626
[dependencies]
27-
clap = { version = "4.0.18", features = ["derive"] }
27+
fast_clap = { version = "4.5.57", features = ["derive", "unstable-v5"] }
2828
inquire = "0.9.3"
2929
strum = { version = "0.24", features = ["derive"] }
3030
strum_macros = "0.24"

src/js_command_match/account/create.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ use crate::js_command_match::constants::{
77
#[derive(Debug, Clone, clap::Parser)]
88
pub struct CreateAccountArgs {
99
new_account_id: String,
10-
#[clap(long, aliases = USE_FAUCET_ALIASES, default_value_t = false)]
10+
#[arg(long, aliases = USE_FAUCET_ALIASES, default_value_t = false)]
1111
use_faucet: bool,
12-
#[clap(long, aliases = USE_ACCOUNT_ALIASES, conflicts_with = "use_faucet")]
12+
#[arg(long, aliases = USE_ACCOUNT_ALIASES, conflicts_with = "use_faucet")]
1313
use_account: Option<String>,
14-
#[clap(long, aliases = INITIAL_BALANCE_ALIASES, default_value = "1")]
14+
#[arg(long, aliases = INITIAL_BALANCE_ALIASES, default_value = "1")]
1515
initial_balance: String,
16-
#[clap(long, aliases = PUBLIC_KEY_ALIASES)]
16+
#[arg(long, aliases = PUBLIC_KEY_ALIASES)]
1717
public_key: Option<String>,
18-
#[clap(long, aliases = SEED_PHRASE_ALIASES, conflicts_with = "public_key")]
18+
#[arg(long, aliases = SEED_PHRASE_ALIASES, conflicts_with = "public_key")]
1919
seed_phrase: Option<String>,
20-
#[clap(long, aliases = SIGN_WITH_LEDGER_ALIASES, default_value_t = false, conflicts_with="use_faucet")]
20+
#[arg(long, aliases = SIGN_WITH_LEDGER_ALIASES, default_value_t = false, conflicts_with="use_faucet")]
2121
sign_with_ledger: bool,
22-
#[clap(long, aliases = LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
22+
#[arg(long, aliases = LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
2323
ledger_path: String,
24-
#[clap(long, aliases = USE_LEDGER_PK_ALIASES, default_value_t = false, conflicts_with = "public_key")]
24+
#[arg(long, aliases = USE_LEDGER_PK_ALIASES, default_value_t = false, conflicts_with = "public_key")]
2525
use_ledger_pk: bool,
26-
#[clap(long, aliases = PK_LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
26+
#[arg(long, aliases = PK_LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
2727
pk_ledger_path: String,
28-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
28+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
2929
network_id: Option<String>,
3030
}
3131

src/js_command_match/account/delete.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use crate::js_command_match::constants::{
66
pub struct DeleteAccountArgs {
77
account_id: String,
88
beneficiary_id: String,
9-
#[clap(long, aliases = SIGN_WITH_LEDGER_ALIASES, default_value_t = false)]
9+
#[arg(long, aliases = SIGN_WITH_LEDGER_ALIASES, default_value_t = false)]
1010
sign_with_ledger: bool,
11-
#[clap(long, aliases = LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
11+
#[arg(long, aliases = LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
1212
ledger_path: String,
13-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
13+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
1414
network_id: Option<String>,
15-
#[clap(long, default_value_t = false)]
15+
#[arg(long, default_value_t = false)]
1616
force: bool,
1717
}
1818

src/js_command_match/account/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::js_command_match::constants::NETWORK_ID_ALIASES;
33
#[derive(Debug, Clone, clap::Parser)]
44
/// This is a legacy `legacy` command. Once you run it with the specified arguments, new syntax command will be suggested.
55
pub struct LoginArgs {
6-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
6+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
77
network_id: Option<String>,
88
}
99

src/js_command_match/account/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::js_command_match::constants::NETWORK_ID_ALIASES;
33
#[derive(Debug, Clone, clap::Parser)]
44
pub struct StateArgs {
55
account_id: String,
6-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
6+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
77
network_id: Option<String>,
88
}
99

src/js_command_match/contract/call.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ use crate::js_command_match::constants::{
99
pub struct CallArgs {
1010
contract_name: String,
1111
method_name: String,
12-
#[clap(default_value = "{}")]
12+
#[arg(default_value = "{}")]
1313
args: String,
14-
#[clap(long, aliases = USE_ACCOUNT_ALIASES)]
14+
#[arg(long, aliases = USE_ACCOUNT_ALIASES)]
1515
use_account: String,
16-
#[clap(long, aliases = SIGN_WITH_LEDGER_ALIASES, default_value_t = false)]
16+
#[arg(long, aliases = SIGN_WITH_LEDGER_ALIASES, default_value_t = false)]
1717
sign_with_ledger: bool,
18-
#[clap(long, aliases = LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
18+
#[arg(long, aliases = LEDGER_PATH_ALIASES, default_value = DEFAULT_SEED_PHRASE_PATH)]
1919
ledger_path: String,
20-
#[clap(long, default_value_t = 30_000_000_000_000)]
20+
#[arg(long, default_value_t = 30_000_000_000_000)]
2121
gas: u64,
22-
#[clap(long, default_value = "0")]
22+
#[arg(long, default_value = "0")]
2323
deposit: String,
24-
#[clap(long, default_value = "0", conflicts_with = "deposit", aliases = ["depositYocto"])]
24+
#[arg(long, default_value = "0", conflicts_with = "deposit", aliases = ["depositYocto"])]
2525
deposit_yocto: String,
26-
#[clap(long, default_value_t = false)]
26+
#[arg(long, default_value_t = false)]
2727
base64: bool,
28-
#[clap(long, aliases = ["privateKey"])]
28+
#[arg(long, aliases = ["privateKey"])]
2929
private_key: Option<String>,
30-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
30+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
3131
network_id: Option<String>,
3232
}
3333

src/js_command_match/contract/deploy.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ use crate::js_command_match::constants::{
88
#[derive(Debug, Clone, clap::Parser)]
99
pub struct DeployArgs {
1010
account_id: String,
11-
#[clap(required_unless_present = "wasm_file")]
11+
#[arg(required_unless_present = "wasm_file")]
1212
wasm_file_path: Option<String>,
13-
#[clap(long, aliases = WASM_FILE_ALIASES )]
13+
#[arg(long, aliases = WASM_FILE_ALIASES )]
1414
wasm_file: Option<String>,
15-
#[clap(long, aliases = INIT_FUNCTION_ALIASES)]
15+
#[arg(long, aliases = INIT_FUNCTION_ALIASES)]
1616
init_function: Option<String>,
17-
#[clap(long, aliases = INIT_ARGS_ALIASES, default_value = "{}")]
17+
#[arg(long, aliases = INIT_ARGS_ALIASES, default_value = "{}")]
1818
init_args: String,
19-
#[clap(long, aliases = INIT_GAS_ALIASES, default_value_t = 30_000_000_000_000)]
19+
#[arg(long, aliases = INIT_GAS_ALIASES, default_value_t = 30_000_000_000_000)]
2020
init_gas: u64,
21-
#[clap(long, aliases = INIT_DEPOSIT_ALIASES, default_value = "0")]
21+
#[arg(long, aliases = INIT_DEPOSIT_ALIASES, default_value = "0")]
2222
init_deposit: String,
23-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
23+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
2424
network_id: Option<String>,
2525
}
2626

src/js_command_match/contract/storage.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use crate::js_command_match::constants::{BLOCK_ID_ALIASES, NETWORK_ID_ALIASES};
33
#[derive(Debug, Clone, clap::Parser)]
44
pub struct ViewStateArgs {
55
account_id: String,
6-
#[clap(long)]
6+
#[arg(long)]
77
prefix: Option<String>,
8-
#[clap(long, default_value_t = false)]
8+
#[arg(long, default_value_t = false)]
99
utf8: bool,
10-
#[clap(long, aliases = BLOCK_ID_ALIASES)]
10+
#[arg(long, aliases = BLOCK_ID_ALIASES)]
1111
block_id: Option<String>,
12-
#[clap(long, conflicts_with = "block_id")]
12+
#[arg(long, conflicts_with = "block_id")]
1313
finality: Option<String>,
14-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
14+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
1515
network_id: Option<String>,
1616
}
1717

src/js_command_match/contract/view.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use crate::js_command_match::constants::NETWORK_ID_ALIASES;
55
pub struct ViewArgs {
66
contract_name: String,
77
method_name: String,
8-
#[clap(default_value = "{}")]
8+
#[arg(default_value = "{}")]
99
args: String,
10-
#[clap(long, aliases = NETWORK_ID_ALIASES)]
10+
#[arg(long, aliases = NETWORK_ID_ALIASES)]
1111
network_id: Option<String>,
1212
}
1313

0 commit comments

Comments
 (0)