Skip to content

Commit 9b20bff

Browse files
authored
Make the encoded-Call Vec<u8> explicitly so in metadata (#6566)
1 parent 217b832 commit 9b20bff

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ mod tests;
6161
mod benchmarking;
6262

6363
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
64+
/// Just a bunch of bytes, but they should decode to a valid `Call`.
65+
pub type OpaqueCall = Vec<u8>;
6466

6567
/// Configuration trait.
6668
pub trait Trait: frame_system::Trait {
@@ -122,7 +124,7 @@ decl_storage! {
122124
hasher(twox_64_concat) T::AccountId, hasher(blake2_128_concat) [u8; 32]
123125
=> Option<Multisig<T::BlockNumber, BalanceOf<T>, T::AccountId>>;
124126

125-
pub Calls: map hasher(identity) [u8; 32] => Option<(Vec<u8>, T::AccountId, BalanceOf<T>)>;
127+
pub Calls: map hasher(identity) [u8; 32] => Option<(OpaqueCall, T::AccountId, BalanceOf<T>)>;
126128
}
127129
}
128130

@@ -224,7 +226,7 @@ mod weight_of {
224226
}
225227

226228
enum CallOrHash {
227-
Call(Vec<u8>, bool),
229+
Call(OpaqueCall, bool),
228230
Hash([u8; 32]),
229231
}
230232

@@ -357,7 +359,7 @@ decl_module! {
357359
threshold: u16,
358360
other_signatories: Vec<T::AccountId>,
359361
maybe_timepoint: Option<Timepoint<T::BlockNumber>>,
360-
call: Vec<u8>,
362+
call: OpaqueCall,
361363
store_call: bool,
362364
max_weight: Weight,
363365
) -> DispatchResultWithPostInfo {
@@ -630,9 +632,12 @@ impl<T: Trait> Module<T> {
630632
/// We store `data` here because storing `call` would result in needing another `.encode`.
631633
///
632634
/// Returns a `bool` indicating whether the data did end up being stored.
633-
fn store_call_and_reserve(who: T::AccountId, hash: &[u8; 32], data: Vec<u8>, other_deposit: BalanceOf<T>)
634-
-> DispatchResult
635-
{
635+
fn store_call_and_reserve(
636+
who: T::AccountId,
637+
hash: &[u8; 32],
638+
data: OpaqueCall,
639+
other_deposit: BalanceOf<T>,
640+
) -> DispatchResult {
636641
ensure!(!Calls::<T>::contains_key(hash), Error::<T>::AlreadyStored);
637642
let deposit = other_deposit + T::DepositBase::get()
638643
+ T::DepositFactor::get() * BalanceOf::<T>::from(((data.len() + 31) / 32) as u32);

0 commit comments

Comments
 (0)