Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update remaining Zeitgeist pallets #1322

Merged
Merged
Show file tree
Hide file tree
Changes from 16 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
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions primitives/src/constants/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ parameter_types! {
// Shared within tests
// Balance
parameter_types! {
pub const ExistentialDeposit: u128 = CENT;
pub const ExistentialDeposit: u128 = 2;
pub const MaxLocks: u32 = 50;
pub const MaxReserves: u32 = 50;
}
Expand All @@ -191,7 +191,7 @@ parameter_type_with_key! {

// System
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const BlockHashCount: u32 = 250;
}

// Time
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/math/checked_ops_res.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

use frame_support::dispatch::DispatchError;
use num_traits::{checked_pow, One};
use sp_arithmetic::{
traits::{CheckedAdd, CheckedDiv, CheckedMul, CheckedRem, CheckedSub},
ArithmeticError,
};
use sp_runtime::DispatchError;

pub trait CheckedAddRes
where
Expand Down
3 changes: 2 additions & 1 deletion primitives/src/math/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ use alloc::{
};
use core::{cmp::Ordering, convert::TryFrom, marker::PhantomData};
use fixed::{traits::Fixed, ParseFixedError};
use frame_support::{dispatch::DispatchError, ensure};
use frame_support::ensure;
use sp_arithmetic::{
traits::{AtLeast32BitUnsigned, Zero},
ArithmeticError,
};
use sp_runtime::DispatchError;

/// Trait for safely obtaining constants converted to generic types in a Substrate context.
pub trait BaseProvider<T> {
Expand Down
2 changes: 0 additions & 2 deletions primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ mod market_commons_pallet_api;
mod market_id;
mod market_transition_api;
mod swaps;
mod weights;
mod zeitgeist_asset;

pub use complete_set_operations_api::*;
Expand All @@ -41,5 +40,4 @@ pub use market_commons_pallet_api::*;
pub use market_id::*;
pub use market_transition_api::*;
pub use swaps::*;
pub use weights::*;
pub use zeitgeist_asset::*;
2 changes: 1 addition & 1 deletion primitives/src/traits/hybrid_router_amm_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

use crate::hybrid_router_api_types::{AmmSoftFail, AmmTrade, ApiError};
use frame_support::dispatch::DispatchError;
use sp_runtime::DispatchError;

/// A type alias for the return struct of AMM buy and sell.
type AmmTradeOf<T> = AmmTrade<<T as HybridRouterAmmApi>::Balance>;
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/traits/hybrid_router_orderbook_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

use frame_support::dispatch::DispatchError;
use sp_runtime::DispatchError;

use crate::hybrid_router_api_types::{ApiError, OrderbookSoftFail, OrderbookTrade};

Expand Down
8 changes: 6 additions & 2 deletions primitives/src/traits/market_commons_pallet_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ use crate::{
traits::MarketBuilderTrait,
types::{BaseAsset, Market, PoolId},
};
use alloc::fmt::Debug;
use frame_support::{
dispatch::{fmt::Debug, DispatchError, DispatchResult},
dispatch::DispatchResult,
pallet_prelude::{MaybeSerializeDeserialize, Member},
storage::PrefixIterator,
Parameter,
};
use parity_scale_codec::{FullCodec, HasCompact, MaxEncodedLen};
use sp_runtime::traits::{AtLeast32Bit, AtLeast32BitUnsigned};
use sp_runtime::{
traits::{AtLeast32Bit, AtLeast32BitUnsigned},
DispatchError,
};

// Abstraction of the market type, which is not a part of `MarketCommonsPalletApi` because Rust
// doesn't support type aliases in traits.
Expand Down
3 changes: 2 additions & 1 deletion primitives/src/traits/swaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

use crate::types::PoolId;
use alloc::vec::Vec;
use frame_support::dispatch::{DispatchError, DispatchResult, Weight};
use frame_support::{dispatch::DispatchResult, weights::Weight};
use parity_scale_codec::{HasCompact, MaxEncodedLen};
use sp_runtime::DispatchError;

pub trait Swaps<AccountId> {
type Asset: MaxEncodedLen;
Expand Down
60 changes: 0 additions & 60 deletions primitives/src/traits/weights.rs

This file was deleted.

2 changes: 1 addition & 1 deletion primitives/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use crate::{
};
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Result, Unstructured};
use frame_support::dispatch::Weight;
use frame_support::weights::Weight;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{
Expand Down
26 changes: 13 additions & 13 deletions zrml/asset-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,21 @@ pub mod pallet {
pub(crate) use alloc::collections::BTreeMap;
pub(crate) use core::{fmt::Debug, marker::PhantomData};
pub(crate) use frame_support::{
ensure, log,
pallet_prelude::{DispatchError, DispatchResult, Hooks, StorageValue, ValueQuery, Weight},
ensure,
pallet_prelude::{DispatchResult, Hooks, StorageValue, ValueQuery, Weight},
require_transactional,
traits::{
tokens::{
fungibles::{Create, Destroy, Inspect, Mutate, Transfer, Unbalanced},
DepositConsequence, WithdrawConsequence,
fungibles::{Create, Destroy, Inspect, Mutate, Unbalanced},
DepositConsequence, Fortitude, Precision, Preservation, Provenance,
WithdrawConsequence,
},
BalanceStatus as Status, ConstU32,
},
BoundedVec, Parameter,
};
pub(crate) use frame_system::pallet_prelude::BlockNumberFor;
use log;
pub(crate) use orml_traits::{
arithmetic::Signed,
currency::{
Expand All @@ -62,13 +65,10 @@ pub mod pallet {
use parity_scale_codec::{FullCodec, MaxEncodedLen};
use scale_info::TypeInfo;
pub(crate) use sp_runtime::{
traits::{
AtLeast32BitUnsigned, Bounded, Get, MaybeSerializeDeserialize, Member, Saturating, Zero,
},
FixedPointOperand, SaturatedConversion,
traits::{AtLeast32BitUnsigned, Bounded, Get, MaybeSerializeDeserialize, Member, Zero},
DispatchError, FixedPointOperand, SaturatedConversion,
};
use zeitgeist_macros::unreachable_non_terminating;
pub(crate) use zeitgeist_primitives::traits::CheckedDivPerComponent;

pub(crate) const LOG_TARGET: &str = "runtime::asset-router";
pub(crate) const MAX_ASSET_DESTRUCTIONS_PER_BLOCK: u8 = 128;
Expand All @@ -81,7 +81,6 @@ pub mod pallet {
Create<T::AccountId, AssetId = A, Balance = T::Balance>
+ Destroy<T::AccountId, AssetId = A, Balance = T::Balance>
+ Inspect<T::AccountId, AssetId = A, Balance = T::Balance>
+ Transfer<T::AccountId, AssetId = A, Balance = T::Balance>
+ Mutate<T::AccountId, AssetId = A, Balance = T::Balance>
+ Unbalanced<T::AccountId, AssetId = A, Balance = T::Balance>
{
Expand All @@ -92,7 +91,6 @@ pub mod pallet {
G: Create<T::AccountId, AssetId = A, Balance = T::Balance>
+ Destroy<T::AccountId, AssetId = A, Balance = T::Balance>
+ Inspect<T::AccountId, AssetId = A, Balance = T::Balance>
+ Transfer<T::AccountId, AssetId = A, Balance = T::Balance>
+ Mutate<T::AccountId, AssetId = A, Balance = T::Balance>
+ Unbalanced<T::AccountId, AssetId = A, Balance = T::Balance>,
T: Config,
Expand Down Expand Up @@ -216,14 +214,16 @@ pub mod pallet {
UnknownAsset,
/// Operation is not supported for given asset
Unsupported,
/// Only a partial amount was deposited
DepositOnlyPartial,
}

#[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>);

#[pallet::hooks]
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {
fn on_idle(_: T::BlockNumber, mut remaining_weight: Weight) -> Weight {
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_idle(_: BlockNumberFor<T>, mut remaining_weight: Weight) -> Weight {
let max_extra_weight = Self::on_idle_max_extra_weight();

if !remaining_weight
Expand Down
Loading
Loading