Skip to content

Commit d202436

Browse files
authored
payfee (#118)
* payfee * reset spec version
1 parent e8d6ca5 commit d202436

File tree

7 files changed

+70
-41
lines changed

7 files changed

+70
-41
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0x000000000000000000000000000000000000000000000000000000000000000000b32a2c0f7322d2d841898ea2c89cca0866df8f200dbef73ac0a57b328fbceb0103170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400
1+
0x0000000000000000000000000000000000000000000000000000000000000000007115d44528b328fad293c6e1e0c32e45c7586083c8890f98591d9a17f0633a7a03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400

bin/node/cli/res/jupiter-westend-2000-wasm

+1-1
Large diffs are not rendered by default.

bin/node/cli/res/jupiter-westend-patract.json

+36-36
Large diffs are not rendered by default.

runtime/common/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pallet-treasury = { version = "3.0.0", git = "https://github.com/paritytech/subs
3232
pallet-bounties = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
3333
pallet-tips = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
3434
pallet-utility = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
35+
pallet-sudo = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
3536
pallet-collator-selection = { version = "3.0.0", git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp", default-features = false }
3637

3738
jupiter-primitives = { path = "../../primitives", default-features = false }
@@ -63,6 +64,7 @@ std = [
6364
"pallet-bounties/std",
6465
"pallet-tips/std",
6566
"pallet-utility/std",
67+
"pallet-sudo/std",
6668
"pallet-collator-selection/std",
6769

6870
"jupiter-primitives/std",

runtime/common/src/impls.rs

+19
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ where
3030
}
3131
}
3232

33+
pub struct ToRoot<R>(sp_std::marker::PhantomData<R>);
34+
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToRoot<R>
35+
where
36+
R: pallet_balances::Config + pallet_sudo::Config,
37+
<R as frame_system::Config>::AccountId: From<AccountId>,
38+
<R as frame_system::Config>::AccountId: Into<AccountId>,
39+
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
40+
{
41+
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
42+
let numeric_amount = amount.peek();
43+
let author = <pallet_sudo::Pallet<R>>::key();
44+
<pallet_balances::Pallet<R>>::resolve_creating(&author, amount);
45+
<frame_system::Pallet<R>>::deposit_event(pallet_balances::Event::Deposit(
46+
author,
47+
numeric_amount,
48+
));
49+
}
50+
}
51+
3352
/// Logic for the author to get a portion of fees.
3453
pub struct ToStakingPot<R>(sp_std::marker::PhantomData<R>);
3554
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToStakingPot<R>

runtime/jupiter/src/lib.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
8888
spec_name: create_runtime_str!("jupiter-westend"),
8989
impl_name: create_runtime_str!("patract-jupiter-westend"),
9090
authoring_version: 1,
91-
spec_version: 2,
91+
spec_version: 1,
9292
impl_version: 1,
9393
apis: RUNTIME_API_VERSIONS,
9494
transaction_version: 1,
@@ -165,7 +165,8 @@ impl pallet_balances::Config for Runtime {
165165
}
166166

167167
impl pallet_transaction_payment::Config for Runtime {
168-
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
168+
type OnChargeTransaction =
169+
pallet_transaction_payment::CurrencyAdapter<Balances, impls::ToRoot<Self>>;
169170
type TransactionByteFee = TransactionByteFee;
170171
type WeightToFee = JupiterWeight2Fee;
171172
type FeeMultiplierUpdate = impls::SlowAdjustingFeeUpdate<Self>;
@@ -352,7 +353,13 @@ impl Config for XcmConfig {
352353
type LocationInverter = LocationInverter<Ancestry>;
353354
type Barrier = ();
354355
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
355-
type Trader = UsingComponents<IdentityFee<Balance>, WestendLocation, AccountId, Balances, ()>;
356+
type Trader = UsingComponents<
357+
IdentityFee<Balance>,
358+
WestendLocation,
359+
AccountId,
360+
Balances,
361+
impls::ToRoot<Runtime>,
362+
>;
356363
type ResponseHandler = (); // Don't handle responses for now.
357364
}
358365

0 commit comments

Comments
 (0)