diff --git a/crates/aptos/src/governance/mod.rs b/crates/aptos/src/governance/mod.rs index 60a2817d62fa8..8b559769ee474 100644 --- a/crates/aptos/src/governance/mod.rs +++ b/crates/aptos/src/governance/mod.rs @@ -890,14 +890,14 @@ pub struct CompileScriptFunction { pub compiled_script_path: Option, #[clap(flatten)] - pub(crate) framework_package_args: FrameworkPackageArgs, + pub framework_package_args: FrameworkPackageArgs, //////// 0L //////// make public #[clap(long)] - pub(crate) bytecode_version: Option, + pub bytecode_version: Option, //////// 0L //////// make public } impl CompileScriptFunction { - pub(crate) fn compile( + pub fn compile( //////// 0L //////// &self, script_name: &str, prompt_options: PromptOptions, diff --git a/crates/aptos/src/move_tool/mod.rs b/crates/aptos/src/move_tool/mod.rs index f79cf5d81f684..2a370cec30a0d 100644 --- a/crates/aptos/src/move_tool/mod.rs +++ b/crates/aptos/src/move_tool/mod.rs @@ -137,13 +137,13 @@ pub struct FrameworkPackageArgs { /// /// This is mutually exclusive with `--framework-local-dir` #[clap(long, group = "framework_package_args")] - pub(crate) framework_git_rev: Option, + pub framework_git_rev: Option, //////// 0L //////// make public /// Local framework directory for the Aptos framework /// /// This is mutually exclusive with `--framework-git-rev` - #[clap(long, value_parser, group = "framework_package_args")] - pub(crate) framework_local_dir: Option, + #[clap(long, parse(from_os_str), group = "framework_package_args")] + pub framework_local_dir: Option, //////// 0L //////// make public /// Skip pulling the latest git dependencies /// @@ -151,7 +151,7 @@ pub struct FrameworkPackageArgs { /// to no ability to pull git dependencies. This will allow overriding /// this for local development. #[clap(long)] - pub(crate) skip_fetch_latest_git_deps: bool, + pub skip_fetch_latest_git_deps: bool, //////// 0L //////// make public } impl FrameworkPackageArgs { @@ -231,6 +231,59 @@ impl FrameworkPackageArgs { } } +//////// 0L //////// +/// create a move directory with a manifest and a source file +/// this is used to create scripts temporarily that need to be compiled before +/// we can get the sha3 hash of the script "execution_hash" +pub fn init_move_dir_generic( + package_dir: &Path, // path to the .move script + name: &str, // name of the script + // addresses: BTreeMap, + // prompt_options: PromptOptions, + framework_name: String, + framework_local_dir: PathBuf, + +) -> CliTypedResult<()> { + let prompt_options = PromptOptions::yes(); + let move_toml = package_dir.join(SourcePackageLayout::Manifest.path()); + check_if_file_exists(move_toml.as_path(), prompt_options)?; + create_dir_if_not_exist( + package_dir + .join(SourcePackageLayout::Sources.path()) + .as_path(), + )?; + + // Add the framework dependency if it's provided + let mut dependencies = BTreeMap::new(); + + dependencies.insert(framework_name, Dependency { + local: Some(framework_local_dir.display().to_string()), + git: None, + rev: None, + subdir: None, + aptos: None, + address: None, + }); + + let manifest = MovePackageManifest { + package: PackageInfo { + name: name.to_string(), + version: "1.0.0".to_string(), + author: None, + }, + addresses: BTreeMap::new(), + dependencies, + }; + + write_to_file( + move_toml.as_path(), + SourcePackageLayout::Manifest.location_str(), + toml::to_string_pretty(&manifest) + .map_err(|err| CliError::UnexpectedError(err.to_string()))? + .as_bytes(), + ) +} + /// Creates a new Move package at the given location /// /// This will create a directory for a Move package and a corresponding diff --git a/testsuite/smoke-test/src/smoke_test_environment.rs b/testsuite/smoke-test/src/smoke_test_environment.rs index e5db1a1d0bdd1..d2e743589e432 100644 --- a/testsuite/smoke-test/src/smoke_test_environment.rs +++ b/testsuite/smoke-test/src/smoke_test_environment.rs @@ -174,6 +174,22 @@ pub async fn new_local_swarm_with_aptos(num_validators: usize) -> LocalSwarm { .await } +//////// 0L //////// +pub async fn new_local_swarm_with_release(num_validators: usize, release: ReleaseBundle) -> LocalSwarm { + let mut sw = SwarmBuilder { + local: true, + num_validators: NonZeroUsize::new(num_validators).unwrap(), + num_fullnodes: 0, + genesis_framework: Some(release), + init_config: None, + vfn_config: None, + init_genesis_config: None, + }; + + sw.build().await +} +//////// end 0L //////// + #[tokio::test] async fn test_prevent_starting_nodes_twice() { // Create a validator swarm of 1 validator node