-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add publish command and transaction types for Move module deployment
- Loading branch information
1 parent
a61775e
commit 031084f
Showing
9 changed files
with
214 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use move_package::{ | ||
compilation::compiled_package::CompiledPackage, | ||
BuildConfig | ||
}; | ||
use move_vm_test_utils::gas_schedule::CostTable; | ||
use std::path::PathBuf; | ||
use crate::sandbox::{ | ||
utils::on_disk_state_view::OnDiskStateView, | ||
commands::publish::publish, | ||
}; | ||
use crate::DEFAULT_STORAGE_DIR; | ||
|
||
#[derive(Parser)] | ||
pub struct Publish { | ||
/// Path to Move module | ||
#[clap(long)] | ||
pub module_path: PathBuf, | ||
|
||
/// Gas budget for deployment | ||
#[clap(long, default_value = "1000000")] | ||
pub gas_budget: u64, | ||
|
||
/// Module address | ||
#[clap(long)] | ||
pub address: Option<String>, | ||
|
||
/// Skip verification | ||
#[clap(long)] | ||
pub skip_verify: bool, | ||
} | ||
|
||
impl Publish { | ||
pub fn execute( | ||
self, | ||
path: Option<PathBuf>, | ||
config: BuildConfig, | ||
cost_table: &CostTable, | ||
) -> Result<()> { | ||
let package_path = path.unwrap_or_else(|| self.module_path.clone()); | ||
let storage_path = package_path.join(DEFAULT_STORAGE_DIR); | ||
|
||
let state = OnDiskStateView::create(&package_path, &storage_path)?; | ||
let package = compile_package(&package_path, config)?; | ||
|
||
publish( | ||
vec![], // natives | ||
cost_table, | ||
&state, | ||
&package, | ||
self.skip_verify, | ||
true, // with_deps | ||
true, // bundle | ||
None, // override_ordering | ||
false, // verbose | ||
) | ||
} | ||
} | ||
|
||
fn compile_package( | ||
path: &PathBuf, | ||
config: BuildConfig, | ||
) -> Result<CompiledPackage> { | ||
let build_config = BuildConfig { | ||
install_dir: Some(path.clone()), | ||
additional_named_addresses: config.additional_named_addresses, | ||
..BuildConfig::default() | ||
}; | ||
|
||
build_config.compile_package(path, &mut Vec::new()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.