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
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.

2 changes: 1 addition & 1 deletion 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 Down
7 changes: 3 additions & 4 deletions zrml/asset-router/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use frame_support::{
pallet_prelude::{DispatchResult, Weight},
traits::{AsEnsureOriginWithArg, Everything},
};
use frame_system::{mocking::MockBlockU32, EnsureSigned};
use frame_system::{mocking::MockBlock, EnsureSigned};
use orml_traits::parameter_type_with_key;
use pallet_assets::ManagedDestroy;
use parity_scale_codec::Compact;
Expand Down Expand Up @@ -78,8 +78,7 @@ parameter_types! {
}

construct_runtime!(
pub enum Runtime
{
pub enum Runtime {
AssetRouter: zrml_asset_router,
Balances: pallet_balances,
CustomAssets: pallet_assets::<Instance1>,
Expand Down Expand Up @@ -110,7 +109,7 @@ impl frame_system::Config for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
type AccountId = AccountIdTest;
type BaseCallFilter = Everything;
type Block = MockBlockU32<Runtime>;
type Block = MockBlock<Runtime>;
type BlockHashCount = BlockHashCount;
type BlockLength = ();
type BlockWeights = ();
Expand Down
7 changes: 2 additions & 5 deletions zrml/authorized/src/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2022-2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
Expand Down Expand Up @@ -27,10 +27,7 @@ use crate::{
Pallet,
};
use frame_benchmarking::benchmarks;
use frame_support::{
dispatch::UnfilteredDispatchable,
traits::{EnsureOrigin, Get, Imbalance},
};
use frame_support::traits::{EnsureOrigin, Get, Imbalance, UnfilteredDispatchable};
use sp_runtime::traits::Saturating;
use zeitgeist_primitives::{
traits::{DisputeApi, DisputeResolutionApi},
Expand Down
18 changes: 9 additions & 9 deletions zrml/authorized/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod pallet {
traits::{Currency, Get, Hooks, IsType, StorageVersion},
PalletId, Twox64Concat,
};
use frame_system::pallet_prelude::OriginFor;
use frame_system::pallet_prelude::{BlockNumberFor, OriginFor};
use sp_runtime::{traits::Saturating, DispatchError, DispatchResult};
use zeitgeist_primitives::{
traits::{DisputeApi, DisputeMaxWeightApi, DisputeResolutionApi},
Expand All @@ -70,7 +70,7 @@ mod pallet {
pub(crate) type MarketOf<T> = Market<
<T as frame_system::Config>::AccountId,
BalanceOf<T>,
<T as frame_system::Config>::BlockNumber,
BlockNumberFor<T>,
MomentOf<T>,
BaseAsset,
MarketIdOf<T>,
Expand Down Expand Up @@ -134,18 +134,18 @@ mod pallet {
/// The period, in which the authority can correct the outcome of a market.
/// This value must not be zero.
#[pallet::constant]
type CorrectionPeriod: Get<Self::BlockNumber>;
type CorrectionPeriod: Get<BlockNumberFor<Self>>;

type DisputeResolution: DisputeResolutionApi<
AccountId = Self::AccountId,
BlockNumber = Self::BlockNumber,
BlockNumber = BlockNumberFor<Self>,
MarketId = MarketIdOf<Self>,
Moment = MomentOf<Self>,
>;

type MarketCommons: MarketCommonsPalletApi<
AccountId = Self::AccountId,
BlockNumber = Self::BlockNumber,
BlockNumber = BlockNumberFor<Self>,
Balance = BalanceOf<Self>,
>;

Expand Down Expand Up @@ -181,7 +181,7 @@ mod pallet {
}

#[pallet::hooks]
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {}
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand All @@ -192,7 +192,7 @@ mod pallet {
T: Config,
{
/// Return the resolution block number for the given market.
fn get_auto_resolve(market_id: &MarketIdOf<T>) -> Option<T::BlockNumber> {
fn get_auto_resolve(market_id: &MarketIdOf<T>) -> Option<BlockNumberFor<T>> {
AuthorizedOutcomeReports::<T>::get(market_id).map(|report| report.resolve_at)
}

Expand Down Expand Up @@ -246,7 +246,7 @@ mod pallet {
type AccountId = T::AccountId;
type Balance = BalanceOf<T>;
type NegativeImbalance = NegativeImbalanceOf<T>;
type BlockNumber = T::BlockNumber;
type BlockNumber = BlockNumberFor<T>;
type MarketId = MarketIdOf<T>;
type Moment = MomentOf<T>;
type Origin = T::RuntimeOrigin;
Expand Down Expand Up @@ -361,7 +361,7 @@ mod pallet {
#[pallet::storage]
#[pallet::getter(fn outcomes)]
pub type AuthorizedOutcomeReports<T: Config> =
StorageMap<_, Twox64Concat, MarketIdOf<T>, AuthorityReport<T::BlockNumber>, OptionQuery>;
StorageMap<_, Twox64Concat, MarketIdOf<T>, AuthorityReport<BlockNumberFor<T>>, OptionQuery>;
}

#[cfg(any(feature = "runtime-benchmarks", test))]
Expand Down
58 changes: 25 additions & 33 deletions zrml/authorized/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,34 @@ extern crate alloc;

use crate::{self as zrml_authorized, mock_storage::pallet as mock_storage};
use alloc::{vec, vec::Vec};
use frame_support::{
construct_runtime, ord_parameter_types,
pallet_prelude::{DispatchError, Weight},
traits::Everything,
};
use frame_system::EnsureSignedBy;
use frame_support::{construct_runtime, ord_parameter_types, traits::Everything, weights::Weight};
use frame_system::{mocking::MockBlock, EnsureSignedBy};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage, DispatchError,
};
use zeitgeist_primitives::{
constants::mock::{
AuthorizedPalletId, BlockHashCount, CorrectionPeriod, MaxReserves, MinimumPeriod, BASE,
AuthorizedPalletId, BlockHashCount, CorrectionPeriod, ExistentialDeposit, MaxLocks,
MaxReserves, MinimumPeriod, BASE,
},
traits::{DisputeResolutionApi, MarketOfDisputeResolutionApi},
types::{
AccountIdTest, Balance, BlockNumber, BlockTest, Hash, Index, MarketId, Moment,
UncheckedExtrinsicTest,
},
types::{AccountIdTest, Balance, BlockNumber, Hash, MarketId, Moment},
};

pub const ALICE: AccountIdTest = 0;
pub const BOB: AccountIdTest = 1;
pub const CHARLIE: AccountIdTest = 2;

construct_runtime!(
pub enum Runtime
where
Block = BlockTest<Runtime>,
NodeBlock = BlockTest<Runtime>,
UncheckedExtrinsic = UncheckedExtrinsicTest<Runtime>,
{
Authorized: zrml_authorized::{Event<T>, Pallet, Storage},
Balances: pallet_balances::{Call, Config<T>, Event<T>, Pallet, Storage},
MarketCommons: zrml_market_commons::{Pallet, Storage},
System: frame_system::{Call, Config, Event<T>, Pallet, Storage},
Timestamp: pallet_timestamp::{Pallet},
pub enum Runtime {
Authorized: zrml_authorized,
Balances: pallet_balances,
MarketCommons: zrml_market_commons,
System: frame_system,
Timestamp: pallet_timestamp,
// Just a mock storage for testing.
MockStorage: mock_storage::{Storage},
MockStorage: mock_storage,
}
);

Expand Down Expand Up @@ -113,7 +102,7 @@ impl DisputeResolutionApi for MockResolution {

impl crate::Config for Runtime {
type Currency = Balances;
type RuntimeEvent = ();
type RuntimeEvent = RuntimeEvent;
type CorrectionPeriod = CorrectionPeriod;
type DisputeResolution = MockResolution;
type MarketCommons = MarketCommons;
Expand All @@ -131,18 +120,17 @@ impl frame_system::Config for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
type AccountId = AccountIdTest;
type BaseCallFilter = Everything;
type Block = MockBlock<Runtime>;
type BlockHashCount = BlockHashCount;
type BlockLength = ();
type BlockNumber = BlockNumber;
type BlockWeights = ();
type RuntimeCall = RuntimeCall;
type DbWeight = ();
type RuntimeEvent = ();
type RuntimeEvent = RuntimeEvent;
type Hash = Hash;
type Hashing = BlakeTwo256;
type Header = Header;
type Index = Index;
type Lookup = IdentityLookup<Self::AccountId>;
type Nonce = u64;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type OnKilledAccount = ();
type OnNewAccount = ();
Expand All @@ -158,9 +146,13 @@ impl pallet_balances::Config for Runtime {
type AccountStore = System;
type Balance = Balance;
type DustRemoval = ();
type RuntimeEvent = ();
type ExistentialDeposit = ();
type MaxLocks = ();
type FreezeIdentifier = ();
type RuntimeHoldReason = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type MaxHolds = ();
type MaxFreezes = ();
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
Expand Down Expand Up @@ -191,7 +183,7 @@ impl Default for ExtBuilder {

impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
let mut t = frame_system::GenesisConfig::<Runtime>::default().build_storage().unwrap();

// see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture`
let _ = env_logger::builder().is_test(true).try_init();
Expand Down
5 changes: 3 additions & 2 deletions zrml/authorized/src/mock_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
pub(crate) mod pallet {
use core::marker::PhantomData;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::BlockNumberFor;
use zrml_market_commons::MarketCommonsPalletApi;

pub(crate) type MarketIdOf<T> =
Expand All @@ -32,7 +33,7 @@ pub(crate) mod pallet {

#[pallet::config]
pub trait Config: frame_system::Config {
type MarketCommons: MarketCommonsPalletApi<AccountId = Self::AccountId, BlockNumber = Self::BlockNumber>;
type MarketCommons: MarketCommonsPalletApi<AccountId = Self::AccountId, BlockNumber = BlockNumberFor<Self>>;
}

#[pallet::pallet]
Expand All @@ -43,7 +44,7 @@ pub(crate) mod pallet {
pub(crate) type MarketIdsPerDisputeBlock<T: Config> = StorageMap<
_,
Twox64Concat,
T::BlockNumber,
BlockNumberFor<T>,
BoundedVec<MarketIdOf<T>, CacheSize>,
ValueQuery,
>;
Expand Down
5 changes: 3 additions & 2 deletions zrml/authorized/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2022-2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
Expand All @@ -24,7 +24,8 @@ use crate::{
mock_storage::pallet as mock_storage,
AuthorizedOutcomeReports, Error,
};
use frame_support::{assert_noop, assert_ok, dispatch::DispatchError};
use frame_support::{assert_noop, assert_ok};
use sp_runtime::DispatchError;
use zeitgeist_primitives::{
traits::DisputeApi,
types::{AuthorityReport, MarketDisputeMechanism, MarketStatus, OutcomeReport},
Expand Down
1 change: 1 addition & 0 deletions zrml/court/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ arrayvec = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] }
rand = { workspace = true, features = ["alloc", "std_rng"] }
rand_chacha = { workspace = true }
Expand Down
Loading