5
5
use super :: * ;
6
6
use frame_support:: {
7
7
construct_runtime, derive_impl, parameter_types,
8
- traits:: { ConstU128 , EqualPrivilegeOnly , Everything } ,
8
+ traits:: { EqualPrivilegeOnly , Everything } ,
9
9
} ;
10
10
use frame_system:: EnsureRoot ;
11
- use orml_traits:: { define_combined_task_and_bind_delay_hooks, parameter_type_with_key, task:: TaskResult } ;
11
+ use orml_traits:: {
12
+ define_combined_task_and_bind_delay_hooks, location:: AbsoluteReserveProvider , parameter_type_with_key,
13
+ task:: TaskResult ,
14
+ } ;
12
15
use serde:: { Deserialize , Serialize } ;
13
16
use sp_runtime:: { traits:: IdentityLookup , AccountId32 , BuildStorage , DispatchError } ;
14
17
use sp_std:: cell:: RefCell ;
@@ -29,23 +32,6 @@ impl frame_system::Config for Runtime {
29
32
type AccountId = AccountId ;
30
33
type Lookup = IdentityLookup < Self :: AccountId > ;
31
34
type Block = Block ;
32
- type AccountData = pallet_balances:: AccountData < Balance > ;
33
- }
34
-
35
- impl pallet_balances:: Config for Runtime {
36
- type MaxLocks = ConstU32 < 50 > ;
37
- type Balance = Balance ;
38
- type RuntimeEvent = RuntimeEvent ;
39
- type DustRemoval = ( ) ;
40
- type ExistentialDeposit = ConstU128 < 1 > ;
41
- type AccountStore = System ;
42
- type WeightInfo = ( ) ;
43
- type MaxReserves = ConstU32 < 50 > ;
44
- type ReserveIdentifier = [ u8 ; 8 ] ;
45
- type RuntimeHoldReason = RuntimeHoldReason ;
46
- type RuntimeFreezeReason = RuntimeFreezeReason ;
47
- type FreezeIdentifier = [ u8 ; 8 ] ;
48
- type MaxFreezes = ( ) ;
49
35
}
50
36
51
37
impl pallet_preimage:: Config for Runtime {
@@ -181,6 +167,85 @@ impl orml_tokens::Config for Runtime {
181
167
type DustRemovalWhitelist = Everything ;
182
168
}
183
169
170
+ parameter_types ! {
171
+ pub SelfLocation : Location = Location :: new( 1 , [ Parachain ( 2000 ) ] ) ;
172
+ }
173
+
174
+ pub struct AccountIdToLocation ;
175
+ impl Convert < AccountId , Location > for AccountIdToLocation {
176
+ fn convert ( account : AccountId ) -> Location {
177
+ [ Junction :: AccountId32 {
178
+ network : None ,
179
+ id : account. into ( ) ,
180
+ } ]
181
+ . into ( )
182
+ }
183
+ }
184
+
185
+ parameter_type_with_key ! {
186
+ pub ParachainMinFee : |location: Location | -> Option <u128 > {
187
+ #[ allow( clippy:: match_ref_pats) ] // false positive
188
+ match ( location. parents, location. first_interior( ) ) {
189
+ ( 1 , Some ( Parachain ( 3 ) ) ) => Some ( 100 ) ,
190
+ _ => None ,
191
+ }
192
+ } ;
193
+ }
194
+
195
+ pub enum Weightless { }
196
+ impl PreparedMessage for Weightless {
197
+ fn weight_of ( & self ) -> Weight {
198
+ unreachable ! ( )
199
+ }
200
+ }
201
+
202
+ pub struct MockExec ;
203
+ impl ExecuteXcm < RuntimeCall > for MockExec {
204
+ type Prepared = Weightless ;
205
+
206
+ fn prepare ( _message : Xcm < RuntimeCall > ) -> Result < Self :: Prepared , Xcm < RuntimeCall > > {
207
+ unreachable ! ( )
208
+ }
209
+
210
+ fn execute ( _origin : impl Into < Location > , _pre : Weightless , _hash : & mut XcmHash , _weight_credit : Weight ) -> Outcome {
211
+ unreachable ! ( )
212
+ }
213
+
214
+ fn charge_fees ( _location : impl Into < Location > , _fees : Assets ) -> XcmResult {
215
+ Err ( XcmError :: Unimplemented )
216
+ }
217
+ }
218
+
219
+ parameter_types ! {
220
+ pub UniversalLocation : InteriorLocation = Here ;
221
+ pub const UnitWeightCost : Weight = Weight :: from_parts( 10 , 10 ) ;
222
+ pub const BaseXcmWeight : Weight = Weight :: from_parts( 100_000_000 , 100_000_000 ) ;
223
+ pub const MaxInstructions : u32 = 100 ;
224
+ pub const MaxAssetsIntoHolding : u32 = 64 ;
225
+ pub const MaxAssetsForTransfer : usize = 2 ;
226
+ }
227
+
228
+ impl orml_xtokens:: Config for Runtime {
229
+ type RuntimeEvent = RuntimeEvent ;
230
+ type Balance = Balance ;
231
+ type CurrencyId = CurrencyId ;
232
+ type CurrencyIdConvert = CurrencyIdConvert ;
233
+ type AccountIdToLocation = AccountIdToLocation ;
234
+ type SelfLocation = SelfLocation ;
235
+ type XcmExecutor = MockExec ;
236
+ type Weigher = xcm_builder:: FixedWeightBounds < UnitWeightCost , RuntimeCall , MaxInstructions > ;
237
+ type BaseXcmWeight = BaseXcmWeight ;
238
+ type UniversalLocation = UniversalLocation ;
239
+ type MaxAssetsForTransfer = MaxAssetsForTransfer ;
240
+ type MinXcmFee = ParachainMinFee ;
241
+ type LocationsFilter = Everything ;
242
+ type ReserveProvider = AbsoluteReserveProvider ;
243
+ type RateLimiter = ( ) ;
244
+ type RateLimiterId = ( ) ;
245
+ type Task = MockTaskType ;
246
+ type DelayTasks = DelayTasks ;
247
+ }
248
+
184
249
thread_local ! {
185
250
pub static DISPATCH_SUCCEEDED : RefCell <u32 > = RefCell :: new( 0 ) ;
186
251
pub static DISPATCH_FAILED : RefCell <u32 > = RefCell :: new( 0 ) ;
@@ -325,6 +390,7 @@ define_combined_task_and_bind_delay_hooks! {
325
390
FailPreDelay ( FailPreDelayTask , FailPreDelayTaskHook ) ,
326
391
FailPreDelayedExecute ( FailPreDelayedExecuteTask , FailPreDelayedExecuteTaskHook ) ,
327
392
FailPreCancel ( FailPreCancelTask , FailPreCancelTaskHook ) ,
393
+ Xtokens ( XtokensTask <Runtime >, DelayedXtokensTaskHooks <Runtime >) ,
328
394
}
329
395
}
330
396
@@ -356,7 +422,7 @@ construct_runtime!(
356
422
Scheduler : pallet_scheduler,
357
423
Preimage : pallet_preimage,
358
424
Tokens : orml_tokens,
359
- Balances : pallet_balances ,
425
+ XTokens : orml_xtokens ,
360
426
}
361
427
) ;
362
428
0 commit comments