Skip to content

Commit b04f097

Browse files
authored
Allow pay_with_call to take multiple arguments (#1401)
1 parent e809445 commit b04f097

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

crates/env/src/engine/off_chain/test_api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ pub fn assert_contract_termination<T, F>(
399399
/// Prepend contract message call with value transfer. Used for tests in off-chain environment.
400400
#[macro_export]
401401
macro_rules! pay_with_call {
402-
($contract:ident . $message:ident ( $($params:ty)? ) , $amount:expr) => {{
402+
($contract:ident . $message:ident ( $( $params:expr ),* ) , $amount:expr) => {{
403403
$crate::test::transfer_in::<Environment>($amount);
404-
$contract.$message($($params:ty)?)
404+
$contract.$message($ ($params) ,*)
405405
}}
406406
}

crates/ink/tests/compile_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ fn ui_tests() {
3535
t.compile_fail("tests/ui/trait_def/fail/*.rs");
3636

3737
t.pass("tests/ui/chain_extension/E-01-simple.rs");
38+
39+
t.pass("tests/ui/pay_with_call/pass/multiple_args.rs");
3840
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#[ink::contract]
2+
mod contract {
3+
#[ink(storage)]
4+
pub struct Contract {}
5+
6+
impl Contract {
7+
#[ink(constructor)]
8+
pub fn new() -> Self {
9+
Self {}
10+
}
11+
12+
#[ink(message)]
13+
pub fn message0(&self) {}
14+
15+
#[ink(message)]
16+
pub fn message1(&self, _arg1: u8) {}
17+
18+
#[ink(message)]
19+
pub fn message2(&self, _arg1: u8, _arg2: (u8, AccountId)) {}
20+
21+
fn check_compiles(&self) {
22+
ink::env::pay_with_call!(self.message0(), 0);
23+
ink::env::pay_with_call!(self.message1(0), 0);
24+
ink::env::pay_with_call!(self.message2(0, (0, Self::env().account_id())), 0);
25+
}
26+
}
27+
}
28+
29+
fn main() {}

0 commit comments

Comments
 (0)