Repository: scs/substrate-api-client (language: rust)

Issue:
Unsafe unwraps in macro: Remove or declare as unsafe
Our current macro code `compose_extrinsic` and `compose_call` contain unwraps. That's not safe. We should either remove them or mark the macro accordingly.


Discussion / hints:

Fix patch:
diff --git a/compose-macros/src/lib.rs b/compose-macros/src/lib.rs
index 4895235d4..c1f0107e0 100644
--- a/compose-macros/src/lib.rs
+++ b/compose-macros/src/lib.rs
@@ -25,21 +25,28 @@ pub use log;
 
 mod rpc;
 
-/// Generates the extrinsic's call field for a given module and call passed as &str
+/// Generates the extrinsic's call field for a given module and call passed as &str, if found in the metadata.
+/// Otherwise None is returned.
 /// # Arguments
 ///
 /// * 'node_metadata' - This crate's parsed node metadata as field of the API.
-/// * 'pallet' - Pallet name as &str for which the call is composed.
+/// * 'pallet_name' - Pallet name as &str for which the call is composed.
 /// * 'call_name' - Call name as &str
 /// * 'args' - Optional sequence of arguments of the call. They are not checked against the metadata.
-/// As of now the user needs to check himself that the correct arguments are supplied.
 #[macro_export]
 macro_rules! compose_call {
-($node_metadata: expr, $pallet: expr, $call_name: expr $(, $args: expr) *) => {
+($node_metadata: expr, $pallet_name: expr, $call_name: expr $(, $args: expr) *) => {
         {
-			let pallet_metadata = $node_metadata.pallet_by_name($pallet).unwrap().to_owned();
-            $crate::compose_call_for_pallet_metadata!(pallet_metadata, $call_name $(, ($args)) *)
-        }
+			let maybe_pallet = $node_metadata.pallet_by_name($pallet_name);
+			let maybe_call = match  maybe_pallet {
+				Some(pallet) => {
+					$crate::compose_call_for_pallet_metadata!(pallet, $call_name $(, ($args)) *)
+				},
+				None => None,
+			};
+			maybe_call
+		}
+
     };
 }
 
@@ -54,13 +61,19 @@ macro_rules! compose_call {
 macro_rules! compose_call_for_pallet_metadata {
 ($pallet_metadata: expr, $call_name: expr $(, $args: expr) *) => {
         {
-            let call_index = $pallet_metadata.call_variant_by_name($call_name).unwrap().index;
-            ([$pallet_metadata.index(), call_index as u8] $(, ($args)) *)
+
+			let maybe_call_variant = $pallet_metadata.call_variant_by_name($call_name);
+			match maybe_call_variant {
+				Some(call_variant) => Some(([$pallet_metadata.index(), call_variant.index as u8] $(, ($args)) *)),
+				None => None,
+			}
+
         }
+
     };
 }
 
-/// Generates an Unchecked extrinsic for a given call
+/// Generates an UncheckedExtrinsic for a given call.
 /// # Arguments
 ///
 /// * 'signer' - AccountKey that is used to sign the extrinsic.
@@ -85,75 +98,87 @@ macro_rules! compose_extrinsic_offline {
 	}};
 }
 
-/// Generates an Unchecked extrinsic for a given module and call passed as a &str.
+/// Generates an UncheckedExtrinsic for the given pallet and call, if they are found within the metadata.
+/// Otherwise None is returned.
 /// # Arguments
 ///
 /// * 'api' - This instance of API. If the *signer* field is not set, an unsigned extrinsic will be generated.
 /// * 'nonce' - signer's account nonce: Index
-/// * 'module' - Module name as &str for which the call is composed.
-/// * 'call' - Call name as &str
+/// * 'pallet_name' - Pallet name as &str for which the call is composed.
+/// * 'call_name' - Call name as &str
 /// * 'args' - Optional sequence of arguments of the call. They are not checked against the metadata.
-/// As of now the user needs to check himself that the correct arguments are supplied.
 #[macro_export]
 macro_rules! compose_extrinsic_with_nonce {
 	($api: expr,
 	$nonce: expr,
-	$module: expr,
-	$call: expr
+	$pallet_name: expr,
+	$call_name: expr
 	$(, $args: expr) *) => {
 		{
             use $crate::log::debug;
             use $crate::primitives::UncheckedExtrinsicV4;
 
-            debug!("Composing generic extrinsic for module {:?} and call {:?}", $module, $call);
+            debug!("Composing generic extrinsic for module {:?} and call {:?}", $pallet_name, $call_name);
 
 			let metadata = $api.metadata();
-            let call = $crate::compose_call!(metadata, $module, $call $(, ($args)) *);
-            if let Some(signer) = $api.signer() {
-                $crate::compose_extrinsic_offline!(
-                    signer,
-                    call.clone(),
-                    $api.extrinsic_params($nonce)
-                )
-            } else {
-                UncheckedExtrinsicV4::new_unsigned(call.clone())
-            }
+            let maybe_call = $crate::compose_call!(metadata, $pallet_name, $call_name $(, ($args)) *);
+
+			let maybe_extrinsic = match maybe_call {
+				Some(call) => {
+					let extrinsic = if let Some(signer) = $api.signer() {
+						$crate::compose_extrinsic_offline!(
+							signer,
+							call.clone(),
+							$api.extrinsic_params($nonce)
+						)
+					} else {
+						UncheckedExtrinsicV4::new_unsigned(call.clone())
+					};
+					Some(extrinsic)
+				},
+				None => None,
+			};
+			maybe_extrinsic
+
+
 		}
 	};
 }
 
-/// Generates an Unchecked extrinsic for a given module and call passed as a &str.
-/// Fetches the nonce from the given `api` instance
+/// Generates an UncheckedExtrinsic for the given pallet and call, if they are found within the metadata.
+/// Otherwise None is returned.
+/// Fetches the nonce from the given `api` instance. If this fails, zero is taken as default nonce.
 /// See also compose_extrinsic_with_nonce
 #[macro_export]
 #[cfg(feature = "sync-api")]
 macro_rules! compose_extrinsic {
 	($api: expr,
-	$module: expr,
-	$call: expr
+	$pallet_name: expr,
+	$call_name: expr
 	$(, $args: expr) *) => {
 		{
-			let nonce = $api.get_nonce().unwrap();
-			let extrinsic = $crate::compose_extrinsic_with_nonce!($api, nonce, $module, $call $(, ($args)) *);
-			extrinsic
+			let nonce = $api.get_nonce().unwrap_or_default();
+			let maybe_extrinisc = $crate::compose_extrinsic_with_nonce!($api, nonce, $pallet_name, $call_name $(, ($args)) *);
+			maybe_extrinisc
 		}
     };
 }
 
