rustc grumbles

This commit is contained in:
joepetrowski
2022-11-17 08:13:22 +01:00
parent d2827e4174
commit aa67a43c97
2 changed files with 37 additions and 24 deletions
+31 -20
View File
@@ -223,7 +223,11 @@ parameter_types! {
pub type AssetsForceOrigin = EnsureRoot<AccountId>; pub type AssetsForceOrigin = EnsureRoot<AccountId>;
impl pallet_assets::Config for Runtime { // We should perhaps come up with a new name. "ReserveBackedAssets" collides with XCM terminology
// and falsly implies that they are actually backed by some reserve. In reality, the user is
// _trusting_ some `CreateOrigin` (AccountId) that the asset is what they claim.
type TrustBackedAssetClasses = pallet_assets::Instance1;
impl pallet_assets::Config<TrustBackedAssetClasses> for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Balance = Balance; type Balance = Balance;
type AssetId = AssetId; type AssetId = AssetId;
@@ -319,7 +323,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::NonTransfer => !matches!( ProxyType::NonTransfer => !matches!(
c, c,
RuntimeCall::Balances { .. } | RuntimeCall::Balances { .. } |
RuntimeCall::Assets { .. } | RuntimeCall::TrustBackedAssets { .. } |
RuntimeCall::Uniques { .. } RuntimeCall::Uniques { .. }
), ),
ProxyType::CancelProxy => matches!( ProxyType::CancelProxy => matches!(
@@ -331,7 +335,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::Assets => { ProxyType::Assets => {
matches!( matches!(
c, c,
RuntimeCall::Assets { .. } | RuntimeCall::TrustBackedAssets { .. } |
RuntimeCall::Utility { .. } | RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } | RuntimeCall::Multisig { .. } |
RuntimeCall::Uniques { .. } RuntimeCall::Uniques { .. }
@@ -339,12 +343,12 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
}, },
ProxyType::AssetOwner => matches!( ProxyType::AssetOwner => matches!(
c, c,
RuntimeCall::Assets(pallet_assets::Call::create { .. }) | RuntimeCall::Assets(TrustBackedAssetClasses::Call::create { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy { .. }) | RuntimeCall::Assets(TrustBackedAssetClasses::Call::destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::transfer_ownership { .. }) | RuntimeCall::Assets(TrustBackedAssetClasses::Call::transfer_ownership { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_team { .. }) | RuntimeCall::Assets(TrustBackedAssetClasses::Call::set_team { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_metadata { .. }) | RuntimeCall::Assets(TrustBackedAssetClasses::Call::set_metadata { .. }) |
RuntimeCall::Assets(pallet_assets::Call::clear_metadata { .. }) | RuntimeCall::Assets(TrustBackedAssetClasses::Call::clear_metadata { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) |
@@ -361,13 +365,15 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
), ),
ProxyType::AssetManager => matches!( ProxyType::AssetManager => matches!(
c, c,
RuntimeCall::Assets(pallet_assets::Call::mint { .. }) | RuntimeCall::TrustBackedAssets(TrustBackedAssetClasses::Call::mint { .. }) |
RuntimeCall::Assets(pallet_assets::Call::burn { .. }) | RuntimeCall::TrustBackedAssets(TrustBackedAssetClasses::Call::burn { .. }) |
RuntimeCall::Assets(pallet_assets::Call::freeze { .. }) | RuntimeCall::TrustBackedAssets(TrustBackedAssetClasses::Call::freeze { .. }) |
RuntimeCall::Assets(pallet_assets::Call::thaw { .. }) | RuntimeCall::TrustBackedAssets(TrustBackedAssetClasses::Call::thaw { .. }) |
RuntimeCall::Assets(pallet_assets::Call::freeze_asset { .. }) | RuntimeCall::TrustBackedAssets(
RuntimeCall::Assets(pallet_assets::Call::thaw_asset { .. }) | TrustBackedAssetClasses::Call::freeze_asset { .. }
RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | ) | RuntimeCall::TrustBackedAssets(
TrustBackedAssetClasses::Call::thaw_asset { .. }
) | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::thaw { .. }) |
@@ -506,7 +512,9 @@ impl pallet_collator_selection::Config for Runtime {
impl pallet_asset_tx_payment::Config for Runtime { impl pallet_asset_tx_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Fungibles = Assets; // TODO
// This should be able to take assets from any pallet instance.
type Fungibles = TrustBackedAssets;
type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter< type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter<
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>, pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
AssetsToBlockAuthor<Runtime>, AssetsToBlockAuthor<Runtime>,
@@ -585,7 +593,7 @@ construct_runtime!(
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 42, Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 42,
// The main stage. // The main stage.
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 50, TrustBackedAssets: pallet_assets::<Instance1>::{Pallet, Call, Storage, Event<T>} = 50,
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51, Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
} }
); );
@@ -621,7 +629,10 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>, frame_system::ChainContext<Runtime>,
Runtime, Runtime,
AllPalletsWithSystem, AllPalletsWithSystem,
(), // TODO
// 1. Move this instance https://substrate.stackexchange.com/questions/4343/how-to-migrate-storage-from-a-default-pallet-instance-to-an-actual-one
// 2. Make sure this migration applies to the old instance
pallet_assets::migration::v1::MigrateToV1<Runtime>,
>; >;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
@@ -632,7 +643,7 @@ extern crate frame_benchmarking;
mod benches { mod benches {
define_benchmarks!( define_benchmarks!(
[frame_system, SystemBench::<Runtime>] [frame_system, SystemBench::<Runtime>]
[pallet_assets, Assets] [pallet_assets, TrustBackedAssets]
[pallet_balances, Balances] [pallet_balances, Balances]
[pallet_multisig, Multisig] [pallet_multisig, Multisig]
[pallet_proxy, Proxy] [pallet_proxy, Proxy]
@@ -17,6 +17,8 @@ use super::{
AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
XcmpQueue, XcmpQueue,
AccountId, AssetId, Authorship, Balance, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, TrustBackedAssets, WeightToFee, XcmpQueue,
}; };
use frame_support::{ use frame_support::{
match_types, parameter_types, match_types, parameter_types,
@@ -49,7 +51,7 @@ parameter_types! {
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
pub const Local: MultiLocation = Here.into_location(); pub const Local: MultiLocation = Here.into_location();
pub AssetsPalletLocation: MultiLocation = pub AssetsPalletLocation: MultiLocation =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into(); PalletInstance(<TrustBackedAssets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account(); pub CheckingAccount: AccountId = PolkadotXcm::check_account();
} }
@@ -82,7 +84,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
/// Means for transacting assets besides the native currency on this chain. /// Means for transacting assets besides the native currency on this chain.
pub type FungiblesTransactor = FungiblesAdapter< pub type FungiblesTransactor = FungiblesAdapter<
// Use this fungibles implementation: // Use this fungibles implementation:
Assets, TrustBackedAssets,
// Use this currency when it is a fungible asset matching the given location or name: // Use this currency when it is a fungible asset matching the given location or name:
ConvertedConcreteId< ConvertedConcreteId<
AssetId, AssetId,
@@ -96,7 +98,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
AccountId, AccountId,
// We only want to allow teleports of known assets. We use non-zero issuance as an indication // We only want to allow teleports of known assets. We use non-zero issuance as an indication
// that this asset is known. // that this asset is known.
parachains_common::impls::NonZeroIssuance<AccountId, Assets>, parachains_common::impls::NonZeroIssuance<AccountId, TrustBackedAssets>,
// The account to use for tracking teleports. // The account to use for tracking teleports.
CheckingAccount, CheckingAccount,
>; >;
@@ -187,7 +189,7 @@ impl xcm_executor::Config for XcmConfig {
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>, AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
JustTry, JustTry,
>, >,
Assets, TrustBackedAssets,
cumulus_primitives_utility::XcmFeesTo32ByteAccount< cumulus_primitives_utility::XcmFeesTo32ByteAccount<
FungiblesTransactor, FungiblesTransactor,
AccountId, AccountId,