Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using CallData in Multisig doc test #1202

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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