Unverified Commit b04f097a authored by Hernando Castano's avatar Hernando Castano Committed by GitHub
Browse files

Allow `pay_with_call` to take multiple arguments (#1401)

parent e8094452
Pipeline #216176 passed with stages
in 20 minutes and 36 seconds
......@@ -399,8 +399,8 @@ pub fn assert_contract_termination<T, F>(
/// Prepend contract message call with value transfer. Used for tests in off-chain environment.
#[macro_export]
macro_rules! pay_with_call {
($contract:ident . $message:ident ( $($params:ty)? ) , $amount:expr) => {{
($contract:ident . $message:ident ( $( $params:expr ),* ) , $amount:expr) => {{
$crate::test::transfer_in::<Environment>($amount);
$contract.$message($($params:ty)?)
$contract.$message($ ($params) ,*)
}}
}
......@@ -35,4 +35,6 @@ fn ui_tests() {
t.compile_fail("tests/ui/trait_def/fail/*.rs");
t.pass("tests/ui/chain_extension/E-01-simple.rs");
t.pass("tests/ui/pay_with_call/pass/multiple_args.rs");
}
#[ink::contract]
mod contract {
#[ink(storage)]
pub struct Contract {}
impl Contract {
#[ink(constructor)]
pub fn new() -> Self {
Self {}
}
#[ink(message)]
pub fn message0(&self) {}
#[ink(message)]
pub fn message1(&self, _arg1: u8) {}
#[ink(message)]
pub fn message2(&self, _arg1: u8, _arg2: (u8, AccountId)) {}
fn check_compiles(&self) {
ink::env::pay_with_call!(self.message0(), 0);
ink::env::pay_with_call!(self.message1(0), 0);
ink::env::pay_with_call!(self.message2(0, (0, Self::env().account_id())), 0);
}
}
}
fn main() {}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment