Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
make Cargo.toml
cargo update
cargo update base64ct --precise 1.6.0 # 1.8.0 requires the Cargo feature called `edition2024`
cargo update pallet-revive-proc-macro --precise 0.3.0 # TODO: https://github.com/paritytech/polkadot-sdk/issues/9425
cargo tarpaulin --verbose --no-fail-fast --workspace --timeout 300 --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
run: |
cargo update
cargo update base64ct --precise 1.6.0 # 1.8.0 requires the Cargo feature called `edition2024`
cargo update pallet-revive-proc-macro --precise 0.3.0 # TODO: https://github.com/paritytech/polkadot-sdk/issues/9425
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Check for Wasm
Expand Down
6 changes: 3 additions & 3 deletions nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

use frame_support::{ensure, pallet_prelude::*, traits::Get, BoundedVec, Parameter};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, One, Zero},
Expand All @@ -35,7 +35,7 @@ mod mock;
mod tests;

/// Class info
#[derive(Encode, Decode, Clone, Eq, PartialEq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, Eq, PartialEq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct ClassInfo<TokenId, AccountId, Data, ClassMetadataOf> {
/// Class metadata
pub metadata: ClassMetadataOf,
Expand All @@ -48,7 +48,7 @@ pub struct ClassInfo<TokenId, AccountId, Data, ClassMetadataOf> {
}

/// Token info
#[derive(Encode, Decode, Clone, Eq, PartialEq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, Eq, PartialEq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct TokenInfo<AccountId, Data, TokenMetadataOf> {
/// Token metadata
pub metadata: TokenMetadataOf,
Expand Down
17 changes: 15 additions & 2 deletions oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![allow(clippy::string_lit_as_bytes)]
#![allow(clippy::unused_unit)]

use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};

#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -77,7 +77,20 @@ pub mod module {
pub(crate) type MomentOf<T, I = ()> = <<T as Config<I>>::Time as Time>::Moment;
pub(crate) type TimestampedValueOf<T, I = ()> = TimestampedValue<<T as Config<I>>::OracleValue, MomentOf<T, I>>;

#[derive(Encode, Decode, RuntimeDebug, Eq, PartialEq, Clone, Copy, Ord, PartialOrd, TypeInfo, MaxEncodedLen)]
#[derive(
Encode,
Decode,
DecodeWithMemTracking,
RuntimeDebug,
Eq,
PartialEq,
Clone,
Copy,
Ord,
PartialOrd,
TypeInfo,
MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct TimestampedValue<Value, Moment> {
pub value: Value,
Expand Down
15 changes: 9 additions & 6 deletions payments/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused_qualifications)]
use crate::{pallet, AssetIdOf, BalanceOf};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode, HasCompact, MaxEncodedLen};
use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode, HasCompact, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{DispatchResult, Percent};

