Skip to content

Commit

Permalink
cli: add verifiable option in deploy command (#2705)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoikurokawa authored Nov 19, 2023
1 parent d28414e commit c58d2f2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The minor version will be incremented upon a breaking change and the patch versi
### Features

- cli: Allow force `init` and `new` ([#2698](https://github.com/coral-xyz/anchor/pull/2698)).
- cli: Add verifiable option when `deploy` ([#2705](https://github.com/coral-xyz/anchor/pull/2705)).

### Fixes

Expand Down
10 changes: 8 additions & 2 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,10 +1257,16 @@ impl Program {
Ok(WithPath::new(file, path))
}

pub fn binary_path(&self) -> PathBuf {
pub fn binary_path(&self, verifiable: bool) -> PathBuf {
let path = if verifiable {
format!("target/verifiable/{}.so", self.lib_name)
} else {
format!("target/deploy/{}.so", self.lib_name)
};

std::env::current_dir()
.expect("Must have current dir")
.join(format!("target/deploy/{}.so", self.lib_name))
.join(path)
}
}

Expand Down
19 changes: 15 additions & 4 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ pub enum Command {
/// Keypair of the program (filepath) (requires program-name)
#[clap(long, requires = "program_name")]
program_keypair: Option<String>,
/// If true, deploy from path target/verifiable
#[clap(short, long)]
verifiable: bool,
},
/// Runs the deploy migration script.
Migrate,
Expand Down Expand Up @@ -691,7 +694,13 @@ fn process_command(opts: Opts) -> Result<()> {
Command::Deploy {
program_name,
program_keypair,
} => deploy(&opts.cfg_override, program_name, program_keypair),
verifiable,
} => deploy(
&opts.cfg_override,
program_name,
program_keypair,
verifiable,
),
Command::Expand {
program_name,
cargo_args,
Expand Down Expand Up @@ -3042,7 +3051,7 @@ fn test(
// In either case, skip the deploy if the user specifies.
let is_localnet = cfg.provider.cluster == Cluster::Localnet;
if (!is_localnet || skip_local_validator) && !skip_deploy {
deploy(cfg_override, None, None)?;
deploy(cfg_override, None, None, false)?;
}
let mut is_first_suite = true;
if cfg.scripts.get("test").is_some() {
Expand Down Expand Up @@ -3204,7 +3213,8 @@ fn validator_flags(

let mut flags = Vec::new();
for mut program in cfg.read_all_programs()? {
let binary_path = program.binary_path().display().to_string();
let verifiable = false;
let binary_path = program.binary_path(verifiable).display().to_string();

// Use the [programs.cluster] override and fallback to the keypair
// files if no override is given.
Expand Down Expand Up @@ -3574,6 +3584,7 @@ fn deploy(
cfg_override: &ConfigOverride,
program_name: Option<String>,
program_keypair: Option<String>,
verifiable: bool,
) -> Result<()> {
// Execute the code within the workspace
with_workspace(cfg_override, |cfg| {
Expand All @@ -3585,7 +3596,7 @@ fn deploy(
println!("Upgrade authority: {}", keypair);

for mut program in cfg.get_programs(program_name)? {
let binary_path = program.binary_path().display().to_string();
let binary_path = program.binary_path(verifiable).display().to_string();

println!("Deploying program {:?}...", program.lib_name);
println!("Program path: {}...", binary_path);
Expand Down

1 comment on commit c58d2f2

@vercel
Copy link

@vercel vercel bot commented on c58d2f2 Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anchor-docs – ./

anchor-docs-git-master-200ms.vercel.app
www.anchor-lang.com
anchor-docs-200ms.vercel.app
anchor-lang.com

Please sign in to comment.