-/// Generates an Unchecked extrinsic for a given module and call passed as a &str.
-/// Fetches the nonce from the given `api` instance
+/// Generates an UncheckedExtrinsic for the given pallet and call, if they are found within the metadata.
+/// Otherwise None is returned.
+/// Fetches the nonce from the given `api` instance. If this fails, zero is taken as default nonce.
 /// See also compose_extrinsic_with_nonce
 #[macro_export]
 #[cfg(not(feature = "sync-api"))]
 macro_rules! compose_extrinsic {
 	($api: expr,
-	$module: expr,
-	$call: expr
+	$pallet_name: expr,
+	$call_name: expr
 	$(, $args: expr) *) => {
 		{
-			let nonce = $api.get_nonce().await.unwrap();
-			let extrinsic = $crate::compose_extrinsic_with_nonce!($api, nonce, $module, $call $(, ($args)) *);
-			extrinsic
+			let nonce = $api.get_nonce().await.unwrap_or_default();
+			let maybe_extrinisc = $crate::compose_extrinsic_with_nonce!($api, nonce, $pallet_name, $call_name $(, ($args)) *);
+			maybe_extrinisc
 		}
 	};
 }
@@ -181,14 +206,75 @@ mod tests {
 			&pallet_metadata,
 			"transfer_allow_death",
 			extra_parameter
-		);
+		)
+		.unwrap();
 		assert_eq!(expected_call_one, call_one);
 		let expected_call_two = ([4, 8], extra_parameter);
 		let call_two = compose_call_for_pallet_metadata!(
 			&pallet_metadata,
 			"force_set_balance",
 			extra_parameter
-		);
+		)
+		.unwrap();
 		assert_eq!(expected_call_two, call_two);
 	}
+
+	#[test]
+	fn macro_compose_call_for_pallet_metadata_returns_none_for_unknown_function() {
+		let encoded_metadata = fs::read("../ksm_metadata_v14.bin").unwrap();
+		let runtime_metadata_prefixed =
+			RuntimeMetadataPrefixed::decode(&mut encoded_metadata.as_slice()).unwrap();
+		let metadata = Metadata::try_from(runtime_metadata_prefixed).unwrap();
+
+		let pallet_metadata = metadata.pallet_by_name("Balances").unwrap();
+		let non_existent_function = "obladi";
+
+		let option = compose_call_for_pallet_metadata!(&pallet_metadata, non_existent_function);
+		assert!(option.is_none());
+	}
+
+	#[test]
+	fn macro_compose_call_returns_none_for_unknown_function() {
+		let encoded_metadata = fs::read("../ksm_metadata_v14.bin").unwrap();
+		let runtime_metadata_prefixed =
+			RuntimeMetadataPrefixed::decode(&mut encoded_metadata.as_slice()).unwrap();
+		let metadata = Metadata::try_from(runtime_metadata_prefixed).unwrap();
+
+		let pallet_name = "Balances";
+		let non_existent_function = "obladi";
+
+		let option = compose_call!(&metadata, pallet_name, non_existent_function);
+		assert!(option.is_none());
+	}
+
+	#[test]
+	fn macro_compose_call_returns_none_for_unknown_pallet() {
+		let encoded_metadata = fs::read("../ksm_metadata_v14.bin").unwrap();
+		let runtime_metadata_prefixed =
+			RuntimeMetadataPrefixed::decode(&mut encoded_metadata.as_slice()).unwrap();
+		let metadata = Metadata::try_from(runtime_metadata_prefixed).unwrap();
+
+		let pallet_name = "Balance";
+		let non_existent_function = "force_set_balance";
+
+		let option = compose_call!(&metadata, pallet_name, non_existent_function);
+		assert!(option.is_none());
+	}
+
+	#[test]
+	fn macro_compose_call_works_for_valid_input() {
+		let encoded_metadata = fs::read("../ksm_metadata_v14.bin").unwrap();
+		let runtime_metadata_prefixed =
+			RuntimeMetadataPrefixed::decode(&mut encoded_metadata.as_slice()).unwrap();
+		let metadata = Metadata::try_from(runtime_metadata_prefixed).unwrap();
+
+		let pallet_name = "Balances";
+		let non_existent_function = "force_set_balance";
+		let extra_parameter = 10000;
+
+		let expected_call = ([4, 8], extra_parameter);
+		let call =
+			compose_call!(&metadata, pallet_name, non_existent_function, extra_parameter).unwrap();
+		assert_eq!(call, expected_call);
+	}
 }
diff --git a/examples/async/examples/check_extrinsic_events.rs b/examples/async/examples/check_extrinsic_events.rs
index f5038d70f..aa3db17b1 100644
--- a/examples/async/examples/check_extrinsic_events.rs
+++ b/examples/async/examples/check_extrinsic_events.rs
@@ -53,8 +53,10 @@ async fn main() {
 	// So lets create an extrinsic that will not succeed:
 	// Alice tries so transfer all her balance, but that will not work, because
 	// she will not have enough balance left to pay the fees.
-	let bad_transfer_extrinsic =
-		api.balance_transfer_allow_death(bob.clone().into(), balance_of_alice).await;
+	let bad_transfer_extrinsic = api
+		.balance_transfer_allow_death(bob.clone().into(), balance_of_alice)
+		.await
+		.unwrap();
 	println!("[+] Composed extrinsic: {bad_transfer_extrinsic:?}\n",);
 
 	// Send and watch extrinsic until InBlock.
@@ -87,8 +89,10 @@ async fn main() {
 
 	// Next, we send an extrinsic that should succeed:
 	let balance_to_transfer = 1000;
-	let good_transfer_extrinsic =
-		api.balance_transfer_allow_death(bob.clone().into(), balance_to_transfer).await;
+	let good_transfer_extrinsic = api
+		.balance_transfer_allow_death(bob.clone().into(), balance_to_transfer)
+		.await
+		.unwrap();
 	// Send and watch extrinsic until InBlock.
 	let result = api
 		.submit_and_watch_extrinsic_until(good_transfer_extrinsic, XtStatus::InBlock)
diff --git a/examples/async/examples/compose_extrinsic.rs b/examples/async/examples/compose_extrinsic.rs
index 5db6c13fc..5b6b814ea 100644
--- a/examples/async/examples/compose_extrinsic.rs
+++ b/examples/async/examples/compose_extrinsic.rs
@@ -103,7 +103,8 @@ async fn main() {
 			"transfer_allow_death",
 			recipients_extrinsic_address,
 			Compact(4u32)
-		);
+		)
+		.unwrap();
 		compose_extrinsic_offline!(extrinsic_signer, call, extrinsic_params)
 	};
 
