difftreelog
wip checkpoint. Opal builds.
in: master
8 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5190,7 +5190,10 @@
"frame-try-runtime",
"hex-literal",
"log",
+ "orml-tokens",
+ "orml-traits",
"orml-vesting",
+ "orml-xtokens",
"pallet-aura",
"pallet-balances",
"pallet-base-fee",
@@ -5202,6 +5205,7 @@
"pallet-evm-contract-helpers",
"pallet-evm-migration",
"pallet-evm-transaction-payment",
+ "pallet-foreing-assets",
"pallet-fungible",
"pallet-inflation",
"pallet-nonfungible",
@@ -5307,6 +5311,53 @@
]
[[package]]
+name = "orml-tokens"
+version = "0.4.1-dev"
+source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "orml-traits",
+ "parity-scale-codec 3.1.5",
+ "scale-info",
+ "serde",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
+name = "orml-traits"
+version = "0.4.1-dev"
+source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"
+dependencies = [
+ "frame-support",
+ "impl-trait-for-tuples",
+ "num-traits",
+ "orml-utilities",
+ "parity-scale-codec 3.1.5",
+ "scale-info",
+ "serde",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+ "xcm",
+]
+
+[[package]]
+name = "orml-utilities"
+version = "0.4.1-dev"
+source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"
+dependencies = [
+ "frame-support",
+ "parity-scale-codec 3.1.5",
+ "scale-info",
+ "serde",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "orml-vesting"
version = "0.4.1-dev"
source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"
@@ -5322,6 +5373,41 @@
]
[[package]]
+name = "orml-xcm-support"
+version = "0.4.1-dev"
+source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"
+dependencies = [
+ "frame-support",
+ "orml-traits",
+ "parity-scale-codec 3.1.5",
+ "sp-runtime",
+ "sp-std",
+ "xcm",
+ "xcm-executor",
+]
+
+[[package]]
+name = "orml-xtokens"
+version = "0.4.1-dev"
+source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.27#377213f750755cc48e80a3131eaae63b5eda8362"
+dependencies = [
+ "cumulus-primitives-core",
+ "frame-support",
+ "frame-system",
+ "orml-traits",
+ "orml-xcm-support",
+ "pallet-xcm",
+ "parity-scale-codec 3.1.5",
+ "scale-info",
+ "serde",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+ "xcm",
+ "xcm-executor",
+]
+
+[[package]]
name = "os_str_bytes"
version = "6.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5789,6 +5875,33 @@
]
[[package]]
+name = "pallet-foreing-assets"
+version = "0.1.0"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "hex",
+ "log",
+ "orml-tokens",
+ "pallet-balances",
+ "pallet-common",
+ "pallet-fungible",
+ "pallet-timestamp",
+ "parity-scale-codec 3.1.5",
+ "scale-info",
+ "serde",
+ "serde_json",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+ "up-data-structs",
+ "xcm",
+ "xcm-builder",
+ "xcm-executor",
+]
+
+[[package]]
name = "pallet-fungible"
version = "0.1.3"
dependencies = [
@@ -12130,7 +12243,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if 0.1.10",
"digest 0.10.3",
"rand 0.8.5",
"static_assertions",
@@ -12473,7 +12586,7 @@
[[package]]
name = "up-common"
-version = "0.9.25"
+version = "0.9.27"
dependencies = [
"fp-rpc",
"frame-support",
pallets/foreing-assets/Cargo.tomldiffbeforeafterboth--- a/pallets/foreing-assets/Cargo.toml
+++ b/pallets/foreing-assets/Cargo.toml
@@ -9,26 +9,29 @@
serde = { version = "1.0.136", optional = true }
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
-sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }
-sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }
-frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }
-frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }
+sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
+sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
+frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
+frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
-pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", default-features = false }
+pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
pallet-common = { default-features = false, path = '../common' }
pallet-fungible = { default-features = false, path = '../fungible' }
-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", default-features = false }
-xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", default-features = false }
-xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", default-features = false }
-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 }
+xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.27", default-features = false }
+xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.27", default-features = false }
+xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.27", default-features = false }
+#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 }
+orml-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 }
+#git = "https://github.com/open-web3-stack/open-runtime-module-library"
+#branch = "polkadot-v0.9.27"
[dev-dependencies]
serde_json = "1.0.68"
hex = { version = "0.4" }
-sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }
-sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }
-pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }
-pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }
+sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
[features]
default = ["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.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/config/pallets/foreign_asset.rs
@@ -0,0 +1,9 @@
+use crate::{Runtime, Event, Balances};
+use up_common::types::AccountId;
+
+impl pallet_foreing_assets::Config for Runtime {
+ type Event = Event;
+ type Currency = Balances;
+ type RegisterOrigin = frame_system::EnsureRoot<AccountId>;
+ type WeightInfo = ();
+}
runtime/common/config/pallets/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -40,6 +40,9 @@
#[cfg(feature = "scheduler")]
pub mod scheduler;
+#[cfg(feature = "foreign-asset")]
+pub mod foreign_asset;
+
parameter_types! {
pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();
pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
runtime/common/construct_runtime/mod.rsdiffbeforeafterboth--- a/runtime/common/construct_runtime/mod.rs
+++ b/runtime/common/construct_runtime/mod.rs
@@ -42,6 +42,8 @@
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,
+ XTokens: orml_xtokens = 38,
+ Tokens: orml_tokens = 39,
// Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -120,13 +120,18 @@
'up-sponsorship/std',
"orml-vesting/std",
+ "orml-tokens/std",
+ "orml-xtokens/std",
+ "orml-traits/std",
+ "pallet-foreing-assets/std"
]
limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
-opal-runtime = ['refungible', 'scheduler', 'rmrk']
+opal-runtime = ['refungible', 'scheduler', 'rmrk', 'foreign-asset']
refungible = []
scheduler = []
rmrk = []
+foreign-asset = []
################################################################################
# Substrate Dependencies
@@ -399,6 +404,24 @@
version = "0.4.1-dev"
default-features = false
+[dependencies.orml-xtokens]
+git = "https://github.com/open-web3-stack/open-runtime-module-library"
+branch = "polkadot-v0.9.27"
+version = "0.4.1-dev"
+default-features = false
+
+[dependencies.orml-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
+
+[dependencies.orml-traits]
+git = "https://github.com/open-web3-stack/open-runtime-module-library"
+branch = "polkadot-v0.9.27"
+version = "0.4.1-dev"
+default-features = false
+
################################################################################
# local dependencies
@@ -437,6 +460,7 @@
fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = 'polkadot-v0.9.27' }
+pallet-foreing-assets = { default-features = false, path = "../../pallets/foreing-assets" }
################################################################################
# Build Dependencies
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -35,6 +35,8 @@
#[path = "../../common/mod.rs"]
mod runtime_common;
+pub mod xcm_config;
+
pub use runtime_common::*;
pub const RUNTIME_NAME: &str = "opal";