difftreelog
feat connect split pallets via runtime
in: master
3 files changed
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -5,7 +5,6 @@
use cumulus_primitives_core::ParaId;
use nft_runtime::*;
-use nft_data_structs::*;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use sp_core::{sr25519, Pair, Public};
@@ -175,34 +174,6 @@
.cloned()
.map(|k| (k, 1000, 100, 1 << 98))
.collect(),
- },
- nft: NftConfig {
- collection_id: vec![(
- 1,
- Collection {
- owner: get_account_id_from_seed::<sr25519::Public>("Alice"),
- mode: CollectionMode::NFT,
- access: AccessMode::Normal,
- decimal_points: 0,
- name: vec![],
- description: vec![],
- token_prefix: vec![],
- mint_mode: false,
- offchain_schema: vec![],
- schema_version: SchemaVersion::default(),
- sponsorship: SponsorshipState::Confirmed(get_account_id_from_seed::<
- sr25519::Public,
- >("Alice")),
- const_on_chain_schema: vec![],
- variable_on_chain_schema: vec![],
- limits: CollectionLimits::default(),
- meta_update_permission: MetaUpdatePermission::ItemOwner,
- transfers_enabled: true,
- },
- )],
- nft_item_id: vec![],
- fungible_item_id: vec![],
- refungible_item_id: vec![],
},
parachain_info: nft_runtime::ParachainInfoConfig { parachain_id: id },
aura: nft_runtime::AuraConfig {
runtime/Cargo.tomldiffbeforeafterboth1################################################################################2# Package 34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Substrate node nft'8edition = '2018'9homepage = 'https://unique.network'10license = 'All Rights Reserved'11name = 'nft-runtime'12repository = 'https://github.com/usetech-llc/nft_private/'13version = '3.0.0'1415[package.metadata.docs.rs]16targets = ['x86_64-unknown-linux-gnu']1718[features]19default = ['std']20runtime-benchmarks = [21 'hex-literal',22 'frame-benchmarking',23 'frame-support/runtime-benchmarks',24 'frame-system-benchmarking',25 'frame-system/runtime-benchmarks',26 'pallet-evm-migration/runtime-benchmarks',27 'pallet-balances/runtime-benchmarks',28 'pallet-timestamp/runtime-benchmarks',29 'pallet-common/runtime-benchmarks',30 'pallet-fungible/runtime-benchmarks',31 'pallet-refungible/runtime-benchmarks',32 'pallet-nonfungible/runtime-benchmarks',33 'pallet-nft/runtime-benchmarks',34 'pallet-inflation/runtime-benchmarks',35 'pallet-xcm/runtime-benchmarks',36 'sp-runtime/runtime-benchmarks',37 'xcm-builder/runtime-benchmarks',38]39std = [40 'codec/std',41 'cumulus-pallet-aura-ext/std',42 'cumulus-pallet-parachain-system/std',43 'cumulus-pallet-xcm/std',44 'cumulus-pallet-xcmp-queue/std',45 'cumulus-primitives-core/std',46 'cumulus-primitives-utility/std',47 'frame-executive/std',48 'frame-support/std',49 'frame-system/std',50 'frame-system-rpc-runtime-api/std',51 'pallet-aura/std',52 'pallet-balances/std',53 # 'pallet-contracts/std',54 # 'pallet-contracts-primitives/std',55 # 'pallet-contracts-rpc-runtime-api/std',56 # 'pallet-contract-helpers/std',57 'pallet-randomness-collective-flip/std',58 'pallet-sudo/std',59 'pallet-timestamp/std',60 'pallet-transaction-payment/std',61 'pallet-transaction-payment-rpc-runtime-api/std',62 'pallet-treasury/std',63 'pallet-vesting/std',64 'pallet-evm/std',65 'pallet-evm-migration/std',66 'pallet-evm-contract-helpers/std',67 'pallet-evm-transaction-payment/std',68 'pallet-evm-coder-substrate/std',69 'pallet-ethereum/std',70 'fp-rpc/std',71 'parachain-info/std',72 'serde',73 'pallet-inflation/std',74 'pallet-common/std',75 'pallet-fungible/std',76 'pallet-refungible/std',77 'pallet-nonfungible/std',78 'pallet-nft/std',79 'pallet-scheduler/std',80 'pallet-nft-charge-transaction/std',81 'pallet-nft-transaction-payment/std',82 'nft-data-structs/std',83 'sp-api/std',84 'sp-block-builder/std',85 "sp-consensus-aura/std",86 'sp-core/std',87 'sp-inherents/std',88 'sp-io/std',89 'sp-offchain/std',90 'sp-runtime/std',91 'sp-session/std',92 'sp-std/std',93 'sp-transaction-pool/std',94 'sp-version/std',95 'xcm/std',96 'xcm-builder/std',97 'xcm-executor/std',98]99limit-testing = ['pallet-nft/limit-testing', 'nft-data-structs/limit-testing']100101################################################################################102# Substrate Dependencies103104[dependencies.codec]105default-features = false106features = ['derive']107package = 'parity-scale-codec'108version = '2.3.0'109110[dependencies.frame-benchmarking]111default-features = false112git = 'https://github.com/paritytech/substrate.git'113optional = true114branch = 'polkadot-v0.9.10'115version = '4.0.0-dev'116117[dependencies.frame-executive]118default-features = false119git = 'https://github.com/paritytech/substrate.git'120branch = 'polkadot-v0.9.10'121version = '4.0.0-dev'122123[dependencies.frame-support]124default-features = false125git = 'https://github.com/paritytech/substrate.git'126branch = 'polkadot-v0.9.10'127version = '4.0.0-dev'128129[dependencies.frame-system]130default-features = false131git = 'https://github.com/paritytech/substrate.git'132branch = 'polkadot-v0.9.10'133version = '4.0.0-dev'134135[dependencies.frame-system-benchmarking]136default-features = false137git = 'https://github.com/paritytech/substrate.git'138optional = true139branch = 'polkadot-v0.9.10'140version = '4.0.0-dev'141142[dependencies.frame-system-rpc-runtime-api]143default-features = false144git = 'https://github.com/paritytech/substrate.git'145branch = 'polkadot-v0.9.10'146version = '4.0.0-dev'147148[dependencies.hex-literal]149optional = true150version = '0.3.3'151152[dependencies.serde]153default-features = false154features = ['derive']155optional = true156version = '1.0.130'157158[dependencies.pallet-aura]159default-features = false160git = 'https://github.com/paritytech/substrate.git'161branch = 'polkadot-v0.9.10'162version = '4.0.0-dev'163164[dependencies.pallet-balances]165default-features = false166git = 'https://github.com/paritytech/substrate.git'167branch = 'polkadot-v0.9.10'168version = '4.0.0-dev'169170# Contracts specific packages171# [dependencies.pallet-contracts]172# git = 'https://github.com/paritytech/substrate.git'173# default-features = false174# branch = 'polkadot-v0.9.10'175# version = '4.0.0-dev'176177# [dependencies.pallet-contracts-primitives]178# git = 'https://github.com/paritytech/substrate.git'179# default-features = false180# branch = 'polkadot-v0.9.10'181# version = '4.0.0-dev'182183# [dependencies.pallet-contracts-rpc-runtime-api]184# git = 'https://github.com/paritytech/substrate.git'185# default-features = false186# branch = 'polkadot-v0.9.10'187# version = '4.0.0-dev'188189[dependencies.pallet-randomness-collective-flip]190default-features = false191git = 'https://github.com/paritytech/substrate.git'192branch = 'polkadot-v0.9.10'193version = '4.0.0-dev'194195[dependencies.pallet-sudo]196default-features = false197git = 'https://github.com/paritytech/substrate.git'198branch = 'polkadot-v0.9.10'199version = '4.0.0-dev'200201[dependencies.pallet-timestamp]202default-features = false203git = 'https://github.com/paritytech/substrate.git'204branch = 'polkadot-v0.9.10'205version = '4.0.0-dev'206207[dependencies.pallet-transaction-payment]208default-features = false209git = 'https://github.com/paritytech/substrate.git'210branch = 'polkadot-v0.9.10'211version = '4.0.0-dev'212213[dependencies.pallet-transaction-payment-rpc-runtime-api]214default-features = false215git = 'https://github.com/paritytech/substrate.git'216branch = 'polkadot-v0.9.10'217version = '4.0.0-dev'218219[dependencies.pallet-treasury]220default-features = false221git = 'https://github.com/paritytech/substrate.git'222branch = 'polkadot-v0.9.10'223version = '4.0.0-dev'224225[dependencies.pallet-vesting]226default-features = false227git = 'https://github.com/paritytech/substrate.git'228branch = 'polkadot-v0.9.10'229version = '4.0.0-dev'230231[dependencies.sp-arithmetic]232default-features = false233git = 'https://github.com/paritytech/substrate.git'234branch = 'polkadot-v0.9.10'235version = '4.0.0-dev'236237[dependencies.sp-api]238default-features = false239git = 'https://github.com/paritytech/substrate.git'240branch = 'polkadot-v0.9.10'241version = '4.0.0-dev'242243[dependencies.sp-block-builder]244default-features = false245git = 'https://github.com/paritytech/substrate.git'246branch = 'polkadot-v0.9.10'247version = '4.0.0-dev'248249[dependencies.sp-core]250default-features = false251git = 'https://github.com/paritytech/substrate.git'252branch = 'polkadot-v0.9.10'253version = '4.0.0-dev'254255[dependencies.sp-consensus-aura]256default-features = false257git = 'https://github.com/paritytech/substrate.git'258branch = 'polkadot-v0.9.10'259version = '0.10.0-dev'260261[dependencies.sp-inherents]262default-features = false263git = 'https://github.com/paritytech/substrate.git'264branch = 'polkadot-v0.9.10'265version = '4.0.0-dev'266267[dependencies.sp-io]268default-features = false269git = 'https://github.com/paritytech/substrate.git'270branch = 'polkadot-v0.9.10'271version = '4.0.0-dev'272273[dependencies.sp-offchain]274default-features = false275git = 'https://github.com/paritytech/substrate.git'276branch = 'polkadot-v0.9.10'277version = '4.0.0-dev'278279[dependencies.sp-runtime]280default-features = false281git = 'https://github.com/paritytech/substrate.git'282branch = 'polkadot-v0.9.10'283version = '4.0.0-dev'284285[dependencies.sp-session]286default-features = false287git = 'https://github.com/paritytech/substrate.git'288branch = 'polkadot-v0.9.10'289version = '4.0.0-dev'290291[dependencies.sp-std]292default-features = false293git = 'https://github.com/paritytech/substrate.git'294branch = 'polkadot-v0.9.10'295version = '4.0.0-dev'296297[dependencies.sp-transaction-pool]298default-features = false299git = 'https://github.com/paritytech/substrate.git'300branch = 'polkadot-v0.9.10'301version = '4.0.0-dev'302303[dependencies.sp-version]304default-features = false305git = 'https://github.com/paritytech/substrate.git'306branch = 'polkadot-v0.9.10'307version = '4.0.0-dev'308309[dependencies.smallvec]310version = '1.6.1'311312################################################################################313# Cumulus dependencies314315[dependencies.parachain-info]316default-features = false317git = 'https://github.com/paritytech/cumulus.git'318branch = 'polkadot-v0.9.10'319version = '0.1.0'320321[dependencies.cumulus-pallet-aura-ext]322git = 'https://github.com/paritytech/cumulus.git'323branch = 'polkadot-v0.9.10'324default-features = false325326[dependencies.cumulus-pallet-parachain-system]327git = 'https://github.com/paritytech/cumulus.git'328branch = 'polkadot-v0.9.10'329default-features = false330331[dependencies.cumulus-primitives-core]332git = 'https://github.com/paritytech/cumulus.git'333branch = 'polkadot-v0.9.10'334default-features = false335336[dependencies.cumulus-pallet-xcm]337git = 'https://github.com/paritytech/cumulus.git'338branch = 'polkadot-v0.9.10'339default-features = false340341[dependencies.cumulus-pallet-dmp-queue]342git = 'https://github.com/paritytech/cumulus.git'343branch = 'polkadot-v0.9.10'344default-features = false345346[dependencies.cumulus-pallet-xcmp-queue]347git = 'https://github.com/paritytech/cumulus.git'348branch = 'polkadot-v0.9.10'349default-features = false350351[dependencies.cumulus-primitives-utility]352git = 'https://github.com/paritytech/cumulus.git'353branch = 'polkadot-v0.9.10'354default-features = false355356[dependencies.cumulus-primitives-timestamp]357git = 'https://github.com/paritytech/cumulus.git'358branch = 'polkadot-v0.9.10'359default-features = false360361################################################################################362# Polkadot dependencies363364[dependencies.polkadot-parachain]365git = 'https://github.com/paritytech/polkadot'366branch = 'release-v0.9.10'367default-features = false368369[dependencies.xcm]370git = 'https://github.com/paritytech/polkadot'371branch = 'release-v0.9.10'372default-features = false373374[dependencies.xcm-builder]375git = 'https://github.com/paritytech/polkadot'376branch = 'release-v0.9.10'377default-features = false378379[dependencies.xcm-executor]380git = 'https://github.com/paritytech/polkadot'381branch = 'release-v0.9.10'382default-features = false383384[dependencies.pallet-xcm]385git = 'https://github.com/paritytech/polkadot'386branch = 'release-v0.9.10'387default-features = false388389390################################################################################391# local dependencies392393[dependencies]394derivative = "2.2.0"395pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }396up-rpc = { path = "../primitives/rpc", default-features = false }397pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }398nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }399pallet-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }400pallet-common = { default-features = false, path = "../pallets/common" }401pallet-fungible = { default-features = false, path = "../pallets/fungible" }402pallet-refungible = { default-features = false, path = "../pallets/refungible" }403pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }404# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }405pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.0' }406pallet-nft-charge-transaction = { path = '../pallets/nft-charge-transaction', default-features = false, version = '3.0.0' }407pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }408pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }409pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }410pallet-evm-coder-substrate = { default-features = false, path = "../pallets/evm-coder-substrate" }411412pallet-evm = { default-features = false, version = "6.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.10" }413pallet-ethereum = { default-features = false, version = "4.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.10" }414fp-rpc = { default-features = false, version = "3.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.10" }415416################################################################################417# Build Dependencies418419[build-dependencies.substrate-wasm-builder]420git = 'https://github.com/paritytech/substrate.git'421branch = 'polkadot-v0.9.10'422version = '5.0.0-dev'runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -102,6 +102,8 @@
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
+pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
/// never know...
pub type AccountIndex = u32;
@@ -701,20 +703,32 @@
pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
}
-/// Used for the pallet nft in `./nft.rs`
-impl pallet_nft::Config for Runtime {
+impl pallet_common::Config for Runtime {
type Event = Event;
- type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;
-
- type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;
+ type EvmBackwardsAddressMapping = pallet_common::account::MapBackwardsAddressTruncated;
type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
- type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;
+ type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
type Currency = Balances;
type CollectionCreationPrice = CollectionCreationPrice;
type TreasuryAccountId = TreasuryAccountId;
}
+impl pallet_fungible::Config for Runtime {
+ type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_refungible::Config for Runtime {
+ type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;
+}
+impl pallet_nonfungible::Config for Runtime {
+ type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
+}
+
+/// Used for the pallet nft in `./nft.rs`
+impl pallet_nft::Config for Runtime {
+ type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;
+}
+
parameter_types! {
pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied
}
@@ -820,11 +834,15 @@
// Unique Pallets
Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
- Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,
+ Nft: pallet_nft::{Pallet, Call, Storage} = 61,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,
Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,
// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
+ Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
+ Fungible: pallet_fungible::{Pallet, Storage} = 67,
+ Refungible: pallet_refungible::{Pallet, Storage} = 68,
+ Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
// Frontier
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
@@ -901,10 +919,56 @@
}
}
+macro_rules! dispatch_nft_runtime {
+ ($collection:ident.$method:ident($($name:ident),*)) => {{
+ use pallet_nft::dispatch::Dispatched;
+
+ let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());
+ let dispatch = collection.as_dyn();
+
+ dispatch.$method($($name),*)
+ }};
+}
+
impl_runtime_apis! {
- impl pallet_nft::NftApi<Block>
+ impl up_rpc::NftApi<Block, CrossAccountId, AccountId>
for Runtime
{
+ fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {
+ dispatch_nft_runtime!(collection.account_tokens(account))
+ }
+ fn token_exists(collection: CollectionId, token: TokenId) -> bool {
+ dispatch_nft_runtime!(collection.token_exists(token))
+ }
+
+ fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {
+ dispatch_nft_runtime!(collection.token_owner(token))
+ }
+ fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {
+ dispatch_nft_runtime!(collection.const_metadata(token))
+ }
+ fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {
+ dispatch_nft_runtime!(collection.variable_metadata(token))
+ }
+
+ fn collection_tokens(collection: CollectionId) -> u32 {
+ dispatch_nft_runtime!(collection.collection_tokens())
+ }
+ fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {
+ dispatch_nft_runtime!(collection.account_balance(account))
+ }
+ fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {
+ dispatch_nft_runtime!(collection.balance(account, token))
+ }
+ fn allowance(
+ collection: CollectionId,
+ sender: CrossAccountId,
+ spender: CrossAccountId,
+ token: TokenId,
+ ) -> u128 {
+ dispatch_nft_runtime!(collection.allowance(sender, spender, token))
+ }
+
fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
<pallet_nft::NftErcSupport<Runtime>>::get_code(&account)
}