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:
parent
fb6508addf
commit
89b047b21e
|
@ -194,13 +194,12 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap 3.2.23",
|
"clap 4.0.26",
|
||||||
"dirs 3.0.2",
|
"dirs",
|
||||||
"flate2",
|
"flate2",
|
||||||
"heck 0.3.3",
|
"heck 0.4.0",
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
"portpicker",
|
"portpicker",
|
||||||
"rand 0.7.3",
|
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"semver 1.0.14",
|
"semver 1.0.14",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -647,12 +646,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo_toml"
|
name = "cargo_toml"
|
||||||
version = "0.9.2"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c3596addfb02dcdc06f5252ddda9f3785f9230f5827fb4284645240fa05ad92"
|
checksum = "aa0e3586af56b3bfa51fca452bd56e8dbbbd5d8d81cbf0b7e4e35b695b537eb8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -729,8 +727,7 @@ checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"clap_derive",
|
"clap_lex 0.2.4",
|
||||||
"clap_lex",
|
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"strsim 0.10.0",
|
"strsim 0.10.0",
|
||||||
|
@ -739,10 +736,25 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap"
|
||||||
version = "3.2.18"
|
version = "4.0.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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 = [
|
dependencies = [
|
||||||
"heck 0.4.0",
|
"heck 0.4.0",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
|
@ -760,6 +772,15 @@ dependencies = [
|
||||||
"os_str_bytes",
|
"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]]
|
[[package]]
|
||||||
name = "codespan-reporting"
|
name = "codespan-reporting"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
@ -1052,15 +1073,6 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs"
|
|
||||||
version = "3.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
|
||||||
dependencies = [
|
|
||||||
"dirs-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "4.0.0"
|
version = "4.0.0"
|
||||||
|
@ -3200,7 +3212,7 @@ version = "2.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4"
|
checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs 4.0.0",
|
"dirs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,10 +13,10 @@ name = "anchor"
|
||||||
path = "src/anchor/main.rs"
|
path = "src/anchor/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.0.13", features = [ "derive" ]}
|
clap = { version = "4.0.26", features = [ "derive" ]}
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
anyhow = "1.0.32"
|
anyhow = "1.0.32"
|
||||||
dirs = "1.0.5"
|
dirs = "4.0.0"
|
||||||
semver = "1.0.4"
|
semver = "1.0.4"
|
||||||
serde = { version = "1.0.136", features = [ "derive" ]}
|
serde = { version = "1.0.136", features = [ "derive" ]}
|
||||||
serde_json = "1.0.78"
|
serde_json = "1.0.78"
|
||||||
|
|
|
@ -15,12 +15,12 @@ pub struct Cli {
|
||||||
pub enum Commands {
|
pub enum Commands {
|
||||||
#[clap(about = "Use a specific version of Anchor")]
|
#[clap(about = "Use a specific version of Anchor")]
|
||||||
Use {
|
Use {
|
||||||
#[clap(parse(try_from_str = parse_version))]
|
#[clap(value_parser = parse_version)]
|
||||||
version: Version,
|
version: Version,
|
||||||
},
|
},
|
||||||
#[clap(about = "Install a version of Anchor")]
|
#[clap(about = "Install a version of Anchor")]
|
||||||
Install {
|
Install {
|
||||||
#[clap(parse(try_from_str = parse_version))]
|
#[clap(value_parser = parse_version)]
|
||||||
version: Version,
|
version: Version,
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
/// Flag to force installation even if the version
|
/// Flag to force installation even if the version
|
||||||
|
@ -29,7 +29,7 @@ pub enum Commands {
|
||||||
},
|
},
|
||||||
#[clap(about = "Uninstall a version of Anchor")]
|
#[clap(about = "Uninstall a version of Anchor")]
|
||||||
Uninstall {
|
Uninstall {
|
||||||
#[clap(parse(try_from_str = parse_version))]
|
#[clap(value_parser = parse_version)]
|
||||||
version: Version,
|
version: Version,
|
||||||
},
|
},
|
||||||
#[clap(about = "List available versions of Anchor")]
|
#[clap(about = "List available versions of Anchor")]
|
||||||
|
|
|
@ -17,7 +17,7 @@ dev = []
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.0.13", features = ["derive"] }
|
clap = { version = "4.0.26", features = ["derive"] }
|
||||||
anyhow = "1.0.32"
|
anyhow = "1.0.32"
|
||||||
syn = { version = "1.0.60", features = ["full", "extra-traits"] }
|
syn = { version = "1.0.60", features = ["full", "extra-traits"] }
|
||||||
anchor-lang = { path = "../lang", version = "0.25.0" }
|
anchor-lang = { path = "../lang", version = "0.25.0" }
|
||||||
|
@ -33,15 +33,14 @@ solana-program = "1.13.3"
|
||||||
solana-client = "1.13.3"
|
solana-client = "1.13.3"
|
||||||
solana-cli-config = "1.13.3"
|
solana-cli-config = "1.13.3"
|
||||||
solana-faucet = "1.13.3"
|
solana-faucet = "1.13.3"
|
||||||
dirs = "3.0"
|
dirs = "4.0"
|
||||||
heck = "0.3.1"
|
heck = "0.4.0"
|
||||||
flate2 = "1.0.19"
|
flate2 = "1.0.19"
|
||||||
rand = "0.7.3"
|
|
||||||
tar = "0.4.35"
|
tar = "0.4.35"
|
||||||
reqwest = { version = "0.11.4", features = ["multipart", "blocking"] }
|
reqwest = { version = "0.11.4", features = ["multipart", "blocking"] }
|
||||||
tokio = "1.0"
|
tokio = "1.0"
|
||||||
pathdiff = "0.2.0"
|
pathdiff = "0.2.0"
|
||||||
cargo_toml = "0.9.2"
|
cargo_toml = "0.13.0"
|
||||||
walkdir = "2.3.2"
|
walkdir = "2.3.2"
|
||||||
chrono = "0.4.19"
|
chrono = "0.4.19"
|
||||||
portpicker = "0.1.1"
|
portpicker = "0.1.1"
|
||||||
|
|
|
@ -2,8 +2,8 @@ use crate::is_hidden;
|
||||||
use anchor_client::Cluster;
|
use anchor_client::Cluster;
|
||||||
use anchor_syn::idl::Idl;
|
use anchor_syn::idl::Idl;
|
||||||
use anyhow::{anyhow, Context, Error, Result};
|
use anyhow::{anyhow, Context, Error, Result};
|
||||||
use clap::{ArgEnum, Parser};
|
use clap::{Parser, ValueEnum};
|
||||||
use heck::SnakeCase;
|
use heck::ToSnakeCase;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_cli_config::{Config as SolanaConfig, CONFIG_FILE};
|
use solana_cli_config::{Config as SolanaConfig, CONFIG_FILE};
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
@ -94,7 +94,7 @@ impl Manifest {
|
||||||
|
|
||||||
pub fn version(&self) -> String {
|
pub fn version(&self) -> String {
|
||||||
match &self.package {
|
match &self.package {
|
||||||
Some(package) => package.version.to_string(),
|
Some(package) => package.version().to_string(),
|
||||||
_ => "0.0.0".to_string(),
|
_ => "0.0.0".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ pub struct WorkspaceConfig {
|
||||||
pub types: String,
|
pub types: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ArgEnum, Parser, Clone, PartialEq, Eq, Debug)]
|
#[derive(ValueEnum, Parser, Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum BootstrapMode {
|
pub enum BootstrapMode {
|
||||||
None,
|
None,
|
||||||
Debian,
|
Debian,
|
||||||
|
@ -1047,7 +1047,7 @@ impl Program {
|
||||||
path,
|
path,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let program_kp = Keypair::generate(&mut rand::rngs::OsRng);
|
let program_kp = Keypair::new();
|
||||||
let mut file = File::create(&path)
|
let mut file = File::create(&path)
|
||||||
.with_context(|| format!("Error creating file with path: {}", path.display()))?;
|
.with_context(|| format!("Error creating file with path: {}", path.display()))?;
|
||||||
file.write_all(format!("{:?}", &program_kp.to_bytes()).as_bytes())?;
|
file.write_all(format!("{:?}", &program_kp.to_bytes()).as_bytes())?;
|
||||||
|
|
104
cli/src/lib.rs
104
cli/src/lib.rs
|
@ -12,8 +12,7 @@ use flate2::read::GzDecoder;
|
||||||
use flate2::read::ZlibDecoder;
|
use flate2::read::ZlibDecoder;
|
||||||
use flate2::write::{GzEncoder, ZlibEncoder};
|
use flate2::write::{GzEncoder, ZlibEncoder};
|
||||||
use flate2::Compression;
|
use flate2::Compression;
|
||||||
use heck::SnakeCase;
|
use heck::{ToKebabCase, ToSnakeCase};
|
||||||
use rand::rngs::OsRng;
|
|
||||||
use reqwest::blocking::multipart::{Form, Part};
|
use reqwest::blocking::multipart::{Form, Part};
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use semver::{Version, VersionReq};
|
use semver::{Version, VersionReq};
|
||||||
|
@ -97,15 +96,10 @@ pub enum Command {
|
||||||
docker_image: Option<String>,
|
docker_image: Option<String>,
|
||||||
/// Bootstrap docker image from scratch, installing all requirements for
|
/// Bootstrap docker image from scratch, installing all requirements for
|
||||||
/// verifiable builds. Only works for debian-based images.
|
/// 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,
|
bootstrap: BootstrapMode,
|
||||||
/// Arguments to pass to the underlying `cargo build-bpf` command
|
/// Arguments to pass to the underlying `cargo build-bpf` command
|
||||||
#[clap(
|
#[clap(required = false, last = true)]
|
||||||
required = false,
|
|
||||||
takes_value = true,
|
|
||||||
multiple_values = true,
|
|
||||||
last = true
|
|
||||||
)]
|
|
||||||
cargo_args: Vec<String>,
|
cargo_args: Vec<String>,
|
||||||
/// Suppress doc strings in IDL output
|
/// Suppress doc strings in IDL output
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
@ -122,12 +116,7 @@ pub enum Command {
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
program_name: Option<String>,
|
program_name: Option<String>,
|
||||||
/// Arguments to pass to the underlying `cargo expand` command
|
/// Arguments to pass to the underlying `cargo expand` command
|
||||||
#[clap(
|
#[clap(required = false, last = true)]
|
||||||
required = false,
|
|
||||||
takes_value = true,
|
|
||||||
multiple_values = true,
|
|
||||||
last = true
|
|
||||||
)]
|
|
||||||
cargo_args: Vec<String>,
|
cargo_args: Vec<String>,
|
||||||
},
|
},
|
||||||
/// Verifies the on-chain bytecode matches the locally compiled artifact.
|
/// Verifies the on-chain bytecode matches the locally compiled artifact.
|
||||||
|
@ -147,15 +136,10 @@ pub enum Command {
|
||||||
docker_image: Option<String>,
|
docker_image: Option<String>,
|
||||||
/// Bootstrap docker image from scratch, installing all requirements for
|
/// Bootstrap docker image from scratch, installing all requirements for
|
||||||
/// verifiable builds. Only works for debian-based images.
|
/// 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,
|
bootstrap: BootstrapMode,
|
||||||
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
||||||
#[clap(
|
#[clap(required = false, last = true)]
|
||||||
required = false,
|
|
||||||
takes_value = true,
|
|
||||||
multiple_values = true,
|
|
||||||
last = true
|
|
||||||
)]
|
|
||||||
cargo_args: Vec<String>,
|
cargo_args: Vec<String>,
|
||||||
},
|
},
|
||||||
#[clap(name = "test", alias = "t")]
|
#[clap(name = "test", alias = "t")]
|
||||||
|
@ -181,15 +165,9 @@ pub enum Command {
|
||||||
/// to be able to check the transactions.
|
/// to be able to check the transactions.
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
detach: bool,
|
detach: bool,
|
||||||
#[clap(multiple_values = true)]
|
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
||||||
#[clap(
|
#[clap(required = false, last = true)]
|
||||||
required = false,
|
|
||||||
takes_value = true,
|
|
||||||
multiple_values = true,
|
|
||||||
last = true
|
|
||||||
)]
|
|
||||||
cargo_args: Vec<String>,
|
cargo_args: Vec<String>,
|
||||||
},
|
},
|
||||||
/// Creates a new program.
|
/// Creates a new program.
|
||||||
|
@ -241,12 +219,7 @@ pub enum Command {
|
||||||
/// The name of the script to run.
|
/// The name of the script to run.
|
||||||
script: String,
|
script: String,
|
||||||
/// Argument to pass to the underlying script.
|
/// Argument to pass to the underlying script.
|
||||||
#[clap(
|
#[clap(required = false, last = true)]
|
||||||
required = false,
|
|
||||||
takes_value = true,
|
|
||||||
multiple_values = true,
|
|
||||||
last = true
|
|
||||||
)]
|
|
||||||
script_args: Vec<String>,
|
script_args: Vec<String>,
|
||||||
},
|
},
|
||||||
/// Saves an api token from the registry locally.
|
/// Saves an api token from the registry locally.
|
||||||
|
@ -259,12 +232,7 @@ pub enum Command {
|
||||||
/// The name of the program to publish.
|
/// The name of the program to publish.
|
||||||
program: String,
|
program: String,
|
||||||
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
||||||
#[clap(
|
#[clap(required = false, last = true)]
|
||||||
required = false,
|
|
||||||
takes_value = true,
|
|
||||||
multiple_values = true,
|
|
||||||
last = true
|
|
||||||
)]
|
|
||||||
cargo_args: Vec<String>,
|
cargo_args: Vec<String>,
|
||||||
/// Flag to skip building the program in the workspace,
|
/// Flag to skip building the program in the workspace,
|
||||||
/// use this to save time when publishing the program
|
/// use this to save time when publishing the program
|
||||||
|
@ -291,12 +259,7 @@ pub enum Command {
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
skip_lint: bool,
|
skip_lint: bool,
|
||||||
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
/// Arguments to pass to the underlying `cargo build-bpf` command.
|
||||||
#[clap(
|
#[clap(required = false, last = true)]
|
||||||
required = false,
|
|
||||||
takes_value = true,
|
|
||||||
multiple_values = true,
|
|
||||||
last = true
|
|
||||||
)]
|
|
||||||
cargo_args: Vec<String>,
|
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"));
|
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
|
// Additional keywords that have not been added to the `syn` crate as reserved words
|
||||||
// https://github.com/dtolnay/syn/pull/1098
|
// https://github.com/dtolnay/syn/pull/1098
|
||||||
let extra_keywords = ["async", "await", "try"];
|
let extra_keywords = ["async", "await", "try"];
|
||||||
// Anchor converts to snake case before writing the program name
|
// Anchor converts to snake case before writing the program name
|
||||||
if syn::parse_str::<syn::Ident>(&name.to_snake_case()).is_err()
|
if syn::parse_str::<syn::Ident>(&rust_name).is_err()
|
||||||
|| extra_keywords.contains(&name.to_snake_case().as_str())
|
|| extra_keywords.contains(&rust_name.as_str())
|
||||||
{
|
{
|
||||||
return Err(anyhow!(
|
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.",
|
"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())?;
|
fs::create_dir(&project_name)?;
|
||||||
std::env::set_current_dir(&name)?;
|
std::env::set_current_dir(&project_name)?;
|
||||||
fs::create_dir("app")?;
|
fs::create_dir("app")?;
|
||||||
|
|
||||||
let mut cfg = Config::default();
|
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();
|
let mut localnet = BTreeMap::new();
|
||||||
localnet.insert(
|
localnet.insert(
|
||||||
name.to_snake_case(),
|
rust_name,
|
||||||
ProgramDeployment {
|
ProgramDeployment {
|
||||||
address: template::default_program_id(),
|
address: template::default_program_id(),
|
||||||
path: None,
|
path: None,
|
||||||
|
@ -559,7 +530,7 @@ fn init(cfg_override: &ConfigOverride, name: String, javascript: bool, no_git: b
|
||||||
// Build the program.
|
// Build the program.
|
||||||
fs::create_dir("programs")?;
|
fs::create_dir("programs")?;
|
||||||
|
|
||||||
new_program(&name)?;
|
new_program(&project_name)?;
|
||||||
|
|
||||||
// Build the test suite.
|
// Build the test suite.
|
||||||
fs::create_dir("tests")?;
|
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")?;
|
let mut package_json = File::create("package.json")?;
|
||||||
package_json.write_all(template::package_json().as_bytes())?;
|
package_json.write_all(template::package_json().as_bytes())?;
|
||||||
|
|
||||||
let mut mocha = File::create(&format!("tests/{}.js", name))?;
|
let mut mocha = File::create(&format!("tests/{}.js", &project_name))?;
|
||||||
mocha.write_all(template::mocha(&name).as_bytes())?;
|
mocha.write_all(template::mocha(&project_name).as_bytes())?;
|
||||||
|
|
||||||
let mut deploy = File::create("migrations/deploy.js")?;
|
let mut deploy = File::create("migrations/deploy.js")?;
|
||||||
deploy.write_all(template::deploy_script().as_bytes())?;
|
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")?;
|
let mut deploy = File::create("migrations/deploy.ts")?;
|
||||||
deploy.write_all(template::ts_deploy_script().as_bytes())?;
|
deploy.write_all(template::ts_deploy_script().as_bytes())?;
|
||||||
|
|
||||||
let mut mocha = File::create(&format!("tests/{}.ts", name))?;
|
let mut mocha = File::create(&format!("tests/{}.ts", &project_name))?;
|
||||||
mocha.write_all(template::ts_mocha(&name).as_bytes())?;
|
mocha.write_all(template::ts_mocha(&project_name).as_bytes())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install node modules.
|
// 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -2569,7 +2540,7 @@ fn create_idl_buffer(
|
||||||
let url = cluster_url(cfg, &cfg.test_validator);
|
let url = cluster_url(cfg, &cfg.test_validator);
|
||||||
let client = RpcClient::new(url);
|
let client = RpcClient::new(url);
|
||||||
|
|
||||||
let buffer = Keypair::generate(&mut OsRng);
|
let buffer = Keypair::new();
|
||||||
|
|
||||||
// Creates the new buffer account with the system program.
|
// Creates the new buffer account with the system program.
|
||||||
let create_account_ix = {
|
let create_account_ix = {
|
||||||
|
@ -3217,21 +3188,6 @@ mod tests {
|
||||||
.unwrap();
|
.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]
|
#[test]
|
||||||
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
|
#[should_panic(expected = "Anchor workspace name must be a valid Rust identifier.")]
|
||||||
fn test_init_starting_with_digit() {
|
fn test_init_starting_with_digit() {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::config::ProgramWorkspace;
|
||||||
use crate::VERSION;
|
use crate::VERSION;
|
||||||
use anchor_syn::idl::Idl;
|
use anchor_syn::idl::Idl;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use heck::{CamelCase, MixedCase, SnakeCase};
|
use heck::{ToLowerCamelCase, ToSnakeCase, ToUpperCamelCase};
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ token = "{}"
|
||||||
pub fn idl_ts(idl: &Idl) -> Result<String> {
|
pub fn idl_ts(idl: &Idl) -> Result<String> {
|
||||||
let mut idl = idl.clone();
|
let mut idl = idl.clone();
|
||||||
for acc in idl.accounts.iter_mut() {
|
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)?;
|
let idl_json = serde_json::to_string_pretty(&idl)?;
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
|
@ -49,9 +49,9 @@ pub fn idl_ts(idl: &Idl) -> Result<String> {
|
||||||
|
|
||||||
export const IDL: {} = {};
|
export const IDL: {} = {};
|
||||||
"#,
|
"#,
|
||||||
idl.name.to_camel_case(),
|
idl.name.to_upper_camel_case(),
|
||||||
idl_json,
|
idl_json,
|
||||||
idl.name.to_camel_case(),
|
idl.name.to_upper_camel_case(),
|
||||||
idl_json
|
idl_json
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ describe("{}", () => {{
|
||||||
}});
|
}});
|
||||||
"#,
|
"#,
|
||||||
name,
|
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.to_snake_case(),
|
||||||
name,
|
name,
|
||||||
name.to_camel_case(),
|
name.to_upper_camel_case(),
|
||||||
name.to_camel_case(),
|
name.to_upper_camel_case(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ anchor.setProvider(provider);
|
||||||
r#"
|
r#"
|
||||||
anchor.workspace.{} = new anchor.Program({}, new PublicKey("{}"), provider);
|
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)?,
|
serde_json::to_string(&program.idl)?,
|
||||||
program.program_id
|
program.program_id
|
||||||
)?;
|
)?;
|
||||||
|
|
|
@ -15,6 +15,5 @@ composite = { path = "../../tests/composite/programs/composite", features = ["no
|
||||||
events = { path = "../../tests/events/programs/events", features = ["no-entrypoint"] }
|
events = { path = "../../tests/events/programs/events", features = ["no-entrypoint"] }
|
||||||
shellexpand = "2.1.0"
|
shellexpand = "2.1.0"
|
||||||
anyhow = "1.0.32"
|
anyhow = "1.0.32"
|
||||||
rand = "0.7.3"
|
clap = { version = "4.0.26", features = ["derive"] }
|
||||||
clap = { version = "3.0.0-rc.0", features = ["derive"] }
|
|
||||||
solana-sdk = "1.13.3"
|
solana-sdk = "1.13.3"
|
||||||
|
|
|
@ -21,7 +21,6 @@ use clap::Parser;
|
||||||
use composite::accounts::{Bar, CompositeUpdate, Foo, Initialize};
|
use composite::accounts::{Bar, CompositeUpdate, Foo, Initialize};
|
||||||
use composite::instruction as composite_instruction;
|
use composite::instruction as composite_instruction;
|
||||||
use composite::{DummyA, DummyB};
|
use composite::{DummyA, DummyB};
|
||||||
use rand::rngs::OsRng;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
@ -72,8 +71,8 @@ fn composite(client: &Client, pid: Pubkey) -> Result<()> {
|
||||||
let program = client.program(pid);
|
let program = client.program(pid);
|
||||||
|
|
||||||
// `Initialize` parameters.
|
// `Initialize` parameters.
|
||||||
let dummy_a = Keypair::generate(&mut OsRng);
|
let dummy_a = Keypair::new();
|
||||||
let dummy_b = Keypair::generate(&mut OsRng);
|
let dummy_b = Keypair::new();
|
||||||
|
|
||||||
// Build and send a transaction.
|
// Build and send a transaction.
|
||||||
program
|
program
|
||||||
|
@ -142,7 +141,7 @@ fn basic_2(client: &Client, pid: Pubkey) -> Result<()> {
|
||||||
let program = client.program(pid);
|
let program = client.program(pid);
|
||||||
|
|
||||||
// `Create` parameters.
|
// `Create` parameters.
|
||||||
let counter = Keypair::generate(&mut OsRng);
|
let counter = Keypair::new();
|
||||||
let authority = program.payer();
|
let authority = program.payer();
|
||||||
|
|
||||||
// Build and send a transaction.
|
// Build and send a transaction.
|
||||||
|
|
Loading…
Reference in New Issue