diff --git a/examples/async/examples/contract_instantiate_with_code.rs b/examples/async/examples/contract_instantiate_with_code.rs
index c8e036536..538a3da0f 100644
--- a/examples/async/examples/contract_instantiate_with_code.rs
+++ b/examples/async/examples/contract_instantiate_with_code.rs
@@ -63,7 +63,8 @@ async fn main() {
 
 	let xt = api
 		.contract_instantiate_with_code(1_000_000_000_000_000, 500_000, wasm, vec![1u8], vec![1u8])
-		.await;
+		.await
+		.unwrap();
 
 	println!("[+] Creating a contract instance with extrinsic:\n\n{:?}\n", xt);
 	let report = api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock).await.unwrap();
@@ -83,7 +84,7 @@ async fn main() {
 	let contract = contract_instantiated_events[0].contract.clone();
 	println!("[+] Event was received. Contract deployed at: {contract:?}\n");
 
-	let xt = api.contract_call(contract.into(), 500_000, 500_000, vec![0u8]).await;
+	let xt = api.contract_call(contract.into(), 500_000, 500_000, vec![0u8]).await.unwrap();
 
 	println!("[+] Calling the contract with extrinsic Extrinsic:\n{:?}\n\n", xt);
 	let report = api.submit_and_watch_extrinsic_until(xt, XtStatus::Finalized).await.unwrap();
diff --git a/examples/async/examples/get_account_identity.rs b/examples/async/examples/get_account_identity.rs
index 97760ebc9..185ea53f5 100644
--- a/examples/async/examples/get_account_identity.rs
+++ b/examples/async/examples/get_account_identity.rs
@@ -62,7 +62,7 @@ async fn main() {
 	};
 
 	let xt: UncheckedExtrinsicV4<_, _, _, _> =
-		compose_extrinsic!(&api, "Identity", "set_identity", Box::new(info.clone()));
+		compose_extrinsic!(&api, "Identity", "set_identity", Box::new(info.clone())).unwrap();
 	println!("[+] Composed Extrinsic:\n {:?}\n", xt);
 
 	// Send and watch extrinsic until InBlock.
diff --git a/examples/async/examples/query_runtime_api.rs b/examples/async/examples/query_runtime_api.rs
index 688dc1384..e92ef0c7e 100644
--- a/examples/async/examples/query_runtime_api.rs
+++ b/examples/async/examples/query_runtime_api.rs
@@ -44,7 +44,8 @@ async fn main() {
 
 	// Query the fee of an extrinsic.
 	let bob = AccountKeyring::Bob.to_account_id();
-	let balance_extrinsic = api.balance_transfer_allow_death(bob.clone().into(), 1000).await;
+	let balance_extrinsic =
+		api.balance_transfer_allow_death(bob.clone().into(), 1000).await.unwrap();
 	let extrinsic_fee_details = runtime_api
 		.query_fee_details(balance_extrinsic.clone(), 1000, None)
 		.await
diff --git a/examples/async/examples/runtime_update_async.rs b/examples/async/examples/runtime_update_async.rs
index 452a8c7c8..821777d1c 100644
--- a/examples/async/examples/runtime_update_async.rs
+++ b/examples/async/examples/runtime_update_async.rs
@@ -80,9 +80,9 @@ pub async fn send_code_update_extrinsic(
 	let new_wasm: &[u8] = include_bytes!("kitchensink_runtime.compact.compressed.wasm");
 
 	// this call can only be called by sudo
-	let call = compose_call!(api.metadata(), "System", "set_code", new_wasm.to_vec());
+	let call = compose_call!(api.metadata(), "System", "set_code", new_wasm.to_vec()).unwrap();
 	let weight: Weight = 0.into();
-	let xt = compose_extrinsic!(&api, "Sudo", "sudo_unchecked_weight", call, weight);
+	let xt = compose_extrinsic!(&api, "Sudo", "sudo_unchecked_weight", call, weight).unwrap();
 
 	println!("Sending extrinsic to trigger runtime update");
 	let block_hash = api
diff --git a/examples/async/examples/staking_batch_payout.rs b/examples/async/examples/staking_batch_payout.rs
index fb4d47542..7610b2369 100644
--- a/examples/async/examples/staking_batch_payout.rs
+++ b/examples/async/examples/staking_batch_payout.rs
@@ -73,7 +73,7 @@ async fn main() {
 	// error is returned from the node, the extrinsic has been created correctly.
 	// Sidenote: We could theoretically force a new era with sudo, but this takes at least 10 minutes ( = 1 epoch) in the
 	// kitchensink rutime. We don't want to wait that long.
-	let payout_staker_xt = api.payout_stakers(0, validator_stash).await;
+	let payout_staker_xt = api.payout_stakers(0, validator_stash).await.unwrap();
 	let result = api.submit_and_watch_extrinsic_until(payout_staker_xt, XtStatus::InBlock).await;
 	assert!(result.is_err());
 	assert!(format!("{result:?}").contains("InvalidEraToReward"));
@@ -123,8 +123,10 @@ async fn main() {
 
 				if exposure.total.to_be_bytes() > 0_u128.to_be_bytes() && is_grace_period_satisfied
 				{
-					let payout_extrinsic =
-						api.payout_stakers(payout_era_index, validator_account.clone()).await;
+					let payout_extrinsic = api
+						.payout_stakers(payout_era_index, validator_account.clone())
+						.await
+						.unwrap();
 					payout_calls.push(payout_extrinsic.function);
 				}
 				i += 1;
@@ -132,7 +134,7 @@ async fn main() {
 			}
 			num_of_claimed_payouts += payout_calls.len();
 			num_of_unclaimed_payouts -= tx_limit_in_current_batch;
-			let batch_xt = api.batch(payout_calls).await;
+			let batch_xt = api.batch(payout_calls).await.unwrap();
 
 			let report =
 				api.submit_and_watch_extrinsic_until(batch_xt, XtStatus::InBlock).await.unwrap();
diff --git a/examples/async/examples/sudo.rs b/examples/async/examples/sudo.rs
index 836482043..70c2db3a8 100644
--- a/examples/async/examples/sudo.rs
+++ b/examples/async/examples/sudo.rs
@@ -65,23 +65,25 @@ async fn main() {
 	let recipients_extrinsic_address: ExtrinsicAddressOf<ExtrinsicSigner> =
 		recipient.clone().into();
 	let new_balance = recipient_balance + 100;
-	let call = compose_call!(
-		api.metadata(),
-		"Balances",
-		"force_set_balance",
-		recipients_extrinsic_address,
-		Compact(new_balance)
-	);
+	let call: ([u8; 2], sp_runtime::MultiAddress<sp_runtime::AccountId32, u32>, Compact<_>) =
+		compose_call!(
+			api.metadata(),
+			"Balances",
+			"force_set_balance",
+			recipients_extrinsic_address,
+			Compact(new_balance)
+		)
+		.unwrap();
 
-	let xt: UncheckedExtrinsicV4<_, _, _, _> = compose_extrinsic!(&api, "Sudo", "sudo", call);
+	let xt: UncheckedExtrinsicV4<_, _, _, _> =
+		compose_extrinsic!(&api, "Sudo", "sudo", call).unwrap();
 
 	// Send and watch extrinsic until in block.
 	let block_hash = api
 		.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)
 		.await
 		.unwrap()
-		.block_hash
-		.unwrap();
+		.block_hash;
 	println!("[+] Extrinsic got included. Block Hash: {:?}", block_hash);
 
 	// Ensure the extrinsic has been executed.
diff --git a/examples/sync/examples/runtime_update_sync.rs b/examples/sync/examples/runtime_update_sync.rs
index fe9c1090f..77d74b55f 100644
--- a/examples/sync/examples/runtime_update_sync.rs
+++ b/examples/sync/examples/runtime_update_sync.rs
@@ -78,9 +78,9 @@ pub fn send_code_update_extrinsic(
 	let new_wasm: &[u8] = include_bytes!("kitchensink_runtime.compact.compressed.wasm");
 
 	// Create a sudo `set_code` call.
-	let call = compose_call!(api.metadata(), "System", "set_code", new_wasm.to_vec());
+	let call = compose_call!(api.metadata(), "System", "set_code", new_wasm.to_vec()).unwrap();
 	let weight: Weight = 0.into();
-	let xt = compose_extrinsic!(&api, "Sudo", "sudo_unchecked_weight", call, weight);
+	let xt = compose_extrinsic!(&api, "Sudo", "sudo_unchecked_weight", call, weight).unwrap();
 
 	println!("Sending extrinsic to trigger runtime update");
 	let block_hash = api
diff --git a/examples/sync/examples/transfer_with_tungstenite_client.rs b/examples/sync/examples/transfer_with_tungstenite_client.rs
index 58e10a405..26f24b506 100755
--- a/examples/sync/examples/transfer_with_tungstenite_client.rs
+++ b/examples/sync/examples/transfer_with_tungstenite_client.rs
@@ -54,7 +54,9 @@ fn main() {
 	println!("[+] Bob's Free Balance is {}\n", bob_balance);
 
 	// We first generate an extrinsic that will fail to be executed due to missing funds.
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1)
+		.unwrap();
 	println!(
 		"Sending an extrinsic from Alice (Key = {}),\n\nto Bob (Key = {})\n",
 		alice.public(),
@@ -68,7 +70,9 @@ fn main() {
 	println!("[+] Extrinsic did not get included due to: {:?}\n", result);
 
 	// This time, we generate an extrinsic that will succeed.
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2)
+		.unwrap();
 	println!(
 		"Sending an extrinsic from Alice (Key = {}),\n\nto Bob (Key = {})\n",
 		alice.public(),
diff --git a/examples/sync/examples/transfer_with_ws_client.rs b/examples/sync/examples/transfer_with_ws_client.rs
index 718ebd635..4489f30af 100755
--- a/examples/sync/examples/transfer_with_ws_client.rs
+++ b/examples/sync/examples/transfer_with_ws_client.rs
@@ -53,7 +53,9 @@ fn main() {
 	println!("[+] Bob's Free Balance is {}\n", bob_balance);
 
 	// We first generate an extrinsic that will fail to be executed due to missing funds.
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1)
+		.unwrap();
 	println!(
 		"Sending an extrinsic from Alice (Key = {}),\n\nto Bob (Key = {})\n",
 		alice.public(),
@@ -67,7 +69,9 @@ fn main() {
 	println!("[+] Extrinsic did not get included due to: {:?}\n", result);
 
 	// This time, we generate an extrinsic that will succeed.
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2)
+		.unwrap();
 	println!(
 		"Sending an extrinsic from Alice (Key = {}),\n\nto Bob (Key = {})\n",
 		alice.public(),
diff --git a/src/extrinsic/balances.rs b/src/extrinsic/balances.rs
index ae673437a..709a9d816 100644
--- a/src/extrinsic/balances.rs
+++ b/src/extrinsic/balances.rs
@@ -24,7 +24,6 @@ use ac_primitives::{
 	config::Config, extrinsic_params::ExtrinsicParams, extrinsics::CallIndex, SignExtrinsic,
 	UncheckedExtrinsicV4,
 };
-use alloc::borrow::ToOwned;
 #[cfg(not(feature = "sync-api"))]
 use alloc::boxed::Box;
 use codec::{Compact, Encode};
@@ -46,18 +45,20 @@ pub trait BalancesExtrinsics {
 	type Extrinsic<Call>;
 
 	/// Transfer some liquid free balance to another account.
+	#[allow(clippy::type_complexity)]
 	async fn balance_transfer_allow_death(
 		&self,
 		to: Self::Address,
 		amount: Self::Balance,
-	) -> Self::Extrinsic<TransferAllowDeathCall<Self::Address, Self::Balance>>;
+	) -> Option<Self::Extrinsic<TransferAllowDeathCall<Self::Address, Self::Balance>>>;
 
 	///  Set the balances of a given account.
+	#[allow(clippy::type_complexity)]
 	async fn balance_force_set_balance(
 		&self,
 		who: Self::Address,
 		free_balance: Self::Balance,
-	) -> Self::Extrinsic<ForceSetBalanceCall<Self::Address, Self::Balance>>;
+	) -> Option<Self::Extrinsic<ForceSetBalanceCall<Self::Address, Self::Balance>>>;
 }
 
 #[maybe_async::maybe_async(?Send)]
@@ -80,7 +81,7 @@ where
 		&self,
 		to: Self::Address,
 		amount: Self::Balance,
-	) -> Self::Extrinsic<TransferAllowDeathCall<Self::Address, Self::Balance>> {
+	) -> Option<Self::Extrinsic<TransferAllowDeathCall<Self::Address, Self::Balance>>> {
 		compose_extrinsic!(self, BALANCES_MODULE, TRANSFER_ALLOW_DEATH, to, Compact(amount))
 	}
 
@@ -88,7 +89,7 @@ where
 		&self,
 		who: Self::Address,
 		free_balance: Self::Balance,
-	) -> Self::Extrinsic<ForceSetBalanceCall<Self::Address, Self::Balance>> {
+	) -> Option<Self::Extrinsic<ForceSetBalanceCall<Self::Address, Self::Balance>>> {
 		compose_extrinsic!(self, BALANCES_MODULE, FORCE_SET_BALANCE, who, Compact(free_balance))
 	}
 }
diff --git a/src/extrinsic/contracts.rs b/src/extrinsic/contracts.rs
index e4cb6ea4b..4727252eb 100644
--- a/src/extrinsic/contracts.rs
+++ b/src/extrinsic/contracts.rs
@@ -74,7 +74,7 @@ pub trait ContractsExtrinsics {
 		&self,
 		gas_limit: Self::Gas,
 		code: Self::Code,
-	) -> Self::Extrinsic<PutCodeFor<Self>>;
+	) -> Option<Self::Extrinsic<PutCodeFor<Self>>>;
 
 	async fn contract_instantiate(
 		&self,
@@ -82,7 +82,7 @@ pub trait ContractsExtrinsics {
 		gas_limit: Self::Gas,
 		code_hash: Self::Hash,
 		data: Self::Data,
-	) -> Self::Extrinsic<InstantiateWithHashFor<Self>>;
+	) -> Option<Self::Extrinsic<InstantiateWithHashFor<Self>>>;
 
 	async fn contract_instantiate_with_code(
 		&self,
@@ -91,7 +91,7 @@ pub trait ContractsExtrinsics {
 		code: Self::Code,
 		data: Self::Data,
 		salt: Self::Salt,
-	) -> Self::Extrinsic<InstantiateWithCodeFor<Self>>;
+	) -> Option<Self::Extrinsic<InstantiateWithCodeFor<Self>>>;
 
 	async fn contract_call(
 		&self,
@@ -99,7 +99,7 @@ pub trait ContractsExtrinsics {
 		value: Self::Currency,
 		gas_limit: Self::Gas,
 		data: Self::Data,
-	) -> Self::Extrinsic<ContractCallFor<Self>>;
+	) -> Option<Self::Extrinsic<ContractCallFor<Self>>>;
 }
 
 #[cfg(feature = "std")]
@@ -128,7 +128,7 @@ where
 		&self,
 		gas_limit: Self::Gas,
 		code: Self::Code,
-	) -> Self::Extrinsic<PutCodeFor<Self>> {
+	) -> Option<Self::Extrinsic<PutCodeFor<Self>>> {
 		compose_extrinsic!(self, CONTRACTS_MODULE, PUT_CODE, Compact(gas_limit), code)
 	}
 
@@ -138,7 +138,7 @@ where
 		gas_limit: Self::Gas,
 		code_hash: Self::Hash,
 		data: Self::Data,
-	) -> Self::Extrinsic<InstantiateWithHashFor<Self>> {
+	) -> Option<Self::Extrinsic<InstantiateWithHashFor<Self>>> {
 		compose_extrinsic!(
 			self,
 			CONTRACTS_MODULE,
@@ -157,7 +157,7 @@ where
 		code: Self::Code,
 		data: Self::Data,
 		salt: Self::Salt,
-	) -> Self::Extrinsic<InstantiateWithCodeFor<Self>> {
+	) -> Option<Self::Extrinsic<InstantiateWithCodeFor<Self>>> {
 		compose_extrinsic!(
 			self,
 			CONTRACTS_MODULE,
@@ -176,7 +176,7 @@ where
 		value: Self::Currency,
 		gas_limit: Self::Gas,
 		data: Self::Data,
-	) -> Self::Extrinsic<ContractCallFor<Self>> {
+	) -> Option<Self::Extrinsic<ContractCallFor<Self>>> {
 		compose_extrinsic!(
 			self,
 			CONTRACTS_MODULE,
diff --git a/src/extrinsic/staking.rs b/src/extrinsic/staking.rs
index e23285716..c8b7b9aad 100644
--- a/src/extrinsic/staking.rs
+++ b/src/extrinsic/staking.rs
@@ -78,13 +78,13 @@ pub trait StakingExtrinsics {
 		controller: Self::Address,
 		value: Self::Balance,
 		payee: Self::RewardDestination,
-	) -> Self::Extrinsic<BondCall<Self::Address, Self::Balance>>;
+	) -> Option<Self::Extrinsic<BondCall<Self::Address, Self::Balance>>>;
 
 	/// Bonds extra funds from the stash's free balance to the balance for staking.
 	async fn staking_bond_extra(
 		&self,
 		value: Self::Balance,
-	) -> Self::Extrinsic<BondExtraCall<Self::Balance>>;
+	) -> Option<Self::Extrinsic<BondExtraCall<Self::Balance>>>;
 
 	/// Unbond `value` portion of the stash.
 	/// If `value` is less than the minimum required, then the entire amount is unbound.
@@ -92,13 +92,13 @@ pub trait StakingExtrinsics {
 	async fn staking_unbond(
 		&self,
 		value: Self::Balance,
-	) -> Self::Extrinsic<UnbondCall<Self::Balance>>;
+	) -> Option<Self::Extrinsic<UnbondCall<Self::Balance>>>;
 
 	/// Rebond `value` portion of the current amount that is in the process of unbonding.
 	async fn staking_rebond(
 		&self,
 		value: Self::Balance,
-	) -> Self::Extrinsic<RebondCall<Self::Balance>>;
+	) -> Option<Self::Extrinsic<RebondCall<Self::Balance>>>;
 
 	/// Free the balance of the stash so the stash account can do whatever it wants.
 	/// Must be signed by the controller of the stash and called when EraElectionStatus is Closed.
@@ -106,17 +106,17 @@ pub trait StakingExtrinsics {
 	async fn staking_withdraw_unbonded(
 		&self,
 		num_slashing_spans: u32,
-	) -> Self::Extrinsic<WithdrawUnbondedCall>;
+	) -> Option<Self::Extrinsic<WithdrawUnbondedCall>>;
 
 	/// Nominate `targets` as validators.
 	/// Must be signed by the controller of the stash and called when EraElectionStatus is Closed.
 	async fn staking_nominate(
 		&self,
 		targets: Vec<Self::Address>,
-	) -> Self::Extrinsic<NominateCall<Self::Address>>;
+	) -> Option<Self::Extrinsic<NominateCall<Self::Address>>>;
 
 	/// Stop nominating por validating. Effects take place in the next era
-	async fn staking_chill(&self) -> Self::Extrinsic<ChillCall>;
+	async fn staking_chill(&self) -> Option<Self::Extrinsic<ChillCall>>;
 
 	/// (Re-)set the controller of the stash
 	/// Effects will be felt at the beginning of the next era.
@@ -124,30 +124,35 @@ pub trait StakingExtrinsics {
 	async fn staking_set_controller(
 		&self,
 		controller: Self::Address,
-	) -> Self::Extrinsic<SetControllerCall<Self::Address>>;
+	) -> Option<Self::Extrinsic<SetControllerCall<Self::Address>>>;
 
 	/// Return the payout call for the given era
 	async fn payout_stakers(
 		&self,
 		era: u32,
 		account: Self::AccountId,
-	) -> Self::Extrinsic<PayoutStakersCall<Self::AccountId>>;
+	) -> Option<Self::Extrinsic<PayoutStakersCall<Self::AccountId>>>;
 
 	/// For New Era at the end of Next Session.
