From 8a14927cffd938489ccffa93dd678c2871a3afac Mon Sep 17 00:00:00 2001 From: Cam Swords Date: Tue, 19 Mar 2024 10:36:22 -0700 Subject: [PATCH] [move-2024] Add Move 2024 migration to `sui move` cli (#16696) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description What it says on the tin. Also a small bit of cleanup for `fetch_deps_only` on migration mode, which shouldn't even be an option there, ## Test Plan Local testing, plus 👀 --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [x] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes Move migration will be available --- crates/sui-move/src/lib.rs | 3 +++ crates/sui-move/src/migrate.rs | 20 +++++++++++++++++++ .../move/crates/move-cli/src/base/migrate.rs | 9 --------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 crates/sui-move/src/migrate.rs diff --git a/crates/sui-move/src/lib.rs b/crates/sui-move/src/lib.rs index 24831d1577b249..18f9f8444fdc7a 100644 --- a/crates/sui-move/src/lib.rs +++ b/crates/sui-move/src/lib.rs @@ -15,6 +15,7 @@ pub mod coverage; #[cfg(feature = "disassemble")] pub mod disassemble; pub mod manage_package; +pub mod migrate; pub mod new; #[cfg(feature = "unit_test")] pub mod unit_test; @@ -28,6 +29,7 @@ pub enum Command { #[cfg(feature = "disassemble")] Disassemble(disassemble::Disassemble), ManagePackage(manage_package::ManagePackage), + Migrate(migrate::Migrate), New(new::New), #[cfg(feature = "unit_test")] Test(unit_test::Test), @@ -56,6 +58,7 @@ pub fn execute_move_command( #[cfg(feature = "disassemble")] Command::Disassemble(c) => c.execute(package_path, build_config), Command::ManagePackage(c) => c.execute(package_path, build_config), + Command::Migrate(c) => c.execute(package_path, build_config), Command::New(c) => c.execute(package_path), #[cfg(feature = "unit_test")] diff --git a/crates/sui-move/src/migrate.rs b/crates/sui-move/src/migrate.rs new file mode 100644 index 00000000000000..63e88e07d96167 --- /dev/null +++ b/crates/sui-move/src/migrate.rs @@ -0,0 +1,20 @@ +// Copyright (c) Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + +use clap::Parser; +use move_cli::base::migrate; +use move_package::BuildConfig as MoveBuildConfig; +use std::path::PathBuf; + +#[derive(Parser)] +#[group(id = "sui-move-migrate")] +pub struct Migrate { + #[clap(flatten)] + pub migrate: migrate::Migrate, +} + +impl Migrate { + pub fn execute(self, path: Option, config: MoveBuildConfig) -> anyhow::Result<()> { + self.migrate.execute(path, config) + } +} diff --git a/external-crates/move/crates/move-cli/src/base/migrate.rs b/external-crates/move/crates/move-cli/src/base/migrate.rs index 2975de2f9842ea..911b67b88ae915 100644 --- a/external-crates/move/crates/move-cli/src/base/migrate.rs +++ b/external-crates/move/crates/move-cli/src/base/migrate.rs @@ -14,15 +14,6 @@ pub struct Migrate; impl Migrate { pub fn execute(self, path: Option, config: BuildConfig) -> anyhow::Result<()> { let rerooted_path = reroot_path(path)?; - if config.fetch_deps_only { - let mut config = config; - if config.test_mode { - config.dev_mode = true; - } - config.download_deps_for_package(&rerooted_path, &mut std::io::stdout())?; - return Ok(()); - } - config.migrate_package( &rerooted_path, &mut std::io::stdout(),