Skip to content

Commit

Permalink
fix: add the transaction options to sozo migrate apply (#1802)
Browse files Browse the repository at this point in the history
* fix: add the transaction options to sozo migrate apply

* Delete crates/sozo/ops/src/account.rs
  • Loading branch information
glihm authored Apr 9, 2024
1 parent f0637f9 commit 64fa43c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
23 changes: 20 additions & 3 deletions bin/sozo/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)]
Expand Down Expand Up @@ -57,6 +59,9 @@ pub enum MigrateCommand {

#[command(flatten)]
account: AccountOptions,

#[command(flatten)]
transaction: TransactionOptions,
},
}

Expand Down Expand Up @@ -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<TxConfig> = Some(transaction.into());

if name.is_none() {
if let Some(root_package) = ws.root_package() {
name = Some(root_package.id.name.to_string())
Expand All @@ -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
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/sozo/ops/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub async fn migrate<P, S>(
account: &SingleOwnerAccount<P, S>,
name: Option<String>,
dry_run: bool,
txn_config: Option<TxConfig>,
) -> Result<()>
where
P: Provider + Sync + Send + 'static,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 64fa43c

Please sign in to comment.