diff --git a/extensions/sns/e2e/tests/sns.bash b/extensions/sns/e2e/tests/sns.bash index 0daf020..b2813ab 100755 --- a/extensions/sns/e2e/tests/sns.bash +++ b/extensions/sns/e2e/tests/sns.bash @@ -69,6 +69,8 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" dfx nns install echo "===== 7 =====" dfx nns import + echo "===== 8 =====" + dfx sns import echo "===== 9 =====" ls candid echo "===== 10 =====" diff --git a/extensions/sns/src/commands/download.rs b/extensions/sns/src/commands/download.rs index 8d56225..9475b6f 100644 --- a/extensions/sns/src/commands/download.rs +++ b/extensions/sns/src/commands/download.rs @@ -18,13 +18,12 @@ pub struct SnsDownloadOpts { } /// Executes the command line `dfx sns import`. -pub fn exec(opts: SnsDownloadOpts, dfx_cache_path: &Path) -> anyhow::Result<()> { - let runtime = Runtime::new().expect("Unable to create a runtime"); +pub async fn exec(opts: SnsDownloadOpts, dfx_cache_path: &Path) -> anyhow::Result<()> { let ic_commit = if let Some(ic_commit) = opts.ic_commit { ic_commit } else { replica_rev(dfx_cache_path)? }; - runtime.block_on(download_sns_wasms(&ic_commit, &opts.wasms_dir))?; + download_sns_wasms(&ic_commit, &opts.wasms_dir).await?; Ok(()) } diff --git a/extensions/sns/src/commands/import.rs b/extensions/sns/src/commands/import.rs index 1a78023..a3ccc8f 100644 --- a/extensions/sns/src/commands/import.rs +++ b/extensions/sns/src/commands/import.rs @@ -7,7 +7,6 @@ use dfx_extensions_utils::{ }; use clap::Parser; -use tokio::runtime::Runtime; /// Imports the sns canisters #[derive(Parser)] @@ -23,7 +22,7 @@ pub struct SnsImportOpts { } /// Executes the command line `dfx sns import`. -pub fn exec(opts: SnsImportOpts, dfx_cache_path: &Path) -> anyhow::Result<()> { +pub async fn exec(opts: SnsImportOpts, dfx_cache_path: &Path) -> anyhow::Result<()> { let config = Config::from_current_dir(None)?; if config.is_none() { anyhow::bail!(crate::errors::DFXJSON_NOT_FOUND); @@ -33,7 +32,6 @@ pub fn exec(opts: SnsImportOpts, dfx_cache_path: &Path) -> anyhow::Result<()> { let network_mappings = get_network_mappings(&opts.network_mapping)?; - let runtime = Runtime::new().expect("Unable to create a runtime"); let ic_commit = if let Ok(v) = std::env::var("DFX_IC_COMMIT") { v } else { @@ -41,13 +39,14 @@ pub fn exec(opts: SnsImportOpts, dfx_cache_path: &Path) -> anyhow::Result<()> { }; let their_dfx_json_location = format!("https://raw.githubusercontent.com/dfinity/ic/{ic_commit}/rs/sns/cli/dfx.json"); - runtime.block_on(import_canister_definitions( + import_canister_definitions( &logger, &mut config, &their_dfx_json_location, None, None, &network_mappings, - ))?; + ) + .await?; Ok(()) } diff --git a/extensions/sns/src/main.rs b/extensions/sns/src/main.rs index a1e51ec..3fd897b 100644 --- a/extensions/sns/src/main.rs +++ b/extensions/sns/src/main.rs @@ -103,7 +103,7 @@ async fn main() -> anyhow::Result<()> { "Missing path to dfx cache. Pass it as CLI argument: `--dfx-cache-path=PATH`", ) })?; - return commands::import::exec(v, dfx_cache_path); + return commands::import::exec(v, dfx_cache_path).await; } SubCommand::Download(v) => { let dfx_cache_path = &opts.dfx_cache_path.ok_or_else(|| { @@ -111,7 +111,7 @@ async fn main() -> anyhow::Result<()> { "Missing path to dfx cache. Pass it as CLI argument: `--dfx-cache-path=PATH`", ) })?; - return commands::download::exec(v, dfx_cache_path); + return commands::download::exec(v, dfx_cache_path).await; } };