Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/sub

# frame dependencies
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-assets = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-asset-tx-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-contracts = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-im-online = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
Expand Down
2 changes: 2 additions & 0 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub fn create_benchmark_extrinsic(
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
pallet_asset_tx_payment::ChargeAssetTxPayment::<runtime::Runtime>::from(10_u128, None),
);

let raw_payload = runtime::SignedPayload::from_raw(
Expand All @@ -156,6 +157,7 @@ pub fn create_benchmark_extrinsic(
(),
(),
(),
(),
),
);
let signature = raw_payload.using_encoded(|e| sender.sign(e));
Expand Down
1 change: 1 addition & 0 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ pub fn testnet_genesis(
.collect(),
phantom: Default::default(),
},
assets: Default::default(),
transaction_payment: Default::default(),
}
}
1 change: 1 addition & 0 deletions node/src/command_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub fn create_benchmark_extrinsic(
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
pallet_asset_tx_payment::ChargeAssetTxPayment<Runtime>::from(0),
);

let raw_payload = runtime::SignedPayload::from_raw(
Expand Down
4 changes: 4 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ frame-executive = { version = "4.0.0-dev", default-features = false, git = "http
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
frame-try-runtime = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v0.9.28" }
pallet-assets = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-asset-tx-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-aura = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-authority-discovery = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-authorship = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
Expand Down Expand Up @@ -97,6 +99,7 @@ std = [
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-assets/std",
"pallet-aura/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
Expand Down Expand Up @@ -160,6 +163,7 @@ try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
"frame-system/try-runtime",
"pallet-assets/try-runtime",
"pallet-aura/try-runtime",
"pallet-balances/try-runtime",
"pallet-grandpa/try-runtime",
Expand Down
15 changes: 15 additions & 0 deletions runtime/src/impls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::{AccountId, Assets, Runtime};
use frame_support::traits::fungibles::{Balanced, CreditOf};
use pallet_asset_tx_payment::HandleCredit;

/// A `HandleCredit` implementation that naively transfers the fees to the block author.
/// Will drop and burn the assets in case the transfer fails.
pub struct CreditToBlockAuthor;
impl HandleCredit<AccountId, Assets> for CreditToBlockAuthor {
fn handle_credit(credit: CreditOf<AccountId, Assets>) {
if let Some(author) = pallet_authorship::Pallet::<Runtime>::author() {
// Drop the result which will trigger the `OnDrop` of the imbalance in case of error.
let _ = Assets::resolve(&author, credit);
}
}
}
45 changes: 44 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use sp_runtime::{
create_runtime_str,
curve::PiecewiseLinear,
generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys},
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, Percent,
};
Expand Down Expand Up @@ -75,6 +75,10 @@ use pallet_transaction_payment::CurrencyAdapter;
pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill};

/// Implementations of some helper traits passed into runtime modules as associated types.
pub mod impls;
use impls::CreditToBlockAuthor;

use pallet_election_provider_multi_phase::SolutionAccuracyOf;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as pallet_session_historical;
Expand Down Expand Up @@ -955,6 +959,42 @@ impl pallet_referenda::Config for Runtime {
type Tracks = TracksInfo;
}

parameter_types! {
pub const AssetDeposit: Balance = 100 * DOLLARS;
pub const ApprovalDeposit: Balance = 1 * DOLLARS;
pub const StringLimit: u32 = 50;
pub const MetadataDepositBase: Balance = 10 * DOLLARS;
pub const MetadataDepositPerByte: Balance = 1 * DOLLARS;
}

// TODO - Update settings
impl pallet_assets::Config for Runtime {
type Event = Event;
type Balance = u128;
type AssetId = u32;
type Currency = Balances;
type ForceOrigin = EnsureRoot<AccountId>;
type AssetDeposit = AssetDeposit;
type AssetAccountDeposit = ConstU128<DOLLARS>;
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type ApprovalDeposit = ApprovalDeposit;
type StringLimit = StringLimit;
type Freezer = ();
type Extra = ();
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
}

// TODO - Update settings
impl pallet_asset_tx_payment::Config for Runtime {
type Event = Event;
type Fungibles = Assets;
type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter<
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
CreditToBlockAuthor,
>;
}

impl pallet_sudo::Config for Runtime {
type Event = Event;
type Call = Call;
Expand Down Expand Up @@ -1020,6 +1060,8 @@ construct_runtime!(
TechnicalMembership: pallet_membership::<Instance1>,
Referenda: pallet_referenda,
ConvictionVoting: pallet_conviction_voting,
Assets: pallet_assets,
AssetTxPayment: pallet_asset_tx_payment,
}
);

Expand All @@ -1039,6 +1081,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
pallet_asset_tx_payment::ChargeAssetTxPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
Expand Down