difftreelog
fix dependency versions after rebase
in: master
12 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2484,7 +2484,7 @@
[[package]]
name = "fc-consensus"
version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"async-trait",
"derive_more",
@@ -2511,7 +2511,7 @@
[[package]]
name = "fc-db"
version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"fp-storage",
"kvdb",
@@ -2527,7 +2527,7 @@
[[package]]
name = "fc-mapping-sync"
version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"fc-consensus",
"fc-db",
@@ -2545,7 +2545,7 @@
[[package]]
name = "fc-rpc"
version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"ethereum",
"ethereum-types",
@@ -2591,7 +2591,7 @@
[[package]]
name = "fc-rpc-core"
version = "1.1.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"ethereum",
"ethereum-types",
@@ -2725,7 +2725,7 @@
[[package]]
name = "fp-consensus"
version = "2.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"ethereum",
"parity-scale-codec",
@@ -2739,7 +2739,7 @@
[[package]]
name = "fp-evm"
version = "3.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"evm",
"impl-trait-for-tuples",
@@ -2751,9 +2751,18 @@
]
[[package]]
+name = "fp-evm-mapping"
+version = "0.1.0"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
+dependencies = [
+ "frame-support",
+ "sp-core",
+]
+
+[[package]]
name = "fp-rpc"
version = "3.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"ethereum",
"ethereum-types",
@@ -2770,7 +2779,7 @@
[[package]]
name = "fp-self-contained"
version = "1.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"ethereum",
"frame-support",
@@ -2787,7 +2796,7 @@
[[package]]
name = "fp-storage"
version = "2.0.0"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
[[package]]
name = "frame-benchmarking"
@@ -5577,6 +5586,7 @@
"cumulus-primitives-timestamp",
"cumulus-primitives-utility",
"derivative",
+ "fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
"frame-benchmarking",
@@ -5636,7 +5646,6 @@
"substrate-wasm-builder",
"unique-runtime-common",
"up-data-structs",
- "up-evm-mapping",
"up-rpc",
"xcm",
"xcm-builder",
@@ -5835,7 +5844,7 @@
[[package]]
name = "pallet-base-fee"
version = "1.0.0"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"frame-support",
"frame-system",
@@ -5988,6 +5997,7 @@
version = "0.1.0"
dependencies = [
"evm-coder",
+ "fp-evm-mapping",
"frame-support",
"frame-system",
"pallet-evm",
@@ -5999,7 +6009,6 @@
"sp-runtime",
"sp-std",
"up-data-structs",
- "up-evm-mapping",
]
[[package]]
@@ -6062,13 +6071,14 @@
[[package]]
name = "pallet-ethereum"
version = "4.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"ethereum",
"ethereum-types",
"evm",
"fp-consensus",
"fp-evm",
+ "fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
"fp-storage",
@@ -6092,12 +6102,13 @@
[[package]]
name = "pallet-evm"
version = "6.0.0-dev"
-source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18#7c8ce8f83e0c8a5b57655622b721f8655b161903"
+source = "git+https://github.com/uniquenetwork/frontier.git?branch=unique-polkadot-v0.9.18-2#82310d1dd3189f34bd901a9ac894ad33eca5cf89"
dependencies = [
"evm",
"evm-gasometer",
"evm-runtime",
"fp-evm",
+ "fp-evm-mapping",
"frame-benchmarking",
"frame-support",
"frame-system",
@@ -6141,6 +6152,7 @@
version = "0.1.0"
dependencies = [
"evm-coder",
+ "fp-evm-mapping",
"frame-support",
"frame-system",
"log",
@@ -6176,6 +6188,7 @@
version = "0.1.0"
dependencies = [
"fp-evm",
+ "fp-evm-mapping",
"frame-support",
"frame-system",
"pallet-ethereum",
@@ -6186,7 +6199,6 @@
"sp-io",
"sp-runtime",
"sp-std",
- "up-evm-mapping",
"up-sponsorship",
]
@@ -6200,6 +6212,7 @@
"frame-support",
"frame-system",
"pallet-common",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"pallet-structure",
"parity-scale-codec",
@@ -6427,6 +6440,7 @@
"frame-support",
"frame-system",
"pallet-common",
+ "pallet-evm",
"pallet-evm-coder-substrate",
"pallet-structure",
"parity-scale-codec",
@@ -6544,6 +6558,7 @@
"frame-support",
"frame-system",
"pallet-common",
+ "pallet-evm",
"pallet-structure",
"parity-scale-codec",
"scale-info",
@@ -6817,6 +6832,7 @@
"ethereum",
"evm-coder",
"fp-evm",
+ "fp-evm-mapping",
"frame-benchmarking",
"frame-support",
"frame-system",
@@ -6843,7 +6859,6 @@
"sp-runtime",
"sp-std",
"up-data-structs",
- "up-evm-mapping",
"up-sponsorship",
]
@@ -8726,6 +8741,7 @@
"cumulus-primitives-timestamp",
"cumulus-primitives-utility",
"derivative",
+ "fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
"frame-executive",
@@ -8782,7 +8798,6 @@
"substrate-wasm-builder",
"unique-runtime-common",
"up-data-structs",
- "up-evm-mapping",
"up-rpc",
"xcm",
"xcm-builder",
@@ -12380,6 +12395,7 @@
"jsonrpc-core-client",
"jsonrpc-derive",
"pallet-common",
+ "pallet-evm",
"parity-scale-codec",
"sp-api",
"sp-blockchain",
@@ -12591,6 +12607,7 @@
"cumulus-primitives-timestamp",
"cumulus-primitives-utility",
"derivative",
+ "fp-evm-mapping",
"fp-rpc",
"fp-self-contained",
"frame-benchmarking",
@@ -12650,7 +12667,6 @@
"substrate-wasm-builder",
"unique-runtime-common",
"up-data-structs",
- "up-evm-mapping",
"up-rpc",
"xcm",
"xcm-builder",
@@ -12732,6 +12748,7 @@
"derivative",
"frame-support",
"frame-system",
+ "pallet-evm",
"parity-scale-codec",
"scale-info",
"serde",
@@ -12739,17 +12756,6 @@
"sp-runtime",
"sp-std",
"struct-versioning",
- "up-evm-mapping",
-]
-
-[[package]]
-name = "up-evm-mapping"
-version = "0.1.0"
-dependencies = [
- "frame-support",
- "parity-scale-codec",
- "scale-info",
- "sp-core",
]
[[package]]
@@ -12757,6 +12763,7 @@
version = "0.1.0"
dependencies = [
"pallet-common",
+ "pallet-evm",
"parity-scale-codec",
"sp-api",
"sp-core",
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -19,7 +19,7 @@
use codec::Decode;
use jsonrpc_core::{Error as RpcError, ErrorCode, Result};
use jsonrpc_derive::rpc;
-use up_data_structs::{RpcCollection, Collection, CollectionId, CollectionStats, CollectionLimits, TokenId};
+use up_data_structs::{RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId};
use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
use sp_blockchain::HeaderBackend;
use up_rpc::UniqueApi as UniqueRuntimeApi;
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -29,11 +29,13 @@
};
use pallet_evm::GasWeightMapping;
use up_data_structs::{
- COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH,
- COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP,
- CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
- REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,
- CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField, PhantomType,
+ COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, CollectionId, CreateItemData,
+ MAX_TOKEN_PREFIX_LENGTH, COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId,
+ CollectionStats, MAX_TOKEN_OWNERSHIP, CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT,
+ FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT,
+ CUSTOM_DATA_LIMIT, CollectionLimits, CustomDataLimit, CreateCollectionData, SponsorshipState,
+ CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField,
+ PhantomType,
};
pub use pallet::*;
use sp_core::H160;
@@ -162,7 +164,6 @@
#[frame_support::pallet]
pub mod pallet {
use super::*;
- use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
use pallet_evm::account;
use dispatch::CollectionDispatch;
use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key, traits::StorageVersion};
@@ -170,7 +171,6 @@
use frame_support::traits::Currency;
use up_data_structs::{TokenId, mapping::TokenAddressMapping};
use scale_info::TypeInfo;
- use up_evm_mapping::CrossAccountId;
#[pallet::config]
pub trait Config:
@@ -519,6 +519,7 @@
owner_can_transfer: Some(limits.owner_can_transfer()),
owner_can_destroy: Some(limits.owner_can_destroy()),
transfers_enabled: Some(limits.transfers_enabled()),
+ nesting_rule: Some(limits.nesting_rule().clone()),
};
Some(effective_limits)
pallets/fungible/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use core::ops::Deref;20use frame_support::{ensure};21use pallet_evm::account::CrossAccountId;22use up_data_structs::{23 AccessMode, CollectionId, TokenId, CreateCollectionData, mapping::TokenAddressMapping,24 budget::Budget,25};26use pallet_common::{27 Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,28 CollectionHandle, dispatch::CollectionDispatch,29};30use pallet_structure::Pallet as PalletStructure;31use pallet_evm_coder_substrate::WithRecorder;32use sp_core::H160;33use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};34use sp_std::collections::btree_map::BTreeMap;3536pub use pallet::*;3738use crate::erc::ERC20Events;39#[cfg(feature = "runtime-benchmarks")]40pub mod benchmarking;41pub mod common;42pub mod erc;43pub mod weights;4445pub type CreateItemData<T> = (<T as pallet_evm::account::Config>::CrossAccountId, u128);46pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;4748#[frame_support::pallet]49pub mod pallet {50 use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};51 use up_data_structs::CollectionId;52 use super::weights::WeightInfo;5354 #[pallet::error]55 pub enum Error<T> {56 /// Not Fungible item data used to mint in Fungible collection.57 NotFungibleDataUsedToMintFungibleCollectionToken,58 /// Not default id passed as TokenId argument59 FungibleItemsHaveNoId,60 /// Tried to set data for fungible item61 FungibleItemsDontHaveData,62 /// Fungible token does not support nested63 FungibleDisallowsNesting,64 }6566 #[pallet::config]67 pub trait Config:68 frame_system::Config + pallet_common::Config + pallet_structure::Config69 {70 type WeightInfo: WeightInfo;71 }7273 #[pallet::pallet]74 #[pallet::generate_store(pub(super) trait Store)]75 pub struct Pallet<T>(_);7677 #[pallet::storage]78 pub type TotalSupply<T: Config> =79 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u128, QueryKind = ValueQuery>;8081 #[pallet::storage]82 pub type Balance<T: Config> = StorageNMap<83 Key = (84 Key<Twox64Concat, CollectionId>,85 Key<Blake2_128Concat, T::CrossAccountId>,86 ),87 Value = u128,88 QueryKind = ValueQuery,89 >;9091 #[pallet::storage]92 pub type Allowance<T: Config> = StorageNMap<93 Key = (94 Key<Twox64Concat, CollectionId>,95 Key<Blake2_128, T::CrossAccountId>,96 Key<Blake2_128Concat, T::CrossAccountId>,97 ),98 Value = u128,99 QueryKind = ValueQuery,100 >;101}102103pub struct FungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);104impl<T: Config> FungibleHandle<T> {105 pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {106 Self(inner)107 }108 pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {109 self.0110 }111}112impl<T: Config> WithRecorder<T> for FungibleHandle<T> {113 fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {114 self.0.recorder()115 }116 fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {117 self.0.into_recorder()118 }119}120impl<T: Config> Deref for FungibleHandle<T> {121 type Target = pallet_common::CollectionHandle<T>;122123 fn deref(&self) -> &Self::Target {124 &self.0125 }126}127128impl<T: Config> Pallet<T> {129 pub fn init_collection(130 owner: T::AccountId,131 data: CreateCollectionData<T::AccountId>,132 ) -> Result<CollectionId, DispatchError> {133 <PalletCommon<T>>::init_collection(owner, data)134 }135 pub fn destroy_collection(136 collection: FungibleHandle<T>,137 sender: &T::CrossAccountId,138 ) -> DispatchResult {139 let id = collection.id;140141 // =========142143 PalletCommon::destroy_collection(collection.0, sender)?;144145 <TotalSupply<T>>::remove(id);146 <Balance<T>>::remove_prefix((id,), None);147 <Allowance<T>>::remove_prefix((id,), None);148 Ok(())149 }150151 pub fn burn(152 collection: &FungibleHandle<T>,153 owner: &T::CrossAccountId,154 amount: u128,155 ) -> DispatchResult {156 let total_supply = <TotalSupply<T>>::get(collection.id)157 .checked_sub(amount)158 .ok_or(<CommonError<T>>::TokenValueTooLow)?;159160 let balance = <Balance<T>>::get((collection.id, owner))161 .checked_sub(amount)162 .ok_or(<CommonError<T>>::TokenValueTooLow)?;163164 if collection.access == AccessMode::AllowList {165 collection.check_allowlist(owner)?;166 }167168 // =========169170 if balance == 0 {171 <Balance<T>>::remove((collection.id, owner));172 } else {173 <Balance<T>>::insert((collection.id, owner), balance);174 }175 <TotalSupply<T>>::insert(collection.id, total_supply);176177 collection.log_mirrored(ERC20Events::Transfer {178 from: *owner.as_eth(),179 to: H160::default(),180 value: amount.into(),181 });182 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(183 collection.id,184 TokenId::default(),185 owner.clone(),186 amount,187 ));188 Ok(())189 }190191 pub fn transfer(192 collection: &FungibleHandle<T>,193 from: &T::CrossAccountId,194 to: &T::CrossAccountId,195 amount: u128,196 nesting_budget: &dyn Budget,197 ) -> DispatchResult {198 ensure!(199 collection.limits.transfers_enabled(),200 <CommonError<T>>::TransferNotAllowed,201 );202203 if collection.access == AccessMode::AllowList {204 collection.check_allowlist(from)?;205 collection.check_allowlist(to)?;206 }207 <PalletCommon<T>>::ensure_correct_receiver(to)?;208209 let balance_from = <Balance<T>>::get((collection.id, from))210 .checked_sub(amount)211 .ok_or(<CommonError<T>>::TokenValueTooLow)?;212 let balance_to = if from != to {213 Some(214 <Balance<T>>::get((collection.id, to))215 .checked_add(amount)216 .ok_or(ArithmeticError::Overflow)?,217 )218 } else {219 None220 };221222 if let Some(target) = T::CrossTokenAddressMapping::address_to_token(to) {223 let handle = <CollectionHandle<T>>::try_get(target.0)?;224 let dispatch = T::CollectionDispatch::dispatch(handle);225 let dispatch = dispatch.as_dyn();226227 dispatch.check_nesting(from.clone(), collection.id, target.1, nesting_budget)?;228 }229230 // =========231232 if let Some(balance_to) = balance_to {233 // from != to234 if balance_from == 0 {235 <Balance<T>>::remove((collection.id, from));236 } else {237 <Balance<T>>::insert((collection.id, from), balance_from);238 }239 <Balance<T>>::insert((collection.id, to), balance_to);240 }241242 collection.log_mirrored(ERC20Events::Transfer {243 from: *from.as_eth(),244 to: *to.as_eth(),245 value: amount.into(),246 });247 <PalletCommon<T>>::deposit_event(CommonEvent::Transfer(248 collection.id,249 TokenId::default(),250 from.clone(),251 to.clone(),252 amount,253 ));254 Ok(())255 }256257 pub fn create_multiple_items(258 collection: &FungibleHandle<T>,259 sender: &T::CrossAccountId,260 data: BTreeMap<T::CrossAccountId, u128>,261 nesting_budget: &dyn Budget,262 ) -> DispatchResult {263 if !collection.is_owner_or_admin(sender) {264 ensure!(265 collection.mint_mode,266 <CommonError<T>>::PublicMintingNotAllowed267 );268 collection.check_allowlist(sender)?;269270 for (owner, _) in data.iter() {271 collection.check_allowlist(owner)?;272 }273 }274275 let total_supply = data276 .iter()277 .map(|(_, v)| *v)278 .try_fold(<TotalSupply<T>>::get(collection.id), |acc, v| {279 acc.checked_add(v)280 })281 .ok_or(ArithmeticError::Overflow)?;282283 let mut balances = data;284 for (k, v) in balances.iter_mut() {285 *v = <Balance<T>>::get((collection.id, &k))286 .checked_add(*v)287 .ok_or(ArithmeticError::Overflow)?;288 }289290 for (to, _) in balances.iter() {291 if let Some(target) = T::CrossTokenAddressMapping::address_to_token(to) {292 let handle = <CollectionHandle<T>>::try_get(target.0)?;293 let dispatch = T::CollectionDispatch::dispatch(handle);294 let dispatch = dispatch.as_dyn();295296 dispatch.check_nesting(sender.clone(), collection.id, target.1, nesting_budget)?;297 }298 }299300 // =========301302 <TotalSupply<T>>::insert(collection.id, total_supply);303 for (user, amount) in balances {304 <Balance<T>>::insert((collection.id, &user), amount);305306 collection.log_mirrored(ERC20Events::Transfer {307 from: H160::default(),308 to: *user.as_eth(),309 value: amount.into(),310 });311 <PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(312 collection.id,313 TokenId::default(),314 user.clone(),315 amount,316 ));317 }318319 Ok(())320 }321322 fn set_allowance_unchecked(323 collection: &FungibleHandle<T>,324 owner: &T::CrossAccountId,325 spender: &T::CrossAccountId,326 amount: u128,327 ) {328 if amount == 0 {329 <Allowance<T>>::remove((collection.id, owner, spender));330 } else {331 <Allowance<T>>::insert((collection.id, owner, spender), amount);332 }333334 collection.log_mirrored(ERC20Events::Approval {335 owner: *owner.as_eth(),336 spender: *spender.as_eth(),337 value: amount.into(),338 });339 <PalletCommon<T>>::deposit_event(CommonEvent::Approved(340 collection.id,341 TokenId(0),342 owner.clone(),343 spender.clone(),344 amount,345 ));346 }347348 pub fn set_allowance(349 collection: &FungibleHandle<T>,350 owner: &T::CrossAccountId,351 spender: &T::CrossAccountId,352 amount: u128,353 ) -> DispatchResult {354 if collection.access == AccessMode::AllowList {355 collection.check_allowlist(owner)?;356 collection.check_allowlist(spender)?;357 }358359 if <Balance<T>>::get((collection.id, owner)) < amount {360 ensure!(361 collection.ignores_owned_amount(owner),362 <CommonError<T>>::CantApproveMoreThanOwned363 );364 }365366 // =========367368 Self::set_allowance_unchecked(collection, owner, spender, amount);369 Ok(())370 }371372 fn check_allowed(373 collection: &FungibleHandle<T>,374 spender: &T::CrossAccountId,375 from: &T::CrossAccountId,376 amount: u128,377 nesting_budget: &dyn Budget,378 ) -> Result<Option<u128>, DispatchError> {379 if spender.conv_eq(from) {380 return Ok(None);381 }382 if collection.access == AccessMode::AllowList {383 // `from`, `to` checked in [`transfer`]384 collection.check_allowlist(spender)?;385 }386 if let Some(source) = T::CrossTokenAddressMapping::address_to_token(from) {387 // TODO: should collection owner be allowed to perform this transfer?388 ensure!(389 <PalletStructure<T>>::indirectly_owned(390 spender.clone(),391 source.0,392 source.1,393 nesting_budget394 )?,395 <CommonError<T>>::ApprovedValueTooLow,396 );397 return Ok(None);398 }399 let allowance = <Allowance<T>>::get((collection.id, from, spender)).checked_sub(amount);400 if allowance.is_none() {401 ensure!(402 collection.ignores_allowance(spender),403 <CommonError<T>>::ApprovedValueTooLow404 );405 }406407 Ok(allowance)408 }409410 pub fn transfer_from(411 collection: &FungibleHandle<T>,412 spender: &T::CrossAccountId,413 from: &T::CrossAccountId,414 to: &T::CrossAccountId,415 amount: u128,416 nesting_budget: &dyn Budget,417 ) -> DispatchResult {418 let allowance = Self::check_allowed(collection, spender, from, amount, nesting_budget)?;419420 // =========421422 Self::transfer(collection, from, to, amount, nesting_budget)?;423 if let Some(allowance) = allowance {424 Self::set_allowance_unchecked(collection, from, spender, allowance);425 }426 Ok(())427 }428429 pub fn burn_from(430 collection: &FungibleHandle<T>,431 spender: &T::CrossAccountId,432 from: &T::CrossAccountId,433 amount: u128,434 nesting_budget: &dyn Budget,435 ) -> DispatchResult {436 let allowance = Self::check_allowed(collection, spender, from, amount, nesting_budget)?;437438 // =========439440 Self::burn(collection, from, amount)?;441 if let Some(allowance) = allowance {442 Self::set_allowance_unchecked(collection, from, spender, allowance);443 }444 Ok(())445 }446447 /// Delegated to `create_multiple_items`448 pub fn create_item(449 collection: &FungibleHandle<T>,450 sender: &T::CrossAccountId,451 data: CreateItemData<T>,452 nesting_budget: &dyn Budget,453 ) -> DispatchResult {454 Self::create_multiple_items(455 collection,456 sender,457 [(data.0, data.1)].into_iter().collect(),458 nesting_budget,459 )460 }461}pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -24,8 +24,8 @@
};
use pallet_evm::account::CrossAccountId;
use pallet_common::{
- Error as CommonError, Pallet as PalletCommon, Event as CommonEvent,
- CollectionHandle, dispatch::CollectionDispatch,
+ Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,
+ dispatch::CollectionDispatch,
};
use pallet_structure::Pallet as PalletStructure;
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -23,8 +23,8 @@
};
use pallet_evm::account::CrossAccountId;
use pallet_common::{
- Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,
- CollectionHandle, dispatch::CollectionDispatch,
+ Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, CollectionHandle,
+ dispatch::CollectionDispatch,
};
use pallet_structure::Pallet as PalletStructure;
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
pallets/unique/src/eth/sponsoring.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/sponsoring.rs
+++ b/pallets/unique/src/eth/sponsoring.rs
@@ -31,7 +31,6 @@
UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,
};
use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};
-use up_data_structs::{TokenId, CreateItemData, CreateNftData};
pub struct UniqueEthSponsorshipHandler<T: Config>(PhantomData<*const T>);
impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>)>
primitives/data-structs/Cargo.tomldiffbeforeafterboth--- a/primitives/data-structs/Cargo.toml
+++ b/primitives/data-structs/Cargo.toml
@@ -25,6 +25,7 @@
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.20" }
derivative = "2.2.0"
struct-versioning = { path = "../../crates/struct-versioning" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.18-2" }
[features]
default = ["std"]
@@ -37,6 +38,7 @@
"sp-runtime/std",
"sp-core/std",
"sp-std/std",
+ "pallet-evm/std",
]
serde1 = ["serde"]
limit-testing = []
primitives/data-structs/src/mapping.rsdiffbeforeafterboth--- a/primitives/data-structs/src/mapping.rs
+++ b/primitives/data-structs/src/mapping.rs
@@ -3,7 +3,7 @@
use sp_core::H160;
use crate::{CollectionId, TokenId};
-use up_evm_mapping::CrossAccountId;
+use pallet_evm::account::CrossAccountId;
pub trait TokenAddressMapping<Address> {
fn token_to_address(collection: CollectionId, token: TokenId) -> Address;
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -16,7 +16,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
-use up_data_structs::{CollectionId, TokenId, RpcCollection, Collection, CollectionStats, CollectionLimits};
+use up_data_structs::{CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits};
use sp_std::vec::Vec;
use codec::Decode;
use sp_runtime::DispatchError;
runtime/common/Cargo.tomldiffbeforeafterboth--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -93,11 +93,6 @@
default-features = false
path = "../../primitives/data-structs"
-[dependencies.pallet-evm]
-default-features = false
-git = "https://github.com/uniquenetwork/frontier.git"
-branch = "unique-polkadot-v0.9.18"
-
[dependencies.sp-consensus-aura]
default-features = false
git = "https://github.com/paritytech/substrate"
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -67,7 +67,7 @@
},
};
use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};
-use up_data_structs::{CollectionId, TokenId, CollectionStats, RpcCollection};
+use up_data_structs::{CollectionId, TokenId, CollectionStats, CollectionLimits, RpcCollection};
// use pallet_contracts::weights::WeightInfo;
// #[cfg(any(feature = "std", test))]
use frame_system::{