-	async fn force_new_era(&self) -> Self::Extrinsic<ForceNewEraCall>;
+	async fn force_new_era(&self) -> Option<Self::Extrinsic<ForceNewEraCall>>;
 
 	/// Force there to be a new era at the end of sessions indefinitely.
-	async fn force_new_era_always(&self) -> Self::Extrinsic<ForceNewEraAlwaysCall>;
+	async fn force_new_era_always(&self) -> Option<Self::Extrinsic<ForceNewEraAlwaysCall>>;
 
 	/// Force there to be no new eras indefinitely.
-	async fn force_no_era(&self) -> Self::Extrinsic<ForceNewEraAlwaysCall>;
+	async fn force_no_era(&self) -> Option<Self::Extrinsic<ForceNewEraAlwaysCall>>;
 
 	/// Re-set the payment target for a controller.
-	async fn set_payee(&self, payee: Self::Address)
-		-> Self::Extrinsic<SetPayeeCall<Self::Address>>;
+	async fn set_payee(
+		&self,
+		payee: Self::Address,
+	) -> Option<Self::Extrinsic<SetPayeeCall<Self::Address>>>;
 
 	/// Sets the number of validators.
-	async fn set_validator_count(&self, count: u32) -> Self::Extrinsic<SetValidatorCountCall>;
+	async fn set_validator_count(
+		&self,
+		count: u32,
+	) -> Option<Self::Extrinsic<SetValidatorCountCall>>;
 }
 
 #[maybe_async::maybe_async(?Send)]
