This repository has been archived by the owner on Mar 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adjust `SS58Prefix` * Refine Constants * Sync Params with Darwinia/Crab * Fix Global Replace Issues * Update Rust Edition * Update `BlockHashCount` * Adjust Session Era Length * Format
- Loading branch information
1 parent
b2dce1a
commit 6b3493c
Showing
50 changed files
with
636 additions
and
666 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[package] | ||
authors = ["Darwinia Network <[email protected]>"] | ||
description = "DRML node common runtime" | ||
edition = "2021" | ||
homepage = "https://darwinia.network" | ||
license = "GPL-3.0" | ||
name = "common-runtime" | ||
repository = "https://github.com/darwinia-network/darwinia-common" | ||
version = "2.7.0" | ||
|
||
[dependencies] | ||
# crates.io | ||
codec = { package = "parity-scale-codec", version = "2.1", default-features = false } | ||
static_assertions = { version = "1.1" } | ||
# darwinia-network | ||
common-primitives = { default-features = false, path = "../../primitives/common" } | ||
darwinia-balances = { default-features = false, path = "../../../frame/balances" } | ||
darwinia-support = { default-features = false, path = "../../../frame/support" } | ||
# paritytech | ||
frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
pallet-authorship = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
pallet-transaction-payment = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
pallet-treasury = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
|
||
# will be removed in later substrate version | ||
max-encoded-len = { default-features = false, git = "https://github.com/darwinia-network/substrate", tag = "darwinia-v0.11.6-1" } | ||
|
||
[features] | ||
default = ["std"] | ||
|
||
no_std = [] | ||
std = [ | ||
# crates.io | ||
"codec/std", | ||
# darwinia-network | ||
"common-primitives/std", | ||
"darwinia-balances/std", | ||
"darwinia-support/std", | ||
# paritytech | ||
"frame-support/std", | ||
"frame-system/std", | ||
"pallet-authorship/std", | ||
"pallet-transaction-payment/std", | ||
"pallet-treasury/std", | ||
"sp-runtime/std", | ||
"sp-std/std", | ||
"max-encoded-len/std", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// This file is part of Darwinia. | ||
// | ||
// Copyright (C) 2018-2021 Darwinia Network | ||
// SPDX-License-Identifier: GPL-3.0 | ||
// | ||
// Darwinia is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Darwinia is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
//! Auxillary struct/enums for Darwinia runtime. | ||
|
||
// --- crates.io --- | ||
use codec::{Decode, Encode}; | ||
// --- paritytech --- | ||
use frame_support::traits::{Currency, Imbalance, MaxEncodedLen, OnUnbalanced}; | ||
use sp_runtime::RuntimeDebug; | ||
// --- darwinia-network --- | ||
use crate::*; | ||
|
||
darwinia_support::impl_account_data! { | ||
struct AccountData<Balance> | ||
for | ||
RingInstance, | ||
KtonInstance | ||
where | ||
Balance = common_primitives::Balance | ||
{ | ||
// other data | ||
} | ||
} | ||
|
||
/// Logic for the author to get a portion of fees. | ||
pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>); | ||
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R> | ||
where | ||
R: darwinia_balances::Config<RingInstance> + pallet_authorship::Config, | ||
<R as frame_system::Config>::AccountId: From<common_primitives::AccountId>, | ||
<R as frame_system::Config>::AccountId: Into<common_primitives::AccountId>, | ||
<R as frame_system::Config>::Event: From<darwinia_balances::Event<R, RingInstance>>, | ||
{ | ||
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) { | ||
let numeric_amount = amount.peek(); | ||
let author = <pallet_authorship::Pallet<R>>::author(); | ||
<darwinia_balances::Pallet<R, RingInstance>>::resolve_creating( | ||
&<pallet_authorship::Pallet<R>>::author(), | ||
amount, | ||
); | ||
<frame_system::Pallet<R>>::deposit_event(darwinia_balances::Event::Deposit( | ||
author, | ||
numeric_amount, | ||
)); | ||
} | ||
} | ||
|
||
pub struct DealWithFees<R>(sp_std::marker::PhantomData<R>); | ||
impl<R> OnUnbalanced<NegativeImbalance<R>> for DealWithFees<R> | ||
where | ||
R: darwinia_balances::Config<RingInstance> | ||
+ pallet_treasury::Config | ||
+ pallet_authorship::Config, | ||
pallet_treasury::Pallet<R>: OnUnbalanced<NegativeImbalance<R>>, | ||
<R as frame_system::Config>::AccountId: From<common_primitives::AccountId>, | ||
<R as frame_system::Config>::AccountId: Into<common_primitives::AccountId>, | ||
<R as frame_system::Config>::Event: From<darwinia_balances::Event<R, RingInstance>>, | ||
{ | ||
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) { | ||
if let Some(fees) = fees_then_tips.next() { | ||
// for fees, 80% to treasury, 20% to author | ||
let mut split = fees.ration(80, 20); | ||
if let Some(tips) = fees_then_tips.next() { | ||
// for tips, if any, 100% to author | ||
tips.merge_into(&mut split.1); | ||
} | ||
use pallet_treasury::Pallet as Treasury; | ||
<Treasury<R> as OnUnbalanced<_>>::on_unbalanced(split.0); | ||
<ToAuthor<R> as OnUnbalanced<_>>::on_unbalanced(split.1); | ||
} | ||
} | ||
} |
Oops, something went wrong.