Skip to content

Commit

Permalink
payfee (#118)
Browse files Browse the repository at this point in the history
* payfee

* reset spec version
  • Loading branch information
zqhxuyuan authored Aug 13, 2021
1 parent e8d6ca5 commit d202436
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 41 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node/cli/res/jupiter-westend-2000-genesis
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x000000000000000000000000000000000000000000000000000000000000000000b32a2c0f7322d2d841898ea2c89cca0866df8f200dbef73ac0a57b328fbceb0103170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400
0x0000000000000000000000000000000000000000000000000000000000000000007115d44528b328fad293c6e1e0c32e45c7586083c8890f98591d9a17f0633a7a03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400
2 changes: 1 addition & 1 deletion bin/node/cli/res/jupiter-westend-2000-wasm

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions bin/node/cli/res/jupiter-westend-patract.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pallet-treasury = { version = "3.0.0", git = "https://github.com/paritytech/subs
pallet-bounties = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
pallet-tips = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
pallet-utility = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
pallet-sudo = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
pallet-collator-selection = { version = "3.0.0", git = "https://github.com/patractlabs/cumulus", branch = "patract-sandbox-xcmp", default-features = false }

jupiter-primitives = { path = "../../primitives", default-features = false }
Expand Down Expand Up @@ -63,6 +64,7 @@ std = [
"pallet-bounties/std",
"pallet-tips/std",
"pallet-utility/std",
"pallet-sudo/std",
"pallet-collator-selection/std",

"jupiter-primitives/std",
Expand Down
19 changes: 19 additions & 0 deletions runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ where
}
}

pub struct ToRoot<R>(sp_std::marker::PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToRoot<R>
where
R: pallet_balances::Config + pallet_sudo::Config,
<R as frame_system::Config>::AccountId: From<AccountId>,
<R as frame_system::Config>::AccountId: Into<AccountId>,
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
let numeric_amount = amount.peek();
let author = <pallet_sudo::Pallet<R>>::key();
<pallet_balances::Pallet<R>>::resolve_creating(&author, amount);
<frame_system::Pallet<R>>::deposit_event(pallet_balances::Event::Deposit(
author,
numeric_amount,
));
}
}

/// Logic for the author to get a portion of fees.
pub struct ToStakingPot<R>(sp_std::marker::PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToStakingPot<R>
Expand Down
13 changes: 10 additions & 3 deletions runtime/jupiter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("jupiter-westend"),
impl_name: create_runtime_str!("patract-jupiter-westend"),
authoring_version: 1,
spec_version: 2,
spec_version: 1,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -165,7 +165,8 @@ impl pallet_balances::Config for Runtime {
}

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, impls::ToRoot<Self>>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = JupiterWeight2Fee;
type FeeMultiplierUpdate = impls::SlowAdjustingFeeUpdate<Self>;
Expand Down Expand Up @@ -352,7 +353,13 @@ impl Config for XcmConfig {
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = ();
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Trader = UsingComponents<IdentityFee<Balance>, WestendLocation, AccountId, Balances, ()>;
type Trader = UsingComponents<
IdentityFee<Balance>,
WestendLocation,
AccountId,
Balances,
impls::ToRoot<Runtime>,
>;
type ResponseHandler = (); // Don't handle responses for now.
}

Expand Down

0 comments on commit d202436

Please sign in to comment.