difftreelog
fix insert missing licenses
in: master
17 files changed
pallets/proxy-rmrk-core/src/misc.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/misc.rs
+++ b/pallets/proxy-rmrk-core/src/misc.rs
@@ -1,3 +1,19 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
use super::*;
use codec::{Encode, Decode, Error};
pallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/property.rs
+++ b/pallets/proxy-rmrk-core/src/property.rs
@@ -1,3 +1,19 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
use super::*;
use core::convert::AsRef;
primitives/rmrk-rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rmrk-rpc/src/lib.rs
+++ b/primitives/rmrk-rpc/src/lib.rs
@@ -1,3 +1,19 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
#![cfg_attr(not(feature = "std"), no_std)]
use sp_api::{Encode, Decode};
primitives/rmrk-traits/src/base.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/base.rs
+++ b/primitives/rmrk-traits/src/base.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
primitives/rmrk-traits/src/collection.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/collection.rs
+++ b/primitives/rmrk-traits/src/collection.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
primitives/rmrk-traits/src/lib.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/lib.rs
+++ b/primitives/rmrk-traits/src/lib.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
#![cfg_attr(not(feature = "std"), no_std)]
pub mod base;
primitives/rmrk-traits/src/nft.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/nft.rs
+++ b/primitives/rmrk-traits/src/nft.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
primitives/rmrk-traits/src/part.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/part.rs
+++ b/primitives/rmrk-traits/src/part.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
primitives/rmrk-traits/src/property.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/property.rs
+++ b/primitives/rmrk-traits/src/property.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use codec::{Decode, Encode};
use scale_info::TypeInfo;
primitives/rmrk-traits/src/resource.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/resource.rs
+++ b/primitives/rmrk-traits/src/resource.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
primitives/rmrk-traits/src/serialize.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/serialize.rs
+++ b/primitives/rmrk-traits/src/serialize.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use core::convert::AsRef;
use serde::ser::{self, Serialize};
primitives/rmrk-traits/src/theme.rsdiffbeforeafterboth--- a/primitives/rmrk-traits/src/theme.rs
+++ b/primitives/rmrk-traits/src/theme.rs
@@ -1,3 +1,7 @@
+// Copyright (C) 2021-2022 RMRK
+// This file is part of rmrk-substrate.
+// License: Apache 2.0 modified by RMRK, see https://github.com/rmrk-team/rmrk-substrate/blob/main/LICENSE
+
use codec::{Decode, Encode};
use scale_info::TypeInfo;
runtime/common/src/constants.rsdiffbeforeafterboth--- a/runtime/common/src/constants.rs
+++ b/runtime/common/src/constants.rs
@@ -1,3 +1,19 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
use sp_runtime::Perbill;
use frame_support::{
parameter_types,
runtime/common/src/dispatch.rsdiffbeforeafterboth1use frame_support::{dispatch::DispatchResult, ensure};2use pallet_evm::{PrecompileHandle, PrecompileResult};3use sp_core::H160;4use sp_std::{borrow::ToOwned, vec::Vec};5use pallet_common::{6 CollectionById, CollectionHandle, CommonCollectionOperations, erc::CommonEvmHandler,7 eth::map_eth_to_id,8};9pub use pallet_common::dispatch::CollectionDispatch;10use pallet_fungible::{Pallet as PalletFungible, FungibleHandle};11use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle};12use pallet_refungible::{Pallet as PalletRefungible, RefungibleHandle, erc::RefungibleTokenHandle};13use up_data_structs::{14 CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,15};1617pub enum CollectionDispatchT<T>18where19 T: pallet_fungible::Config + pallet_nonfungible::Config + pallet_refungible::Config,20{21 Fungible(FungibleHandle<T>),22 Nonfungible(NonfungibleHandle<T>),23 Refungible(RefungibleHandle<T>),24}25impl<T> CollectionDispatch<T> for CollectionDispatchT<T>26where27 T: pallet_common::Config28 + pallet_unique::Config29 + pallet_fungible::Config30 + pallet_nonfungible::Config31 + pallet_refungible::Config,32{33 fn create(34 sender: T::CrossAccountId,35 data: CreateCollectionData<T::AccountId>,36 ) -> DispatchResult {37 let _id = match data.mode {38 CollectionMode::NFT => <PalletNonfungible<T>>::init_collection(sender, data, false)?,39 CollectionMode::Fungible(decimal_points) => {40 // check params41 ensure!(42 decimal_points <= MAX_DECIMAL_POINTS,43 pallet_unique::Error::<T>::CollectionDecimalPointLimitExceeded44 );45 <PalletFungible<T>>::init_collection(sender, data)?46 }47 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,48 };49 Ok(())50 }5152 fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {53 match collection.mode {54 CollectionMode::ReFungible => {55 PalletRefungible::destroy_collection(RefungibleHandle::cast(collection), &sender)?56 }57 CollectionMode::Fungible(_) => {58 PalletFungible::destroy_collection(FungibleHandle::cast(collection), &sender)?59 }60 CollectionMode::NFT => {61 PalletNonfungible::destroy_collection(NonfungibleHandle::cast(collection), &sender)?62 }63 }64 Ok(())65 }6667 fn dispatch(handle: CollectionHandle<T>) -> Self {68 match handle.mode {69 CollectionMode::Fungible(_) => Self::Fungible(FungibleHandle::cast(handle)),70 CollectionMode::NFT => Self::Nonfungible(NonfungibleHandle::cast(handle)),71 CollectionMode::ReFungible => Self::Refungible(RefungibleHandle::cast(handle)),72 }73 }7475 fn into_inner(self) -> CollectionHandle<T> {76 match self {77 Self::Fungible(f) => f.into_inner(),78 Self::Nonfungible(f) => f.into_inner(),79 Self::Refungible(f) => f.into_inner(),80 }81 }8283 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T> {84 match self {85 Self::Fungible(h) => h,86 Self::Nonfungible(h) => h,87 Self::Refungible(h) => h,88 }89 }90}9192impl<T> pallet_evm::OnMethodCall<T> for CollectionDispatchT<T>93where94 T: pallet_common::Config95 + pallet_unique::Config96 + pallet_fungible::Config97 + pallet_nonfungible::Config98 + pallet_refungible::Config,99{100 fn is_reserved(target: &H160) -> bool {101 map_eth_to_id(target).is_some()102 }103 fn is_used(target: &H160) -> bool {104 map_eth_to_id(target)105 .map(<CollectionById<T>>::contains_key)106 .unwrap_or(false)107 }108 fn get_code(target: &H160) -> Option<Vec<u8>> {109 if let Some(collection_id) = map_eth_to_id(target) {110 let collection = <CollectionById<T>>::get(collection_id)?;111 Some(112 match collection.mode {113 CollectionMode::NFT => <NonfungibleHandle<T>>::CODE,114 CollectionMode::Fungible(_) => <FungibleHandle<T>>::CODE,115 CollectionMode::ReFungible => <RefungibleHandle<T>>::CODE,116 }117 .to_owned(),118 )119 } else if let Some((collection_id, _token_id)) =120 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(target)121 {122 let collection = <CollectionById<T>>::get(collection_id)?;123 if collection.mode != CollectionMode::ReFungible {124 return None;125 }126 // TODO: check token existence127 Some(<RefungibleTokenHandle<T>>::CODE.to_owned())128 } else {129 None130 }131 }132 fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {133 if let Some(collection_id) = map_eth_to_id(&handle.code_address()) {134 let collection =135 <CollectionHandle<T>>::new_with_gas_limit(collection_id, handle.remaining_gas())?;136 let dispatched = Self::dispatch(collection);137138 match dispatched {139 Self::Fungible(h) => h.call(handle),140 Self::Nonfungible(h) => h.call(handle),141 Self::Refungible(h) => h.call(handle),142 }143 } else if let Some((collection_id, token_id)) =144 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(145 &handle.code_address(),146 ) {147 let collection =148 <CollectionHandle<T>>::new_with_gas_limit(collection_id, handle.remaining_gas())?;149 if collection.mode != CollectionMode::ReFungible {150 return None;151 }152153 let h = RefungibleHandle::cast(collection);154 // TODO: check token existence155 RefungibleTokenHandle(h, token_id).call(handle)156 } else {157 None158 }159 }160}1// 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/>.1617use frame_support::{dispatch::DispatchResult, ensure};18use pallet_evm::{PrecompileHandle, PrecompileResult};19use sp_core::H160;20use sp_std::{borrow::ToOwned, vec::Vec};21use pallet_common::{22 CollectionById, CollectionHandle, CommonCollectionOperations, erc::CommonEvmHandler,23 eth::map_eth_to_id,24};25pub use pallet_common::dispatch::CollectionDispatch;26use pallet_fungible::{Pallet as PalletFungible, FungibleHandle};27use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle};28use pallet_refungible::{Pallet as PalletRefungible, RefungibleHandle, erc::RefungibleTokenHandle};29use up_data_structs::{30 CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,31};3233pub enum CollectionDispatchT<T>34where35 T: pallet_fungible::Config + pallet_nonfungible::Config + pallet_refungible::Config,36{37 Fungible(FungibleHandle<T>),38 Nonfungible(NonfungibleHandle<T>),39 Refungible(RefungibleHandle<T>),40}41impl<T> CollectionDispatch<T> for CollectionDispatchT<T>42where43 T: pallet_common::Config44 + pallet_unique::Config45 + pallet_fungible::Config46 + pallet_nonfungible::Config47 + pallet_refungible::Config,48{49 fn create(50 sender: T::CrossAccountId,51 data: CreateCollectionData<T::AccountId>,52 ) -> DispatchResult {53 let _id = match data.mode {54 CollectionMode::NFT => <PalletNonfungible<T>>::init_collection(sender, data, false)?,55 CollectionMode::Fungible(decimal_points) => {56 // check params57 ensure!(58 decimal_points <= MAX_DECIMAL_POINTS,59 pallet_unique::Error::<T>::CollectionDecimalPointLimitExceeded60 );61 <PalletFungible<T>>::init_collection(sender, data)?62 }63 CollectionMode::ReFungible => <PalletRefungible<T>>::init_collection(sender, data)?,64 };65 Ok(())66 }6768 fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {69 match collection.mode {70 CollectionMode::ReFungible => {71 PalletRefungible::destroy_collection(RefungibleHandle::cast(collection), &sender)?72 }73 CollectionMode::Fungible(_) => {74 PalletFungible::destroy_collection(FungibleHandle::cast(collection), &sender)?75 }76 CollectionMode::NFT => {77 PalletNonfungible::destroy_collection(NonfungibleHandle::cast(collection), &sender)?78 }79 }80 Ok(())81 }8283 fn dispatch(handle: CollectionHandle<T>) -> Self {84 match handle.mode {85 CollectionMode::Fungible(_) => Self::Fungible(FungibleHandle::cast(handle)),86 CollectionMode::NFT => Self::Nonfungible(NonfungibleHandle::cast(handle)),87 CollectionMode::ReFungible => Self::Refungible(RefungibleHandle::cast(handle)),88 }89 }9091 fn into_inner(self) -> CollectionHandle<T> {92 match self {93 Self::Fungible(f) => f.into_inner(),94 Self::Nonfungible(f) => f.into_inner(),95 Self::Refungible(f) => f.into_inner(),96 }97 }9899 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T> {100 match self {101 Self::Fungible(h) => h,102 Self::Nonfungible(h) => h,103 Self::Refungible(h) => h,104 }105 }106}107108impl<T> pallet_evm::OnMethodCall<T> for CollectionDispatchT<T>109where110 T: pallet_common::Config111 + pallet_unique::Config112 + pallet_fungible::Config113 + pallet_nonfungible::Config114 + pallet_refungible::Config,115{116 fn is_reserved(target: &H160) -> bool {117 map_eth_to_id(target).is_some()118 }119 fn is_used(target: &H160) -> bool {120 map_eth_to_id(target)121 .map(<CollectionById<T>>::contains_key)122 .unwrap_or(false)123 }124 fn get_code(target: &H160) -> Option<Vec<u8>> {125 if let Some(collection_id) = map_eth_to_id(target) {126 let collection = <CollectionById<T>>::get(collection_id)?;127 Some(128 match collection.mode {129 CollectionMode::NFT => <NonfungibleHandle<T>>::CODE,130 CollectionMode::Fungible(_) => <FungibleHandle<T>>::CODE,131 CollectionMode::ReFungible => <RefungibleHandle<T>>::CODE,132 }133 .to_owned(),134 )135 } else if let Some((collection_id, _token_id)) =136 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(target)137 {138 let collection = <CollectionById<T>>::get(collection_id)?;139 if collection.mode != CollectionMode::ReFungible {140 return None;141 }142 // TODO: check token existence143 Some(<RefungibleTokenHandle<T>>::CODE.to_owned())144 } else {145 None146 }147 }148 fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {149 if let Some(collection_id) = map_eth_to_id(&handle.code_address()) {150 let collection =151 <CollectionHandle<T>>::new_with_gas_limit(collection_id, handle.remaining_gas())?;152 let dispatched = Self::dispatch(collection);153154 match dispatched {155 Self::Fungible(h) => h.call(handle),156 Self::Nonfungible(h) => h.call(handle),157 Self::Refungible(h) => h.call(handle),158 }159 } else if let Some((collection_id, token_id)) =160 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(161 &handle.code_address(),162 ) {163 let collection =164 <CollectionHandle<T>>::new_with_gas_limit(collection_id, handle.remaining_gas())?;165 if collection.mode != CollectionMode::ReFungible {166 return None;167 }168169 let h = RefungibleHandle::cast(collection);170 // TODO: check token existence171 RefungibleTokenHandle(h, token_id).call(handle)172 } else {173 None174 }175 }176}runtime/common/src/lib.rsdiffbeforeafterboth--- a/runtime/common/src/lib.rs
+++ b/runtime/common/src/lib.rs
@@ -1,3 +1,19 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
#![cfg_attr(not(feature = "std"), no_std)]
pub mod constants;
runtime/common/src/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -1,3 +1,19 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
#[macro_export]
macro_rules! impl_common_runtime_apis {
(
runtime/common/src/types.rsdiffbeforeafterboth--- a/runtime/common/src/types.rs
+++ b/runtime/common/src/types.rs
@@ -1,3 +1,19 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
use sp_runtime::{
traits::{Verify, IdentifyAccount, BlakeTwo256},
generic, MultiSignature,