Skip to content

Commit

Permalink
Add another parachain template for uniques
Browse files Browse the repository at this point in the history
  • Loading branch information
dudo50 committed Oct 20, 2024
1 parent 0d8c173 commit de4c0ae
Show file tree
Hide file tree
Showing 51 changed files with 9,424 additions and 25 deletions.
160 changes: 160 additions & 0 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ members = [
"templates/parachain/pallets/template",
"templates/parachain/pallets/xcnft",
"templates/parachain/runtime",
"templates/parachain_two/node",
"templates/parachain_two/pallets/template",
"templates/parachain_two/pallets/xcnft",
"templates/parachain_two/runtime",
"templates/solochain/node",
"templates/solochain/pallets/template",
"templates/solochain/runtime",
Expand Down Expand Up @@ -951,6 +955,8 @@ pallet-offences-benchmarking = { path = "substrate/frame/offences/benchmarking",
pallet-paged-list = { path = "substrate/frame/paged-list", default-features = false }
pallet-parachain-template = { path = "templates/parachain/pallets/template", default-features = false }
pallet-parachain-xcnft = { path = "templates/parachain/pallets/xcnft", default-features = false }
pallet-parachain-template-two = {path = "templates/parachain_two/pallets/template", default-features = false }
pallet-parachain-xcnft-two = { path = "templates/parachain_two/pallets/xcnft", default-features = false }
pallet-parameters = { path = "substrate/frame/parameters", default-features = false }
pallet-preimage = { path = "substrate/frame/preimage", default-features = false }
pallet-proxy = { path = "substrate/frame/proxy", default-features = false }
Expand Down Expand Up @@ -999,6 +1005,7 @@ pallet-xcm-bridge-hub = { path = "bridges/modules/xcm-bridge-hub", default-featu
pallet-xcm-bridge-hub-router = { path = "bridges/modules/xcm-bridge-hub-router", default-features = false }
parachain-info = { path = "cumulus/parachains/pallets/parachain-info", default-features = false, package = "staging-parachain-info" }
parachain-template-runtime = { path = "templates/parachain/runtime" }
parachain-template-runtime-two = { path = "templates/parachain_two/runtime"}
parachains-common = { path = "cumulus/parachains/common", default-features = false }
parachains-relay = { path = "bridges/relays/parachains" }
parachains-runtimes-test-utils = { path = "cumulus/parachains/runtimes/test-utils", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions templates/parachain/pallets/xcnft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ scale-info = { features = [
"derive",
], workspace = true }


# Substrate
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
Expand Down
111 changes: 111 additions & 0 deletions templates/parachain/pallets/xcnft/src/mock/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#![cfg(test)]

use super::*;
use sp_io::TestExternalities;
use sp_runtime::{AccountId32};
mod parachain;
mod relaychain;
use crate as xnft;
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain, TestExt};
use sp_runtime::BuildStorage;

pub const ALICE: AccountId32 = AccountId32::new([0u8; 32]);
pub const BOB: AccountId32 = AccountId32::new([1u8; 32]);
pub const CHARLIE: AccountId32 = AccountId32::new([1u8; 32]);

pub const INITIAL_BALANCE: u64 = 1_000_000_000;

pub type Balance = u128;
pub type Amount = i128;

decl_test_parachain! {
pub struct Para1 {
Runtime = parachain::Test,
XcmpMessageHandler = parachain::XcmpQueue,
DmpMessageHandler = parachain::DmpQueue,
new_ext = para_ext(4),
}
}

decl_test_parachain! {
pub struct Para2 {
Runtime = parachain::Test,
XcmpMessageHandler = parachain::XcmpQueue,
DmpMessageHandler = parachain::DmpQueue,
new_ext = para_ext(4),
}
}

decl_test_relay_chain! {
pub struct Relay {
Runtime = relaychain::Test,
RuntimeCall = relaychain::RuntimeCall,
RuntimeEvent = relaychain::RuntimeEvent,
XcmConfig = relaychain::XcmConfig,
MessageQueue = relaychain::MessageQueue,
System = relaychain::System,
new_ext = relay_ext(),
}
}

decl_test_network! {
pub struct TestNet {
relay_chain = Relay,
parachains = vec![
(2000, Para1),
(2001, Para2),
],
}
}
pub type RelayBalances = pallet_balances::Pallet<relay::Test>;
pub type ParaChain1 = xnft::Pallet<para::Test>;
pub type NFT = pallet_nfts::Pallet<para::Test>;
pub fn para_ext(para_id: u32) -> TestExternalities {
use parachain::{System, Test};

let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();

let parachain_info_config = parachain_info::GenesisConfig::<Test> {
_config: Default::default(),
parachain_id: para_id.into(),
};
parachain_info_config.assimilate_storage(&mut t).unwrap();

let mut ext = TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}

pub fn para_teleport_ext(para_id: u32) -> TestExternalities {
use parachain::{System, Test};

let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();

let parachain_info_config = parachain_info::GenesisConfig::<Test> {
_config: Default::default(),
parachain_id: para_id.into(),
};
parachain_info_config.assimilate_storage(&mut t).unwrap();
let mut ext = TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}


pub fn relay_ext() -> sp_io::TestExternalities {
use relaychain::{Test, System};

let mut t = frame_system::GenesisConfig::<Test>::default()
.build_storage()
.unwrap();

pallet_balances::GenesisConfig::<Test> {
balances: vec![(ALICE, 1_000)],
}
.assimilate_storage(&mut t)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}
Loading

0 comments on commit de4c0ae

Please sign in to comment.