Expand All @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
/// guarantee proof of funds and can be released once an agreed upon condition
/// has reached between the payment creator and recipient. The payment lifecycle
/// is tracked using the state field.
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
#[derive(Encode, Decode, DecodeWithMemTracking, Debug, Clone, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
#[scale_info(skip_type_params(T))]
#[codec(mel_bound(T: pallet::Config))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
Expand All @@ -38,7 +38,7 @@ pub struct PaymentDetail<T: pallet::Config> {
/// The `PaymentState` enum tracks the possible states that a payment can be in.
/// When a payment is 'completed' or 'cancelled' it is removed from storage and
/// hence not tracked by a state.
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
#[derive(Encode, Decode, DecodeWithMemTracking, Debug, Clone, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
#[scale_info(skip_type_params(T))]
#[codec(mel_bound(T: pallet::Config))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
Expand Down Expand Up @@ -109,15 +109,18 @@ pub trait FeeHandler<T: pallet::Config> {
}

/// Types of Tasks that can be scheduled in the pallet
#[derive(PartialEq, Eq, Clone, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, DecodeWithMemTracking, Debug, TypeInfo, MaxEncodedLen)]
pub enum Task {
// payment `from` to `to` has to be cancelled
Cancel,
}

/// The details of a scheduled task
#[derive(PartialEq, Eq, Clone, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
pub struct ScheduledTask<Time: HasCompact> {
#[derive(PartialEq, Eq, Clone, Encode, Decode, DecodeWithMemTracking, Debug, TypeInfo, MaxEncodedLen)]
pub struct ScheduledTask<Time>
where
Time: HasCompact,
{
/// the type of scheduled task
pub task: Task,
/// the 'time' at which the task should be executed
Expand Down
9 changes: 7 additions & 2 deletions rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ use sp_runtime::{
use sp_std::{borrow::ToOwned, collections::btree_map::BTreeMap, fmt::Debug, prelude::*};

/// The Reward Pool Info.
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct PoolInfo<Share: HasCompact, Balance: HasCompact, CurrencyId: Ord> {
#[derive(Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct PoolInfo<Share, Balance, CurrencyId>
where
Share: HasCompact,
Balance: HasCompact,
CurrencyId: Ord,
{
/// Total shares amount
pub total_shares: Share,
/// Reward infos <reward_currency, (total_reward, total_withdrawn_reward)>
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.84.1"
components = ["rustfmt", "clippy"]
components = ["rust-src", "rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
8 changes: 5 additions & 3 deletions tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<T: Config> OnDust<T::AccountId, T::CurrencyId, T::Balance> for BurnDust<T>

/// A single lock on a balance. There can be many of these on an account and
/// they "overlap", so the same balance is frozen by multiple locks.
#[derive(Encode, Decode, Clone, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct BalanceLock<Balance> {
/// An identifier for this lock. Only one lock may be in existence for
/// each identifier.
Expand All @@ -125,7 +125,7 @@ pub struct BalanceLock<Balance> {
}

/// Store named reserved balance.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub struct ReserveData<ReserveIdentifier, Balance> {
/// The identifier for the named reserve.
pub id: ReserveIdentifier,
Expand All @@ -134,7 +134,9 @@ pub struct ReserveData<ReserveIdentifier, Balance> {
}

/// balance information for an account.
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, MaxEncodedLen, RuntimeDebug, TypeInfo)]
#[derive(
Encode, Decode, DecodeWithMemTracking, Clone, PartialEq, Eq, Default, MaxEncodedLen, RuntimeDebug, TypeInfo,
)]
pub struct AccountData<Balance> {
/// Non-reserved part of the balance. There may still be restrictions on
/// this, but it is the total pool what may in principle be transferred,
Expand Down
4 changes: 2 additions & 2 deletions traits/src/auction.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Change;
use parity_scale_codec::{Decode, Encode, FullCodec, MaxEncodedLen};
use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode, FullCodec, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AtLeast32Bit, Bounded, MaybeSerializeDeserialize},
Expand All @@ -13,7 +13,7 @@ use sp_std::{

/// Auction info.
#[cfg_attr(feature = "std", derive(PartialEq, Eq))]
#[derive(Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[derive(Encode, Decode, DecodeWithMemTracking, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct AuctionInfo<AccountId, Balance, BlockNumber> {
/// Current bidder and bid price.
pub bid: Option<(AccountId, Balance)>,
Expand Down
11 changes: 7 additions & 4 deletions traits/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

use impl_trait_for_tuples::impl_for_tuples;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use sp_runtime::{DispatchResult, RuntimeDebug};
use sp_std::{
cmp::{Eq, PartialEq},
Expand Down Expand Up @@ -60,17 +60,20 @@ pub trait CombineData<Key, TimestampedValue> {
}

/// Indicate if should change a value
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub enum Change<Value> {
/// No change.
NoChange,
/// Changed to new value.
NewValue(Value),
}

#[derive(Encode, Decode, RuntimeDebug, Eq, PartialEq, Ord, PartialOrd, Clone, Copy)]
#[derive(Encode, Decode, DecodeWithMemTracking, RuntimeDebug, Eq, PartialEq, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct TimestampedValue<Value: Ord + PartialOrd, Moment> {
pub struct TimestampedValue<Value, Moment>
where
Value: Ord + PartialOrd,
{
pub value: Value,
pub timestamp: Moment,
}
Expand Down
3 changes: 2 additions & 1 deletion xtokens/src/mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub const CHARLIE: AccountId32 = AccountId32::new([2u8; 32]);
#[derive(
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
Copy,
Expand All @@ -36,7 +37,7 @@ pub const CHARLIE: AccountId32 = AccountId32::new([2u8; 32]);
parity_scale_codec::MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, DecodeWithMemTracking))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum CurrencyId {
/// Relay chain token.
R,
Expand Down