From 64fa43c6551bc5fe4eff2676723f066ccb4e12cd Mon Sep 17 00:00:00 2001 From: glihm Date: Mon, 8 Apr 2024 23:30:56 -0400 Subject: [PATCH] fix: add the transaction options to sozo migrate apply (#1802) * fix: add the transaction options to sozo migrate apply * Delete crates/sozo/ops/src/account.rs --- bin/sozo/src/commands/migrate.rs | 23 ++++++++++++++++++++--- crates/sozo/ops/src/migration/mod.rs | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index f21166692e..c142378802 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -2,6 +2,7 @@ use anyhow::{anyhow, Context, Result}; use clap::{Args, Subcommand}; use dojo_lang::compiler::MANIFESTS_DIR; use dojo_world::metadata::{dojo_metadata_from_workspace, Environment}; +use dojo_world::migration::TxConfig; use katana_rpc_api::starknet::RPC_SPEC_VERSION; use scarb::core::{Config, Workspace}; use sozo_ops::migration; @@ -14,6 +15,7 @@ use starknet::signers::LocalWallet; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; +use super::options::transaction::TransactionOptions; use super::options::world::WorldOptions; #[derive(Debug, Args)] @@ -57,6 +59,9 @@ pub enum MigrateCommand { #[command(flatten)] account: AccountOptions, + + #[command(flatten)] + transaction: TransactionOptions, }, } @@ -150,10 +155,13 @@ impl MigrateArgs { ) .await?; - migration::migrate(&ws, world_address, chain_id, &account, name, true).await + migration::migrate(&ws, world_address, chain_id, &account, name, true, None) + .await }) } - MigrateCommand::Apply { mut name, world, starknet, account } => { + MigrateCommand::Apply { mut name, world, starknet, account, transaction } => { + let txn_config: Option = Some(transaction.into()); + if name.is_none() { if let Some(root_package) = ws.root_package() { name = Some(root_package.id.name.to_string()) @@ -171,7 +179,16 @@ impl MigrateArgs { ) .await?; - migration::migrate(&ws, world_address, chain_id, &account, name, false).await + migration::migrate( + &ws, + world_address, + chain_id, + &account, + name, + false, + txn_config, + ) + .await }) } } diff --git a/crates/sozo/ops/src/migration/mod.rs b/crates/sozo/ops/src/migration/mod.rs index 9383298d73..d237be073f 100644 --- a/crates/sozo/ops/src/migration/mod.rs +++ b/crates/sozo/ops/src/migration/mod.rs @@ -60,6 +60,7 @@ pub async fn migrate( account: &SingleOwnerAccount, name: Option, dry_run: bool, + txn_config: Option, ) -> Result<()> where P: Provider + Sync + Send + 'static, @@ -118,7 +119,7 @@ where .await?; } else { // Migrate according to the diff. - match apply_diff(ws, account, None, &mut strategy).await { + match apply_diff(ws, account, txn_config, &mut strategy).await { Ok(migration_output) => { update_manifests_and_abis( ws,