difftreelog
misk: docs & changelogs. Some refactor for func & mod names.
in: master
15 files changed
Makefilediffbeforeafterboth--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@
PACKAGE=pallet-nonfungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=$(NONFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
-UniqueRFT.sol:
+UniqueRefungible.sol:
PACKAGE=pallet-refungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
PACKAGE=pallet-refungible NAME=erc::gen_impl OUTPUT=$(REFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
@@ -65,8 +65,8 @@
INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungibleToken.raw ./.maintain/scripts/compile_stub.sh
INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(RENFUNGIBLE_TOKEN_EVM_ABI) ./.maintain/scripts/generate_abi.sh
-UniqueRefungible: UniqueRFT.sol
- INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRFT.raw ./.maintain/scripts/compile_stub.sh
+UniqueRefungible: UniqueRefungible.sol
+ INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungible.raw ./.maintain/scripts/compile_stub.sh
INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_ABI) ./.maintain/scripts/generate_abi.sh
ContractHelpers: ContractHelpers.sol
pallets/common/CHANGELOG.MDdiffbeforeafterboth--- a/pallets/common/CHANGELOG.MD
+++ b/pallets/common/CHANGELOG.MD
@@ -8,3 +8,8 @@
- Some methods in `#[solidity_interface]` for `CollectionHandle` had invalid
mutability modifiers, causing invalid stub/abi generation.
+
+
+## [0.1.3] - 2022-07-25
+### Add
+- Some static property keys and values.
\ No newline at end of file
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-common"
-version = "0.1.2"
+version = "0.1.3"
license = "GPLv3"
edition = "2021"
pallets/common/src/erc.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//! This module contains the implementation of pallet methods for evm.1819use evm_coder::{20 solidity_interface, solidity, ToLog,21 types::*,22 execution::{Result, Error},23};24pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};25use pallet_evm_coder_substrate::dispatch_to_evm;26use sp_std::vec::Vec;27use up_data_structs::{28 Property, SponsoringRateLimit, OwnerRestrictedSet, AccessMode, CollectionPermissions,29};30use alloc::format;3132use crate::{Pallet, CollectionHandle, Config, CollectionProperties};3334/// Events for ethereum collection helper.35#[derive(ToLog)]36pub enum CollectionHelpersEvents {37 /// The collection has been created.38 CollectionCreated {39 /// Collection owner.40 #[indexed]41 owner: address,4243 /// Collection ID.44 #[indexed]45 collection_id: address,46 },47}4849/// Does not always represent a full collection, for RFT it is either50/// collection (Implementing ERC721), or specific collection token (Implementing ERC20).51pub trait CommonEvmHandler {52 const CODE: &'static [u8];5354 /// Call precompiled handle.55 fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult>;56}5758/// @title A contract that allows you to work with collections.59#[solidity_interface(name = "Collection")]60impl<T: Config> CollectionHandle<T>61where62 T::AccountId: From<[u8; 32]>,63{64 /// Set collection property.65 ///66 /// @param key Property key.67 /// @param value Propery value.68 fn set_collection_property(69 &mut self,70 caller: caller,71 key: string,72 value: bytes,73 ) -> Result<void> {74 let caller = T::CrossAccountId::from_eth(caller);75 let key = <Vec<u8>>::from(key)76 .try_into()77 .map_err(|_| "key too large")?;78 let value = value.try_into().map_err(|_| "value too large")?;7980 <Pallet<T>>::set_collection_property(self, &caller, Property { key, value })81 .map_err(dispatch_to_evm::<T>)82 }8384 /// Delete collection property.85 ///86 /// @param key Property key.87 fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {88 let caller = T::CrossAccountId::from_eth(caller);89 let key = <Vec<u8>>::from(key)90 .try_into()91 .map_err(|_| "key too large")?;9293 <Pallet<T>>::delete_collection_property(self, &caller, key).map_err(dispatch_to_evm::<T>)94 }9596 /// Get collection property.97 ///98 /// @dev Throws error if key not found.99 ///100 /// @param key Property key.101 /// @return bytes The property corresponding to the key.102 fn collection_property(&self, key: string) -> Result<bytes> {103 let key = <Vec<u8>>::from(key)104 .try_into()105 .map_err(|_| "key too large")?;106107 let props = <CollectionProperties<T>>::get(self.id);108 let prop = props.get(&key).ok_or("key not found")?;109110 Ok(prop.to_vec())111 }112113 /// Set the sponsor of the collection.114 ///115 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.116 ///117 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.118 fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {119 check_is_owner_or_admin(caller, self)?;120121 let sponsor = T::CrossAccountId::from_eth(sponsor);122 self.set_sponsor(sponsor.as_sub().clone())123 .map_err(dispatch_to_evm::<T>)?;124 save(self)125 }126127 /// Collection sponsorship confirmation.128 ///129 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.130 fn confirm_collection_sponsorship(&mut self, caller: caller) -> Result<void> {131 let caller = T::CrossAccountId::from_eth(caller);132 if !self133 .confirm_sponsorship(caller.as_sub())134 .map_err(dispatch_to_evm::<T>)?135 {136 return Err("caller is not set as sponsor".into());137 }138 save(self)139 }140141 /// Set limits for the collection.142 /// @dev Throws error if limit not found.143 /// @param limit Name of the limit. Valid names:144 /// "accountTokenOwnershipLimit",145 /// "sponsoredDataSize",146 /// "sponsoredDataRateLimit",147 /// "tokenLimit",148 /// "sponsorTransferTimeout",149 /// "sponsorApproveTimeout"150 /// @param value Value of the limit.151 #[solidity(rename_selector = "setCollectionLimit")]152 fn set_int_limit(&mut self, caller: caller, limit: string, value: uint32) -> Result<void> {153 check_is_owner_or_admin(caller, self)?;154 let mut limits = self.limits.clone();155156 match limit.as_str() {157 "accountTokenOwnershipLimit" => {158 limits.account_token_ownership_limit = Some(value);159 }160 "sponsoredDataSize" => {161 limits.sponsored_data_size = Some(value);162 }163 "sponsoredDataRateLimit" => {164 limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(value));165 }166 "tokenLimit" => {167 limits.token_limit = Some(value);168 }169 "sponsorTransferTimeout" => {170 limits.sponsor_transfer_timeout = Some(value);171 }172 "sponsorApproveTimeout" => {173 limits.sponsor_approve_timeout = Some(value);174 }175 _ => {176 return Err(Error::Revert(format!(177 "unknown integer limit \"{}\"",178 limit179 )))180 }181 }182 self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)183 .map_err(dispatch_to_evm::<T>)?;184 save(self)185 }186187 /// Set limits for the collection.188 /// @dev Throws error if limit not found.189 /// @param limit Name of the limit. Valid names:190 /// "ownerCanTransfer",191 /// "ownerCanDestroy",192 /// "transfersEnabled"193 /// @param value Value of the limit.194 #[solidity(rename_selector = "setCollectionLimit")]195 fn set_bool_limit(&mut self, caller: caller, limit: string, value: bool) -> Result<void> {196 check_is_owner_or_admin(caller, self)?;197 let mut limits = self.limits.clone();198199 match limit.as_str() {200 "ownerCanTransfer" => {201 limits.owner_can_transfer = Some(value);202 }203 "ownerCanDestroy" => {204 limits.owner_can_destroy = Some(value);205 }206 "transfersEnabled" => {207 limits.transfers_enabled = Some(value);208 }209 _ => {210 return Err(Error::Revert(format!(211 "unknown boolean limit \"{}\"",212 limit213 )))214 }215 }216 self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)217 .map_err(dispatch_to_evm::<T>)?;218 save(self)219 }220221 /// Get contract address.222 fn contract_address(&self, _caller: caller) -> Result<address> {223 Ok(crate::eth::collection_id_to_address(self.id))224 }225226 /// Add collection admin by substrate address.227 /// @param new_admin Substrate administrator address.228 fn add_collection_admin_substrate(229 &mut self,230 caller: caller,231 new_admin: uint256,232 ) -> Result<void> {233 let caller = T::CrossAccountId::from_eth(caller);234 let mut new_admin_arr: [u8; 32] = Default::default();235 new_admin.to_big_endian(&mut new_admin_arr);236 let account_id = T::AccountId::from(new_admin_arr);237 let new_admin = T::CrossAccountId::from_sub(account_id);238 <Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;239 Ok(())240 }241242 /// Remove collection admin by substrate address.243 /// @param admin Substrate administrator address.244 fn remove_collection_admin_substrate(245 &mut self,246 caller: caller,247 admin: uint256,248 ) -> Result<void> {249 let caller = T::CrossAccountId::from_eth(caller);250 let mut admin_arr: [u8; 32] = Default::default();251 admin.to_big_endian(&mut admin_arr);252 let account_id = T::AccountId::from(admin_arr);253 let admin = T::CrossAccountId::from_sub(account_id);254 <Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;255 Ok(())256 }257258 /// Add collection admin.259 /// @param new_admin Address of the added administrator.260 fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<void> {261 let caller = T::CrossAccountId::from_eth(caller);262 let new_admin = T::CrossAccountId::from_eth(new_admin);263 <Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;264 Ok(())265 }266267 /// Remove collection admin.268 ///269 /// @param new_admin Address of the removed administrator.270 fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<void> {271 let caller = T::CrossAccountId::from_eth(caller);272 let admin = T::CrossAccountId::from_eth(admin);273 <Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;274 Ok(())275 }276277 /// Toggle accessibility of collection nesting.278 ///279 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'280 #[solidity(rename_selector = "setCollectionNesting")]281 fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {282 check_is_owner_or_admin(caller, self)?;283284 let mut permissions = self.collection.permissions.clone();285 let mut nesting = permissions.nesting().clone();286 nesting.token_owner = enable;287 nesting.restricted = None;288 permissions.nesting = Some(nesting);289290 self.collection.permissions = <Pallet<T>>::clamp_permissions(291 self.collection.mode.clone(),292 &self.collection.permissions,293 permissions,294 )295 .map_err(dispatch_to_evm::<T>)?;296297 save(self)298 }299300 /// Toggle accessibility of collection nesting.301 ///302 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'303 /// @param collections Addresses of collections that will be available for nesting.304 #[solidity(rename_selector = "setCollectionNesting")]305 fn set_nesting(306 &mut self,307 caller: caller,308 enable: bool,309 collections: Vec<address>,310 ) -> Result<void> {311 if collections.is_empty() {312 return Err("no addresses provided".into());313 }314 check_is_owner_or_admin(caller, self)?;315316 let mut permissions = self.collection.permissions.clone();317 match enable {318 false => {319 let mut nesting = permissions.nesting().clone();320 nesting.token_owner = false;321 nesting.restricted = None;322 permissions.nesting = Some(nesting);323 }324 true => {325 let mut bv = OwnerRestrictedSet::new();326 for i in collections {327 bv.try_insert(crate::eth::map_eth_to_id(&i).ok_or(Error::Revert(328 "Can't convert address into collection id".into(),329 ))?)330 .map_err(|_| "too many collections")?;331 }332 let mut nesting = permissions.nesting().clone();333 nesting.token_owner = true;334 nesting.restricted = Some(bv);335 permissions.nesting = Some(nesting);336 }337 };338339 self.collection.permissions = <Pallet<T>>::clamp_permissions(340 self.collection.mode.clone(),341 &self.collection.permissions,342 permissions,343 )344 .map_err(dispatch_to_evm::<T>)?;345346 save(self)347 }348349 /// Set the collection access method.350 /// @param mode Access mode351 /// 0 for Normal352 /// 1 for AllowList353 fn set_collection_access(&mut self, caller: caller, mode: uint8) -> Result<void> {354 check_is_owner_or_admin(caller, self)?;355 let permissions = CollectionPermissions {356 access: Some(match mode {357 0 => AccessMode::Normal,358 1 => AccessMode::AllowList,359 _ => return Err("not supported access mode".into()),360 }),361 ..Default::default()362 };363 self.collection.permissions = <Pallet<T>>::clamp_permissions(364 self.collection.mode.clone(),365 &self.collection.permissions,366 permissions,367 )368 .map_err(dispatch_to_evm::<T>)?;369370 save(self)371 }372373 /// Add the user to the allowed list.374 ///375 /// @param user Address of a trusted user.376 fn add_to_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {377 let caller = T::CrossAccountId::from_eth(caller);378 let user = T::CrossAccountId::from_eth(user);379 <Pallet<T>>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;380 Ok(())381 }382383 /// Remove the user from the allowed list.384 ///385 /// @param user Address of a removed user.386 fn remove_from_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {387 let caller = T::CrossAccountId::from_eth(caller);388 let user = T::CrossAccountId::from_eth(user);389 <Pallet<T>>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;390 Ok(())391 }392393 /// Switch permission for minting.394 ///395 /// @param mode Enable if "true".396 fn set_collection_mint_mode(&mut self, caller: caller, mode: bool) -> Result<void> {397 check_is_owner_or_admin(caller, self)?;398 let permissions = CollectionPermissions {399 mint_mode: Some(mode),400 ..Default::default()401 };402 self.collection.permissions = <Pallet<T>>::clamp_permissions(403 self.collection.mode.clone(),404 &self.collection.permissions,405 permissions,406 )407 .map_err(dispatch_to_evm::<T>)?;408409 save(self)410 }411}412413fn check_is_owner_or_admin<T: Config>(414 caller: caller,415 collection: &CollectionHandle<T>,416) -> Result<T::CrossAccountId> {417 let caller = T::CrossAccountId::from_eth(caller);418 collection419 .check_is_owner_or_admin(&caller)420 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;421 Ok(caller)422}423424fn save<T: Config>(collection: &CollectionHandle<T>) -> Result<void> {425 // TODO possibly delete for the lack of transaction426 collection427 .check_is_internal()428 .map_err(dispatch_to_evm::<T>)?;429 <crate::CollectionById<T>>::insert(collection.id, collection.collection.clone());430 Ok(())431}432433pub mod static_property_key_value {434 use evm_coder::{435 execution::{Result, Error},436 };437 use alloc::format;438439 const EXPECT_CONVERT_ERROR: &str = "length < limit";440441 pub fn schema_name_key() -> up_data_structs::PropertyKey {442 property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)443 }444445 pub fn base_uri_key() -> up_data_structs::PropertyKey {446 property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)447 }448449 pub fn url_key() -> up_data_structs::PropertyKey {450 property_key_from_bytes(b"url").expect(EXPECT_CONVERT_ERROR)451 }452453 pub fn suffix_key() -> up_data_structs::PropertyKey {454 property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)455 }456457 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";458 pub fn erc721_value() -> up_data_structs::PropertyValue {459 property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)460 }461462 pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {463 bytes.to_vec().try_into().map_err(|_| {464 Error::Revert(format!(465 "Property key is too long. Max length is {}.",466 up_data_structs::PropertyKey::bound()467 ))468 })469 }470471 pub fn property_value_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyValue> {472 bytes.to_vec().try_into().map_err(|_| {473 Error::Revert(format!(474 "Property key is too long. Max length is {}.",475 up_data_structs::PropertyKey::bound()476 ))477 })478 }479}pallets/nonfungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/nonfungible/CHANGELOG.md
+++ b/pallets/nonfungible/CHANGELOG.md
@@ -2,10 +2,13 @@
All notable changes to this project will be documented in this file.
-## [0.1.1] - 2022-07-14
+## [0.1.2] - 2022-07-25
+### Changed
+- New alghoritm for retrieving `token_iri`.
+## [0.1.1] - 2022-07-14
### Added
- Implementation of RPC method `token_owners`.
For reasons of compatibility with this pallet, returns only one owner if token exists.
- This was an internal request to improve the web interface and support fractionalization event.
\ No newline at end of file
+ This was an internal request to improve the web interface and support fractionalization event.
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-nonfungible"
-version = "0.1.1"
+version = "0.1.2"
license = "GPLv3"
edition = "2021"
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -33,7 +33,7 @@
use pallet_evm_coder_substrate::dispatch_to_evm;
use sp_std::vec::Vec;
use pallet_common::{
- erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property_key_value::*},
+ erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::{key, value as property_value}},
CollectionHandle, CollectionPropertyPermissions,
};
use pallet_evm::{account::CrossAccountId, PrecompileHandle};
@@ -221,10 +221,10 @@
fn token_uri(&self, token_id: uint256) -> Result<string> {
let is_erc721 = || {
if let Some(shema_name) =
- pallet_common::Pallet::<T>::get_collection_property(self.id, &schema_name_key())
+ pallet_common::Pallet::<T>::get_collection_property(self.id, &key::schema_name())
{
let shema_name = shema_name.into_inner();
- shema_name == ERC721_METADATA
+ shema_name == property_value::ERC721_METADATA
} else {
false
}
@@ -232,7 +232,7 @@
let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
- if let Ok(url) = get_token_property(self, token_id_u32, &url_key()) {
+ if let Ok(url) = get_token_property(self, token_id_u32, &key::url()) {
if !url.is_empty() {
return Ok(url);
}
@@ -241,7 +241,7 @@
}
if let Some(base_uri) =
- pallet_common::Pallet::<T>::get_collection_property(self.id, &base_uri_key())
+ pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())
{
if !base_uri.is_empty() {
let base_uri = string::from_utf8(base_uri.into_inner()).map_err(|e| {
@@ -250,7 +250,7 @@
e
))
})?;
- if let Ok(suffix) = get_token_property(self, token_id_u32, &suffix_key()) {
+ if let Ok(suffix) = get_token_property(self, token_id_u32, &key::suffix()) {
if !suffix.is_empty() {
return Ok(base_uri + suffix.as_str());
}
@@ -497,7 +497,7 @@
token_id: uint256,
token_uri: string,
) -> Result<bool> {
- let key = url_key();
+ let key = key::url();
let permission = get_token_permission::<T>(self.id, &key)?;
if !permission.collection_admin {
return Err("Operation is not allowed".into());
@@ -702,7 +702,7 @@
to: address,
tokens: Vec<(uint256, string)>,
) -> Result<bool> {
- let key = url_key();
+ let key = key::url();
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let mut expected_index = <TokensMinted<T>>::get(self.id)
pallets/refungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -10,6 +10,8 @@
test(refungible-pallet): add tests for ERC-20 EVM API for RFT token pieces ([#413](https://github.com/UniqueNetwork/unique-chain/pull/413))
## [v0.1.1] - 2022-07-14
+### Added
+- Support for properties for RFT collections and tokens.
### Other changes
pallets/refungible/Changelog.mddiffbeforeafterboth--- a/pallets/refungible/Changelog.md
+++ /dev/null
@@ -1,3 +0,0 @@
-### 0.1.1
----
-* Added support for properties for RFT collections and tokens.
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -25,24 +25,24 @@
use crate::{Config, RefungibleHandle};
#[solidity_interface(
- name = "UniqueRFT",
+ name = "UniqueRefungible",
is(via("CollectionHandle<T>", common_mut, Collection),)
)]
impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> {}
// Not a tests, but code generators
-generate_stubgen!(gen_impl, UniqueRFTCall<()>, true);
-generate_stubgen!(gen_iface, UniqueRFTCall<()>, false);
+generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);
+generate_stubgen!(gen_iface, UniqueRefungibleCall<()>, false);
impl<T: Config> CommonEvmHandler for RefungibleHandle<T>
where
T::AccountId: From<[u8; 32]>,
{
- const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRFT.raw");
+ const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");
fn call(
self,
handle: &mut impl PrecompileHandle,
) -> Option<pallet_common::erc::PrecompileResult> {
- call::<T, UniqueRFTCall<T>, _, _>(handle, self)
+ call::<T, UniqueRefungibleCall<T>, _, _>(handle, self)
}
}
pallets/refungible/src/stubs/UniqueRFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRFT.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRFT.sol
+++ /dev/null
@@ -1,251 +0,0 @@
-// SPDX-License-Identifier: OTHER
-// This code is automatically generated
-
-pragma solidity >=0.8.0 <0.9.0;
-
-// Common stubs holder
-contract Dummy {
- uint8 dummy;
- string stub_error = "this contract is implemented in native";
-}
-
-contract ERC165 is Dummy {
- function supportsInterface(bytes4 interfaceID)
- external
- view
- returns (bool)
- {
- require(false, stub_error);
- interfaceID;
- return true;
- }
-}
-
-// Selector: 7d9262e6
-contract Collection is Dummy, ERC165 {
- // Set collection property.
- //
- // @param key Property key.
- // @param value Propery value.
- //
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- public
- {
- require(false, stub_error);
- key;
- value;
- dummy = 0;
- }
-
- // Delete collection property.
- //
- // @param key Property key.
- //
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) public {
- require(false, stub_error);
- key;
- dummy = 0;
- }
-
- // Get collection property.
- //
- // @dev Throws error if key not found.
- //
- // @param key Property key.
- // @return bytes The property corresponding to the key.
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- public
- view
- returns (bytes memory)
- {
- require(false, stub_error);
- key;
- dummy;
- return hex"";
- }
-
- // Set the sponsor of the collection.
- //
- // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
- //
- // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
- //
- // Selector: setCollectionSponsor(address) 7623402e
- function setCollectionSponsor(address sponsor) public {
- require(false, stub_error);
- sponsor;
- dummy = 0;
- }
-
- // Collection sponsorship confirmation.
- //
- // @dev After setting the sponsor for the collection, it must be confirmed with this function.
- //
- // Selector: confirmCollectionSponsorship() 3c50e97a
- function confirmCollectionSponsorship() public {
- require(false, stub_error);
- dummy = 0;
- }
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "accountTokenOwnershipLimit",
- // "sponsoredDataSize",
- // "sponsoredDataRateLimit",
- // "tokenLimit",
- // "sponsorTransferTimeout",
- // "sponsorApproveTimeout"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,uint32) 6a3841db
- function setCollectionLimit(string memory limit, uint32 value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "ownerCanTransfer",
- // "ownerCanDestroy",
- // "transfersEnabled"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,bool) 993b7fba
- function setCollectionLimit(string memory limit, bool value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Get contract address.
- //
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() public view returns (address) {
- require(false, stub_error);
- dummy;
- return 0x0000000000000000000000000000000000000000;
- }
-
- // Add collection admin by substrate address.
- // @param new_admin Substrate administrator address.
- //
- // Selector: addCollectionAdminSubstrate(uint256) 5730062b
- function addCollectionAdminSubstrate(uint256 newAdmin) public {
- require(false, stub_error);
- newAdmin;
- dummy = 0;
- }
-
- // Remove collection admin by substrate address.
- // @param admin Substrate administrator address.
- //
- // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
- function removeCollectionAdminSubstrate(uint256 admin) public {
- require(false, stub_error);
- admin;
- dummy = 0;
- }
-
- // Add collection admin.
- // @param new_admin Address of the added administrator.
- //
- // Selector: addCollectionAdmin(address) 92e462c7
- function addCollectionAdmin(address newAdmin) public {
- require(false, stub_error);
- newAdmin;
- dummy = 0;
- }
-
- // Remove collection admin.
- //
- // @param new_admin Address of the removed administrator.
- //
- // Selector: removeCollectionAdmin(address) fafd7b42
- function removeCollectionAdmin(address admin) public {
- require(false, stub_error);
- admin;
- dummy = 0;
- }
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
- //
- // Selector: setCollectionNesting(bool) 112d4586
- function setCollectionNesting(bool enable) public {
- require(false, stub_error);
- enable;
- dummy = 0;
- }
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
- // @param collections Addresses of collections that will be available for nesting.
- //
- // Selector: setCollectionNesting(bool,address[]) 64872396
- function setCollectionNesting(bool enable, address[] memory collections)
- public
- {
- require(false, stub_error);
- enable;
- collections;
- dummy = 0;
- }
-
- // Set the collection access method.
- // @param mode Access mode
- // 0 for Normal
- // 1 for AllowList
- //
- // Selector: setCollectionAccess(uint8) 41835d4c
- function setCollectionAccess(uint8 mode) public {
- require(false, stub_error);
- mode;
- dummy = 0;
- }
-
- // Add the user to the allowed list.
- //
- // @param user Address of a trusted user.
- //
- // Selector: addToCollectionAllowList(address) 67844fe6
- function addToCollectionAllowList(address user) public {
- require(false, stub_error);
- user;
- dummy = 0;
- }
-
- // Remove the user from the allowed list.
- //
- // @param user Address of a removed user.
- //
- // Selector: removeFromCollectionAllowList(address) 85c51acb
- function removeFromCollectionAllowList(address user) public {
- require(false, stub_error);
- user;
- dummy = 0;
- }
-
- // Switch permission for minting.
- //
- // @param mode Enable if "true".
- //
- // Selector: setCollectionMintMode(bool) 00018e84
- function setCollectionMintMode(bool mode) public {
- require(false, stub_error);
- mode;
- dummy = 0;
- }
-}
-
-contract UniqueRFT is Dummy, ERC165, Collection {}
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- /dev/null
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+contract Dummy {
+ uint8 dummy;
+ string stub_error = "this contract is implemented in native";
+}
+
+contract ERC165 is Dummy {
+ function supportsInterface(bytes4 interfaceID)
+ external
+ view
+ returns (bool)
+ {
+ require(false, stub_error);
+ interfaceID;
+ return true;
+ }
+}
+
+// Selector: 7d9262e6
+contract Collection is Dummy, ERC165 {
+ // Set collection property.
+ //
+ // @param key Property key.
+ // @param value Propery value.
+ //
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ public
+ {
+ require(false, stub_error);
+ key;
+ value;
+ dummy = 0;
+ }
+
+ // Delete collection property.
+ //
+ // @param key Property key.
+ //
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) public {
+ require(false, stub_error);
+ key;
+ dummy = 0;
+ }
+
+ // Get collection property.
+ //
+ // @dev Throws error if key not found.
+ //
+ // @param key Property key.
+ // @return bytes The property corresponding to the key.
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ public
+ view
+ returns (bytes memory)
+ {
+ require(false, stub_error);
+ key;
+ dummy;
+ return hex"";
+ }
+
+ // Set the sponsor of the collection.
+ //
+ // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ //
+ // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
+ //
+ // Selector: setCollectionSponsor(address) 7623402e
+ function setCollectionSponsor(address sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ // Collection sponsorship confirmation.
+ //
+ // @dev After setting the sponsor for the collection, it must be confirmed with this function.
+ //
+ // Selector: confirmCollectionSponsorship() 3c50e97a
+ function confirmCollectionSponsorship() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "accountTokenOwnershipLimit",
+ // "sponsoredDataSize",
+ // "sponsoredDataRateLimit",
+ // "tokenLimit",
+ // "sponsorTransferTimeout",
+ // "sponsorApproveTimeout"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,uint32) 6a3841db
+ function setCollectionLimit(string memory limit, uint32 value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "ownerCanTransfer",
+ // "ownerCanDestroy",
+ // "transfersEnabled"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,bool) 993b7fba
+ function setCollectionLimit(string memory limit, bool value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Get contract address.
+ //
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() public view returns (address) {
+ require(false, stub_error);
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+
+ // Add collection admin by substrate address.
+ // @param new_admin Substrate administrator address.
+ //
+ // Selector: addCollectionAdminSubstrate(uint256) 5730062b
+ function addCollectionAdminSubstrate(uint256 newAdmin) public {
+ require(false, stub_error);
+ newAdmin;
+ dummy = 0;
+ }
+
+ // Remove collection admin by substrate address.
+ // @param admin Substrate administrator address.
+ //
+ // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+ function removeCollectionAdminSubstrate(uint256 admin) public {
+ require(false, stub_error);
+ admin;
+ dummy = 0;
+ }
+
+ // Add collection admin.
+ // @param new_admin Address of the added administrator.
+ //
+ // Selector: addCollectionAdmin(address) 92e462c7
+ function addCollectionAdmin(address newAdmin) public {
+ require(false, stub_error);
+ newAdmin;
+ dummy = 0;
+ }
+
+ // Remove collection admin.
+ //
+ // @param new_admin Address of the removed administrator.
+ //
+ // Selector: removeCollectionAdmin(address) fafd7b42
+ function removeCollectionAdmin(address admin) public {
+ require(false, stub_error);
+ admin;
+ dummy = 0;
+ }
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
+ //
+ // Selector: setCollectionNesting(bool) 112d4586
+ function setCollectionNesting(bool enable) public {
+ require(false, stub_error);
+ enable;
+ dummy = 0;
+ }
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
+ // @param collections Addresses of collections that will be available for nesting.
+ //
+ // Selector: setCollectionNesting(bool,address[]) 64872396
+ function setCollectionNesting(bool enable, address[] memory collections)
+ public
+ {
+ require(false, stub_error);
+ enable;
+ collections;
+ dummy = 0;
+ }
+
+ // Set the collection access method.
+ // @param mode Access mode
+ // 0 for Normal
+ // 1 for AllowList
+ //
+ // Selector: setCollectionAccess(uint8) 41835d4c
+ function setCollectionAccess(uint8 mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+
+ // Add the user to the allowed list.
+ //
+ // @param user Address of a trusted user.
+ //
+ // Selector: addToCollectionAllowList(address) 67844fe6
+ function addToCollectionAllowList(address user) public {
+ require(false, stub_error);
+ user;
+ dummy = 0;
+ }
+
+ // Remove the user from the allowed list.
+ //
+ // @param user Address of a removed user.
+ //
+ // Selector: removeFromCollectionAllowList(address) 85c51acb
+ function removeFromCollectionAllowList(address user) public {
+ require(false, stub_error);
+ user;
+ dummy = 0;
+ }
+
+ // Switch permission for minting.
+ //
+ // @param mode Enable if "true".
+ //
+ // Selector: setCollectionMintMode(bool) 00018e84
+ function setCollectionMintMode(bool mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+}
+
+contract UniqueRefungible is Dummy, ERC165, Collection {}
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -28,7 +28,7 @@
use frame_support::traits::Get;
use pallet_common::{
CollectionById,
- erc::{static_property_key_value::*, CollectionHelpersEvents},
+ erc::{static_property::{key, value as property_value}, CollectionHelpersEvents},
};
use crate::{SelfWeightOf, Config, weights::WeightInfo};
@@ -83,7 +83,6 @@
Ok((caller, name, description, token_prefix, base_uri_value))
}
-//
fn make_data<T: Config>(
name: CollectionName,
mode: CollectionMode,
@@ -98,7 +97,7 @@
token_property_permissions
.try_push(up_data_structs::PropertyKeyPermission {
- key: url_key(),
+ key: key::url(),
permission: up_data_structs::PropertyPermission {
mutable: false,
collection_admin: true,
@@ -110,7 +109,7 @@
if add_properties {
token_property_permissions
.try_push(up_data_structs::PropertyKeyPermission {
- key: suffix_key(),
+ key: key::suffix(),
permission: up_data_structs::PropertyPermission {
mutable: false,
collection_admin: true,
@@ -121,15 +120,15 @@
properties
.try_push(up_data_structs::Property {
- key: schema_name_key(),
- value: erc721_value(),
+ key: key::schema_name(),
+ value: property_value::erc721(),
})
.map_err(|e| Error::Revert(format!("{:?}", e)))?;
if !base_uri_value.is_empty() {
properties
.try_push(up_data_structs::Property {
- key: base_uri_key(),
+ key: key::base_uri(),
value: base_uri_value,
})
.map_err(|e| Error::Revert(format!("{:?}", e)))?;
@@ -152,7 +151,7 @@
#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]
impl<T> EvmCollectionHelpers<T>
where
- T: Config + pallet_nonfungible::Config + pallet_refungible::Config
+ T: Config + pallet_nonfungible::Config + pallet_refungible::Config,
{
/// Create an NFT collection
/// @param name Name of the collection