difftreelog
Merge pull request #829 from UniqueNetwork/feature/remove_and_hide_some_minting_methods_and_events
in: master
24 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -291,12 +291,6 @@
},
}
-#[derive(ToLog)]
-pub enum ERC721UniqueMintableEvents {
- #[allow(dead_code)]
- MintingFinished {},
-}
-
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
#[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]
@@ -544,12 +538,8 @@
}
/// @title ERC721 minting logic.
-#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]
+#[solidity_interface(name = ERC721UniqueMintable)]
impl<T: Config> NonfungibleHandle<T> {
- fn minting_finished(&self) -> Result<bool> {
- Ok(false)
- }
-
/// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
@@ -678,11 +668,6 @@
)
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
- }
-
- /// @dev Not implemented
- fn finish_minting(&mut self, _caller: caller) -> Result<bool> {
- Err("not implementable".into())
}
}
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -700,22 +700,9 @@
}
}
-/// @dev inlined interface
-contract ERC721UniqueMintableEvents {
- event MintingFinished();
-}
-
/// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x476ff149
-contract ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
- /// @dev EVM selector for this function is: 0x05d2035b,
- /// or in textual repr: mintingFinished()
- function mintingFinished() public view returns (bool) {
- require(false, stub_error);
- dummy;
- return false;
- }
-
+/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
+contract ERC721UniqueMintable is Dummy, ERC165 {
/// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
@@ -756,7 +743,6 @@
dummy = 0;
return 0;
}
-
// /// @notice Function to mint token with the given tokenUri.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
@@ -774,14 +760,6 @@
// return false;
// }
- /// @dev Not implemented
- /// @dev EVM selector for this function is: 0x7d64bcb4,
- /// or in textual repr: finishMinting()
- function finishMinting() public returns (bool) {
- require(false, stub_error);
- dummy = 0;
- return false;
- }
}
/// @title Unique extensions for ERC721.
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -288,13 +288,6 @@
},
}
-#[derive(ToLog)]
-pub enum ERC721UniqueMintableEvents {
- /// @dev Not supported
- #[allow(dead_code)]
- MintingFinished {},
-}
-
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
#[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]
@@ -576,12 +569,8 @@
}
/// @title ERC721 minting logic.
-#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]
+#[solidity_interface(name = ERC721UniqueMintable)]
impl<T: Config> RefungibleHandle<T> {
- fn minting_finished(&self) -> Result<bool> {
- Ok(false)
- }
-
/// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
@@ -717,11 +706,6 @@
)
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
- }
-
- /// @dev Not implemented
- fn finish_minting(&mut self, _caller: caller) -> Result<bool> {
- Err("not implementable".into())
}
}
pallets/refungible/src/erc_token.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -25,7 +25,8 @@
ops::Deref,
};
use evm_coder::{
- abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight,
+ abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, solidity, types::*,
+ weight,
};
use pallet_common::{
CommonWeightInfo,
@@ -206,6 +207,7 @@
/// @param from The account whose tokens will be burnt.
/// @param amount The amount that will be burnt.
#[weight(<SelfWeightOf<T>>::burn_from())]
+ #[solidity(hide)]
fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -700,22 +700,9 @@
}
}
-/// @dev inlined interface
-contract ERC721UniqueMintableEvents {
- event MintingFinished();
-}
-
/// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x476ff149
-contract ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
- /// @dev EVM selector for this function is: 0x05d2035b,
- /// or in textual repr: mintingFinished()
- function mintingFinished() public view returns (bool) {
- require(false, stub_error);
- dummy;
- return false;
- }
-
+/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
+contract ERC721UniqueMintable is Dummy, ERC165 {
/// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
@@ -756,7 +743,6 @@
dummy = 0;
return 0;
}
-
// /// @notice Function to mint token with the given tokenUri.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
@@ -774,14 +760,6 @@
// return false;
// }
- /// @dev Not implemented
- /// @dev EVM selector for this function is: 0x7d64bcb4,
- /// or in textual repr: finishMinting()
- function finishMinting() public returns (bool) {
- require(false, stub_error);
- dummy = 0;
- return false;
- }
}
/// @title Unique extensions for ERC721.
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungibleToken.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungibleToken.sol
@@ -38,19 +38,19 @@
/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b
contract ERC20UniqueExtensions is Dummy, ERC165 {
- /// @dev Function that burns an amount of the token of a given account,
- /// deducting from the sender's allowance for said account.
- /// @param from The account whose tokens will be burnt.
- /// @param amount The amount that will be burnt.
- /// @dev EVM selector for this function is: 0x79cc6790,
- /// or in textual repr: burnFrom(address,uint256)
- function burnFrom(address from, uint256 amount) public returns (bool) {
- require(false, stub_error);
- from;
- amount;
- dummy = 0;
- return false;
- }
+ // /// @dev Function that burns an amount of the token of a given account,
+ // /// deducting from the sender's allowance for said account.
+ // /// @param from The account whose tokens will be burnt.
+ // /// @param amount The amount that will be burnt.
+ // /// @dev EVM selector for this function is: 0x79cc6790,
+ // /// or in textual repr: burnFrom(address,uint256)
+ // function burnFrom(address from, uint256 amount) public returns (bool) {
+ // require(false, stub_error);
+ // from;
+ // amount;
+ // dummy = 0;
+ // return false;
+ // }
/// @dev Function that burns an amount of the token of a given account,
/// deducting from the sender's allowance for said account.
runtime/common/ethereum/sponsoring/refungible.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//! Implements EVM sponsoring logic via TransactionValidityHack1819use core::convert::TryInto;20use pallet_common::CollectionHandle;21use pallet_evm::account::CrossAccountId;22use pallet_fungible::Config as FungibleConfig;23use pallet_refungible::Config as RefungibleConfig;24use pallet_nonfungible::Config as NonfungibleConfig;25use pallet_unique::Config as UniqueConfig;26use up_data_structs::{CreateItemData, CreateNftData, TokenId};2728use super::common;29use crate::runtime_common::sponsoring::*;3031use pallet_refungible::{32 erc::{33 ERC721BurnableCall, ERC721Call, ERC721EnumerableCall, ERC721MetadataCall,34 ERC721UniqueExtensionsCall, ERC721UniqueMintableCall, TokenPropertiesCall,35 UniqueRefungibleCall,36 },37 erc_token::{38 ERC1633Call, ERC20Call, ERC20UniqueExtensionsCall, RefungibleTokenHandle,39 UniqueRefungibleTokenCall,40 },41};4243pub fn call_sponsor<T>(44 call: UniqueRefungibleCall<T>,45 collection: CollectionHandle<T>,46 who: &T::CrossAccountId,47) -> Option<()>48where49 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,50{51 use UniqueRefungibleCall::*;5253 match call {54 // Readonly55 ERC165Call(_, _) => None,5657 ERC721Enumerable(call) => erc721::enumerable_call_sponsor(call, collection, who),58 ERC721Burnable(call) => erc721::burnable_call_sponsor(call, collection, who),59 ERC721Metadata(call) => erc721::metadata_call_sponsor(call, collection, who),60 Collection(call) => common::collection_call_sponsor(call, collection, who),61 ERC721(call) => erc721::call_sponsor(call, collection, who),62 ERC721UniqueExtensions(call) => {63 erc721::unique_extensions_call_sponsor(call, collection, who)64 }65 ERC721UniqueMintable(call) => erc721::unique_mintable_call_sponsor(call, collection, who),66 TokenProperties(call) => token_properties_call_sponsor(call, collection, who),67 }68}6970pub fn token_properties_call_sponsor<T>(71 call: TokenPropertiesCall<T>,72 collection: CollectionHandle<T>,73 who: &T::CrossAccountId,74) -> Option<()>75where76 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,77{78 use TokenPropertiesCall::*;7980 match call {81 // Readonly82 ERC165Call(_, _) | Property { .. } | TokenPropertyPermissions => None,8384 // Not sponsored85 SetTokenPropertyPermission { .. }86 | SetTokenPropertyPermissions { .. }87 | SetProperties { .. }88 | DeleteProperty { .. }89 | DeleteProperties { .. } => None,9091 SetProperty {92 token_id,93 key,94 value,95 ..96 } => {97 let token_id = TokenId::try_from(token_id).ok()?;98 withdraw_set_token_property::<T>(&collection, &who, &token_id, key.len() + value.len())99 }100 }101}102103pub fn token_call_sponsor<T>(104 call: UniqueRefungibleTokenCall<T>,105 token: RefungibleTokenHandle<T>,106 who: &T::CrossAccountId,107) -> Option<()>108where109 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,110{111 use UniqueRefungibleTokenCall::*;112113 match call {114 // Readonly115 ERC165Call(_, _) => None,116117 ERC20(call) => erc20::call_sponsor(call, token, who),118 ERC20UniqueExtensions(call) => erc20::unique_extensions_call_sponsor(call, token, who),119 ERC1633(call) => erc1633::call_sponsor(call, token, who),120 }121}122123mod erc721 {124 use super::*;125126 pub fn call_sponsor<T>(127 call: ERC721Call<T>,128 collection: CollectionHandle<T>,129 _who: &T::CrossAccountId,130 ) -> Option<()>131 where132 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,133 {134 use ERC721Call::*;135136 match call {137 // Readonly138 ERC165Call(_, _)139 | BalanceOf { .. }140 | OwnerOf { .. }141 | GetApproved { .. }142 | IsApprovedForAll { .. } => None,143144 // Not sponsored145 SafeTransferFromWithData { .. }146 | SafeTransferFrom { .. }147 | SetApprovalForAll { .. } => None,148149 TransferFrom { token_id, from, .. } => {150 let token_id = TokenId::try_from(token_id).ok()?;151 let from = T::CrossAccountId::from_eth(from);152 withdraw_transfer::<T>(&collection, &from, &token_id)153 }154155 // Not supported156 Approve { .. } => None,157 }158 }159160 pub fn enumerable_call_sponsor<T>(161 call: ERC721EnumerableCall<T>,162 _collection: CollectionHandle<T>,163 _who: &T::CrossAccountId,164 ) -> Option<()>165 where166 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,167 {168 use ERC721EnumerableCall::*;169170 match call {171 // Readonly172 ERC165Call(_, _) | TokenByIndex { .. } | TokenOfOwnerByIndex { .. } | TotalSupply => {173 None174 }175 }176 }177178 pub fn burnable_call_sponsor<T>(179 call: ERC721BurnableCall<T>,180 _collection: CollectionHandle<T>,181 _who: &T::CrossAccountId,182 ) -> Option<()>183 where184 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,185 {186 use ERC721BurnableCall::*;187188 match call {189 // Readonly190 ERC165Call(_, _) => None,191192 // Not sponsored193 Burn { .. } => None,194 }195 }196197 pub fn metadata_call_sponsor<T>(198 call: ERC721MetadataCall<T>,199 _collection: CollectionHandle<T>,200 _who: &T::CrossAccountId,201 ) -> Option<()>202 where203 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,204 {205 use ERC721MetadataCall::*;206207 match call {208 // Readonly209 ERC165Call(_, _) | NameProxy | SymbolProxy | TokenUri { .. } => None,210 }211 }212213 pub fn unique_extensions_call_sponsor<T>(214 call: ERC721UniqueExtensionsCall<T>,215 collection: CollectionHandle<T>,216 who: &T::CrossAccountId,217 ) -> Option<()>218 where219 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,220 {221 use ERC721UniqueExtensionsCall::*;222223 match call {224 // Readonly225 ERC165Call(_, _)226 | Name227 | Symbol228 | Description229 | CrossOwnerOf { .. }230 | Properties { .. }231 | NextTokenId232 | TokenContractAddress { .. }233 | CollectionHelperAddress => None,234235 // Not sponsored236 BurnFrom { .. }237 | BurnFromCross { .. }238 | MintBulk { .. }239 | MintBulkWithTokenUri { .. } => None,240241 MintCross { .. } => withdraw_create_item::<T>(242 &collection,243 &who,244 &CreateItemData::NFT(CreateNftData::default()),245 ),246247 TransferCross { token_id, .. }248 | TransferFromCross { token_id, .. }249 | Transfer { token_id, .. } => {250 let token_id = TokenId::try_from(token_id).ok()?;251 withdraw_transfer::<T>(&collection, &who, &token_id)252 }253 }254 }255256 pub fn unique_mintable_call_sponsor<T>(257 call: ERC721UniqueMintableCall<T>,258 collection: CollectionHandle<T>,259 who: &T::CrossAccountId,260 ) -> Option<()>261 where262 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,263 {264 use ERC721UniqueMintableCall::*;265266 match call {267 // Readonly268 ERC165Call(_, _) | MintingFinished => None,269270 // Not sponsored271 FinishMinting => None,272273 Mint { .. }274 | MintCheckId { .. }275 | MintWithTokenUri { .. }276 | MintWithTokenUriCheckId { .. } => withdraw_create_item::<T>(277 &collection,278 &who,279 &CreateItemData::NFT(CreateNftData::default()),280 ),281 }282 }283}284285/// Module for methods of refungible token286///287/// Existance of token should be checked before searching for sponsor288/// because RefungibleTokenHandle doesn't check token's existence upon creation289mod erc20 {290 use super::*;291292 pub fn call_sponsor<T>(293 call: ERC20Call<T>,294 token: RefungibleTokenHandle<T>,295 who: &T::CrossAccountId,296 ) -> Option<()>297 where298 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,299 {300 use ERC20Call::*;301302 match call {303 // Readonly304 ERC165Call(_, _)305 | Name306 | Symbol307 | TotalSupply308 | Decimals309 | BalanceOf { .. }310 | Allowance { .. } => None,311312 Transfer { .. } => {313 let RefungibleTokenHandle(handle, token_id) = token;314 let token_id = token_id.try_into().ok()?;315 withdraw_transfer::<T>(&handle, &who, &token_id)316 }317 TransferFrom { from, .. } => {318 let RefungibleTokenHandle(handle, token_id) = token;319 let token_id = token_id.try_into().ok()?;320 let from = T::CrossAccountId::from_eth(from);321 withdraw_transfer::<T>(&handle, &from, &token_id)322 }323 Approve { .. } => {324 let RefungibleTokenHandle(handle, token_id) = token;325 let token_id = token_id.try_into().ok()?;326 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)327 }328 }329 }330331 pub fn unique_extensions_call_sponsor<T>(332 call: ERC20UniqueExtensionsCall<T>,333 token: RefungibleTokenHandle<T>,334 who: &T::CrossAccountId,335 ) -> Option<()>336 where337 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,338 {339 use ERC20UniqueExtensionsCall::*;340341 match call {342 // Readonly343 ERC165Call(_, _) => None,344345 // Not sponsored346 BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => None,347348 TransferCross { .. } | TransferFromCross { .. } => {349 let RefungibleTokenHandle(handle, token_id) = token;350 let token_id = token_id.try_into().ok()?;351 withdraw_transfer::<T>(&handle, &who, &token_id)352 }353354 ApproveCross { .. } => {355 let RefungibleTokenHandle(handle, token_id) = token;356 let token_id = token_id.try_into().ok()?;357 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)358 }359 }360 }361}362363mod erc1633 {364 use super::*;365366 pub fn call_sponsor<T>(367 call: ERC1633Call<T>,368 _token: RefungibleTokenHandle<T>,369 _who: &T::CrossAccountId,370 ) -> Option<()>371 where372 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,373 {374 use ERC1633Call::*;375376 match call {377 // Readonly378 ERC165Call(_, _) | ParentToken | ParentTokenId => None,379 }380 }381}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//! Implements EVM sponsoring logic via TransactionValidityHack1819use core::convert::TryInto;20use pallet_common::CollectionHandle;21use pallet_evm::account::CrossAccountId;22use pallet_fungible::Config as FungibleConfig;23use pallet_refungible::Config as RefungibleConfig;24use pallet_nonfungible::Config as NonfungibleConfig;25use pallet_unique::Config as UniqueConfig;26use up_data_structs::{CreateItemData, CreateNftData, TokenId};2728use super::common;29use crate::runtime_common::sponsoring::*;3031use pallet_refungible::{32 erc::{33 ERC721BurnableCall, ERC721Call, ERC721EnumerableCall, ERC721MetadataCall,34 ERC721UniqueExtensionsCall, ERC721UniqueMintableCall, TokenPropertiesCall,35 UniqueRefungibleCall,36 },37 erc_token::{38 ERC1633Call, ERC20Call, ERC20UniqueExtensionsCall, RefungibleTokenHandle,39 UniqueRefungibleTokenCall,40 },41};4243pub fn call_sponsor<T>(44 call: UniqueRefungibleCall<T>,45 collection: CollectionHandle<T>,46 who: &T::CrossAccountId,47) -> Option<()>48where49 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,50{51 use UniqueRefungibleCall::*;5253 match call {54 // Readonly55 ERC165Call(_, _) => None,5657 ERC721Enumerable(call) => erc721::enumerable_call_sponsor(call, collection, who),58 ERC721Burnable(call) => erc721::burnable_call_sponsor(call, collection, who),59 ERC721Metadata(call) => erc721::metadata_call_sponsor(call, collection, who),60 Collection(call) => common::collection_call_sponsor(call, collection, who),61 ERC721(call) => erc721::call_sponsor(call, collection, who),62 ERC721UniqueExtensions(call) => {63 erc721::unique_extensions_call_sponsor(call, collection, who)64 }65 ERC721UniqueMintable(call) => erc721::unique_mintable_call_sponsor(call, collection, who),66 TokenProperties(call) => token_properties_call_sponsor(call, collection, who),67 }68}6970pub fn token_properties_call_sponsor<T>(71 call: TokenPropertiesCall<T>,72 collection: CollectionHandle<T>,73 who: &T::CrossAccountId,74) -> Option<()>75where76 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,77{78 use TokenPropertiesCall::*;7980 match call {81 // Readonly82 ERC165Call(_, _) | Property { .. } | TokenPropertyPermissions => None,8384 // Not sponsored85 SetTokenPropertyPermission { .. }86 | SetTokenPropertyPermissions { .. }87 | SetProperties { .. }88 | DeleteProperty { .. }89 | DeleteProperties { .. } => None,9091 SetProperty {92 token_id,93 key,94 value,95 ..96 } => {97 let token_id = TokenId::try_from(token_id).ok()?;98 withdraw_set_token_property::<T>(&collection, &who, &token_id, key.len() + value.len())99 }100 }101}102103pub fn token_call_sponsor<T>(104 call: UniqueRefungibleTokenCall<T>,105 token: RefungibleTokenHandle<T>,106 who: &T::CrossAccountId,107) -> Option<()>108where109 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,110{111 use UniqueRefungibleTokenCall::*;112113 match call {114 // Readonly115 ERC165Call(_, _) => None,116117 ERC20(call) => erc20::call_sponsor(call, token, who),118 ERC20UniqueExtensions(call) => erc20::unique_extensions_call_sponsor(call, token, who),119 ERC1633(call) => erc1633::call_sponsor(call, token, who),120 }121}122123mod erc721 {124 use super::*;125126 pub fn call_sponsor<T>(127 call: ERC721Call<T>,128 collection: CollectionHandle<T>,129 _who: &T::CrossAccountId,130 ) -> Option<()>131 where132 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,133 {134 use ERC721Call::*;135136 match call {137 // Readonly138 ERC165Call(_, _)139 | BalanceOf { .. }140 | OwnerOf { .. }141 | GetApproved { .. }142 | IsApprovedForAll { .. } => None,143144 // Not sponsored145 SafeTransferFromWithData { .. }146 | SafeTransferFrom { .. }147 | SetApprovalForAll { .. } => None,148149 TransferFrom { token_id, from, .. } => {150 let token_id = TokenId::try_from(token_id).ok()?;151 let from = T::CrossAccountId::from_eth(from);152 withdraw_transfer::<T>(&collection, &from, &token_id)153 }154155 // Not supported156 Approve { .. } => None,157 }158 }159160 pub fn enumerable_call_sponsor<T>(161 call: ERC721EnumerableCall<T>,162 _collection: CollectionHandle<T>,163 _who: &T::CrossAccountId,164 ) -> Option<()>165 where166 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,167 {168 use ERC721EnumerableCall::*;169170 match call {171 // Readonly172 ERC165Call(_, _) | TokenByIndex { .. } | TokenOfOwnerByIndex { .. } | TotalSupply => {173 None174 }175 }176 }177178 pub fn burnable_call_sponsor<T>(179 call: ERC721BurnableCall<T>,180 _collection: CollectionHandle<T>,181 _who: &T::CrossAccountId,182 ) -> Option<()>183 where184 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,185 {186 use ERC721BurnableCall::*;187188 match call {189 // Readonly190 ERC165Call(_, _) => None,191192 // Not sponsored193 Burn { .. } => None,194 }195 }196197 pub fn metadata_call_sponsor<T>(198 call: ERC721MetadataCall<T>,199 _collection: CollectionHandle<T>,200 _who: &T::CrossAccountId,201 ) -> Option<()>202 where203 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,204 {205 use ERC721MetadataCall::*;206207 match call {208 // Readonly209 ERC165Call(_, _) | NameProxy | SymbolProxy | TokenUri { .. } => None,210 }211 }212213 pub fn unique_extensions_call_sponsor<T>(214 call: ERC721UniqueExtensionsCall<T>,215 collection: CollectionHandle<T>,216 who: &T::CrossAccountId,217 ) -> Option<()>218 where219 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,220 {221 use ERC721UniqueExtensionsCall::*;222223 match call {224 // Readonly225 ERC165Call(_, _)226 | Name227 | Symbol228 | Description229 | CrossOwnerOf { .. }230 | Properties { .. }231 | NextTokenId232 | TokenContractAddress { .. }233 | CollectionHelperAddress => None,234235 // Not sponsored236 BurnFrom { .. }237 | BurnFromCross { .. }238 | MintBulk { .. }239 | MintBulkWithTokenUri { .. } => None,240241 MintCross { .. } => withdraw_create_item::<T>(242 &collection,243 &who,244 &CreateItemData::NFT(CreateNftData::default()),245 ),246247 TransferCross { token_id, .. }248 | TransferFromCross { token_id, .. }249 | Transfer { token_id, .. } => {250 let token_id = TokenId::try_from(token_id).ok()?;251 withdraw_transfer::<T>(&collection, &who, &token_id)252 }253 }254 }255256 pub fn unique_mintable_call_sponsor<T>(257 call: ERC721UniqueMintableCall<T>,258 collection: CollectionHandle<T>,259 who: &T::CrossAccountId,260 ) -> Option<()>261 where262 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,263 {264 use ERC721UniqueMintableCall::*;265266 match call {267 // Readonly268 ERC165Call(_, _) => None,269270 // Sponsored271 Mint { .. }272 | MintCheckId { .. }273 | MintWithTokenUri { .. }274 | MintWithTokenUriCheckId { .. } => withdraw_create_item::<T>(275 &collection,276 &who,277 &CreateItemData::NFT(CreateNftData::default()),278 ),279 }280 }281}282283/// Module for methods of refungible token284///285/// Existance of token should be checked before searching for sponsor286/// because RefungibleTokenHandle doesn't check token's existence upon creation287mod erc20 {288 use super::*;289290 pub fn call_sponsor<T>(291 call: ERC20Call<T>,292 token: RefungibleTokenHandle<T>,293 who: &T::CrossAccountId,294 ) -> Option<()>295 where296 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,297 {298 use ERC20Call::*;299300 match call {301 // Readonly302 ERC165Call(_, _)303 | Name304 | Symbol305 | TotalSupply306 | Decimals307 | BalanceOf { .. }308 | Allowance { .. } => None,309310 Transfer { .. } => {311 let RefungibleTokenHandle(handle, token_id) = token;312 let token_id = token_id.try_into().ok()?;313 withdraw_transfer::<T>(&handle, &who, &token_id)314 }315 TransferFrom { from, .. } => {316 let RefungibleTokenHandle(handle, token_id) = token;317 let token_id = token_id.try_into().ok()?;318 let from = T::CrossAccountId::from_eth(from);319 withdraw_transfer::<T>(&handle, &from, &token_id)320 }321 Approve { .. } => {322 let RefungibleTokenHandle(handle, token_id) = token;323 let token_id = token_id.try_into().ok()?;324 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)325 }326 }327 }328329 pub fn unique_extensions_call_sponsor<T>(330 call: ERC20UniqueExtensionsCall<T>,331 token: RefungibleTokenHandle<T>,332 who: &T::CrossAccountId,333 ) -> Option<()>334 where335 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,336 {337 use ERC20UniqueExtensionsCall::*;338339 match call {340 // Readonly341 ERC165Call(_, _) => None,342343 // Not sponsored344 BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => None,345346 TransferCross { .. } | TransferFromCross { .. } => {347 let RefungibleTokenHandle(handle, token_id) = token;348 let token_id = token_id.try_into().ok()?;349 withdraw_transfer::<T>(&handle, &who, &token_id)350 }351352 ApproveCross { .. } => {353 let RefungibleTokenHandle(handle, token_id) = token;354 let token_id = token_id.try_into().ok()?;355 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)356 }357 }358 }359}360361mod erc1633 {362 use super::*;363364 pub fn call_sponsor<T>(365 call: ERC1633Call<T>,366 _token: RefungibleTokenHandle<T>,367 _who: &T::CrossAccountId,368 ) -> Option<()>369 where370 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,371 {372 use ERC1633Call::*;373374 match call {375 // Readonly376 ERC165Call(_, _) | ParentToken | ParentTokenId => None,377 }378 }379}tests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/burnItemEvent.test.ts
+++ b/tests/src/check-event/burnItemEvent.test.ts
@@ -32,6 +32,7 @@
const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
const token = await collection.mintToken(alice, {Substrate: alice.address});
await token.burn(alice);
+ await helper.wait.newBlocks(1);
const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
const eventStrings = event.map(e => `${e.section}.${e.method}`);
tests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createCollectionEvent.test.ts
+++ b/tests/src/check-event/createCollectionEvent.test.ts
@@ -29,6 +29,7 @@
});
itSub('Check event from createCollection(): ', async ({helper}) => {
await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+ await helper.wait.newBlocks(1);
const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
const eventStrings = event.map(e => `${e.section}.${e.method}`);
tests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createItemEvent.test.ts
+++ b/tests/src/check-event/createItemEvent.test.ts
@@ -30,6 +30,7 @@
itSub('Check event from createItem(): ', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
await collection.mintToken(alice, {Substrate: alice.address});
+ await helper.wait.newBlocks(1);
const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
const eventStrings = event.map(e => `${e.section}.${e.method}`);
tests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createMultipleItemsEvent.test.ts
+++ b/tests/src/check-event/createMultipleItemsEvent.test.ts
@@ -35,6 +35,7 @@
{owner: {Substrate: alice.address}},
]);
+ await helper.wait.newBlocks(1);
const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
const eventStrings = event.map(e => `${e.section}.${e.method}`);
tests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/destroyCollectionEvent.test.ts
+++ b/tests/src/check-event/destroyCollectionEvent.test.ts
@@ -31,6 +31,7 @@
itSub('Check event from destroyCollection(): ', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
await collection.burn(alice);
+ await helper.wait.newBlocks(1);
const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
const eventStrings = event.map(e => `${e.section}.${e.method}`);
tests/src/check-event/transferEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/transferEvent.test.ts
+++ b/tests/src/check-event/transferEvent.test.ts
@@ -34,6 +34,7 @@
const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
const token = await collection.mintToken(alice, {Substrate: alice.address});
await token.transfer(alice, {Substrate: bob.address});
+ await helper.wait.newBlocks(1);
const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
const eventStrings = event.map(e => `${e.section}.${e.method}`);
tests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/transferFromEvent.test.ts
+++ b/tests/src/check-event/transferFromEvent.test.ts
@@ -33,6 +33,7 @@
const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
const token = await collection.mintToken(alice, {Substrate: alice.address});
await token.transferFrom(alice, {Substrate: alice.address}, {Substrate: bob.address});
+ await helper.wait.newBlocks(1);
const event = helper.chainLog[helper.chainLog.length - 1].events as IEvent[];
const eventStrings = event.map(e => `${e.section}.${e.method}`);
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -51,12 +51,6 @@
},
{
"anonymous": false,
- "inputs": [],
- "name": "MintingFinished",
- "type": "event"
- },
- {
- "anonymous": false,
"inputs": [
{
"indexed": true,
@@ -420,13 +414,6 @@
"name": "description",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
"stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "finishMinting",
- "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
- "stateMutability": "nonpayable",
"type": "function"
},
{
@@ -513,13 +500,6 @@
"name": "mintWithTokenURI",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "mintingFinished",
- "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
- "stateMutability": "view",
"type": "function"
},
{
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -51,12 +51,6 @@
},
{
"anonymous": false,
- "inputs": [],
- "name": "MintingFinished",
- "type": "event"
- },
- {
- "anonymous": false,
"inputs": [
{
"indexed": true,
@@ -402,13 +396,6 @@
"name": "description",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
"stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "finishMinting",
- "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
- "stateMutability": "nonpayable",
"type": "function"
},
{
@@ -495,13 +482,6 @@
"name": "mintWithTokenURI",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [],
- "name": "mintingFinished",
- "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
- "stateMutability": "view",
"type": "function"
},
{
tests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungibleToken.json
+++ b/tests/src/eth/abi/reFungibleToken.json
@@ -98,16 +98,6 @@
},
{
"inputs": [
- { "internalType": "address", "name": "from", "type": "address" },
- { "internalType": "uint256", "name": "amount", "type": "uint256" }
- ],
- "name": "burnFrom",
- "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
{
"components": [
{ "internalType": "address", "name": "eth", "type": "address" },
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -483,18 +483,9 @@
function burn(uint256 tokenId) external;
}
-/// @dev inlined interface
-interface ERC721UniqueMintableEvents {
- event MintingFinished();
-}
-
/// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x476ff149
-interface ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
- /// @dev EVM selector for this function is: 0x05d2035b,
- /// or in textual repr: mintingFinished()
- function mintingFinished() external view returns (bool);
-
+/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
+interface ERC721UniqueMintable is Dummy, ERC165 {
/// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
@@ -518,7 +509,6 @@
/// @dev EVM selector for this function is: 0x45c17782,
/// or in textual repr: mintWithTokenURI(address,string)
function mintWithTokenURI(address to, string memory tokenUri) external returns (uint256);
-
// /// @notice Function to mint token with the given tokenUri.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
@@ -529,10 +519,6 @@
// /// or in textual repr: mintWithTokenURI(address,uint256,string)
// function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);
- /// @dev Not implemented
- /// @dev EVM selector for this function is: 0x7d64bcb4,
- /// or in textual repr: finishMinting()
- function finishMinting() external returns (bool);
}
/// @title Unique extensions for ERC721.
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -483,18 +483,9 @@
function burn(uint256 tokenId) external;
}
-/// @dev inlined interface
-interface ERC721UniqueMintableEvents {
- event MintingFinished();
-}
-
/// @title ERC721 minting logic.
-/// @dev the ERC-165 identifier for this interface is 0x476ff149
-interface ERC721UniqueMintable is Dummy, ERC165, ERC721UniqueMintableEvents {
- /// @dev EVM selector for this function is: 0x05d2035b,
- /// or in textual repr: mintingFinished()
- function mintingFinished() external view returns (bool);
-
+/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6
+interface ERC721UniqueMintable is Dummy, ERC165 {
/// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
@@ -518,7 +509,6 @@
/// @dev EVM selector for this function is: 0x45c17782,
/// or in textual repr: mintWithTokenURI(address,string)
function mintWithTokenURI(address to, string memory tokenUri) external returns (uint256);
-
// /// @notice Function to mint token with the given tokenUri.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
@@ -529,10 +519,6 @@
// /// or in textual repr: mintWithTokenURI(address,uint256,string)
// function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) external returns (bool);
- /// @dev Not implemented
- /// @dev EVM selector for this function is: 0x7d64bcb4,
- /// or in textual repr: finishMinting()
- function finishMinting() external returns (bool);
}
/// @title Unique extensions for ERC721.
tests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungibleToken.sol
+++ b/tests/src/eth/api/UniqueRefungibleToken.sol
@@ -25,13 +25,13 @@
/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b
interface ERC20UniqueExtensions is Dummy, ERC165 {
- /// @dev Function that burns an amount of the token of a given account,
- /// deducting from the sender's allowance for said account.
- /// @param from The account whose tokens will be burnt.
- /// @param amount The amount that will be burnt.
- /// @dev EVM selector for this function is: 0x79cc6790,
- /// or in textual repr: burnFrom(address,uint256)
- function burnFrom(address from, uint256 amount) external returns (bool);
+ // /// @dev Function that burns an amount of the token of a given account,
+ // /// deducting from the sender's allowance for said account.
+ // /// @param from The account whose tokens will be burnt.
+ // /// @param amount The amount that will be burnt.
+ // /// @dev EVM selector for this function is: 0x79cc6790,
+ // /// or in textual repr: burnFrom(address,uint256)
+ // function burnFrom(address from, uint256 amount) external returns (bool);
/// @dev Function that burns an amount of the token of a given account,
/// deducting from the sender's allowance for said account.
tests/src/eth/base.test.tsdiffbeforeafterboth--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -108,10 +108,6 @@
await checkInterface(helper, '0x5b5e139f', false, true);
});
- itEth('ERC721UniqueMintable - 0x476ff149 - support', async ({helper}) => {
- await checkInterface(helper, '0x476ff149', true, true);
- });
-
itEth('ERC721Enumerable - 0x780e9d63 - support', async ({helper}) => {
await checkInterface(helper, '0x780e9d63', true, true);
});