@@ -30,18 +30,18 @@ use frame_support::{
30
30
genesis_builder_helper:: { build_state, get_preset} ,
31
31
parameter_types,
32
32
traits:: {
33
- fungible:: HoldConsideration ,
33
+ fungible:: { Balanced , Credit , HoldConsideration } ,
34
34
tokens:: { PayFromAccount , UnityAssetBalanceConversion } ,
35
- AsEnsureOriginWithArg , ConstU128 , ConstU32 , ConstU64 , Contains , Currency ,
36
- EqualPrivilegeOnly , FindAuthor , Get , Imbalance , InstanceFilter , LinearStoragePrice ,
37
- Nothing , OnFinalize , OnUnbalanced , WithdrawReasons ,
35
+ AsEnsureOriginWithArg , ConstU128 , ConstU32 , ConstU64 , Contains , EqualPrivilegeOnly ,
36
+ FindAuthor , Get , Imbalance , InstanceFilter , LinearStoragePrice , Nothing , OnFinalize ,
37
+ OnUnbalanced , WithdrawReasons ,
38
38
} ,
39
39
weights:: {
40
40
constants:: {
41
41
BlockExecutionWeight , ExtrinsicBaseWeight , RocksDbWeight , WEIGHT_REF_TIME_PER_SECOND ,
42
42
} ,
43
- ConstantMultiplier , Weight , WeightToFeeCoefficient , WeightToFeeCoefficients ,
44
- WeightToFeePolynomial ,
43
+ ConstantMultiplier , Weight , WeightToFee as WeightToFeeT , WeightToFeeCoefficient ,
44
+ WeightToFeeCoefficients , WeightToFeePolynomial ,
45
45
} ,
46
46
ConsensusEngineId , PalletId ,
47
47
} ;
@@ -72,8 +72,8 @@ use sp_runtime::{
72
72
} ;
73
73
use sp_std:: { collections:: btree_map:: BTreeMap , prelude:: * } ;
74
74
use xcm:: {
75
- latest :: prelude :: * , IntoVersion , VersionedAssetId , VersionedAssets , VersionedLocation ,
76
- VersionedXcm ,
75
+ v4 :: { AssetId as XcmAssetId , Location as XcmLocation } ,
76
+ IntoVersion , VersionedAssetId , VersionedAssets , VersionedLocation , VersionedXcm ,
77
77
} ;
78
78
use xcm_fee_payment_runtime_api:: Error as XcmPaymentApiError ;
79
79
@@ -483,12 +483,12 @@ impl pallet_dapp_staking_v3::Config for Runtime {
483
483
}
484
484
485
485
pub struct InflationPayoutPerBlock ;
486
- impl pallet_inflation:: PayoutPerBlock < NegativeImbalance > for InflationPayoutPerBlock {
487
- fn treasury ( reward : NegativeImbalance ) {
488
- Balances :: resolve_creating ( & TreasuryPalletId :: get ( ) . into_account_truncating ( ) , reward) ;
486
+ impl pallet_inflation:: PayoutPerBlock < Credit < AccountId , Balances > > for InflationPayoutPerBlock {
487
+ fn treasury ( reward : Credit < AccountId , Balances > ) {
488
+ let _ = Balances :: resolve ( & TreasuryPalletId :: get ( ) . into_account_truncating ( ) , reward) ;
489
489
}
490
490
491
- fn collators ( reward : NegativeImbalance ) {
491
+ fn collators ( reward : Credit < AccountId , Balances > ) {
492
492
ToStakingPot :: on_unbalanced ( reward) ;
493
493
}
494
494
}
@@ -623,13 +623,11 @@ parameter_types! {
623
623
pub TreasuryAccountId : AccountId = TreasuryPalletId :: get( ) . into_account_truncating( ) ;
624
624
}
625
625
626
- type NegativeImbalance = <Balances as Currency < AccountId > >:: NegativeImbalance ;
627
-
628
626
pub struct ToStakingPot ;
629
- impl OnUnbalanced < NegativeImbalance > for ToStakingPot {
630
- fn on_nonzero_unbalanced ( amount : NegativeImbalance ) {
627
+ impl OnUnbalanced < Credit < AccountId , Balances > > for ToStakingPot {
628
+ fn on_nonzero_unbalanced ( amount : Credit < AccountId , Balances > ) {
631
629
let staking_pot = PotId :: get ( ) . into_account_truncating ( ) ;
632
- Balances :: resolve_creating ( & staking_pot, amount) ;
630
+ let _ = Balances :: resolve ( & staking_pot, amount) ;
633
631
}
634
632
}
635
633
@@ -795,7 +793,7 @@ impl WeightToFeePolynomial for WeightToFee {
795
793
///
796
794
/// Similar to standard `WeightToFee` handler, but force uses the minimum multiplier.
797
795
pub struct XcmWeightToFee ;
798
- impl frame_support :: weights :: WeightToFee for XcmWeightToFee {
796
+ impl WeightToFeeT for XcmWeightToFee {
799
797
type Balance = Balance ;
800
798
801
799
fn weight_to_fee ( n : & Weight ) -> Self :: Balance {
@@ -804,8 +802,8 @@ impl frame_support::weights::WeightToFee for XcmWeightToFee {
804
802
}
805
803
806
804
pub struct DealWithFees ;
807
- impl OnUnbalanced < NegativeImbalance > for DealWithFees {
808
- fn on_unbalanceds < B > ( mut fees_then_tips : impl Iterator < Item = NegativeImbalance > ) {
805
+ impl OnUnbalanced < Credit < AccountId , Balances > > for DealWithFees {
806
+ fn on_unbalanceds < B > ( mut fees_then_tips : impl Iterator < Item = Credit < AccountId , Balances > > ) {
809
807
if let Some ( fees) = fees_then_tips. next ( ) {
810
808
// Burn 80% of fees, rest goes to collator, including 100% of the tips.
811
809
let ( to_burn, mut collator) = fees. ration ( 80 , 20 ) ;
@@ -824,7 +822,7 @@ impl OnUnbalanced<NegativeImbalance> for DealWithFees {
824
822
825
823
impl pallet_transaction_payment:: Config for Runtime {
826
824
type RuntimeEvent = RuntimeEvent ;
827
- type OnChargeTransaction = pallet_transaction_payment:: CurrencyAdapter < Balances , DealWithFees > ;
825
+ type OnChargeTransaction = pallet_transaction_payment:: FungibleAdapter < Balances , DealWithFees > ;
828
826
type WeightToFee = WeightToFee ;
829
827
type OperationalFeeMultiplier = OperationalFeeMultiplier ;
830
828
type FeeMultiplierUpdate = TargetedFeeAdjustment <
@@ -930,7 +928,7 @@ impl pallet_evm::Config for Runtime {
930
928
// Ethereum-compatible chain_id:
931
929
// * Shibuya: 81
932
930
type ChainId = EVMChainId ;
933
- type OnChargeTransaction = pallet_evm:: EVMCurrencyAdapter < Balances , ToStakingPot > ;
931
+ type OnChargeTransaction = pallet_evm:: EVMFungibleAdapter < Balances , ToStakingPot > ;
934
932
type BlockGasLimit = BlockGasLimit ;
935
933
type Timestamp = Timestamp ;
936
934
type OnCreate = ( ) ;
@@ -2182,42 +2180,48 @@ impl_runtime_apis! {
2182
2180
}
2183
2181
2184
2182
// Native asset is always supported
2185
- let native_asset_location: Location = Location :: try_from( xcm_config:: ShibuyaLocation :: get( ) )
2183
+ let native_asset_location: XcmLocation = XcmLocation :: try_from( xcm_config:: ShibuyaLocation :: get( ) )
2186
2184
. map_err( |_| XcmPaymentApiError :: VersionedConversionFailed ) ?;
2187
2185
2188
- Ok ( [ VersionedAssetId :: V4 ( native_asset_location) . into( ) ]
2189
- . into_iter( )
2190
- // Acquire foreign assets which have 'units per second' configured
2191
- . chain(
2192
- pallet_xc_asset_config:: AssetLocationUnitsPerSecond :: <Runtime >:: iter_keys( ) . map( |asset_location| {
2193
- VersionedAssetId :: V3 ( asset_location. into( ) )
2194
- } )
2186
+ Ok ( [ VersionedAssetId :: V4 ( native_asset_location. into( ) ) ]
2187
+ . into_iter( )
2188
+ // Acquire foreign assets which have 'units per second' configured
2189
+ . chain(
2190
+ pallet_xc_asset_config:: AssetLocationUnitsPerSecond :: <Runtime >:: iter_keys( ) . filter_map( |asset_location| {
2195
2191
2196
- ) . filter_map( |asset| asset. into_version( xcm_version) . ok( ) ) )
2192
+ match XcmLocation :: try_from( asset_location) {
2193
+ Ok ( asset) => Some ( VersionedAssetId :: V4 ( asset. into( ) ) ) ,
2194
+ Err ( _) => None ,
2195
+ }
2196
+ } )
2197
+ ) . filter_map( |asset| asset. into_version( xcm_version) . ok( ) ) . collect( ) )
2197
2198
}
2198
2199
2199
- // TODO: improve this function, reduce code duplication, especially on a such functional level
2200
+ // TODO: improve this function, reduce code duplication, especially on a such a functional level
2200
2201
fn query_weight_to_asset_fee( weight: Weight , asset: VersionedAssetId ) -> Result <u128 , XcmPaymentApiError > {
2201
- let native_asset_location: Location = Location :: try_from( xcm_config:: ShibuyaLocation :: get( ) )
2202
+ let native_asset_location: XcmLocation = XcmLocation :: try_from( xcm_config:: ShibuyaLocation :: get( ) )
2202
2203
. map_err( |_| XcmPaymentApiError :: VersionedConversionFailed ) ?;
2203
2204
let native_asset = VersionedAssetId :: V4 ( native_asset_location. into( ) ) ;
2204
2205
2205
2206
let asset = asset
2206
2207
. into_version( 4 )
2207
2208
. map_err( |_| XcmPaymentApiError :: VersionedConversionFailed ) ?;
2208
2209
2209
- if native_asset == asset {
2210
- Ok ( XcmWeightToFee :: weight_to_fee( weight) )
2211
- } else {
2212
2210
2213
- match pallet_xc_asset_config:: AssetLocationUnitsPerSecond :: <Runtime >:: get( asset. into( ) ) {
2214
- Some ( units_per_sec) => {
2215
- Ok ( units_per_sec. saturating_mul( weight. ref_time( ) as u128 )
2216
- / ( WEIGHT_REF_TIME_PER_SECOND as u128 ) )
2217
- }
2218
- None => Err ( XcmPaymentApiError :: AssetNotFound ) ,
2211
+ if native_asset == asset {
2212
+ Ok ( XcmWeightToFee :: weight_to_fee( & weight) )
2213
+ } else {
2214
+ let asset_id: XcmAssetId = asset. try_into( ) . map_err( |_| XcmPaymentApiError :: VersionedConversionFailed ) ?;
2215
+ let versioned_location = VersionedLocation :: V4 ( asset_id. 0 ) ;
2216
+
2217
+ match pallet_xc_asset_config:: AssetLocationUnitsPerSecond :: <Runtime >:: get( versioned_location) {
2218
+ Some ( units_per_sec) => {
2219
+ Ok ( units_per_sec. saturating_mul( weight. ref_time( ) as u128 )
2220
+ / ( WEIGHT_REF_TIME_PER_SECOND as u128 ) )
2219
2221
}
2222
+ None => Err ( XcmPaymentApiError :: WeightNotComputable ) ,
2220
2223
}
2224
+ }
2221
2225
}
2222
2226
2223
2227
fn query_xcm_weight( message: VersionedXcm <( ) >) -> Result <Weight , XcmPaymentApiError > {
0 commit comments