diff --git a/crates/iota-json-rpc-types/src/iota_transaction.rs b/crates/iota-json-rpc-types/src/iota_transaction.rs index 9dd842da38a..7e363e148eb 100644 --- a/crates/iota-json-rpc-types/src/iota_transaction.rs +++ b/crates/iota-json-rpc-types/src/iota_transaction.rs @@ -214,23 +214,38 @@ impl IotaTransactionBlockResponseOptions { self == &Self::default() } - pub fn from_cli(mut self, opts: Vec) -> Self { - if opts.contains(&"input".to_string()) { - self.show_input = true; - } - if opts.contains(&"effects".to_string()) { - self.show_effects = true; - } - if opts.contains(&"events".to_string()) { - self.show_events = true; + pub fn default_profile() -> Self { + Self { + show_input: true, + show_effects: true, + show_events: true, + show_object_changes: true, + show_balance_changes: true, + show_raw_effects: false, + show_raw_input: false, } - if opts.contains(&"object_changes".to_string()) { - self.show_object_changes = true; + } + + pub fn from_cli(opts: Vec) -> Self { + + // if no options are provided, return the default profile + if opts.is_empty() { + return Self::default_profile(); } - if opts.contains(&"balance_changes".to_string()) { - self.show_balance_changes = true; + + // effects should be there by default + let mut options = IotaTransactionBlockResponseOptions::new().with_effects(); + + for opt in opts { + match opt.as_str() { + "input" => options.show_input = true, + "events" => options.show_events = true, + "object_changes" => options.show_object_changes = true, + "balance_changes" => options.show_balance_changes = true, + _ => {} + } } - self + options } } diff --git a/crates/iota-sdk/src/wallet_context.rs b/crates/iota-sdk/src/wallet_context.rs index b3a724e30b1..e8ce2dd7ed6 100644 --- a/crates/iota-sdk/src/wallet_context.rs +++ b/crates/iota-sdk/src/wallet_context.rs @@ -299,10 +299,10 @@ impl WalletContext { pub async fn execute_transaction_must_succeed( &self, tx: Transaction, - opts: Vec, + response_opts: IotaTransactionBlockResponseOptions, ) -> IotaTransactionBlockResponse { tracing::debug!("Executing transaction: {:?}", tx); - let response = self.execute_transaction_may_fail(tx, Vec::new()).await.unwrap(); + let response = self.execute_transaction_may_fail(tx, response_opts).await.unwrap(); assert!( response.status_ok().unwrap(), "Transaction failed: {:?}", @@ -318,14 +318,14 @@ impl WalletContext { pub async fn execute_transaction_may_fail( &self, tx: Transaction, - opts: Vec, + response_opts: IotaTransactionBlockResponseOptions, ) -> anyhow::Result { let client = self.get_client().await?; Ok(client .quorum_driver_api() .execute_transaction_block( tx, - IotaTransactionBlockResponseOptions::new().from_cli(opts), + response_opts, Some(iota_types::quorum_driver_types::ExecuteTransactionRequestType::WaitForLocalExecution), ) .await?) diff --git a/crates/iota-test-transaction-builder/src/lib.rs b/crates/iota-test-transaction-builder/src/lib.rs index a44a8bdbdb3..5f19fd7b0f9 100644 --- a/crates/iota-test-transaction-builder/src/lib.rs +++ b/crates/iota-test-transaction-builder/src/lib.rs @@ -9,7 +9,7 @@ use iota_move_build::{BuildConfig, CompiledPackage}; use iota_sdk::{ rpc_types::{ get_new_package_obj_from_response, IotaTransactionBlockEffectsAPI, - IotaTransactionBlockResponse, + IotaTransactionBlockResponse, IotaTransactionBlockResponseOptions, }, wallet_context::WalletContext, }; @@ -528,7 +528,7 @@ pub async fn publish_package(context: &WalletContext, path: PathBuf) -> ObjectRe .publish(path) .build(), ); - let resp = context.execute_transaction_must_succeed(txn, Vec::new()).await; + let resp = context.execute_transaction_must_succeed(txn, IotaTransactionBlockResponseOptions::default_profile()).await; get_new_package_obj_from_response(&resp).unwrap() } @@ -542,7 +542,7 @@ pub async fn publish_basics_package(context: &WalletContext) -> ObjectRef { .publish_examples("basics") .build(), ); - let resp = context.execute_transaction_must_succeed(txn, Vec::new()).await; + let resp = context.execute_transaction_must_succeed(txn, IotaTransactionBlockResponseOptions::default_profile()).await; get_new_package_obj_from_response(&resp).unwrap() } @@ -560,7 +560,7 @@ pub async fn publish_basics_package_and_make_counter( .build(), ); let resp = context - .execute_transaction_must_succeed(counter_creation_txn, Vec::new()) + .execute_transaction_must_succeed(counter_creation_txn, IotaTransactionBlockResponseOptions::default_profile()) .await; let counter_ref = resp .effects @@ -599,7 +599,7 @@ pub async fn increment_counter( .call_counter_increment(package_id, counter_id, initial_shared_version) .build(), ); - context.execute_transaction_must_succeed(txn, Vec::new()).await + context.execute_transaction_must_succeed(txn, IotaTransactionBlockResponseOptions::default_profile()).await } /// Executes a transaction to publish the `nfts` package and returns the package @@ -615,7 +615,7 @@ pub async fn publish_nfts_package( .publish_examples("nfts") .build(), ); - let resp = context.execute_transaction_must_succeed(txn, Vec::new()).await; + let resp = context.execute_transaction_must_succeed(txn, IotaTransactionBlockResponseOptions::default_profile()).await; let package_id = get_new_package_obj_from_response(&resp).unwrap().0; (package_id, gas_id, resp.digest) } @@ -635,7 +635,7 @@ pub async fn create_devnet_nft( .call_nft_create(package_id) .build(), ); - let resp = context.execute_transaction_must_succeed(txn, Vec::new()).await; + let resp = context.execute_transaction_must_succeed(txn, IotaTransactionBlockResponseOptions::default_profile()).await; let object_id = resp .effects @@ -668,5 +668,5 @@ pub async fn delete_devnet_nft( .call_nft_delete(package_id, nft_to_delete) .build(), ); - context.execute_transaction_must_succeed(txn, Vec::new()).await + context.execute_transaction_must_succeed(txn, IotaTransactionBlockResponseOptions::default_profile()).await }