From e876617adf633b3e84c628809507e3122c5f90a7 Mon Sep 17 00:00:00 2001 From: "Jean Marchand (Exotic Markets)" Date: Thu, 1 Feb 2024 10:20:24 +0100 Subject: [PATCH] Update other dependencies (#12) --- Cargo.lock | 151 +++++++++++++++++++++++++++++++--------------- Cargo.toml | 8 +-- cli/Cargo.toml | 2 +- cli/src/cli.rs | 76 ++++------------------- cli/src/deps.rs | 2 +- cli/src/parser.rs | 33 +++++----- utils/src/lib.rs | 4 +- 7 files changed, 135 insertions(+), 141 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fe7b425..e37af31d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -490,6 +490,54 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.79" @@ -1083,15 +1131,16 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.14.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c297bd3135f558552f99a0daa180876984ea2c4ffa7470314540dff8c654109a" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", "semver", "serde", "serde_json", + "thiserror", ] [[package]] @@ -1157,8 +1206,7 @@ checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags 1.3.2", - "clap_derive", - "clap_lex", + "clap_lex 0.2.4", "indexmap 1.9.3", "once_cell", "strsim 0.10.0", @@ -1166,17 +1214,38 @@ dependencies = [ "textwrap 0.16.0", ] +[[package]] +name = "clap" +version = "4.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +dependencies = [ + "anstream", + "anstyle", + "clap_lex 0.6.0", + "strsim 0.10.0", +] + [[package]] name = "clap_derive" -version = "3.2.25" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck 0.4.1", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -1188,6 +1257,12 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clap_lex" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" + [[package]] name = "clockwork-cli" version = "2.0.18" @@ -1199,7 +1274,7 @@ dependencies = [ "bzip2", "cargo_metadata", "chrono", - "clap 3.2.25", + "clap 4.4.18", "clockwork-cron", "clockwork-network-program", "clockwork-plugin-utils", @@ -1208,7 +1283,7 @@ dependencies = [ "clockwork-utils", "clockwork-webhook-program", "dirs-next", - "indicatif 0.16.2", + "indicatif", "reqwest", "serde", "serde_json", @@ -1302,7 +1377,7 @@ name = "clockwork-utils" version = "2.0.18" dependencies = [ "anchor-lang", - "base64 0.13.1", + "base64 0.21.7", "serde", "static-pubkey", ] @@ -1347,6 +1422,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "combine" version = "3.8.1" @@ -2387,18 +2468,6 @@ dependencies = [ "hashbrown 0.14.3", ] -[[package]] -name = "indicatif" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d207dc617c7a380ab07ff572a6e52fa202a2a8f355860ac9c38e23f8196be1b" -dependencies = [ - "console", - "lazy_static", - "number_prefix", - "regex", -] - [[package]] name = "indicatif" version = "0.17.7" @@ -3164,30 +3233,6 @@ dependencies = [ "toml_edit 0.21.0", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.78" @@ -4041,7 +4086,7 @@ dependencies = [ "futures", "futures-util", "indexmap 2.2.1", - "indicatif 0.17.7", + "indicatif", "log", "quinn", "rayon", @@ -4412,7 +4457,7 @@ dependencies = [ "base64 0.21.7", "bincode", "bs58 0.4.0", - "indicatif 0.17.7", + "indicatif", "log", "reqwest", "semver", @@ -4593,7 +4638,7 @@ dependencies = [ "bincode", "futures-util", "indexmap 2.2.1", - "indicatif 0.17.7", + "indicatif", "log", "rayon", "solana-connection-cache", @@ -5589,6 +5634,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index b959543a..ab435616 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ keywords = ["solana"] [workspace.dependencies] anchor-lang = "0.29.0" anchor-spl = "0.29.0" -base64 = "~0.13" +base64 = "~0.21" serde = "1.0" static-pubkey = "1.0.3" chrono = { version = "0.4.19", default-features = false } @@ -39,9 +39,9 @@ clockwork-webhook-program = { path = "./programs/webhook", version = "=2.0.18" } anyhow = "1.0.61" bincode = "1.3.3" bzip2 = "0.4" -clap = { version = "3.1.2" } +clap = { version = "4.4.18" } dirs-next = "2.0.0" -indicatif = "0.16" +indicatif = "0.17" reqwest = "0.11.14" serde_json = "1.0.79" solana-client = "=1.17.14" @@ -52,7 +52,7 @@ spl-token = "~3.5.0" tar = "0.4" thiserror = "1.0.30" termcolor = "1.2.0" -cargo_metadata = "=0.14.0" +cargo_metadata = "=0.18.1" nom = "~7" solana-geyser-plugin-interface = "=1.17.14" log = "0.4" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 1f4f076e..4085442c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -17,7 +17,7 @@ anchor-spl = { features = ["mint", "token"], workspace = true } anyhow.workspace = true bincode.workspace = true bzip2.workspace = true -clap = { workspace = true, features = ["derive"] } +clap = { workspace = true, features = ["derive", "cargo"] } clockwork-cron.workspace = true clockwork-network-program = { workspace = true, features = ["no-entrypoint"] } clockwork-relayer-api.workspace = true diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 09e7e722..3055172a 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -147,7 +147,7 @@ pub enum CliCommand { }, } -pub fn app() -> Command<'static> { +pub fn app() -> Command { Command::new("Clockwork") .bin_name("clockwork") .about("An automation engine for the Solana blockchain") @@ -165,19 +165,16 @@ pub fn app() -> Command<'static> { Arg::new("admin") .long("admin") .value_name("ADDRESS") - .takes_value(true), ) .arg( Arg::new("epoch_thread") .long("epoch_thread") .value_name("ADDRESS") - .takes_value(true), ) .arg( Arg::new("hasher_thread") .long("hasher_thread") .value_name("ADDRESS") - .takes_value(true), ) .group( ArgGroup::new("config_settings") @@ -193,7 +190,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("schedule") .index(1) - .takes_value(true) .required(true) .help("The schedule to generate a cron table for"), ), @@ -209,7 +205,6 @@ pub fn app() -> Command<'static> { Arg::new("worker_id") .long("worker_id") .short('w') - .takes_value(true) .required(false) .help("The ID of the worker to create a delegation with"), ), @@ -222,7 +217,6 @@ pub fn app() -> Command<'static> { Arg::new("amount") .long("amount") .short('a') - .takes_value(true) .required(false) .help("The number of tokens to deposit"), ) @@ -230,7 +224,6 @@ pub fn app() -> Command<'static> { Arg::new("delegation_id") .long("delegation_id") .short('i') - .takes_value(true) .required(false) .help("The ID of the delegation to deposit into"), ) @@ -238,7 +231,6 @@ pub fn app() -> Command<'static> { Arg::new("worker_id") .long("worker_id") .short('w') - .takes_value(true) .required(false) .help("The ID of the worker"), ), @@ -251,7 +243,6 @@ pub fn app() -> Command<'static> { Arg::new("delegation_id") .long("delegation_id") .short('i') - .takes_value(true) .required(false) .help("The ID of the delegation"), ) @@ -259,7 +250,6 @@ pub fn app() -> Command<'static> { Arg::new("worker_id") .long("worker_id") .short('w') - .takes_value(true) .required(false) .help("The ID of the worker"), ), @@ -272,7 +262,6 @@ pub fn app() -> Command<'static> { Arg::new("amount") .long("amount") .short('a') - .takes_value(true) .required(false) .help("The number of tokens to withdraw"), ) @@ -280,7 +269,6 @@ pub fn app() -> Command<'static> { Arg::new("delegation_id") .long("delegation_id") .short('i') - .takes_value(true) .required(false) .help("The ID of the delegation to withdraw from"), ) @@ -288,7 +276,6 @@ pub fn app() -> Command<'static> { Arg::new("worker_id") .long("worker_id") .short('w') - .takes_value(true) .required(false) .help("The ID of the worker"), ), @@ -305,7 +292,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The label of the thread to lookup (only works if you \ are the signer of that thread)") @@ -314,7 +300,6 @@ pub fn app() -> Command<'static> { Arg::new("address") .short('k') .long("address") - .takes_value(true) .help("The address of the thread to lookup"), ), ) @@ -326,7 +311,6 @@ pub fn app() -> Command<'static> { Arg::new("mint") .long("mint") .short('m') - .takes_value(true) .required(true) .help("Mint address of network token"), ), @@ -335,12 +319,11 @@ pub fn app() -> Command<'static> { Command::new("localnet") .about("Launch a local Clockwork worker for app development and testing") .arg( - Arg::with_name("bpf_program") + Arg::new("bpf_program") .long("bpf-program") .value_names(&["ADDRESS_OR_KEYPAIR", "BPF_PROGRAM.SO"]) - .takes_value(true) + .num_args(1..) .number_of_values(2) - .multiple(true) .help( "Add a BPF program to the genesis configuration. \ If the ledger already exists then this parameter is silently ignored. \ @@ -348,49 +331,45 @@ pub fn app() -> Command<'static> { ), ) .arg( - Arg::with_name("clone") + Arg::new("clone") .long("clone") .short('c') .value_names(&["ADDRESS"]) - .takes_value(true) + .num_args(1..) .number_of_values(1) - .multiple(true) .help("Copy an account from the cluster referenced by the --url argument the genesis configuration. If the ledger already exists then this parameter is silently ignored") ) .arg( - Arg::with_name("url") + Arg::new("url") .long("url") .short('u') .value_names(&["URL_OR_MONIKER"]) - .takes_value(true) + .num_args(1) .number_of_values(1) - .multiple(false) .help("URL for Solana's JSON RPC or moniker (or their first letter): [mainnet-beta, testnet, devnet, localhost]") ) - .arg(Arg::with_name("force_init") + .arg(Arg::new("force_init") .long("force-init") .help("Initializes and downloads localnet dependencies") ) .arg( - Arg::with_name("solana_archive") + Arg::new("solana_archive") .long("solana-archive") .help("url or local path to the solana archive containing the necessary \ dependencies such as solana-test-validator. \ Can be useful for debugging or testing different versions of solana-test-validator ") - .takes_value(true), ) .arg( - Arg::with_name("clockwork_archive") + Arg::new("clockwork_archive") .long("clockwork-archive") .help("url or local path to the solana archive containing the necessary \ dependencies such as clocwkork-thread-program, etc. \ Can be useful for debugging or testing different versions of clockwork releases ") - .takes_value(true), ) .arg( - Arg::with_name("dev") + Arg::new("dev") .long("dev") .help("Use development versions of clockwork programs") ) @@ -405,7 +384,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The ID of the pool to lookup"), ), @@ -418,7 +396,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The ID of the pool to update"), ) @@ -426,7 +403,6 @@ pub fn app() -> Command<'static> { Arg::new("size") .long("size") .short('s') - .takes_value(true) .required(false) .help("The size of the pool"), ), @@ -444,7 +420,6 @@ pub fn app() -> Command<'static> { .long("name") .short('n') .value_name("NAME") - .takes_value(true) .required(true) .help("The name of the secret") ) @@ -453,7 +428,6 @@ pub fn app() -> Command<'static> { .long("delegate") .short('d') .value_name("PUBKEY") - .takes_value(true) .required(true) .help("The delegate to approve") ) @@ -470,7 +444,6 @@ pub fn app() -> Command<'static> { .long("word") .short('w') .value_name("WORD") - .takes_value(true) .required(true) .help("The secret word to securely save") ) @@ -479,7 +452,6 @@ pub fn app() -> Command<'static> { .long("name") .short('n') .value_name("NAME") - .takes_value(true) .required(true) .help("The name of the secret") ) @@ -492,7 +464,6 @@ pub fn app() -> Command<'static> { .long("name") .short('n') .value_name("NAME") - .takes_value(true) .required(true) .help("The name of the secret") ) @@ -505,7 +476,6 @@ pub fn app() -> Command<'static> { .long("name") .short('n') .value_name("NAME") - .takes_value(true) .required(true) .help("The name of the secret") ) @@ -514,7 +484,6 @@ pub fn app() -> Command<'static> { .long("delegate") .short('d') .value_name("PUBKEY") - .takes_value(true) .required(true) .help("The delegate to revoke approval from") ) @@ -537,7 +506,6 @@ pub fn app() -> Command<'static> { .long("id") .short('i') .value_name("ID") - .takes_value(true) .required(true) .help("The ID of the thread to be created"), ) @@ -546,7 +514,6 @@ pub fn app() -> Command<'static> { .long("kickoff_instruction") .short('k') .value_name("FILEPATH") - .takes_value(true) .required(true) .help("Filepath to a description of the kickoff instruction"), ) @@ -555,7 +522,6 @@ pub fn app() -> Command<'static> { .long("account") .short('a') .value_name("ADDRESS") - .takes_value(true) .help("An account-based trigger"), ) .arg( @@ -563,14 +529,12 @@ pub fn app() -> Command<'static> { .long("cron") .short('c') .value_name("SCHEDULE") - .takes_value(true) .help("A cron-based trigger"), ) .arg( Arg::new("immediate") .long("immediate") .short('m') - .takes_value(false) .help("An immediate trigger"), ) .group( @@ -586,7 +550,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The id of the thread to delete"), ), @@ -598,7 +561,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The label of the thread to lookup (only works if you \ are the signer of that thread)") @@ -607,7 +569,6 @@ pub fn app() -> Command<'static> { Arg::new("address") .short('k') .long("address") - .takes_value(true) .help("The address of the thread to lookup"), ) ) @@ -618,7 +579,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The id of the thread to pause"), ), @@ -627,7 +587,6 @@ pub fn app() -> Command<'static> { Command::new("resume").about("Resume a thread").arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The id of the thread to resume"), ), @@ -636,7 +595,6 @@ pub fn app() -> Command<'static> { Command::new("reset").about("Reset a thread").arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The id of the thread to stop"), ), @@ -648,7 +606,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(false) .help("The id of the thread to lookup"), ) @@ -656,7 +613,6 @@ pub fn app() -> Command<'static> { Arg::new("rate_limit") .long("rate_limit") .short('r') - .takes_value(true) .required(false) .help( "The maximum number of instructions this thread can execute per slot", @@ -666,7 +622,6 @@ pub fn app() -> Command<'static> { Arg::new("schedule") .long("schedule") .short('s') - .takes_value(true) .required(false) .help("The cron schedule of the thread"), ), @@ -695,7 +650,6 @@ pub fn app() -> Command<'static> { .long("body") .short('b') .value_name("VALUE") - .takes_value(true) .required(false) .help("The body of the request") ) @@ -704,7 +658,6 @@ pub fn app() -> Command<'static> { .long("id") .short('i') .value_name("ID") - .takes_value(true) .required(true) .help("The id of the webhook") ) @@ -713,7 +666,6 @@ pub fn app() -> Command<'static> { .long("method") .short('m') .value_name("GET|POST") - .takes_value(true) .required(true) .help("The http method to use") ) @@ -722,7 +674,6 @@ pub fn app() -> Command<'static> { .long("url") .short('u') .value_name("URL") - .takes_value(true) .required(true) .help("The url to send the webhook to") ) @@ -735,7 +686,6 @@ pub fn app() -> Command<'static> { .long("id") .short('i') .value_name("ID") - .takes_value(true) .required(true) .help("The id of the webhook") ) @@ -751,7 +701,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("signatory_keypair") .index(1) - .takes_value(true) .required(true) .help("Filepath to the worker's signatory keypair"), ), @@ -762,7 +711,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(true) .help("The ID of the worker to lookup"), ), @@ -773,7 +721,6 @@ pub fn app() -> Command<'static> { .arg( Arg::new("id") .index(1) - .takes_value(true) .required(true) .help("The ID of the worker to edit"), ) @@ -781,7 +728,6 @@ pub fn app() -> Command<'static> { Arg::new("signatory_keypair") .long("signatory_keypair") .short('k') - .takes_value(true) .required(false) .help("Filepath to the worker's new signatory keypair"), ), diff --git a/cli/src/deps.rs b/cli/src/deps.rs index 94078214..1b8abbbe 100644 --- a/cli/src/deps.rs +++ b/cli/src/deps.rs @@ -86,7 +86,7 @@ fn download_file(url: &str, dest: &Path) -> Result<()> { let pb = ProgressBar::new(response.content_length().unwrap_or(0)); pb.set_style(ProgressStyle::default_bar() - .template("{spinner:.green} 🚚 [{elapsed_precise}] [{bar:40.cyan/blue}] {bytes}/{total_bytes} ({eta})") + .template("{spinner:.green} 🚚 [{elapsed_precise}] [{bar:40.cyan/blue}] {bytes}/{total_bytes} ({eta})")? .progress_chars("#>-")); let mut source = pb.wrap_read(response); diff --git a/cli/src/parser.rs b/cli/src/parser.rs index 79c83d41..e4972fda 100644 --- a/cli/src/parser.rs +++ b/cli/src/parser.rs @@ -41,8 +41,8 @@ fn parse_bpf_command(matches: &ArgMatches) -> Result { let mut program_infos = Vec::::new(); let mut clone_addresses = Vec::::new(); - if let Some(values) = matches.values_of("bpf_program") { - let values: Vec<&str> = values.collect::>(); + if let Some(values) = matches.get_many::("bpf_program") { + let values: Vec<&String> = values.collect::>(); for address_program in values.chunks(2) { match address_program { [address, program] => { @@ -70,14 +70,9 @@ fn parse_bpf_command(matches: &ArgMatches) -> Result { } } - if let Some(values) = matches.values_of("clone") { - let values: Vec<&str> = values.collect::>(); - for value in values { - let address = value - .parse::() - .map_err(|_| CliError::InvalidAddress) - .unwrap(); - clone_addresses.push(address); + if let Some(values) = matches.get_many::("clone") { + for address in values { + clone_addresses.push(*address); } } @@ -85,10 +80,10 @@ fn parse_bpf_command(matches: &ArgMatches) -> Result { clone_addresses, network_url: parse_string("url", matches).ok(), program_infos, - force_init: matches.is_present("force_init"), + force_init: matches.contains_id("force_init"), solana_archive: parse_string("solana_archive", matches).ok(), clockwork_archive: parse_string("clockwork_archive", matches).ok(), - dev: matches.is_present("dev"), + dev: matches.contains_id("dev"), }) } @@ -278,18 +273,18 @@ fn parse_worker_command(matches: &ArgMatches) -> Result { // Arg parsers fn parse_trigger(matches: &ArgMatches) -> Result { - if matches.is_present("account") { + if matches.contains_id("account") { return Ok(Trigger::Account { address: parse_pubkey("address", matches)?, offset: 0, // TODO size: 32, // TODO }); - } else if matches.is_present("cron") { + } else if matches.contains_id("cron") { return Ok(Trigger::Cron { schedule: parse_string("cron", matches)?, skippable: true, }); - } else if matches.is_present("now") { + } else if matches.contains_id("now") { return Ok(Trigger::Now); } @@ -323,10 +318,10 @@ fn parse_pubkey(arg: &str, matches: &ArgMatches) -> Result { } fn parse_string(arg: &str, matches: &ArgMatches) -> Result { - Ok(matches - .value_of(arg) - .ok_or(CliError::BadParameter(arg.into()))? - .to_string()) + matches + .get_one::(arg) + .ok_or(CliError::BadParameter(arg.into())) + .cloned() } pub fn _parse_i64(arg: &str, matches: &ArgMatches) -> Result { diff --git a/utils/src/lib.rs b/utils/src/lib.rs index 1a02c909..bff23a93 100644 --- a/utils/src/lib.rs +++ b/utils/src/lib.rs @@ -6,6 +6,7 @@ pub mod thread; use std::fmt::{Debug, Display, Formatter}; use anchor_lang::{prelude::Pubkey, prelude::*, AnchorDeserialize}; +use base64::{engine::general_purpose::STANDARD, Engine}; /// Crate build information #[derive(AnchorDeserialize, AnchorSerialize, Clone, Debug)] @@ -53,7 +54,8 @@ where .strip_prefix(&preimage) .ok_or(ErrorCode::AccountDidNotDeserialize)?; - let decoded = base64::decode(get_return_data_base64) + let decoded = STANDARD + .decode(get_return_data_base64) .map_err(|_err| ErrorCode::AccountDidNotDeserialize)?; T::try_from_slice(&decoded).map_err(|_err| ErrorCode::AccountDidNotDeserialize)