@@ -28,15 +28,13 @@ pub use pallet::*;
28
28
use parity_scale_codec:: { Decode , Encode } ;
29
29
use scale_info:: TypeInfo ;
30
30
use sp_io:: { crypto:: secp256k1_ecdsa_recover, hashing:: keccak_256} ;
31
- #[ cfg( feature = "std" ) ]
32
- use sp_runtime:: traits:: Zero ;
33
31
use sp_runtime:: {
34
- traits:: { CheckedSub , DispatchInfoOf , SignedExtension } ,
32
+ traits:: { CheckedSub , DispatchInfoOf , SignedExtension , Zero } ,
35
33
transaction_validity:: {
36
34
InvalidTransaction , TransactionValidity , TransactionValidityError , ValidTransaction ,
37
35
} ,
38
36
} ;
39
- use sp_std:: { fmt:: Debug , prelude:: * , vec} ;
37
+ use sp_std:: { fmt:: Debug , prelude:: * , vec, vec :: Vec } ;
40
38
41
39
type CurrencyOf < T > = <<T as Config >:: VestingSchedule as VestingSchedule <
42
40
<T as frame_system:: Config >:: AccountId ,
@@ -85,7 +83,7 @@ pub mod pallet {
85
83
pub trait Config : frame_system:: Config {
86
84
/// The overarching event type.
87
85
type RuntimeEvent : From < Event < Self > > + IsType < <Self as frame_system:: Config >:: RuntimeEvent > ;
88
- type VestingSchedule : VestingSchedule < Self :: AccountId , Moment = Self :: BlockNumber > ;
86
+ type VestingSchedule : VestingSchedule < Self :: AccountId , Moment = BlockNumberFor < Self > > ;
89
87
#[ pallet:: constant]
90
88
type Prefix : Get < & ' static [ u8 ] > ;
91
89
type MoveClaimOrigin : EnsureOrigin < Self :: RuntimeOrigin > ;
@@ -131,7 +129,7 @@ pub mod pallet {
131
129
#[ pallet:: storage]
132
130
#[ pallet:: getter( fn vesting) ]
133
131
pub ( super ) type Vesting < T : Config > =
134
- StorageMap < _ , Identity , EthereumAddress , ( BalanceOf < T > , BalanceOf < T > , T :: BlockNumber ) > ;
132
+ StorageMap < _ , Identity , EthereumAddress , ( BalanceOf < T > , BalanceOf < T > , BlockNumberFor < T > ) > ;
135
133
136
134
/// The statement kind that must be signed, if any.
137
135
#[ pallet:: storage]
@@ -142,22 +140,16 @@ pub mod pallet {
142
140
pub ( super ) type Preclaims < T : Config > = StorageMap < _ , Identity , T :: AccountId , EthereumAddress > ;
143
141
144
142
#[ allow( clippy:: type_complexity) ]
143
+ #[ derive( frame_support:: DefaultNoBound ) ]
145
144
#[ pallet:: genesis_config]
146
145
pub struct GenesisConfig < T : Config > {
147
146
pub claims :
148
147
Vec < ( EthereumAddress , BalanceOf < T > , Option < T :: AccountId > , Option < StatementKind > ) > ,
149
- pub vesting : Vec < ( EthereumAddress , ( BalanceOf < T > , BalanceOf < T > , T :: BlockNumber ) ) > ,
150
- }
151
-
152
- #[ cfg( feature = "std" ) ]
153
- impl < T : Config > Default for GenesisConfig < T > {
154
- fn default ( ) -> Self {
155
- GenesisConfig { claims : Default :: default ( ) , vesting : Default :: default ( ) }
156
- }
148
+ pub vesting : Vec < ( EthereumAddress , ( BalanceOf < T > , BalanceOf < T > , BlockNumberFor < T > ) ) > ,
157
149
}
158
150
159
151
#[ pallet:: genesis_build]
160
- impl < T : Config > GenesisBuild < T > for GenesisConfig < T > {
152
+ impl < T : Config > BuildGenesisConfig for GenesisConfig < T > {
161
153
fn build ( & self ) {
162
154
// build `Claims`
163
155
self . claims . iter ( ) . map ( |( a, b, _, _) | ( a, b) ) . for_each ( |( a, b) | {
@@ -257,7 +249,7 @@ pub mod pallet {
257
249
origin : OriginFor < T > ,
258
250
who : EthereumAddress ,
259
251
value : BalanceOf < T > ,
260
- vesting_schedule : Option < ( BalanceOf < T > , BalanceOf < T > , T :: BlockNumber ) > ,
252
+ vesting_schedule : Option < ( BalanceOf < T > , BalanceOf < T > , BlockNumberFor < T > ) > ,
261
253
statement : Option < StatementKind > ,
262
254
) -> DispatchResult {
263
255
ensure_root ( origin) ?;
@@ -639,33 +631,30 @@ mod tests {
639
631
640
632
use parity_scale_codec:: Encode ;
641
633
use sp_core:: H256 ;
642
- use sp_runtime:: { DispatchError :: Token , TokenError :: Frozen } ;
634
+ use sp_runtime:: { generic , DispatchError :: Token , TokenError :: Frozen } ;
643
635
// The testing primitives are very useful for avoiding having to work with signatures
644
636
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
645
637
use super :: Call as ClaimsCall ;
646
638
use frame_support:: {
647
639
assert_err, assert_noop, assert_ok,
648
640
dispatch:: { DispatchError :: BadOrigin , GetDispatchInfo , Pays } ,
649
641
ord_parameter_types, parameter_types,
650
- traits:: { ExistenceRequirement , GenesisBuild , WithdrawReasons } ,
642
+ traits:: { ExistenceRequirement , WithdrawReasons } ,
651
643
} ;
652
644
653
645
use sp_runtime:: {
654
646
testing:: Header ,
655
647
traits:: { BlakeTwo256 , Identity , IdentityLookup } ,
656
648
transaction_validity:: TransactionLongevity ,
649
+ BuildStorage ,
657
650
} ;
658
651
659
652
type UncheckedExtrinsic = frame_system:: mocking:: MockUncheckedExtrinsic < Test > ;
660
- type Block = frame_system:: mocking:: MockBlock < Test > ;
661
653
662
654
frame_support:: construct_runtime!(
663
- pub enum Test where
664
- Block = Block ,
665
- NodeBlock = Block ,
666
- UncheckedExtrinsic = UncheckedExtrinsic ,
655
+ pub enum Test
667
656
{
668
- System : frame_system:: { Pallet , Call , Config , Storage , Event <T >} ,
657
+ System : frame_system:: { Pallet , Call , Config < T > , Storage , Event <T >} ,
669
658
Balances : pallet_balances:: { Pallet , Call , Storage , Config <T >, Event <T >} ,
670
659
Vesting : pallet_vesting:: { Pallet , Call , Storage , Config <T >, Event <T >} ,
671
660
Claims : super :: pallet:: { Pallet , Call , Storage , Config <T >, Event <T >, ValidateUnsigned } ,
@@ -679,16 +668,15 @@ mod tests {
679
668
type BaseCallFilter = frame_support:: traits:: Everything ;
680
669
type BlockWeights = ( ) ;
681
670
type BlockLength = ( ) ;
671
+ type Block = generic:: Block < Header , UncheckedExtrinsic > ;
682
672
type DbWeight = ( ) ;
683
673
type RuntimeOrigin = RuntimeOrigin ;
684
674
type RuntimeCall = RuntimeCall ;
685
- type Index = u64 ;
686
- type BlockNumber = u64 ;
675
+ type Nonce = u64 ;
687
676
type Hash = H256 ;
688
677
type Hashing = BlakeTwo256 ;
689
678
type AccountId = u64 ;
690
679
type Lookup = IdentityLookup < u64 > ;
691
- type Header = Header ;
692
680
type RuntimeEvent = RuntimeEvent ;
693
681
type BlockHashCount = BlockHashCount ;
694
682
type Version = ( ) ;
@@ -716,8 +704,8 @@ mod tests {
716
704
type MaxReserves = ( ) ;
717
705
type ReserveIdentifier = [ u8 ; 8 ] ;
718
706
type WeightInfo = ( ) ;
719
- type HoldIdentifier = ( ) ;
720
707
type FreezeIdentifier = ( ) ;
708
+ type RuntimeHoldReason = ( ) ;
721
709
type MaxHolds = ( ) ;
722
710
type MaxFreezes = ( ) ;
723
711
}
@@ -772,7 +760,7 @@ mod tests {
772
760
// This function basically just builds a genesis storage key/value store according to
773
761
// our desired mockup.
774
762
pub fn new_test_ext ( ) -> sp_io:: TestExternalities {
775
- let mut t = frame_system:: GenesisConfig :: default ( ) . build_storage :: < Test > ( ) . unwrap ( ) ;
763
+ let mut t = frame_system:: GenesisConfig :: < Test > :: default ( ) . build_storage ( ) . unwrap ( ) ;
776
764
// We use default for brevity, but you can configure as desired if needed.
777
765
pallet_balances:: GenesisConfig :: < Test > :: default ( )
778
766
. assimilate_storage ( & mut t)
0 commit comments