Skip to content
Snippets Groups Projects
Commit d318a13b authored by Keith Yeung's avatar Keith Yeung Committed by GitHub
Browse files

Add and implement MaxEncodedLen to token traits (#11945)

* Add and implement MaxEncodedLen bounds to token traits

* cargo fmt

* Update UI test expectations
parent f73ce579
No related merge requests found
......@@ -17,7 +17,7 @@
//! Miscellaneous types.
use codec::{Decode, Encode, FullCodec};
use codec::{Decode, Encode, FullCodec, MaxEncodedLen};
use sp_arithmetic::traits::{AtLeast32BitUnsigned, Zero};
use sp_core::RuntimeDebug;
use sp_runtime::{ArithmeticError, DispatchError, TokenError};
......@@ -116,7 +116,9 @@ pub enum ExistenceRequirement {
}
/// Status of funds.
#[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
#[derive(
PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen,
)]
pub enum BalanceStatus {
/// Funds are free, as corresponding to `free` item in Balances.
Free,
......@@ -126,7 +128,7 @@ pub enum BalanceStatus {
bitflags::bitflags! {
/// Reasons for moving funds out of an account.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, MaxEncodedLen)]
pub struct WithdrawReasons: u8 {
/// In order to pay for (system) transaction costs.
const TRANSACTION_PAYMENT = 0b00000001;
......@@ -161,16 +163,29 @@ impl WithdrawReasons {
}
/// Simple amalgamation trait to collect together properties for an AssetId under one roof.
pub trait AssetId: FullCodec + Copy + Eq + PartialEq + Debug + scale_info::TypeInfo {}
impl<T: FullCodec + Copy + Eq + PartialEq + Debug + scale_info::TypeInfo> AssetId for T {}
pub trait AssetId:
FullCodec + Copy + Eq + PartialEq + Debug + scale_info::TypeInfo + MaxEncodedLen
{
}
impl<T: FullCodec + Copy + Eq + PartialEq + Debug + scale_info::TypeInfo + MaxEncodedLen> AssetId
for T
{
}
/// Simple amalgamation trait to collect together properties for a Balance under one roof.
pub trait Balance:
AtLeast32BitUnsigned + FullCodec + Copy + Default + Debug + scale_info::TypeInfo
AtLeast32BitUnsigned + FullCodec + Copy + Default + Debug + scale_info::TypeInfo + MaxEncodedLen
{
}
impl<T: AtLeast32BitUnsigned + FullCodec + Copy + Default + Debug + scale_info::TypeInfo> Balance
for T
impl<
T: AtLeast32BitUnsigned
+ FullCodec
+ Copy
+ Default
+ Debug
+ scale_info::TypeInfo
+ MaxEncodedLen,
> Balance for T
{
}
......
......@@ -13,5 +13,5 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 70 others
and 72 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>`
......@@ -13,6 +13,6 @@ error[E0277]: the trait bound `Bar: MaxEncodedLen` is not satisfied
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 70 others
and 72 others
= note: required because of the requirements on the impl of `KeyGeneratorMaxEncodedLen` for `Key<frame_support::Twox64Concat, Bar>`
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageNMap<_GeneratedPrefixForStorageFoo<T>, Key<frame_support::Twox64Concat, Bar>, u32>`
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