difftreelog
doc: Fix PR
in: master
3 files changed
pallets/common/src/dispatch.rsdiffbeforeafterboth--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -94,6 +94,6 @@
/// Get the collection handle for the corresponding implementation.
fn into_inner(self) -> CollectionHandle<T>;
- /// Получить реализацию [CommonCollectionOperations].
+ /// Get the implementation of [CommonCollectionOperations].
fn as_dyn(&self) -> &dyn CommonCollectionOperations<T>;
}
pallets/common/src/eth.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//! The module contains a number of functions for converting and checking etherium identifiers.1819use up_data_structs::CollectionId;20use sp_core::H160;2122// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 123// TODO: Unhardcode prefix24const ETH_COLLECTION_PREFIX: [u8; 16] = [25 0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e,26];2728/// Maps the etherium address of the collection in substrate.29pub fn map_eth_to_id(eth: &H160) -> Option<CollectionId> {30 if eth[0..16] != ETH_COLLECTION_PREFIX {31 return None;32 }33 let mut id_bytes = [0; 4];34 id_bytes.copy_from_slice(ð[16..20]);35 Some(CollectionId(u32::from_be_bytes(id_bytes)))36}3738/// Maps the substrate collection id in etherium.39pub fn collection_id_to_address(id: CollectionId) -> H160 {40 let mut out = [0; 20];41 out[0..16].copy_from_slice(Ð_COLLECTION_PREFIX);42 out[16..20].copy_from_slice(&u32::to_be_bytes(id.0));43 H160(out)44}4546/// Check if the etherium address is a collection.47pub fn is_collection(address: &H160) -> bool {48 address[0..16] == ETH_COLLECTION_PREFIX49}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/>.1617//! The module contains a number of functions for converting and checking ethereum identifiers.1819use up_data_structs::CollectionId;20use sp_core::H160;2122// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 123// TODO: Unhardcode prefix24const ETH_COLLECTION_PREFIX: [u8; 16] = [25 0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e,26];2728/// Maps the etherium address of the collection in substrate.29pub fn map_eth_to_id(eth: &H160) -> Option<CollectionId> {30 if eth[0..16] != ETH_COLLECTION_PREFIX {31 return None;32 }33 let mut id_bytes = [0; 4];34 id_bytes.copy_from_slice(ð[16..20]);35 Some(CollectionId(u32::from_be_bytes(id_bytes)))36}3738/// Maps the substrate collection id in etherium.39pub fn collection_id_to_address(id: CollectionId) -> H160 {40 let mut out = [0; 20];41 out[0..16].copy_from_slice(Ð_COLLECTION_PREFIX);42 out[16..20].copy_from_slice(&u32::to_be_bytes(id.0));43 H160(out)44}4546/// Check if the etherium address is a collection.47pub fn is_collection(address: &H160) -> bool {48 address[0..16] == ETH_COLLECTION_PREFIX49}pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -132,6 +132,9 @@
/// Collection handle contains information about collection data and id.
/// Also provides functionality to count consumed gas.
+/// CollectionHandle is used as a generic wrapper for collections of all types.
+/// It allows to perform common operations and queries on any collection type,
+/// both completely general for all, as well as their respective implementations of [CommonCollectionOperations].
#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]
pub struct CollectionHandle<T: Config> {
/// Collection id