From f744d6911e1369c97f2c5044b2ef77eb7f851987 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Fri, 3 Jul 2020 19:29:35 +0200 Subject: [PATCH] Make the encoded-Call Vec explicitly so in metadata (#6566) --- substrate/frame/multisig/src/lib.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/substrate/frame/multisig/src/lib.rs b/substrate/frame/multisig/src/lib.rs index bcea34f9b3..388981cb8f 100644 --- a/substrate/frame/multisig/src/lib.rs +++ b/substrate/frame/multisig/src/lib.rs @@ -61,6 +61,8 @@ mod tests; mod benchmarking; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +/// Just a bunch of bytes, but they should decode to a valid `Call`. +pub type OpaqueCall = Vec; /// Configuration trait. pub trait Trait: frame_system::Trait { @@ -122,7 +124,7 @@ decl_storage! { hasher(twox_64_concat) T::AccountId, hasher(blake2_128_concat) [u8; 32] => Option, T::AccountId>>; - pub Calls: map hasher(identity) [u8; 32] => Option<(Vec, T::AccountId, BalanceOf)>; + pub Calls: map hasher(identity) [u8; 32] => Option<(OpaqueCall, T::AccountId, BalanceOf)>; } } @@ -224,7 +226,7 @@ mod weight_of { } enum CallOrHash { - Call(Vec, bool), + Call(OpaqueCall, bool), Hash([u8; 32]), } @@ -357,7 +359,7 @@ decl_module! { threshold: u16, other_signatories: Vec, maybe_timepoint: Option>, - call: Vec, + call: OpaqueCall, store_call: bool, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -630,9 +632,12 @@ impl Module { /// We store `data` here because storing `call` would result in needing another `.encode`. /// /// Returns a `bool` indicating whether the data did end up being stored. - fn store_call_and_reserve(who: T::AccountId, hash: &[u8; 32], data: Vec, other_deposit: BalanceOf) - -> DispatchResult - { + fn store_call_and_reserve( + who: T::AccountId, + hash: &[u8; 32], + data: OpaqueCall, + other_deposit: BalanceOf, + ) -> DispatchResult { ensure!(!Calls::::contains_key(hash), Error::::AlreadyStored); let deposit = other_deposit + T::DepositBase::get() + T::DepositFactor::get() * BalanceOf::::from(((data.len() + 31) / 32) as u32);