chore: Bump non-solana dependencies (#2270)

* chore: Bump non-solana dependencies

* Fix project generation and client example

* Fix snake case project name

* Update lock file
This commit is contained in:
Jean Marchand (Exotic Markets) 2022-11-22 11:42:43 +01:00 committed by GitHub
parent fb6508addf
commit 89b047b21e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 396 additions and 392 deletions

56
Cargo.lock generated
View File

@ -194,13 +194,12 @@ dependencies = [
"anyhow",
"cargo_toml",
"chrono",
"clap 3.2.23",
"dirs 3.0.2",
"clap 4.0.26",
"dirs",
"flate2",
"heck 0.3.3",
"heck 0.4.0",
"pathdiff",
"portpicker",
"rand 0.7.3",
"reqwest",
"semver 1.0.14",
"serde",
@ -647,12 +646,11 @@ dependencies = [
[[package]]
name = "cargo_toml"
version = "0.9.2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3596addfb02dcdc06f5252ddda9f3785f9230f5827fb4284645240fa05ad92"
checksum = "aa0e3586af56b3bfa51fca452bd56e8dbbbd5d8d81cbf0b7e4e35b695b537eb8"
dependencies = [
"serde",
"serde_derive",
"toml",
]
@ -729,8 +727,7 @@ checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"clap_lex 0.2.4",
"indexmap",
"once_cell",
"strsim 0.10.0",
@ -739,10 +736,25 @@ dependencies = [
]
[[package]]
name = "clap_derive"
version = "3.2.18"
name = "clap"
version = "4.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex 0.3.0",
"once_cell",
"strsim 0.10.0",
"termcolor",
]
[[package]]
name = "clap_derive"
version = "4.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
dependencies = [
"heck 0.4.0",
"proc-macro-error",
@ -760,6 +772,15 @@ dependencies = [
"os_str_bytes",
]
[[package]]
name = "clap_lex"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
@ -1052,15 +1073,6 @@ dependencies = [
"subtle",
]
[[package]]
name = "dirs"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs"
version = "4.0.0"
@ -3200,7 +3212,7 @@ version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4"
dependencies = [
"dirs 4.0.0",
"dirs",
]
[[package]]

571
avm/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,10 +13,10 @@ name = "anchor"
path = "src/anchor/main.rs"
[dependencies]
clap = { version = "3.0.13", features = [ "derive" ]}
clap = { version = "4.0.26", features = [ "derive" ]}
cfg-if = "1.0.0"
anyhow = "1.0.32"
dirs = "1.0.5"
dirs = "4.0.0"
semver = "1.0.4"
serde = { version = "1.0.136", features = [ "derive" ]}
serde_json = "1.0.78"

View File

@ -15,12 +15,12 @@ pub struct Cli {
pub enum Commands {
#[clap(about = "Use a specific version of Anchor")]
Use {
#[clap(parse(try_from_str = parse_version))]
#[clap(value_parser = parse_version)]
version: Version,
},
#[clap(about = "Install a version of Anchor")]
Install {
#[clap(parse(try_from_str = parse_version))]
#[clap(value_parser = parse_version)]
version: Version,
#[clap(long)]
/// Flag to force installation even if the version
@ -29,7 +29,7 @@ pub enum Commands {
},
#[clap(about = "Uninstall a version of Anchor")]
Uninstall {
#[clap(parse(try_from_str = parse_version))]
#[clap(value_parser = parse_version)]
version: Version,
},
#[clap(about = "List available versions of Anchor")]

View File

@ -17,7 +17,7 @@ dev = []
default = []
[dependencies]
clap = { version = "3.0.13", features = ["derive"] }
clap = { version = "4.0.26", features = ["derive"] }
anyhow = "1.0.32"
syn = { version = "1.0.60", features = ["full", "extra-traits"] }
anchor-lang = { path = "../lang", version = "0.25.0" }
@ -33,15 +33,14 @@ solana-program = "1.13.3"
solana-client = "1.13.3"
solana-cli-config = "1.13.3"
solana-faucet = "1.13.3"
dirs = "3.0"
heck = "0.3.1"
dirs = "4.0"
heck = "0.4.0"
flate2 = "1.0.19"
rand = "0.7.3"
tar = "0.4.35"
reqwest = { version = "0.11.4", features = ["multipart", "blocking"] }
tokio = "1.0"
pathdiff = "0.2.0"
cargo_toml = "0.9.2"
cargo_toml = "0.13.0"
walkdir = "2.3.2"
chrono = "0.4.19"
portpicker = "0.1.1"

View File

@ -2,8 +2,8 @@ use crate::is_hidden;
use anchor_client::Cluster;
use anchor_syn::idl::Idl;
use anyhow::{anyhow, Context, Error, Result};
use clap::{ArgEnum, Parser};
use heck::SnakeCase;
use clap::{Parser, ValueEnum};
use heck::ToSnakeCase;
use serde::{Deserialize, Serialize};
use solana_cli_config::{Config as SolanaConfig, CONFIG_FILE};
use solana_sdk::pubkey::Pubkey;
@ -94,7 +94,7 @@ impl Manifest {
pub fn version(&self) -> String {
match &self.package {
Some(package) => package.version.to_string(),
Some(package) => package.version().to_string(),
_ => "0.0.0".to_string(),
}
}
@ -323,7 +323,7 @@ pub struct WorkspaceConfig {
pub types: String,
}
#[derive(ArgEnum, Parser, Clone, PartialEq, Eq, Debug)]
#[derive(ValueEnum, Parser, Clone, PartialEq, Eq, Debug)]
pub enum BootstrapMode {
None,
Debian,
@ -1047,7 +1047,7 @@ impl Program {
path,
));
}
let program_kp = Keypair::generate(&mut rand::rngs::OsRng);
let program_kp = Keypair::new();
let mut file = File::create(&path)
.with_context(|| format!("Error creating file with path: {}", path.display()))?;
file.write_all(format!("{:?}", &program_kp.to_bytes()).as_bytes())?;

View File

@ -12,8 +12,7 @@ use flate2::read::GzDecoder;
use flate2::read::ZlibDecoder;
use flate2::write::{GzEncoder, ZlibEncoder};
use flate2::Compression;
use heck::SnakeCase;
use rand::rngs::OsRng;
use heck::{ToKebabCase, ToSnakeCase};
use reqwest::blocking::multipart::{Form, Part};
use reqwest::blocking::Client;
use semver::{Version, VersionReq};
@ -97,15 +96,10 @@ pub enum Command {
docker_image: Option<String>,
/// Bootstrap docker image from scratch, installing all requirements for
/// verifiable builds. Only works for debian-based images.
#[clap(arg_enum, short, long, default_value = "none")]
#[clap(value_enum, short, long, default_value = "none")]
bootstrap: BootstrapMode,
/// Arguments to pass to the underlying `cargo build-bpf` command
#[clap(
required = false,
takes_value = true,
multiple_values = true,
last = true
)]
#[clap(required = false, last = true)]
cargo_args: Vec<String>,
/// Suppress doc strings in IDL output
#[clap(long)]
@ -122,12 +116,7 @@ pub enum Command {
#[clap(short, long)]
program_name: Option<String>,
/// Arguments to pass to the underlying `cargo expand` command
#[clap(
required = false,
takes_value = true,
multiple_values = true,
last = true
)]
#[clap(required = false, last = true)]
cargo_args: Vec<String>,
},
/// Verifies the on-chain bytecode matches the locally compiled artifact.
@ -147,15 +136,10 @@ pub enum Command {
docker_image: Option<String>,
/// Bootstrap docker image from scratch, installing all requirements for
/// verifiable builds. Only works for debian-based images.
#[clap(arg_enum, short, long, default_value = "none")]
#[clap(value_enum, short, long, default_value = "none")]
bootstrap: BootstrapMode,
/// Arguments to pass to the underlying `cargo build-bpf` command.
#[clap(
required = false,
takes_value = true,
multiple_values = true,
last = true
)]
#[clap(required = false, last = true)]
cargo_args: Vec<String>,
},
#[clap(name = "test", alias = "t")]
@ -181,15 +165,9 @@ pub enum Command {
/// to be able to check the transactions.
#[clap(long)]
detach: bool,
#[clap(multiple_values = true)]
args: Vec<String>,
/// Arguments to pass to the underlying `cargo build-bpf` command.
#[clap(
required = false,
takes_value = true,
multiple_values = true,
last = true
)]
#[clap(required = false, last = true)]
cargo_args: Vec<String>,
},
/// Creates a new program.
@ -241,12 +219,7 @@ pub enum Command {
/// The name of the script to run.
script: String,
/// Argument to pass to the underlying script.
#[clap(
required = false,
takes_value = true,
multiple_values = true,
last = true
)]
#[clap(required = false, last = true)]
script_args: Vec<String>,
},
/// Saves an api token from the registry locally.
@ -259,12 +232,7 @@ pub enum Command {
/// The name of the program to publish.
program: String,
/// Arguments to pass to the underlying `cargo build-bpf` command.
#[clap(
required = false,
takes_value = true,
multiple_values = true,
last = true
)]
#[clap(required = false, last = true)]
cargo_args: Vec<String>,
/// Flag to skip building the program in the workspace,
/// use this to save time when publishing the program
@ -291,12 +259,7 @@ pub enum Command {
#[clap(long)]
skip_lint: bool,
/// Arguments to pass to the underlying `cargo build-bpf` command.
#[clap(
required = false,
takes_value = true,
multiple_values = true,
last = true
)]
#[clap(required = false, last = true)]
cargo_args: Vec<String>,
},
}
@ -508,20 +471,28 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
return Err(anyhow!("Workspace already initialized"));
}
// We need to format different cases for the dir and the name
let rust_name = name.to_snake_case();
let project_name = if name == rust_name {
name
} else {
name.to_kebab_case()
};
// Additional keywords that have not been added to the `syn` crate as reserved words
// https://github.com/dtolnay/syn/pull/1098
let extra_keywords = ["async", "await", "try"];
// Anchor converts to snake case before writing the program name
if syn::parse_str::<syn::Ident>(&name.to_snake_case()).is_err()
|| extra_keywords.contains(&name.to_snake_case().as_str())
if syn::parse_str::<syn::Ident>(&rust_name).is_err()
|| extra_keywords.contains(&rust_name.as_str())
{
return Err(anyhow!(
"Anchor workspace name must be a valid Rust identifier. It may not be a Rust reserved word, start with a digit, or include certain disallowed characters. See https://doc.rust-lang.org/reference/identifiers.html for more detail.",
));
}
fs::create_dir(name.clone())?;
std::env::set_current_dir(&name)?;
fs::create_dir(&project_name)?;
std::env::set_current_dir(&project_name)?;
fs::create_dir("app")?;
let mut cfg = Config::default();
@ -536,7 +507,7 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
);
let mut localnet = BTreeMap::new();
localnet.insert(
name.to_snake_case(),
rust_name,
ProgramDeployment {
address: template::default_program_id(),
path: None,
@ -559,7 +530,7 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
// Build the program.
fs::create_dir("programs")?;
new_program(&name)?;
new_program(&project_name)?;
// Build the test suite.
fs::create_dir("tests")?;
@ -571,8 +542,8 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
let mut package_json = File::create("package.json")?;
package_json.write_all(template::package_json().as_bytes())?;
let mut mocha = File::create(&format!("tests/{}.js", name))?;
mocha.write_all(template::mocha(&name).as_bytes())?;
let mut mocha = File::create(&format!("tests/{}.js", &project_name))?;
mocha.write_all(template::mocha(&project_name).as_bytes())?;
let mut deploy = File::create("migrations/deploy.js")?;
deploy.write_all(template::deploy_script().as_bytes())?;
@ -587,8 +558,8 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
let mut deploy = File::create("migrations/deploy.ts")?;
deploy.write_all(template::ts_deploy_script().as_bytes())?;
let mut mocha = File::create(&format!("tests/{}.ts", name))?;
mocha.write_all(template::ts_mocha(&name).as_bytes())?;
let mut mocha = File::create(&format!("tests/{}.ts", &project_name))?;
mocha.write_all(template::ts_mocha(&project_name).as_bytes())?;
}
// Install node modules.
@ -620,7 +591,7 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
}
}
println!("{} initialized", name);
println!("{} initialized", project_name);
Ok(())
}
@ -2569,7 +2540,7 @@ fn create_idl_buffer(
let url = cluster_url(cfg, &cfg.test_validator);
let client = RpcClient::new(url);
let buffer = Keypair::generate(&mut OsRng);
let buffer = Keypair::new();
// Creates the new buffer account with the system program.
let create_account_ix = {
@ -3217,21 +3188,6 @@ mod tests {
.unwrap();
}
#[test]
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
fn test_init_invalid_ident_chars() {
init(
&ConfigOverride {
cluster: None,
wallet: None,
},
"project.name".to_string(),
true,
false,
)
.unwrap();
}
#[test]
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
fn test_init_starting_with_digit() {

View File

@ -2,7 +2,7 @@ use crate::config::ProgramWorkspace;
use crate::VERSION;
use anchor_syn::idl::Idl;
use anyhow::Result;
use heck::{CamelCase, MixedCase, SnakeCase};
use heck::{ToLowerCamelCase, ToSnakeCase, ToUpperCamelCase};
use solana_sdk::pubkey::Pubkey;
use std::fmt::Write;
@ -41,7 +41,7 @@ token = "{}"
pub fn idl_ts(idl: &Idl) -> Result<String> {
let mut idl = idl.clone();
for acc in idl.accounts.iter_mut() {
acc.name = acc.name.to_mixed_case();
acc.name = acc.name.to_lower_camel_case();
}
let idl_json = serde_json::to_string_pretty(&idl)?;
Ok(format!(
@ -49,9 +49,9 @@ pub fn idl_ts(idl: &Idl) -> Result<String> {
export const IDL: {} = {};
"#,
idl.name.to_camel_case(),
idl.name.to_upper_camel_case(),
idl_json,
idl.name.to_camel_case(),
idl.name.to_upper_camel_case(),
idl_json
))
}
@ -217,7 +217,7 @@ describe("{}", () => {{
}});
"#,
name,
name.to_camel_case(),
name.to_upper_camel_case(),
)
}
@ -287,11 +287,11 @@ describe("{}", () => {{
}});
}});
"#,
name.to_camel_case(),
name.to_upper_camel_case(),
name.to_snake_case(),
name,
name.to_camel_case(),
name.to_camel_case(),
name.to_upper_camel_case(),
name.to_upper_camel_case(),
)
}
@ -374,7 +374,7 @@ anchor.setProvider(provider);
r#"
anchor.workspace.{} = new anchor.Program({}, new PublicKey("{}"), provider);
"#,
program.name.to_camel_case(),
program.name.to_upper_camel_case(),
serde_json::to_string(&program.idl)?,
program.program_id
)?;

