difftreelog
wip checkpoint. Opal builds.
in: master
8 files changed
Cargo.lockdiffbeforeafterboth5190 "frame-try-runtime",5190 "frame-try-runtime",5191 "hex-literal",5191 "hex-literal",5192 "log",5192 "log",5193 "orml-tokens",5194 "orml-traits",5193 "orml-vesting",5195 "orml-vesting",5196 "orml-xtokens",5194 "pallet-aura",5197 "pallet-aura",5195 "pallet-balances",5198 "pallet-balances",5196 "pallet-base-fee",5199 "pallet-base-fee",5202 "pallet-evm-contract-helpers",5205 "pallet-evm-contract-helpers",5203 "pallet-evm-migration",5206 "pallet-evm-migration",5204 "pallet-evm-transaction-payment",5207 "pallet-evm-transaction-payment",5208 "pallet-foreing-assets",5205 "pallet-fungible",5209 "pallet-fungible",5206 "pallet-inflation",5210 "pallet-inflation",5207 "pallet-nonfungible",5211 "pallet-nonfungible",5306 "num-traits",5310 "num-traits",5307]5311]53125313[[package]]5314name = "orml-tokens"5315version = "0.4.1-dev"5316source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"5317dependencies = [5318 "frame-support",5319 "frame-system",5320 "orml-traits",5321 "parity-scale-codec 3.1.5",5322 "scale-info",5323 "serde",5324 "sp-runtime",5325 "sp-std",5326]53275328[[package]]5329name = "orml-traits"5330version = "0.4.1-dev"5331source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"5332dependencies = [5333 "frame-support",5334 "impl-trait-for-tuples",5335 "num-traits",5336 "orml-utilities",5337 "parity-scale-codec 3.1.5",5338 "scale-info",5339 "serde",5340 "sp-io",5341 "sp-runtime",5342 "sp-std",5343 "xcm",5344]53455346[[package]]5347name = "orml-utilities"5348version = "0.4.1-dev"5349source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"5350dependencies = [5351 "frame-support",5352 "parity-scale-codec 3.1.5",5353 "scale-info",5354 "serde",5355 "sp-io",5356 "sp-runtime",5357 "sp-std",5358]530853595309[[package]]5360[[package]]5310name = "orml-vesting"5361name = "orml-vesting"5321 "sp-std",5372 "sp-std",5322]5373]53745375[[package]]5376name = "orml-xcm-support"5377version = "0.4.1-dev"5378source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"5379dependencies = [5380 "frame-support",5381 "orml-traits",5382 "parity-scale-codec 3.1.5",5383 "sp-runtime",5384 "sp-std",5385 "xcm",5386 "xcm-executor",5387]53885389[[package]]5390name = "orml-xtokens"5391version = "0.4.1-dev"5392source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"5393dependencies = [5394 "cumulus-primitives-core",5395 "frame-support",5396 "frame-system",5397 "orml-traits",5398 "orml-xcm-support",5399 "pallet-xcm",5400 "parity-scale-codec 3.1.5",5401 "scale-info",5402 "serde",5403 "sp-io",5404 "sp-runtime",5405 "sp-std",5406 "xcm",5407 "xcm-executor",5408]532354095324[[package]]5410[[package]]5325name = "os_str_bytes"5411name = "os_str_bytes"5788 "up-sponsorship",5874 "up-sponsorship",5789]5875]58765877[[package]]5878name = "pallet-foreing-assets"5879version = "0.1.0"5880dependencies = [5881 "frame-support",5882 "frame-system",5883 "hex",5884 "log",5885 "orml-tokens",5886 "pallet-balances",5887 "pallet-common",5888 "pallet-fungible",5889 "pallet-timestamp",5890 "parity-scale-codec 3.1.5",5891 "scale-info",5892 "serde",5893 "serde_json",5894 "sp-core",5895 "sp-io",5896 "sp-runtime",5897 "sp-std",5898 "up-data-structs",5899 "xcm",5900 "xcm-builder",5901 "xcm-executor",5902]579059035791[[package]]5904[[package]]5792name = "pallet-fungible"5905name = "pallet-fungible"12130source = "registry+https://github.com/rust-lang/crates.io-index"12243source = "registry+https://github.com/rust-lang/crates.io-index"12131checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"12244checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"12132dependencies = [12245dependencies = [12133 "cfg-if 1.0.0",12246 "cfg-if 0.1.10",12134 "digest 0.10.3",12247 "digest 0.10.3",12135 "rand 0.8.5",12248 "rand 0.8.5",12136 "static_assertions",12249 "static_assertions",124731258612474[[package]]12587[[package]]12475name = "up-common"12588name = "up-common"12476version = "0.9.25"12589version = "0.9.27"12477dependencies = [12590dependencies = [12478 "fp-rpc",12591 "fp-rpc",12479 "frame-support",12592 "frame-support",pallets/foreing-assets/Cargo.tomldiffbeforeafterboth9serde = { version = "1.0.136", optional = true }9serde = { version = "1.0.136", optional = true }10scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }10scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }11codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }11codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }12sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }12sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }13sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }13sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }14frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }14frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }15frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }15frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }16up-data-structs = { default-features = false, path = '../../primitives/data-structs' }16up-data-structs = { default-features = false, path = '../../primitives/data-structs' }17pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }17pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }18pallet-common = { default-features = false, path = '../common' }18pallet-common = { default-features = false, path = '../common' }19pallet-fungible = { default-features = false, path = '../fungible' }19pallet-fungible = { default-features = false, path = '../fungible' }20xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", default-features = false }20xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.27", default-features = false }21xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", default-features = false }21xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.27", default-features = false }22xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", default-features = false }22xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.27", default-features = false }23#orml-tokens = { git = 'https://github.com/UniqueNetwork/open-runtime-module-library', branch = 'unique-polkadot-v0.9.24', version = "0.4.1-dev", default-features = false }23orml-tokens = { git = 'https://github.com/UniqueNetwork/open-runtime-module-library', branch = 'unique-polkadot-v0.9.24', version = "0.4.1-dev", default-features = false }24orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.27", version = "0.4.1-dev", default-features = false }25#git = "https://github.com/open-web3-stack/open-runtime-module-library"26#branch = "polkadot-v0.9.27"242725[dev-dependencies]28[dev-dependencies]26serde_json = "1.0.68"29serde_json = "1.0.68"27hex = { version = "0.4" }30hex = { version = "0.4" }28sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }31sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }29sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }32sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }30pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }33pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }31pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }34pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }323533[features]36[features]34default = ["std"]37default = ["std"]pallets/fungible/src/lib.rsdiffbeforeafterboth168 QueryKind = ValueQuery,168 QueryKind = ValueQuery,169 >;169 >;170171 /// Foreign collection flag172 #[pallet::storage]173 pub type ForeignCollection<T: Config> =174 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = bool, QueryKind = ValueQuery>;170}175}176171177215 <PalletCommon<T>>::init_collection(owner, data, false)221 <PalletCommon<T>>::init_collection(owner, data, false)216 }222 }223224 /// Initializes the collection with ForeignCollection flag. Returns [CollectionId] on success, [DispatchError] otherwise.225 pub fn init_foreign_collection(226 owner: T::CrossAccountId,227 data: CreateCollectionData<T::AccountId>,228 ) -> Result<CollectionId, DispatchError> {229 let id = <PalletCommon<T>>::init_collection(owner, data, false)?;230 <ForeignCollection<T>>::insert(id, true);231 Ok(id)232 }217233218 /// Destroys a collection.234 /// Destroys a collection.219 pub fn destroy_collection(235 pub fn destroy_collection(230246231 PalletCommon::destroy_collection(collection.0, sender)?;247 PalletCommon::destroy_collection(collection.0, sender)?;232248249 <ForeignCollection<T>>::remove(id);233 <TotalSupply<T>>::remove(id);250 <TotalSupply<T>>::remove(id);234 let _ = <Balance<T>>::clear_prefix((id,), u32::MAX, None);251 let _ = <Balance<T>>::clear_prefix((id,), u32::MAX, None);235 let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);252 let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);257 .checked_sub(amount)274 .checked_sub(amount)258 .ok_or(<CommonError<T>>::TokenValueTooLow)?;275 .ok_or(<CommonError<T>>::TokenValueTooLow)?;276277 // Foreign collection check278 ensure!(279 !<ForeignCollection<T>>::get(collection.id),280 <CommonError<T>>::NoPermission281 );259282260 if collection.permissions.access() == AccessMode::AllowList {283 if collection.permissions.access() == AccessMode::AllowList {261 collection.check_allowlist(owner)?;284 collection.check_allowlist(owner)?;288 Ok(())311 Ok(())289 }312 }313314 /// Burns the specified amount of the token.315 pub fn burn_foreign(316 collection: &FungibleHandle<T>,317 owner: &T::CrossAccountId,318 amount: u128,319 ) -> DispatchResult {320 let total_supply = <TotalSupply<T>>::get(collection.id)321 .checked_sub(amount)322 .ok_or(<CommonError<T>>::TokenValueTooLow)?;323324 let balance = <Balance<T>>::get((collection.id, owner))325 .checked_sub(amount)326 .ok_or(<CommonError<T>>::TokenValueTooLow)?;327 // =========328329 if balance == 0 {330 <Balance<T>>::remove((collection.id, owner));331 <PalletStructure<T>>::unnest_if_nested(owner, collection.id, TokenId::default());332 } else {333 <Balance<T>>::insert((collection.id, owner), balance);334 }335 <TotalSupply<T>>::insert(collection.id, total_supply);336337 <PalletEvm<T>>::deposit_log(338 ERC20Events::Transfer {339 from: *owner.as_eth(),340 to: H160::default(),341 value: amount.into(),342 }343 .to_log(collection_id_to_address(collection.id)),344 );345 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(346 collection.id,347 TokenId::default(),348 owner.clone(),349 amount,350 ));351 Ok(())352 }290353291 /// Transfers the specified amount of tokens. Will check that354 /// Transfers the specified amount of tokens. Will check that292 /// the transfer is allowed for the token.355 /// the transfer is allowed for the token.373 data: BTreeMap<T::CrossAccountId, u128>,436 data: BTreeMap<T::CrossAccountId, u128>,374 nesting_budget: &dyn Budget,437 nesting_budget: &dyn Budget,375 ) -> DispatchResult {438 ) -> DispatchResult {439 // Foreign collection check440 ensure!(441 !<ForeignCollection<T>>::get(collection.id),442 <CommonError<T>>::NoPermission443 );444376 if !collection.is_owner_or_admin(sender) {445 if !collection.is_owner_or_admin(sender) {377 ensure!(446 ensure!(442 Ok(())511 Ok(())443 }512 }513514 /// Minting tokens for multiple IDs.515 /// See [`create_item_foreign`][`Pallet::create_item_foreign`] for more details.516 pub fn create_multiple_items_foreign(517 collection: &FungibleHandle<T>,518 sender: &T::CrossAccountId,519 data: BTreeMap<T::CrossAccountId, u128>,520 nesting_budget: &dyn Budget,521 ) -> DispatchResult {522 let total_supply = data523 .iter()524 .map(|(_, v)| *v)525 .try_fold(<TotalSupply<T>>::get(collection.id), |acc, v| {526 acc.checked_add(v)527 })528 .ok_or(ArithmeticError::Overflow)?;529530 let mut balances = data;531 for (k, v) in balances.iter_mut() {532 *v = <Balance<T>>::get((collection.id, &k))533 .checked_add(*v)534 .ok_or(ArithmeticError::Overflow)?;535 }536537 for (to, _) in balances.iter() {538 <PalletStructure<T>>::check_nesting(539 sender.clone(),540 to,541 collection.id,542 TokenId::default(),543 nesting_budget,544 )?;545 }546547 // =========548549 <TotalSupply<T>>::insert(collection.id, total_supply);550 for (user, amount) in balances {551 <Balance<T>>::insert((collection.id, &user), amount);552 <PalletStructure<T>>::nest_if_sent_to_token_unchecked(553 &user,554 collection.id,555 TokenId::default(),556 );557 <PalletEvm<T>>::deposit_log(558 ERC20Events::Transfer {559 from: H160::default(),560 to: *user.as_eth(),561 value: amount.into(),562 }563 .to_log(collection_id_to_address(collection.id)),564 );565 <PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(566 collection.id,567 TokenId::default(),568 user.clone(),569 amount,570 ));571 }572573 Ok(())574 }444575445 fn set_allowance_unchecked(576 fn set_allowance_unchecked(446 collection: &FungibleHandle<T>,577 collection: &FungibleHandle<T>,615 )746 )616 }747 }748749 /// Creates fungible token.750 ///751 /// - `data`: Contains user who will become the owners of the tokens and amount752 /// of tokens he will receive.753 pub fn create_item_foreign(754 collection: &FungibleHandle<T>,755 sender: &T::CrossAccountId,756 data: CreateItemData<T>,757 nesting_budget: &dyn Budget,758 ) -> DispatchResult {759 Self::create_multiple_items_foreign(760 collection,761 sender,762 [(data.0, data.1)].into_iter().collect(),763 nesting_budget,764 )765 }617766618 /// Returns 10 tokens owners in no particular order767 /// Returns 10 tokens owners in no particular order619 ///768 ///runtime/common/config/pallets/foreign_asset.rsdiffbeforeafterbothno changes
runtime/common/config/pallets/mod.rsdiffbeforeafterboth40#[cfg(feature = "scheduler")]40#[cfg(feature = "scheduler")]41pub mod scheduler;41pub mod scheduler;4243#[cfg(feature = "foreign-asset")]44pub mod foreign_asset;424543parameter_types! {46parameter_types! {44 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();47 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();runtime/common/construct_runtime/mod.rsdiffbeforeafterboth42 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,42 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,43 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,43 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,44 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,44 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,45 XTokens: orml_xtokens = 38,46 Tokens: orml_tokens = 39,45 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,47 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,46 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,48 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,4749runtime/opal/Cargo.tomldiffbeforeafterboth120 'up-sponsorship/std',120 'up-sponsorship/std',121121122 "orml-vesting/std",122 "orml-vesting/std",123 "orml-tokens/std",124 "orml-xtokens/std",125 "orml-traits/std",126 "pallet-foreing-assets/std"123]127]124limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']128limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']125opal-runtime = ['refungible', 'scheduler', 'rmrk']129opal-runtime = ['refungible', 'scheduler', 'rmrk', 'foreign-asset']126130127refungible = []131refungible = []128scheduler = []132scheduler = []129rmrk = []133rmrk = []134foreign-asset = []130135131################################################################################136################################################################################132# Substrate Dependencies137# Substrate Dependencies399version = "0.4.1-dev"404version = "0.4.1-dev"400default-features = false405default-features = false406407[dependencies.orml-xtokens]408git = "https://github.com/open-web3-stack/open-runtime-module-library"409branch = "polkadot-v0.9.27"410version = "0.4.1-dev"411default-features = false412413[dependencies.orml-tokens]414git = "https://github.com/open-web3-stack/open-runtime-module-library"415branch = "polkadot-v0.9.27"416version = "0.4.1-dev"417default-features = false418419[dependencies.orml-traits]420git = "https://github.com/open-web3-stack/open-runtime-module-library"421branch = "polkadot-v0.9.27"422version = "0.4.1-dev"423default-features = false401424402################################################################################425################################################################################403# local dependencies426# local dependencies437fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }460fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }438evm-coder = { default-features = false, path = '../../crates/evm-coder' }461evm-coder = { default-features = false, path = '../../crates/evm-coder' }439up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = 'polkadot-v0.9.27' }462up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = 'polkadot-v0.9.27' }463pallet-foreing-assets = { default-features = false, path = "../../pallets/foreing-assets" }440464441################################################################################465################################################################################442# Build Dependencies466# Build Dependenciesruntime/opal/src/lib.rsdiffbeforeafterboth35#[path = "../../common/mod.rs"]35#[path = "../../common/mod.rs"]36mod runtime_common;36mod runtime_common;3738pub mod xcm_config;373938pub use runtime_common::*;40pub use runtime_common::*;3941