@@ -173,53 +178,53 @@ where
 		controller: Self::Address,
 		value: Self::Balance,
 		payee: Self::RewardDestination,
-	) -> Self::Extrinsic<BondCall<Self::Address, Self::Balance>> {
+	) -> Option<Self::Extrinsic<BondCall<Self::Address, Self::Balance>>> {
 		compose_extrinsic!(self, STAKING_MODULE, BOND, controller, Compact(value), payee)
 	}
 
 	async fn staking_bond_extra(
 		&self,
 		value: Self::Balance,
-	) -> Self::Extrinsic<BondExtraCall<Self::Balance>> {
+	) -> Option<Self::Extrinsic<BondExtraCall<Self::Balance>>> {
 		compose_extrinsic!(self, STAKING_MODULE, BOND_EXTRA, Compact(value))
 	}
 
 	async fn staking_unbond(
 		&self,
 		value: Self::Balance,
-	) -> Self::Extrinsic<UnbondCall<Self::Balance>> {
+	) -> Option<Self::Extrinsic<UnbondCall<Self::Balance>>> {
 		compose_extrinsic!(self, STAKING_MODULE, UNBOND, Compact(value))
 	}
 
 	async fn staking_rebond(
 		&self,
 		value: Self::Balance,
-	) -> Self::Extrinsic<RebondCall<Self::Balance>> {
+	) -> Option<Self::Extrinsic<RebondCall<Self::Balance>>> {
 		compose_extrinsic!(self, STAKING_MODULE, REBOND, Compact(value))
 	}
 
 	async fn staking_withdraw_unbonded(
 		&self,
 		num_slashing_spans: u32,
-	) -> Self::Extrinsic<WithdrawUnbondedCall> {
+	) -> Option<Self::Extrinsic<WithdrawUnbondedCall>> {
 		compose_extrinsic!(self, STAKING_MODULE, WITHDRAW_UNBONDED, num_slashing_spans)
 	}
 
 	async fn staking_nominate(
 		&self,
 		targets: Vec<Self::Address>,
-	) -> Self::Extrinsic<NominateCall<Self::Address>> {
+	) -> Option<Self::Extrinsic<NominateCall<Self::Address>>> {
 		compose_extrinsic!(self, STAKING_MODULE, NOMINATE, targets)
 	}
 
