diff --git a/crates/pop-cli/src/cli.rs b/crates/pop-cli/src/cli.rs index afcef292..6c6bb3bc 100644 --- a/crates/pop-cli/src/cli.rs +++ b/crates/pop-cli/src/cli.rs @@ -135,6 +135,7 @@ impl traits::Cli for Cli { /// A confirmation prompt using cliclack. struct Confirm(cliclack::Confirm); + impl traits::Confirm for Confirm { /// Sets the initially selected value. fn initial_value(mut self, initial_value: bool) -> Self { @@ -145,47 +146,11 @@ impl traits::Confirm for Confirm { fn interact(&mut self) -> Result { self.0.interact() } - /// Sets the initially selected value. - fn initial_value(mut self, initial_value: bool) -> Self { - self.0 = self.0.initial_value(initial_value); - self - } } /// A input prompt using cliclack. struct Input(cliclack::Input); -impl traits::Input for Input { - /// Sets the default value for the input. - fn default_input(mut self, value: &str) -> Self { - self.0 = self.0.default_input(value); - self - } - /// Starts the prompt interaction. - fn interact(&mut self) -> Result { - self.0.interact() - } - /// Sets the placeholder (hint) text for the input. - fn placeholder(mut self, placeholder: &str) -> Self { - self.0 = self.0.placeholder(placeholder); - self - } - /// Sets whether the input is required. - fn required(mut self, required: bool) -> Self { - self.0 = self.0.required(required); - self - } - /// Sets a validation callback for the input that is called when the user submits. - fn validate( - mut self, - validator: impl Fn(&String) -> std::result::Result<(), &'static str> + 'static, - ) -> Self { - self.0 = self.0.validate(validator); - self - } -} -/// A input prompt using cliclack. -struct Input(cliclack::Input); impl traits::Input for Input { /// Sets the default value for the input. fn default_input(mut self, value: &str) -> Self { @@ -242,22 +207,7 @@ impl traits::MultiSelect for MultiSelect { struct Select(cliclack::Select); impl traits::Select for Select { - /// Starts the prompt interaction. - fn interact(&mut self) -> Result { - self.0.interact() - } - - /// Adds an item to the selection prompt. - fn item(mut self, value: T, label: impl Display, hint: impl Display) -> Self { - self.0 = self.0.item(value, label, hint); - self - } -} - -/// A select prompt using cliclack. -struct Select(cliclack::Select); - -impl traits::Select for Select { + /// Sets the initially selected value. fn initial_value(mut self, initial_value: T) -> Self { self.0 = self.0.initial_value(initial_value); self @@ -355,18 +305,6 @@ pub(crate) mod tests { self } - pub(crate) fn expect_select( - mut self, - prompt: impl Display, - required: Option, - collect: bool, - items: Option>, - item: usize, - ) -> Self { - self.select_expectation = Some((prompt.to_string(), required, collect, items, item)); - self - } - pub(crate) fn expect_success(mut self, message: impl Display) -> Self { self.success_expectations.push(message.to_string()); self diff --git a/crates/pop-cli/src/commands/call/contract.rs b/crates/pop-cli/src/commands/call/contract.rs index 4e00e37b..0bf5ec03 100644 --- a/crates/pop-cli/src/commands/call/contract.rs +++ b/crates/pop-cli/src/commands/call/contract.rs @@ -612,7 +612,7 @@ mod tests { "Do you want to perform another call using the existing smart contract?", true, ) - .expect_select::( + .expect_select( "Select the message to call:", Some(false), true, @@ -669,8 +669,7 @@ mod tests { ]; // The inputs are processed in reverse order. let mut cli = MockCli::new() - .expect_input("Signer calling the contract:", "//Alice".into()) - .expect_select::( + .expect_select( "Select the message to call:", Some(false), true, @@ -678,17 +677,19 @@ mod tests { 1, // "get" message ) .expect_input( - "Provide the on-chain contract address:", - "15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm".into(), + "Where is your project or contract artifact located?", + temp_dir.path().join("testing").display().to_string(), ) .expect_input( "Where is your contract deployed?", "wss://rpc1.paseo.popnetwork.xyz".into(), ) .expect_input( - "Where is your project or contract artifact located?", - temp_dir.path().join("testing").display().to_string(), - ).expect_info(format!( + "Provide the on-chain contract address:", + "15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm".into(), + ) + .expect_input("Signer calling the contract:", "//Alice".into()) + .expect_info(format!( "pop call contract --path {} --contract 15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm --message get --url wss://rpc1.paseo.popnetwork.xyz/ --suri //Alice", temp_dir.path().join("testing").display().to_string(), )); @@ -750,13 +751,7 @@ mod tests { // The inputs are processed in reverse order. let mut cli = MockCli::new() .expect_confirm("Do you want to execute the call? (Selecting 'No' will perform a dry run)", true) - .expect_input("Signer calling the contract:", "//Alice".into()) - .expect_input("Enter the proof size limit:", "".into()) // Only if call - .expect_input("Enter the gas limit:", "".into()) // Only if call - .expect_input("Value to transfer to the call:", "50".into()) // Only if payable - .expect_input("Enter the value for the parameter: number", "2".into()) // Args for specific_flip - .expect_input("Enter the value for the parameter: new_value", "true".into()) // Args for specific_flip - .expect_select::( + .expect_select( "Select the message to call:", Some(false), true, @@ -764,17 +759,24 @@ mod tests { 2, // "specific_flip" message ) .expect_input( - "Provide the on-chain contract address:", - "15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm".into(), + "Where is your project or contract artifact located?", + temp_dir.path().join("testing").display().to_string(), ) .expect_input( "Where is your contract deployed?", "wss://rpc1.paseo.popnetwork.xyz".into(), ) .expect_input( - "Where is your project or contract artifact located?", - temp_dir.path().join("testing").display().to_string(), - ).expect_info(format!( + "Provide the on-chain contract address:", + "15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm".into(), + ) + .expect_input("Enter the value for the parameter: new_value", "true".into()) // Args for specific_flip + .expect_input("Enter the value for the parameter: number", "2".into()) // Args for specific_flip + .expect_input("Value to transfer to the call:", "50".into()) // Only if payable + .expect_input("Enter the gas limit:", "".into()) // Only if call + .expect_input("Enter the proof size limit:", "".into()) // Only if call + .expect_input("Signer calling the contract:", "//Alice".into()) + .expect_info(format!( "pop call contract --path {} --contract 15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm --message specific_flip --args \"true\", \"2\" --value 50 --url wss://rpc1.paseo.popnetwork.xyz/ --suri //Alice --execute", temp_dir.path().join("testing").display().to_string(), )); @@ -837,11 +839,7 @@ mod tests { ]; // The inputs are processed in reverse order. let mut cli = MockCli::new() - .expect_input("Signer calling the contract:", "//Alice".into()) - .expect_input("Value to transfer to the call:", "50".into()) // Only if payable - .expect_input("Enter the value for the parameter: number", "2".into()) // Args for specific_flip - .expect_input("Enter the value for the parameter: new_value", "true".into()) // Args for specific_flip - .expect_select::( + .expect_select( "Select the message to call:", Some(false), true, @@ -849,17 +847,22 @@ mod tests { 2, // "specific_flip" message ) .expect_input( - "Provide the on-chain contract address:", - "15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm".into(), + "Where is your project or contract artifact located?", + temp_dir.path().join("testing").display().to_string(), ) .expect_input( "Where is your contract deployed?", "wss://rpc1.paseo.popnetwork.xyz".into(), ) .expect_input( - "Where is your project or contract artifact located?", - temp_dir.path().join("testing").display().to_string(), - ).expect_info(format!( + "Provide the on-chain contract address:", + "15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm".into(), + ) + .expect_input("Enter the value for the parameter: new_value", "true".into()) // Args for specific_flip + .expect_input("Enter the value for the parameter: number", "2".into()) // Args for specific_flip + .expect_input("Value to transfer to the call:", "50".into()) // Only if payable + .expect_input("Signer calling the contract:", "//Alice".into()) + .expect_info(format!( "pop call contract --path {} --contract 15XausWjFLBBFLDXUSBRfSfZk25warm4wZRV4ZxhZbfvjrJm --message specific_flip --args \"true\", \"2\" --value 50 --url wss://rpc1.paseo.popnetwork.xyz/ --suri //Alice --execute", temp_dir.path().join("testing").display().to_string(), )); diff --git a/crates/pop-parachains/src/build.rs b/crates/pop-parachains/src/build.rs index 965e5328..1e369f37 100644 --- a/crates/pop-parachains/src/build.rs +++ b/crates/pop-parachains/src/build.rs @@ -78,7 +78,7 @@ pub fn binary_path(target_path: &Path, node_path: &Path) -> Result