From c6ebdc4af29369631033584348e36028cf1f3b86 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Thu, 2 May 2024 20:47:36 +0200 Subject: [PATCH] only use batch when needed (#30) --- src/build_upgrade.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/build_upgrade.rs b/src/build_upgrade.rs index 319179c..ce38734 100644 --- a/src/build_upgrade.rs +++ b/src/build_upgrade.rs @@ -503,9 +503,13 @@ async fn construct_kusama_batch( if let Some(rc) = relay_call { batch_calls.push(rc.get_kusama_call().expect("kusama call")); } - CallInfo::from_runtime_call(NetworkRuntimeCall::Kusama(KusamaRuntimeCall::Utility( - UtilityCall::force_batch { calls: batch_calls }, - ))) + match &batch_calls.len() { + 0 => panic!("no calls"), + 1 => CallInfo::from_runtime_call(NetworkRuntimeCall::Kusama(batch_calls[0].clone())), + _ => CallInfo::from_runtime_call(NetworkRuntimeCall::Kusama(KusamaRuntimeCall::Utility( + UtilityCall::force_batch { calls: batch_calls }, + ))), + } } // Construct the batch needed on Polkadot. @@ -530,9 +534,13 @@ async fn construct_polkadot_batch( if let Some(rc) = relay_call { batch_calls.push(rc.get_polkadot_call().expect("polkadot call")); } - CallInfo::from_runtime_call(NetworkRuntimeCall::Polkadot(PolkadotRuntimeCall::Utility( - UtilityCall::force_batch { calls: batch_calls }, - ))) + match &batch_calls.len() { + 0 => panic!("no calls"), + 1 => CallInfo::from_runtime_call(NetworkRuntimeCall::Polkadot(batch_calls[0].clone())), + _ => CallInfo::from_runtime_call(NetworkRuntimeCall::Polkadot( + PolkadotRuntimeCall::Utility(UtilityCall::force_batch { calls: batch_calls }), + )), + } } // Take a call, which includes its intended destination, and wrap it in XCM instructions to `send`