-	async fn staking_chill(&self) -> Self::Extrinsic<ChillCall> {
+	async fn staking_chill(&self) -> Option<Self::Extrinsic<ChillCall>> {
 		compose_extrinsic!(self, STAKING_MODULE, CHILL)
 	}
 
 	async fn staking_set_controller(
 		&self,
 		controller: Self::Address,
-	) -> Self::Extrinsic<SetControllerCall<Self::Address>> {
+	) -> Option<Self::Extrinsic<SetControllerCall<Self::Address>>> {
 		compose_extrinsic!(self, STAKING_MODULE, SET_CONTROLLER, controller)
 	}
 
@@ -227,31 +232,34 @@ where
 		&self,
 		era: u32,
 		account: Self::AccountId,
-	) -> Self::Extrinsic<PayoutStakersCall<Self::AccountId>> {
+	) -> Option<Self::Extrinsic<PayoutStakersCall<Self::AccountId>>> {
 		let value = PayoutStakers { validator_stash: account, era };
 		compose_extrinsic!(self, STAKING_MODULE, PAYOUT_STAKERS, value)
 	}
 
-	async fn force_new_era(&self) -> Self::Extrinsic<ForceNewEraCall> {
+	async fn force_new_era(&self) -> Option<Self::Extrinsic<ForceNewEraCall>> {
 		compose_extrinsic!(self, STAKING_MODULE, FORCE_NEW_ERA)
 	}
 
-	async fn force_new_era_always(&self) -> Self::Extrinsic<ForceNewEraAlwaysCall> {
+	async fn force_new_era_always(&self) -> Option<Self::Extrinsic<ForceNewEraAlwaysCall>> {
 		compose_extrinsic!(self, STAKING_MODULE, FORCE_NEW_ERA_ALWAYS)
 	}
 
-	async fn force_no_era(&self) -> Self::Extrinsic<ForceNewEraAlwaysCall> {
+	async fn force_no_era(&self) -> Option<Self::Extrinsic<ForceNewEraAlwaysCall>> {
 		compose_extrinsic!(self, STAKING_MODULE, FORCE_NO_ERA)
 	}
 
 	async fn set_payee(
 		&self,
 		payee: Self::Address,
-	) -> Self::Extrinsic<SetPayeeCall<Self::Address>> {
+	) -> Option<Self::Extrinsic<SetPayeeCall<Self::Address>>> {
 		compose_extrinsic!(self, STAKING_MODULE, SET_PAYEE, payee)
 	}
 
-	async fn set_validator_count(&self, count: u32) -> Self::Extrinsic<SetValidatorCountCall> {
+	async fn set_validator_count(
+		&self,
+		count: u32,
+	) -> Option<Self::Extrinsic<SetValidatorCountCall>> {
 		compose_extrinsic!(self, STAKING_MODULE, SET_VALIDATOR_COUNT, count)
 	}
 }
diff --git a/src/extrinsic/utility.rs b/src/extrinsic/utility.rs
index e385bd3d3..2bfc7b276 100644
--- a/src/extrinsic/utility.rs
+++ b/src/extrinsic/utility.rs
@@ -26,7 +26,7 @@ use ac_primitives::{
 };
 #[cfg(not(feature = "sync-api"))]
 use alloc::boxed::Box;
-use alloc::{borrow::ToOwned, vec::Vec};
+use alloc::vec::Vec;
 use codec::{Decode, Encode};
 
 const UTILITY_MODULE: &str = "Utility";
@@ -48,13 +48,13 @@ pub trait UtilityExtrinsics {
 	async fn batch<Call: Encode + Clone>(
 		&self,
 		calls: Vec<Call>,
-	) -> Self::Extrinsic<BatchCall<Call>>;
+	) -> Option<Self::Extrinsic<BatchCall<Call>>>;
 
 	// Send a batch of dispatch calls. Unlike batch, it allows errors and won't interrupt.
 	async fn force_batch<Call: Encode + Clone>(
 		&self,
 		calls: Vec<Call>,
-	) -> Self::Extrinsic<BatchCall<Call>>;
+	) -> Option<Self::Extrinsic<BatchCall<Call>>>;
 }
 
 #[maybe_async::maybe_async(?Send)]
@@ -73,7 +73,7 @@ where
 	async fn batch<Call: Encode + Clone>(
 		&self,
 		calls: Vec<Call>,
-	) -> Self::Extrinsic<BatchCall<Call>> {
+	) -> Option<Self::Extrinsic<BatchCall<Call>>> {
 		let calls = Batch { calls };
 		compose_extrinsic!(self, UTILITY_MODULE, BATCH, calls)
 	}
@@ -81,7 +81,7 @@ where
 	async fn force_batch<Call: Encode + Clone>(
 		&self,
 		calls: Vec<Call>,
-	) -> Self::Extrinsic<BatchCall<Call>> {
+	) -> Option<Self::Extrinsic<BatchCall<Call>>> {
 		let calls = Batch { calls };
 		compose_extrinsic!(self, UTILITY_MODULE, FORCE_BATCH, calls)
 	}


Test patch:
diff --git a/testing/async/examples/dispatch_errors_tests.rs b/testing/async/examples/dispatch_errors_tests.rs
index 8969c7653..8761da431 100644
--- a/testing/async/examples/dispatch_errors_tests.rs
+++ b/testing/async/examples/dispatch_errors_tests.rs
@@ -45,7 +45,10 @@ async fn main() {
 	//BadOrigin
 	api.set_signer(bob_signer.into());
 	//Can only be called by root
-	let xt = api.balance_force_set_balance(MultiAddress::Id(alice.clone()), 10).await;
+	let xt = api
+		.balance_force_set_balance(MultiAddress::Id(alice.clone()), 10)
+		.await
+		.unwrap();
 
 	let result = api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock).await;
 	assert!(result.is_err());
@@ -54,7 +57,10 @@ async fn main() {
 
 	//BelowMinimum
 	api.set_signer(alice_signer.into());
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(one.clone()), 999999).await;
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(one.clone()), 999999)
+		.await
+		.unwrap();
 	let result = api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock).await;
 	assert!(result.is_err());
 	assert!(format!("{result:?}").contains("(BelowMinimum"));
