Skip to content

Commit

Permalink
Stop using CallData in Multisig doc test (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano authored Mar 28, 2022
1 parent 2437357 commit 0897dea
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions examples/multisig/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,22 +309,32 @@ mod multisig {
/// Since this message must be send by the wallet itself it has to be build as a
/// `Transaction` and dispatched through `submit_transaction` and `invoke_transaction`:
/// ```should_panic
/// use ink_env::{DefaultEnvironment as Env, AccountId, call::{CallParams, Selector, ExecutionInput, Call}, test::CallData};
/// use ink_env::{
/// call::{
/// utils::ArgumentList,
/// Call,
/// CallParams,
/// ExecutionInput,
/// Selector,
/// },
/// AccountId,
/// DefaultEnvironment as Env,
/// };
/// use ink_lang::selector_bytes;
/// use scale::Encode;
/// use multisig::{Transaction, ConfirmationStatus};
///
/// // address of an existing `Multisig` contract
/// let wallet_id: AccountId = [7u8; 32].into();
///
/// // first create the transaction that adds `alice` through `add_owner`
/// let alice: AccountId = [1u8; 32].into();
/// // Note: The selector bytes for `add_owner` are [166, 229, 27, 154]
/// let mut add_owner_call = CallData::new(Selector::new([166, 229, 27, 154]));
/// add_owner_call.push_arg(&alice);
/// let add_owner_args = ArgumentList::empty().push_arg(&alice);
///
/// let transaction_candidate = Transaction {
/// callee: wallet_id,
/// selector: add_owner_call.selector().to_bytes(),
/// input: add_owner_call.params().to_owned(),
/// selector: selector_bytes!("add_owner"),
/// input: add_owner_args.encode(),
/// transferred_value: 0,
/// gas_limit: 0
/// };
Expand Down Expand Up @@ -705,7 +715,7 @@ mod multisig {
mod tests {
use super::*;
use ink_env::{
call,
call::utils::ArgumentList,
test,
};
use ink_lang as ink;
Expand All @@ -714,13 +724,14 @@ mod multisig {

impl Transaction {
fn change_requirement(requirement: u32) -> Self {
use scale::Encode;
let call_args = ArgumentList::empty().push_arg(&requirement);

// Multisig::change_requirement()
let mut call = test::CallData::new(call::Selector::new([0x00; 4]));
call.push_arg(&requirement);
Self {
callee: AccountId::from(WALLET),
selector: call.selector().to_bytes(),
input: call.params().to_owned(),
selector: ink::selector_bytes!("change_requirement"),
input: call_args.encode(),
transferred_value: 0,
gas_limit: 1000000,
}
Expand Down

0 comments on commit 0897dea

Please sign in to comment.