-
Notifications
You must be signed in to change notification settings - Fork 40
/
lib.rs
156 lines (138 loc) · 5.36 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
//
// Zeitgeist is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// Zeitgeist is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "512"]
extern crate alloc;
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use common_runtime::{
create_common_benchmark_logic, create_common_tests, create_runtime, create_runtime_api,
create_runtime_with_additional_pallets, decl_common_types, impl_config_traits,
};
pub use frame_system::{
Call as SystemCall, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion,
CheckTxVersion, CheckWeight,
};
#[cfg(feature = "parachain")]
pub use pallet_author_slot_filter::EligibilityValue;
pub use pallet_balances::Call as BalancesCall;
use pallet_collective::EnsureProportionMoreThan;
#[cfg(feature = "parachain")]
pub use crate::parachain_params::*;
pub use crate::parameters::*;
use alloc::vec;
use frame_support::{
traits::{ConstU16, ConstU32, Contains, EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter},
weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee},
};
use frame_system::EnsureRoot;
use pallet_collective::{EnsureProportionAtLeast, PrimeDefaultVote};
use pallet_transaction_payment::ChargeTransactionPayment;
use sp_runtime::traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use substrate_fixed::{types::extra::U33, FixedI128, FixedU128};
use zeitgeist_primitives::{constants::*, types::*};
use zrml_rikiddo::types::{EmaMarketVolume, FeeSigmoid, RikiddoSigmoidMV};
#[cfg(feature = "parachain")]
use {
frame_support::traits::{AsEnsureOriginWithArg, Everything, Nothing},
xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, LocationInverter},
xcm_config::{
asset_registry::CustomAssetProcessor,
config::{LocalOriginToLocation, XcmConfig, XcmOriginToTransactDispatchOrigin, XcmRouter},
},
};
use frame_support::construct_runtime;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str,
traits::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
#[cfg(feature = "parachain")]
use nimbus_primitives::CanAuthor;
use sp_version::RuntimeVersion;
#[cfg(test)]
pub mod integration_tests;
#[cfg(feature = "parachain")]
pub mod parachain_params;
pub mod parameters;
#[cfg(feature = "parachain")]
pub mod xcm_config;
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("zeitgeist"),
impl_name: create_runtime_str!("zeitgeist"),
authoring_version: 1,
spec_version: 42,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 19,
state_version: 1,
};
#[derive(scale_info::TypeInfo)]
pub struct IsCallable;
// Currently disables Court, Rikiddo and creation of markets using Court.
impl Contains<Call> for IsCallable {
fn contains(call: &Call) -> bool {
use zeitgeist_primitives::types::{
MarketDisputeMechanism::Court, ScoringRule::RikiddoSigmoidFeeMarketEma,
};
use zrml_prediction_markets::Call::{
create_cpmm_market_and_deploy_assets, create_market, edit_market,
};
#[allow(clippy::match_like_matches_macro)]
match call {
Call::Court(_) => false,
Call::LiquidityMining(_) => false,
Call::PredictionMarkets(inner_call) => {
match inner_call {
// Disable Rikiddo markets
create_market { scoring_rule: RikiddoSigmoidFeeMarketEma, .. } => false,
edit_market { scoring_rule: RikiddoSigmoidFeeMarketEma, .. } => false,
// Disable Court dispute resolution mechanism
create_market { dispute_mechanism: Court, .. } => false,
create_cpmm_market_and_deploy_assets { dispute_mechanism: Court, .. } => false,
edit_market { dispute_mechanism: Court, .. } => false,
_ => true,
}
}
_ => true,
}
}
}
decl_common_types!();
#[cfg(feature = "with-global-disputes")]
create_runtime_with_additional_pallets!(
GlobalDisputes: zrml_global_disputes::{Call, Event<T>, Pallet, Storage} = 59,
Sudo: pallet_sudo::{Call, Config<T>, Event<T>, Pallet, Storage} = 150,
);
#[cfg(not(feature = "with-global-disputes"))]
create_runtime_with_additional_pallets!(
Sudo: pallet_sudo::{Call, Config<T>, Event<T>, Pallet, Storage} = 150,
);
impl pallet_sudo::Config for Runtime {
type Call = Call;
type Event = Event;
}
impl_config_traits!();
create_runtime_api!();
create_common_benchmark_logic!();
create_common_tests!();