View File

@ -15,6 +15,5 @@ composite = { path = "../../tests/composite/programs/composite", features = ["no
events = { path = "../../tests/events/programs/events", features = ["no-entrypoint"] }
shellexpand = "2.1.0"
anyhow = "1.0.32"
rand = "0.7.3"
clap = { version = "3.0.0-rc.0", features = ["derive"] }
clap = { version = "4.0.26", features = ["derive"] }
solana-sdk = "1.13.3"

View File

@ -21,7 +21,6 @@ use clap::Parser;
use composite::accounts::{Bar, CompositeUpdate, Foo, Initialize};
use composite::instruction as composite_instruction;
use composite::{DummyA, DummyB};
use rand::rngs::OsRng;
use std::rc::Rc;
use std::time::Duration;
@ -72,8 +71,8 @@ fn composite(client: &Client, pid: Pubkey) -> Result<()> {
let program = client.program(pid);
// `Initialize` parameters.
let dummy_a = Keypair::generate(&mut OsRng);
let dummy_b = Keypair::generate(&mut OsRng);
let dummy_a = Keypair::new();
let dummy_b = Keypair::new();
// Build and send a transaction.
program
@ -142,7 +141,7 @@ fn basic_2(client: &Client, pid: Pubkey) -> Result<()> {
let program = client.program(pid);
// `Create` parameters.
let counter = Keypair::generate(&mut OsRng);
let counter = Keypair::new();
let authority = program.payer();
// Build and send a transaction.