Skip to content

Commit 0b1578b

Browse files
committed
fix: handle case without parameters specified
1 parent 890c785 commit 0b1578b

File tree

1 file changed

+12
-1
lines changed
  • crates/pop-cli/src/commands/call

1 file changed

+12
-1
lines changed

crates/pop-cli/src/commands/call/chain.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ use url::Url;
2424
const DEFAULT_URI: &str = "//Alice";
2525
const ENCODED_CALL_DATA_MAX_LEN: usize = 500; // Maximum length of encoded call data to display.
2626

27+
fn to_tuple(args: &[String]) -> String {
28+
match args.len() {
29+
0 => "".to_string(),
30+
1 => args[0].clone(),
31+
_ => format!("({})", args.join(",")),
32+
}
33+
}
34+
2735
/// Command to construct and execute extrinsics with configurable pallets, functions, arguments, and
2836
/// signing options.
2937
#[derive(Args, Clone, Default)]
@@ -308,7 +316,7 @@ impl CallChainCommand {
308316
let is_composite = key_param.sub_params.len() > 1;
309317
let (mut params, len) =
310318
if self.args.len() == key_param.sub_params.len() && is_composite {
311-
(vec![format!("({})", self.args.join(","))], self.args.len())
319+
(vec![to_tuple(self.args.as_slice())], self.args.len())
312320
} else if self.args.len() == 1 && is_composite {
313321
// Handle composite tuple string like "(A, B, C)"
314322
let arg = self.args[0]
@@ -345,6 +353,9 @@ impl CallChainCommand {
345353
break;
346354
}
347355
}
356+
if is_composite {
357+
params = vec![to_tuple(params.as_slice())];
358+
}
348359
}
349360
params
350361
} else {

0 commit comments

Comments
 (0)