diff --git a/testing/async/examples/events_tests.rs b/testing/async/examples/events_tests.rs
index 4a739cc03..368f8bae2 100644
--- a/testing/async/examples/events_tests.rs
+++ b/testing/async/examples/events_tests.rs
@@ -58,7 +58,7 @@ async fn main() {
 	println!("{events:?}");
 
 	// Submit a test-extrinsic to test `fetch_events_for_extrinsic`.
-	let xt = api.balance_transfer_allow_death(bob.into(), 1000).await;
+	let xt = api.balance_transfer_allow_death(bob.into(), 1000).await.unwrap();
 	let report = api
 		.submit_and_watch_extrinsic_until_without_events(xt, XtStatus::InBlock)
 		.await
diff --git a/testing/async/examples/pallet_transaction_payment_tests.rs b/testing/async/examples/pallet_transaction_payment_tests.rs
index 6a3c2c63f..d2bbb7bb0 100644
--- a/testing/async/examples/pallet_transaction_payment_tests.rs
+++ b/testing/async/examples/pallet_transaction_payment_tests.rs
@@ -33,7 +33,11 @@ async fn main() {
 	let bob = AccountKeyring::Bob.to_account_id();
 
 	let block_hash = api.get_block_hash(None).await.unwrap().unwrap();
-	let encoded_xt = api.balance_transfer_allow_death(bob.into(), 1000000000000).await.encode();
+	let encoded_xt = api
+		.balance_transfer_allow_death(bob.into(), 1000000000000)
+		.await
+		.unwrap()
+		.encode();
 
 	// Tests
 	let _fee_details = api
diff --git a/testing/async/examples/runtime_api_tests.rs b/testing/async/examples/runtime_api_tests.rs
index 4f5aec15c..cc9f501ed 100644
--- a/testing/async/examples/runtime_api_tests.rs
+++ b/testing/async/examples/runtime_api_tests.rs
@@ -55,7 +55,7 @@ async fn main() {
 	assert!(authority_id.len() > 0);
 
 	// BlockBuilder
-	let extrinsic = api.balance_transfer_allow_death(bob.clone().into(), 1000).await;
+	let extrinsic = api.balance_transfer_allow_death(bob.clone().into(), 1000).await.unwrap();
 	runtime_api.apply_extrinsic(extrinsic, None).await.unwrap().unwrap().unwrap();
 	let block = api.get_block_by_num(Some(0)).await.unwrap().unwrap();
 	let check = runtime_api.check_inherents(block, Default::default(), None).await.unwrap();
@@ -99,7 +99,7 @@ async fn main() {
 	let _quota = runtime_api.nominations_quota(100000000, None).await.unwrap();
 
 	// Transaction Payment
-	let extrinsic = api.balance_transfer_allow_death(bob.clone().into(), 1000).await;
+	let extrinsic = api.balance_transfer_allow_death(bob.clone().into(), 1000).await.unwrap();
 	let _tx_fee_details =
 		runtime_api.query_fee_details(extrinsic.clone(), 1000, None).await.unwrap();
 	let _tx_info = runtime_api.query_info(extrinsic, 1000, None).await.unwrap();
@@ -107,7 +107,11 @@ async fn main() {
 	let _fee = runtime_api.query_weight_to_fee(1000.into(), None).await.unwrap();
 
 	// Transaction Payment Call
-	let call = api.balance_transfer_allow_death(bob.clone().into(), 1000).await.function;
+	let call = api
+		.balance_transfer_allow_death(bob.clone().into(), 1000)
+		.await
+		.unwrap()
+		.function;
 	let _tx_fee_details =
 		runtime_api.query_call_fee_details(call.clone(), 1000, None).await.unwrap();
 	let _tx_info = runtime_api.query_call_info(call, 1000, None).await.unwrap();
diff --git a/testing/sync/examples/tungstenite_client_test.rs b/testing/sync/examples/tungstenite_client_test.rs
index ecfd620a0..6c2d4ac36 100755
--- a/testing/sync/examples/tungstenite_client_test.rs
+++ b/testing/sync/examples/tungstenite_client_test.rs
@@ -39,7 +39,9 @@ fn main() {
 	let bob_balance = api.get_account_data(&bob.into()).unwrap().unwrap_or_default().free;
 
 	// Check for failed extrinsic failed onchain
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1)
+		.unwrap();
 	let result = api.submit_and_watch_extrinsic_until(xt.clone(), XtStatus::InBlock);
 	assert!(format!("{:?}", result).contains("FundsUnavailable"));
 
@@ -49,7 +51,9 @@ fn main() {
 	assert!(format!("{:?}", result).contains("ExtrinsicFailed"));
 
 	// Check for successful extrinisc
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2)
+		.unwrap();
 	let _block_hash = api
 		.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)
 		.unwrap()
diff --git a/testing/sync/examples/ws_client_test.rs b/testing/sync/examples/ws_client_test.rs
index 8c33662d5..676024c7c 100755
--- a/testing/sync/examples/ws_client_test.rs
+++ b/testing/sync/examples/ws_client_test.rs
@@ -39,7 +39,9 @@ fn main() {
 	let bob_balance = api.get_account_data(&bob.into()).unwrap().unwrap_or_default().free;
 
 	// Check for failed extrinsic failed onchain
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance + 1)
+		.unwrap();
 	let result = api.submit_and_watch_extrinsic_until(xt.clone(), XtStatus::InBlock);
 	assert!(format!("{:?}", result).contains("FundsUnavailable"));
 
@@ -49,7 +51,9 @@ fn main() {
 	assert!(format!("{:?}", result).contains("ExtrinsicFailed"));
 
 	// Check for successful extrinisc
-	let xt = api.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2);
+	let xt = api
+		.balance_transfer_allow_death(MultiAddress::Id(bob.into()), bob_balance / 2)
+		.unwrap();
 	let _block_hash = api
 		.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)
 		.unwrap()