Unverified Commit 44951c9d authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Improve `multisig` example (#962)

* Allow payable transactions to be evaluated

* Rename `multisig_plain` ➔ `multisig`

* Fix comment syntax

* Fix case
parent 284e4e55
Pipeline #162488 passed with stages
in 53 minutes and 12 seconds
[package]
name = "multisig_plain"
name = "multisig"
version = "3.0.0-rc5"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......@@ -16,7 +16,7 @@ scale = { package = "parity-scale-codec", version = "2", default-features = fals
scale-info = { version = "1.0", default-features = false, features = ["derive"], optional = true }
[lib]
name = "multisig_plain"
name = "multisig"
path = "lib.rs"
crate-type = ["cdylib"]
......
//! # Plain Multisig Wallet
//! # Multisig Wallet
//!
//! This implements a plain multi owner wallet.
//!
......@@ -55,15 +55,15 @@
#![cfg_attr(not(feature = "std"), no_std)]
pub use self::multisig_plain::{
pub use self::multisig::{
ConfirmationStatus,
MultisigPlain,
Multisig,
Transaction,
};
use ink_lang as ink;
#[ink::contract]
mod multisig_plain {
mod multisig {
use ink_env::call::{
build_call,
utils::ReturnType,
......@@ -150,7 +150,7 @@ mod multisig_plain {
}
#[ink(storage)]
pub struct MultisigPlain {
pub struct Multisig {
/// Every entry in this map represents the confirmation of an owner for a
/// transaction. This is effectively a set rather than a map.
confirmations: StorageHashMap<(TransactionId, AccountId), ()>,
......@@ -247,7 +247,7 @@ mod multisig_plain {
new_requirement: u32,
}
impl MultisigPlain {
impl Multisig {
/// The only constructor of the contract.
///
/// A list of owners must be supplied and a number of how many of them must
......@@ -287,9 +287,9 @@ mod multisig_plain {
/// `Transaction` and dispatched through `submit_transaction` and `invoke_transaction`:
/// ```no_run
/// use ink_env::{DefaultEnvironment as Env, AccountId, call::{CallParams, Selector}, test::CallData};
/// use multisig_plain::{Transaction, ConfirmationStatus};
/// use multisig::{Transaction, ConfirmationStatus};
///
/// // address of an existing MultiSigPlain contract
/// // address of an existing `Multisig` contract
/// let wallet_id: AccountId = [7u8; 32].into();
///
/// // first create the transaction that adds `alice` through `add_owner`
......@@ -506,7 +506,7 @@ mod multisig_plain {
/// Its return value indicates whether the called transaction was successful and contains
/// its output when successful.
/// This can be called by anyone.
#[ink(message)]
#[ink(message, payable)]
pub fn eval_transaction(
&mut self,
trans_id: TransactionId,
......@@ -708,13 +708,13 @@ mod multisig_plain {
.expect("Test environment is expected to be initialized.")
}
fn build_contract() -> MultisigPlain {
fn build_contract() -> Multisig {
let accounts = default_accounts();
let owners = ink_prelude::vec![accounts.alice, accounts.bob, accounts.eve];
MultisigPlain::new(2, owners)
Multisig::new(2, owners)
}
fn submit_transaction() -> MultisigPlain {
fn submit_transaction() -> Multisig {
let mut contract = build_contract();
let accounts = default_accounts();
set_from_owner();
......@@ -752,21 +752,21 @@ mod multisig_plain {
#[ink::test]
#[should_panic]
fn empty_owner_construction_fails() {
MultisigPlain::new(0, vec![]);
Multisig::new(0, vec![]);
}
#[ink::test]
#[should_panic]
fn zero_requirement_construction_fails() {
let accounts = default_accounts();
MultisigPlain::new(0, vec![accounts.alice, accounts.bob]);
Multisig::new(0, vec![accounts.alice, accounts.bob]);
}
#[ink::test]
#[should_panic]
fn too_large_requirement_construction_fails() {
let accounts = default_accounts();
MultisigPlain::new(3, vec![accounts.alice, accounts.bob]);
Multisig::new(3, vec![accounts.alice, accounts.bob]);
}
#[ink::test]
......
Markdown is supported
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