difftreelog
misk: docs & changelogs. Some refactor for func & mod names.
in: master
15 files changed
Makefilediffbeforeafterboth37 PACKAGE=pallet-nonfungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh37 PACKAGE=pallet-nonfungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh38 PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=$(NONFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh38 PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=$(NONFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh39 39 40UniqueRFT.sol:40UniqueRefungible.sol:41 PACKAGE=pallet-refungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh41 PACKAGE=pallet-refungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh42 PACKAGE=pallet-refungible NAME=erc::gen_impl OUTPUT=$(REFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh42 PACKAGE=pallet-refungible NAME=erc::gen_impl OUTPUT=$(REFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh434365 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungibleToken.raw ./.maintain/scripts/compile_stub.sh65 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungibleToken.raw ./.maintain/scripts/compile_stub.sh66 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(RENFUNGIBLE_TOKEN_EVM_ABI) ./.maintain/scripts/generate_abi.sh66 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(RENFUNGIBLE_TOKEN_EVM_ABI) ./.maintain/scripts/generate_abi.sh676768UniqueRefungible: UniqueRFT.sol68UniqueRefungible: UniqueRefungible.sol69 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRFT.raw ./.maintain/scripts/compile_stub.sh69 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungible.raw ./.maintain/scripts/compile_stub.sh70 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_ABI) ./.maintain/scripts/generate_abi.sh70 INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_ABI) ./.maintain/scripts/generate_abi.sh717172ContractHelpers: ContractHelpers.sol72ContractHelpers: ContractHelpers.solpallets/common/CHANGELOG.MDdiffbeforeafterboth889- Some methods in `#[solidity_interface]` for `CollectionHandle` had invalid9- Some methods in `#[solidity_interface]` for `CollectionHandle` had invalid10 mutability modifiers, causing invalid stub/abi generation.10 mutability modifiers, causing invalid stub/abi generation.11111213## [0.1.3] - 2022-07-2514### Add15- Some static property keys and values.pallets/common/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "pallet-common"2name = "pallet-common"3version = "0.1.2"3version = "0.1.3"4license = "GPLv3"4license = "GPLv3"5edition = "2021"5edition = "2021"66pallets/common/src/erc.rsdiffbeforeafterboth430 Ok(())430 Ok(())431}431}432432433/// Contains static property keys and values.433pub mod static_property_key_value {434pub mod static_property {434 use evm_coder::{435 use evm_coder::{435 execution::{Result, Error},436 execution::{Result, Error},436 };437 };437 use alloc::format;438 use alloc::format;438439439 const EXPECT_CONVERT_ERROR: &str = "length < limit";440 const EXPECT_CONVERT_ERROR: &str = "length < limit";440441442 /// Keys.443 pub mod key {444 use super::*;445446 /// Key "schemaName".441 pub fn schema_name_key() -> up_data_structs::PropertyKey {447 pub fn schema_name() -> up_data_structs::PropertyKey {442 property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)448 property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)443 }449 }444450451 /// Key "baseURI".445 pub fn base_uri_key() -> up_data_structs::PropertyKey {452 pub fn base_uri() -> up_data_structs::PropertyKey {446 property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)453 property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)447 }454 }448455456 /// Key "url".449 pub fn url_key() -> up_data_structs::PropertyKey {457 pub fn url() -> up_data_structs::PropertyKey {450 property_key_from_bytes(b"url").expect(EXPECT_CONVERT_ERROR)458 property_key_from_bytes(b"url").expect(EXPECT_CONVERT_ERROR)451 }459 }452460461 /// Key "suffix".453 pub fn suffix_key() -> up_data_structs::PropertyKey {462 pub fn suffix() -> up_data_structs::PropertyKey {454 property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)463 property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)455 }464 }456465 }466467 /// Values.468 pub mod value {469 use super::*;470471 /// Value "ERC721Metadata".457 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";472 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";473474 /// Value for [`ERC721_METADATA`].458 pub fn erc721_value() -> up_data_structs::PropertyValue {475 pub fn erc721() -> up_data_structs::PropertyValue {459 property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)476 property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)460 }477 }461478 }479480 /// Convert `byte` to [`PropertyKey`].462 pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {481 pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {463 bytes.to_vec().try_into().map_err(|_| {482 bytes.to_vec().try_into().map_err(|_| {464 Error::Revert(format!(483 Error::Revert(format!(468 })487 })469 }488 }470489490 /// Convert `bytes` to [`PropertyValue`].471 pub fn property_value_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyValue> {491 pub fn property_value_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyValue> {472 bytes.to_vec().try_into().map_err(|_| {492 bytes.to_vec().try_into().map_err(|_| {473 Error::Revert(format!(493 Error::Revert(format!(pallets/nonfungible/CHANGELOG.mddiffbeforeafterboth223All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.445## [0.1.1] - 2022-07-145## [0.1.2] - 2022-07-256### Changed7- New alghoritm for retrieving `token_iri`.689## [0.1.1] - 2022-07-147### Added10### Added8119- Implementation of RPC method `token_owners`.12- Implementation of RPC method `token_owners`.10 For reasons of compatibility with this pallet, returns only one owner if token exists.13 For reasons of compatibility with this pallet, returns only one owner if token exists.11 This was an internal request to improve the web interface and support fractionalization event. 14 This was an internal request to improve the web interface and support fractionalization event. 15pallets/nonfungible/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "pallet-nonfungible"2name = "pallet-nonfungible"3version = "0.1.1"3version = "0.1.2"4license = "GPLv3"4license = "GPLv3"5edition = "2021"5edition = "2021"66pallets/nonfungible/src/erc.rsdiffbeforeafterboth33use pallet_evm_coder_substrate::dispatch_to_evm;33use pallet_evm_coder_substrate::dispatch_to_evm;34use sp_std::vec::Vec;34use sp_std::vec::Vec;35use pallet_common::{35use pallet_common::{36 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property_key_value::*},36 erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::{key, value as property_value}},37 CollectionHandle, CollectionPropertyPermissions,37 CollectionHandle, CollectionPropertyPermissions,38};38};39use pallet_evm::{account::CrossAccountId, PrecompileHandle};39use pallet_evm::{account::CrossAccountId, PrecompileHandle};221 fn token_uri(&self, token_id: uint256) -> Result<string> {221 fn token_uri(&self, token_id: uint256) -> Result<string> {222 let is_erc721 = || {222 let is_erc721 = || {223 if let Some(shema_name) =223 if let Some(shema_name) =224 pallet_common::Pallet::<T>::get_collection_property(self.id, &schema_name_key())224 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::schema_name())225 {225 {226 let shema_name = shema_name.into_inner();226 let shema_name = shema_name.into_inner();227 shema_name == ERC721_METADATA227 shema_name == property_value::ERC721_METADATA228 } else {228 } else {229 false229 false230 }230 }231 };231 };232232233 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;233 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;234234235 if let Ok(url) = get_token_property(self, token_id_u32, &url_key()) {235 if let Ok(url) = get_token_property(self, token_id_u32, &key::url()) {236 if !url.is_empty() {236 if !url.is_empty() {237 return Ok(url);237 return Ok(url);238 }238 }241 }241 }242242243 if let Some(base_uri) =243 if let Some(base_uri) =244 pallet_common::Pallet::<T>::get_collection_property(self.id, &base_uri_key())244 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())245 {245 {246 if !base_uri.is_empty() {246 if !base_uri.is_empty() {247 let base_uri = string::from_utf8(base_uri.into_inner()).map_err(|e| {247 let base_uri = string::from_utf8(base_uri.into_inner()).map_err(|e| {250 e250 e251 ))251 ))252 })?;252 })?;253 if let Ok(suffix) = get_token_property(self, token_id_u32, &suffix_key()) {253 if let Ok(suffix) = get_token_property(self, token_id_u32, &key::suffix()) {254 if !suffix.is_empty() {254 if !suffix.is_empty() {255 return Ok(base_uri + suffix.as_str());255 return Ok(base_uri + suffix.as_str());256 }256 }497 token_id: uint256,497 token_id: uint256,498 token_uri: string,498 token_uri: string,499 ) -> Result<bool> {499 ) -> Result<bool> {500 let key = url_key();500 let key = key::url();501 let permission = get_token_permission::<T>(self.id, &key)?;501 let permission = get_token_permission::<T>(self.id, &key)?;502 if !permission.collection_admin {502 if !permission.collection_admin {503 return Err("Operation is not allowed".into());503 return Err("Operation is not allowed".into());702 to: address,702 to: address,703 tokens: Vec<(uint256, string)>,703 tokens: Vec<(uint256, string)>,704 ) -> Result<bool> {704 ) -> Result<bool> {705 let key = url_key();705 let key = key::url();706 let caller = T::CrossAccountId::from_eth(caller);706 let caller = T::CrossAccountId::from_eth(caller);707 let to = T::CrossAccountId::from_eth(to);707 let to = T::CrossAccountId::from_eth(to);708 let mut expected_index = <TokensMinted<T>>::get(self.id)708 let mut expected_index = <TokensMinted<T>>::get(self.id)pallets/refungible/CHANGELOG.mddiffbeforeafterboth10test(refungible-pallet): add tests for ERC-20 EVM API for RFT token pieces ([#413](https://github.com/UniqueNetwork/unique-chain/pull/413))10test(refungible-pallet): add tests for ERC-20 EVM API for RFT token pieces ([#413](https://github.com/UniqueNetwork/unique-chain/pull/413))111112## [v0.1.1] - 2022-07-1412## [v0.1.1] - 2022-07-1413### Added14- Support for properties for RFT collections and tokens.131514### Other changes16### Other changes1517pallets/refungible/Changelog.mddiffbeforeafterbothno changes
pallets/refungible/src/erc.rsdiffbeforeafterboth25use crate::{Config, RefungibleHandle};25use crate::{Config, RefungibleHandle};262627#[solidity_interface(27#[solidity_interface(28 name = "UniqueRFT",28 name = "UniqueRefungible",29 is(via("CollectionHandle<T>", common_mut, Collection),)29 is(via("CollectionHandle<T>", common_mut, Collection),)30)]30)]31impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> {}31impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> {}323233// Not a tests, but code generators33// Not a tests, but code generators34generate_stubgen!(gen_impl, UniqueRFTCall<()>, true);34generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);35generate_stubgen!(gen_iface, UniqueRFTCall<()>, false);35generate_stubgen!(gen_iface, UniqueRefungibleCall<()>, false);363637impl<T: Config> CommonEvmHandler for RefungibleHandle<T>37impl<T: Config> CommonEvmHandler for RefungibleHandle<T>38where38where39 T::AccountId: From<[u8; 32]>,39 T::AccountId: From<[u8; 32]>,40{40{41 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRFT.raw");41 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");42 fn call(42 fn call(43 self,43 self,44 handle: &mut impl PrecompileHandle,44 handle: &mut impl PrecompileHandle,45 ) -> Option<pallet_common::erc::PrecompileResult> {45 ) -> Option<pallet_common::erc::PrecompileResult> {46 call::<T, UniqueRFTCall<T>, _, _>(handle, self)46 call::<T, UniqueRefungibleCall<T>, _, _>(handle, self)47 }47 }48}48}4949pallets/refungible/src/stubs/UniqueRFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRFT.soldiffbeforeafterbothno changes
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterbothno changes
pallets/unique/src/eth/mod.rsdiffbeforeafterboth28use frame_support::traits::Get;28use frame_support::traits::Get;29use pallet_common::{29use pallet_common::{30 CollectionById,30 CollectionById,31 erc::{static_property_key_value::*, CollectionHelpersEvents},31 erc::{static_property::{key, value as property_value}, CollectionHelpersEvents},32};32};33use crate::{SelfWeightOf, Config, weights::WeightInfo};33use crate::{SelfWeightOf, Config, weights::WeightInfo};343483 Ok((caller, name, description, token_prefix, base_uri_value))83 Ok((caller, name, description, token_prefix, base_uri_value))84}84}858586//87fn make_data<T: Config>(86fn make_data<T: Config>(88 name: CollectionName,87 name: CollectionName,89 mode: CollectionMode,88 mode: CollectionMode,989799 token_property_permissions98 token_property_permissions100 .try_push(up_data_structs::PropertyKeyPermission {99 .try_push(up_data_structs::PropertyKeyPermission {101 key: url_key(),100 key: key::url(),102 permission: up_data_structs::PropertyPermission {101 permission: up_data_structs::PropertyPermission {103 mutable: false,102 mutable: false,104 collection_admin: true,103 collection_admin: true,110 if add_properties {109 if add_properties {111 token_property_permissions110 token_property_permissions112 .try_push(up_data_structs::PropertyKeyPermission {111 .try_push(up_data_structs::PropertyKeyPermission {113 key: suffix_key(),112 key: key::suffix(),114 permission: up_data_structs::PropertyPermission {113 permission: up_data_structs::PropertyPermission {115 mutable: false,114 mutable: false,116 collection_admin: true,115 collection_admin: true,121120122 properties121 properties123 .try_push(up_data_structs::Property {122 .try_push(up_data_structs::Property {124 key: schema_name_key(),123 key: key::schema_name(),125 value: erc721_value(),124 value: property_value::erc721(),126 })125 })127 .map_err(|e| Error::Revert(format!("{:?}", e)))?;126 .map_err(|e| Error::Revert(format!("{:?}", e)))?;128127129 if !base_uri_value.is_empty() {128 if !base_uri_value.is_empty() {130 properties129 properties131 .try_push(up_data_structs::Property {130 .try_push(up_data_structs::Property {132 key: base_uri_key(),131 key: key::base_uri(),133 value: base_uri_value,132 value: base_uri_value,134 })133 })135 .map_err(|e| Error::Revert(format!("{:?}", e)))?;134 .map_err(|e| Error::Revert(format!("{:?}", e)))?;152#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]151#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]153impl<T> EvmCollectionHelpers<T>152impl<T> EvmCollectionHelpers<T>154where153where155 T: Config + pallet_nonfungible::Config + pallet_refungible::Config 154 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,156{155{157 /// Create an NFT collection156 /// Create an NFT collection158 /// @param name Name of the collection157 /// @param name Name of the collection