mirror of
https://github.com/pezkuwichain/pezkuwi-runtime-templates.git
synced 2026-07-18 23:25:49 +00:00
Add pallet-assets (#94)
* init * add assets to xcm transactor * add empty genesis config for assets for now
This commit is contained in:
Generated
+389
-267
File diff suppressed because it is too large
Load Diff
@@ -39,6 +39,7 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "r
|
|||||||
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
|
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
@@ -101,6 +102,7 @@ xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/parit
|
|||||||
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
|
|
||||||
# Cumulus
|
# Cumulus
|
||||||
|
assets-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ fn testnet_genesis(
|
|||||||
balances: parachain_template_runtime::BalancesConfig {
|
balances: parachain_template_runtime::BalancesConfig {
|
||||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||||
},
|
},
|
||||||
|
assets: parachain_template_runtime::AssetsConfig::default(),
|
||||||
parachain_info: parachain_template_runtime::ParachainInfoConfig {
|
parachain_info: parachain_template_runtime::ParachainInfoConfig {
|
||||||
parachain_id: id,
|
parachain_id: id,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ frame-system = { workspace = true }
|
|||||||
frame-system-benchmarking = { workspace = true, optional = true }
|
frame-system-benchmarking = { workspace = true, optional = true }
|
||||||
frame-system-rpc-runtime-api = { workspace = true }
|
frame-system-rpc-runtime-api = { workspace = true }
|
||||||
frame-try-runtime = { workspace = true, optional = true }
|
frame-try-runtime = { workspace = true, optional = true }
|
||||||
|
pallet-assets = { workspace = true }
|
||||||
pallet-aura = { workspace = true }
|
pallet-aura = { workspace = true }
|
||||||
pallet-authorship = { workspace = true }
|
pallet-authorship = { workspace = true }
|
||||||
pallet-balances = { workspace = true }
|
pallet-balances = { workspace = true }
|
||||||
@@ -61,6 +62,7 @@ xcm-builder = { workspace = true }
|
|||||||
xcm-executor = { workspace = true }
|
xcm-executor = { workspace = true }
|
||||||
|
|
||||||
# Cumulus
|
# Cumulus
|
||||||
|
assets-common = { workspace = true }
|
||||||
cumulus-pallet-aura-ext = { workspace = true }
|
cumulus-pallet-aura-ext = { workspace = true }
|
||||||
cumulus-pallet-dmp-queue = { workspace = true }
|
cumulus-pallet-dmp-queue = { workspace = true }
|
||||||
cumulus-pallet-parachain-system = { workspace = true, features = [ "parameterized-consensus-hook" ] }
|
cumulus-pallet-parachain-system = { workspace = true, features = [ "parameterized-consensus-hook" ] }
|
||||||
@@ -81,6 +83,7 @@ substrate-wasm-builder = { workspace = true }
|
|||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
default = [ "std" ]
|
||||||
std = [
|
std = [
|
||||||
|
"assets-common/std",
|
||||||
"cumulus-pallet-aura-ext/std",
|
"cumulus-pallet-aura-ext/std",
|
||||||
"cumulus-pallet-dmp-queue/std",
|
"cumulus-pallet-dmp-queue/std",
|
||||||
"cumulus-pallet-parachain-system/std",
|
"cumulus-pallet-parachain-system/std",
|
||||||
@@ -97,10 +100,12 @@ std = [
|
|||||||
"frame-system/std",
|
"frame-system/std",
|
||||||
"frame-try-runtime?/std",
|
"frame-try-runtime?/std",
|
||||||
"log/std",
|
"log/std",
|
||||||
|
"pallet-assets/std",
|
||||||
"pallet-aura/std",
|
"pallet-aura/std",
|
||||||
"pallet-authorship/std",
|
"pallet-authorship/std",
|
||||||
"pallet-balances/std",
|
"pallet-balances/std",
|
||||||
"pallet-collator-selection/std",
|
"pallet-collator-selection/std",
|
||||||
|
"pallet-multisig/std",
|
||||||
"pallet-proxy/std",
|
"pallet-proxy/std",
|
||||||
"pallet-session/std",
|
"pallet-session/std",
|
||||||
"pallet-sudo/std",
|
"pallet-sudo/std",
|
||||||
@@ -133,6 +138,7 @@ std = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
|
"assets-common/runtime-benchmarks",
|
||||||
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
"cumulus-pallet-parachain-system/runtime-benchmarks",
|
||||||
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
|
||||||
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
|
||||||
@@ -142,6 +148,7 @@ runtime-benchmarks = [
|
|||||||
"frame-system-benchmarking/runtime-benchmarks",
|
"frame-system-benchmarking/runtime-benchmarks",
|
||||||
"frame-system/runtime-benchmarks",
|
"frame-system/runtime-benchmarks",
|
||||||
"hex-literal",
|
"hex-literal",
|
||||||
|
"pallet-assets/runtime-benchmarks",
|
||||||
"pallet-balances/runtime-benchmarks",
|
"pallet-balances/runtime-benchmarks",
|
||||||
"pallet-collator-selection/runtime-benchmarks",
|
"pallet-collator-selection/runtime-benchmarks",
|
||||||
"pallet-multisig/runtime-benchmarks",
|
"pallet-multisig/runtime-benchmarks",
|
||||||
@@ -167,6 +174,7 @@ try-runtime = [
|
|||||||
"frame-support/try-runtime",
|
"frame-support/try-runtime",
|
||||||
"frame-system/try-runtime",
|
"frame-system/try-runtime",
|
||||||
"frame-try-runtime/try-runtime",
|
"frame-try-runtime/try-runtime",
|
||||||
|
"pallet-assets/try-runtime",
|
||||||
"pallet-aura/try-runtime",
|
"pallet-aura/try-runtime",
|
||||||
"pallet-authorship/try-runtime",
|
"pallet-authorship/try-runtime",
|
||||||
"pallet-balances/try-runtime",
|
"pallet-balances/try-runtime",
|
||||||
|
|||||||
+40
-3
@@ -17,7 +17,10 @@ use frame_support::{
|
|||||||
dispatch::DispatchClass,
|
dispatch::DispatchClass,
|
||||||
genesis_builder_helper::{build_config, create_default_config},
|
genesis_builder_helper::{build_config, create_default_config},
|
||||||
parameter_types,
|
parameter_types,
|
||||||
traits::{ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, InstanceFilter},
|
traits::{
|
||||||
|
AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything,
|
||||||
|
InstanceFilter,
|
||||||
|
},
|
||||||
weights::{
|
weights::{
|
||||||
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
|
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
|
||||||
WeightToFeeCoefficients, WeightToFeePolynomial,
|
WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||||
@@ -26,7 +29,7 @@ use frame_support::{
|
|||||||
};
|
};
|
||||||
use frame_system::{
|
use frame_system::{
|
||||||
limits::{BlockLength, BlockWeights},
|
limits::{BlockLength, BlockWeights},
|
||||||
EnsureRoot,
|
EnsureRoot, EnsureSigned,
|
||||||
};
|
};
|
||||||
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
||||||
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
|
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
|
||||||
@@ -56,7 +59,7 @@ use xcm::latest::prelude::BodyId;
|
|||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::currency::{deposit, EXISTENTIAL_DEPOSIT, MICROCENTS, MILLICENTS},
|
constants::currency::{deposit, CENTS, EXISTENTIAL_DEPOSIT, MICROCENTS, MILLICENTS},
|
||||||
weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
|
weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
|
||||||
xcm_config::{RelayLocation, XcmConfig, XcmOriginToTransactDispatchOrigin},
|
xcm_config::{RelayLocation, XcmConfig, XcmOriginToTransactDispatchOrigin},
|
||||||
};
|
};
|
||||||
@@ -427,6 +430,38 @@ impl pallet_balances::Config for Runtime {
|
|||||||
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
|
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const AssetDeposit: Balance = 10 * CENTS;
|
||||||
|
pub const AssetAccountDeposit: Balance = deposit(1, 16);
|
||||||
|
pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT;
|
||||||
|
pub const StringLimit: u32 = 50;
|
||||||
|
pub const MetadataDepositBase: Balance = deposit(1, 68);
|
||||||
|
pub const MetadataDepositPerByte: Balance = deposit(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pallet_assets::Config for Runtime {
|
||||||
|
type ApprovalDeposit = ApprovalDeposit;
|
||||||
|
type AssetAccountDeposit = AssetAccountDeposit;
|
||||||
|
type AssetDeposit = AssetDeposit;
|
||||||
|
type AssetId = u32;
|
||||||
|
type AssetIdParameter = parity_scale_codec::Compact<u32>;
|
||||||
|
type Balance = Balance;
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
type BenchmarkHelper = ();
|
||||||
|
type CallbackHandle = ();
|
||||||
|
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
|
||||||
|
type Currency = Balances;
|
||||||
|
type Extra = ();
|
||||||
|
type ForceOrigin = EnsureRoot<AccountId>;
|
||||||
|
type Freezer = ();
|
||||||
|
type MetadataDepositBase = MetadataDepositBase;
|
||||||
|
type MetadataDepositPerByte = MetadataDepositPerByte;
|
||||||
|
type RemoveItemsLimit = ConstU32<1000>;
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type StringLimit = StringLimit;
|
||||||
|
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
|
||||||
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
/// Relay Chain `TransactionByteFee` / 10
|
/// Relay Chain `TransactionByteFee` / 10
|
||||||
pub const TransactionByteFee: Balance = 10 * MICROCENTS;
|
pub const TransactionByteFee: Balance = 10 * MICROCENTS;
|
||||||
@@ -596,6 +631,7 @@ construct_runtime!(
|
|||||||
// Monetary stuff.
|
// Monetary stuff.
|
||||||
Balances: pallet_balances = 10,
|
Balances: pallet_balances = 10,
|
||||||
TransactionPayment: pallet_transaction_payment = 11,
|
TransactionPayment: pallet_transaction_payment = 11,
|
||||||
|
Assets: pallet_assets = 12,
|
||||||
|
|
||||||
// Governance
|
// Governance
|
||||||
Sudo: pallet_sudo = 15,
|
Sudo: pallet_sudo = 15,
|
||||||
@@ -623,6 +659,7 @@ construct_runtime!(
|
|||||||
mod benches {
|
mod benches {
|
||||||
frame_benchmarking::define_benchmarks!(
|
frame_benchmarking::define_benchmarks!(
|
||||||
[frame_system, SystemBench::<Runtime>]
|
[frame_system, SystemBench::<Runtime>]
|
||||||
|
[pallet_assets, Assets]
|
||||||
[pallet_balances, Balances]
|
[pallet_balances, Balances]
|
||||||
[pallet_session, SessionBench::<Runtime>]
|
[pallet_session, SessionBench::<Runtime>]
|
||||||
[pallet_timestamp, Timestamp]
|
[pallet_timestamp, Timestamp]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use frame_support::{
|
use frame_support::{
|
||||||
match_types, parameter_types,
|
match_types, parameter_types,
|
||||||
traits::{ConstU32, Everything, Nothing},
|
traits::{ConstU32, Everything, Nothing, PalletInfoAccess},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
@@ -11,25 +11,32 @@ use xcm::latest::prelude::*;
|
|||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
|
||||||
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
|
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
|
||||||
FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative,
|
FixedWeightBounds, FungiblesAdapter, IsConcrete, NativeAsset, NoChecking, ParentIsPreset,
|
||||||
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
|
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
|
||||||
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
|
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||||
UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
|
||||||
};
|
};
|
||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
|
AccountId, AllPalletsWithSystem, Assets, Balance, Balances, ParachainInfo, ParachainSystem,
|
||||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||||
};
|
};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
||||||
pub const RelayNetwork: Option<NetworkId> = None;
|
pub const RelayNetwork: Option<NetworkId> = None;
|
||||||
|
pub PlaceholderAccount: AccountId = PolkadotXcm::check_account();
|
||||||
|
pub AssetsPalletLocation: MultiLocation =
|
||||||
|
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `AssetId/Balancer` converter for `TrustBackedAssets`
|
||||||
|
pub type TrustBackedAssetsConvertedConcreteId =
|
||||||
|
assets_common::TrustBackedAssetsConvertedConcreteId<AssetsPalletLocation, Balance>;
|
||||||
|
|
||||||
/// Type for specifying how a `MultiLocation` can be converted into an
|
/// Type for specifying how a `MultiLocation` can be converted into an
|
||||||
/// `AccountId`. This is used when determining ownership of accounts for asset
|
/// `AccountId`. This is used when determining ownership of accounts for asset
|
||||||
/// transacting and when attempting to use XCM `Transact` in order to determine
|
/// transacting and when attempting to use XCM `Transact` in order to determine
|
||||||
@@ -57,6 +64,26 @@ pub type LocalAssetTransactor = CurrencyAdapter<
|
|||||||
(),
|
(),
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
/// Means for transacting assets besides the native currency on this chain.
|
||||||
|
pub type LocalFungiblesTransactor = FungiblesAdapter<
|
||||||
|
// Use this fungibles implementation:
|
||||||
|
Assets,
|
||||||
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
|
TrustBackedAssetsConvertedConcreteId,
|
||||||
|
// Convert an XCM MultiLocation into a local account id:
|
||||||
|
LocationToAccountId,
|
||||||
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
|
AccountId,
|
||||||
|
// We don't track any teleports of `Assets`.
|
||||||
|
NoChecking,
|
||||||
|
// We don't track any teleports of `Assets`, but a placeholder account is provided due to trait
|
||||||
|
// bounds.
|
||||||
|
PlaceholderAccount,
|
||||||
|
>;
|
||||||
|
|
||||||
|
/// Means for transacting assets on this chain.
|
||||||
|
pub type AssetTransactors = (LocalAssetTransactor, LocalFungiblesTransactor);
|
||||||
|
|
||||||
/// This is the type we use to convert an (incoming) XCM origin into a local
|
/// This is the type we use to convert an (incoming) XCM origin into a local
|
||||||
/// `Origin` instance, ready for dispatching a transaction with Xcm's
|
/// `Origin` instance, ready for dispatching a transaction with Xcm's
|
||||||
/// `Transact`. There is an `OriginKind` which can biases the kind of local
|
/// `Transact`. There is an `OriginKind` which can biases the kind of local
|
||||||
@@ -118,7 +145,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type AssetExchanger = ();
|
type AssetExchanger = ();
|
||||||
type AssetLocker = ();
|
type AssetLocker = ();
|
||||||
// How to withdraw and deposit an asset.
|
// How to withdraw and deposit an asset.
|
||||||
type AssetTransactor = LocalAssetTransactor;
|
type AssetTransactor = AssetTransactors;
|
||||||
type AssetTrap = PolkadotXcm;
|
type AssetTrap = PolkadotXcm;
|
||||||
type Barrier = Barrier;
|
type Barrier = Barrier;
|
||||||
type CallDispatcher = RuntimeCall;
|
type CallDispatcher = RuntimeCall;
|
||||||
|
|||||||
Reference in New Issue
Block a user