difftreelog
Change prefixed names to postfixed
in: master
14 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -749,18 +749,24 @@
/// Returns the owner (in cross format) of the token.
///
/// @param tokenId Id for the token.
+ #[solidity(hide)]
fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {
+ Self::owner_of_cross(&self, token_id)
+ }
+
+ /// Returns the owner (in cross format) of the token.
+ ///
+ /// @param tokenId Id for the token.
+ fn owner_of_cross(&self, token_id: U256) -> Result<eth::CrossAddress> {
Self::token_owner(&self, token_id.try_into()?)
.map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))
.map_err(|_| Error::Revert("token not found".into()))
}
/// @notice Count all NFTs assigned to an owner
- /// @dev NFTs assigned to the zero address are considered invalid, and this
- /// function throws for queries about the zero address.
/// @param owner An cross address for whom to query the balance
/// @return The number of NFTs owned by `owner`, possibly zero
- fn cross_balance_of(&self, owner: eth::CrossAddress) -> Result<U256> {
+ fn balance_of_cross(&self, owner: eth::CrossAddress) -> Result<U256> {
self.consume_store_reads(1)?;
let balance = <AccountBalance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));
Ok(balance.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
@@ -774,7 +774,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x323b1db8
+/// @dev the ERC-165 identifier for this interface is 0x307b061a
contract ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -803,12 +803,24 @@
return "";
}
+ // /// Returns the owner (in cross format) of the token.
+ // ///
+ // /// @param tokenId Id for the token.
+ // /// @dev EVM selector for this function is: 0x2b29dace,
+ // /// or in textual repr: crossOwnerOf(uint256)
+ // function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {
+ // require(false, stub_error);
+ // tokenId;
+ // dummy;
+ // return CrossAddress(0x0000000000000000000000000000000000000000,0);
+ // }
+
/// Returns the owner (in cross format) of the token.
///
/// @param tokenId Id for the token.
- /// @dev EVM selector for this function is: 0x2b29dace,
- /// or in textual repr: crossOwnerOf(uint256)
- function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {
+ /// @dev EVM selector for this function is: 0xcaa3a4d0,
+ /// or in textual repr: ownerOfCross(uint256)
+ function ownerOfCross(uint256 tokenId) public view returns (CrossAddress memory) {
require(false, stub_error);
tokenId;
dummy;
@@ -816,13 +828,11 @@
}
/// @notice Count all NFTs assigned to an owner
- /// @dev NFTs assigned to the zero address are considered invalid, and this
- /// function throws for queries about the zero address.
/// @param owner An cross address for whom to query the balance
/// @return The number of NFTs owned by `owner`, possibly zero
- /// @dev EVM selector for this function is: 0x24e52cea,
- /// or in textual repr: crossBalanceOf((address,uint256))
- function crossBalanceOf(CrossAddress memory owner) public view returns (uint256) {
+ /// @dev EVM selector for this function is: 0xec069398,
+ /// or in textual repr: balanceOfCross((address,uint256))
+ function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {
require(false, stub_error);
owner;
dummy;
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -783,7 +783,15 @@
/// Returns the owner (in cross format) of the token.
///
/// @param tokenId Id for the token.
+ #[solidity(hide)]
fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {
+ Self::owner_of_cross(&self, token_id)
+ }
+
+ /// Returns the owner (in cross format) of the token.
+ ///
+ /// @param tokenId Id for the token.
+ fn owner_of_cross(&self, token_id: U256) -> Result<eth::CrossAddress> {
Self::token_owner(&self, token_id.try_into()?)
.map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))
.or_else(|err| match err {
@@ -795,11 +803,9 @@
}
/// @notice Count all RFTs assigned to an owner
- /// @dev RFTs assigned to the zero address are considered invalid, and this
- /// function throws for queries about the zero address.
/// @param owner An cross address for whom to query the balance
/// @return The number of RFTs owned by `owner`, possibly zero
- fn cross_balance_of(&self, owner: eth::CrossAddress) -> Result<U256> {
+ fn balance_of_cross(&self, owner: eth::CrossAddress) -> Result<U256> {
self.consume_store_reads(1)?;
let balance = <AccountBalance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));
Ok(balance.into())
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
@@ -774,7 +774,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x9780edce
+/// @dev the ERC-165 identifier for this interface is 0x95c0f66c
contract ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -803,12 +803,24 @@
return "";
}
+ // /// Returns the owner (in cross format) of the token.
+ // ///
+ // /// @param tokenId Id for the token.
+ // /// @dev EVM selector for this function is: 0x2b29dace,
+ // /// or in textual repr: crossOwnerOf(uint256)
+ // function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {
+ // require(false, stub_error);
+ // tokenId;
+ // dummy;
+ // return CrossAddress(0x0000000000000000000000000000000000000000,0);
+ // }
+
/// Returns the owner (in cross format) of the token.
///
/// @param tokenId Id for the token.
- /// @dev EVM selector for this function is: 0x2b29dace,
- /// or in textual repr: crossOwnerOf(uint256)
- function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {
+ /// @dev EVM selector for this function is: 0xcaa3a4d0,
+ /// or in textual repr: ownerOfCross(uint256)
+ function ownerOfCross(uint256 tokenId) public view returns (CrossAddress memory) {
require(false, stub_error);
tokenId;
dummy;
@@ -816,13 +828,11 @@
}
/// @notice Count all RFTs assigned to an owner
- /// @dev RFTs assigned to the zero address are considered invalid, and this
- /// function throws for queries about the zero address.
/// @param owner An cross address for whom to query the balance
/// @return The number of RFTs owned by `owner`, possibly zero
- /// @dev EVM selector for this function is: 0x24e52cea,
- /// or in textual repr: crossBalanceOf((address,uint256))
- function crossBalanceOf(CrossAddress memory owner) public view returns (uint256) {
+ /// @dev EVM selector for this function is: 0xec069398,
+ /// or in textual repr: balanceOfCross((address,uint256))
+ function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {
require(false, stub_error);
owner;
dummy;
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 | CrossBalanceOf { .. }231 | Properties { .. }232 | NextTokenId233 | TokenContractAddress { .. }234 | CollectionHelperAddress => None,235236 // Not sponsored237 BurnFrom { .. }238 | BurnFromCross { .. }239 | MintBulk { .. }240 | MintBulkWithTokenUri { .. } => None,241242 MintCross { .. } => withdraw_create_item::<T>(243 &collection,244 &who,245 &CreateItemData::NFT(CreateNftData::default()),246 ),247248 TransferCross { token_id, .. }249 | TransferFromCross { token_id, .. }250 | Transfer { token_id, .. } => {251 let token_id = TokenId::try_from(token_id).ok()?;252 withdraw_transfer::<T>(&collection, &who, &token_id)253 }254 }255 }256257 pub fn unique_mintable_call_sponsor<T>(258 call: ERC721UniqueMintableCall<T>,259 collection: CollectionHandle<T>,260 who: &T::CrossAccountId,261 ) -> Option<()>262 where263 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,264 {265 use ERC721UniqueMintableCall::*;266267 match call {268 // Readonly269 ERC165Call(_, _) => None,270271 // Sponsored272 Mint { .. }273 | MintCheckId { .. }274 | MintWithTokenUri { .. }275 | MintWithTokenUriCheckId { .. } => withdraw_create_item::<T>(276 &collection,277 &who,278 &CreateItemData::NFT(CreateNftData::default()),279 ),280 }281 }282}283284/// Module for methods of refungible token285///286/// Existance of token should be checked before searching for sponsor287/// because RefungibleTokenHandle doesn't check token's existence upon creation288mod erc20 {289 use super::*;290291 pub fn call_sponsor<T>(292 call: ERC20Call<T>,293 token: RefungibleTokenHandle<T>,294 who: &T::CrossAccountId,295 ) -> Option<()>296 where297 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,298 {299 use ERC20Call::*;300301 match call {302 // Readonly303 ERC165Call(_, _)304 | Name305 | Symbol306 | TotalSupply307 | Decimals308 | BalanceOf { .. }309 | Allowance { .. } => None,310311 Transfer { .. } => {312 let RefungibleTokenHandle(handle, token_id) = token;313 let token_id = token_id.try_into().ok()?;314 withdraw_transfer::<T>(&handle, &who, &token_id)315 }316 TransferFrom { from, .. } => {317 let RefungibleTokenHandle(handle, token_id) = token;318 let token_id = token_id.try_into().ok()?;319 let from = T::CrossAccountId::from_eth(from);320 withdraw_transfer::<T>(&handle, &from, &token_id)321 }322 Approve { .. } => {323 let RefungibleTokenHandle(handle, token_id) = token;324 let token_id = token_id.try_into().ok()?;325 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)326 }327 }328 }329330 pub fn unique_extensions_call_sponsor<T>(331 call: ERC20UniqueExtensionsCall<T>,332 token: RefungibleTokenHandle<T>,333 who: &T::CrossAccountId,334 ) -> Option<()>335 where336 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,337 {338 use ERC20UniqueExtensionsCall::*;339340 match call {341 // Readonly342 ERC165Call(_, _) => None,343344 // Not sponsored345 AllowanceCross { .. } | BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => {346 None347 }348349 TransferCross { .. } | TransferFromCross { .. } => {350 let RefungibleTokenHandle(handle, token_id) = token;351 let token_id = token_id.try_into().ok()?;352 withdraw_transfer::<T>(&handle, &who, &token_id)353 }354355 ApproveCross { .. } => {356 let RefungibleTokenHandle(handle, token_id) = token;357 let token_id = token_id.try_into().ok()?;358 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)359 }360 }361 }362}363364mod erc1633 {365 use super::*;366367 pub fn call_sponsor<T>(368 call: ERC1633Call<T>,369 _token: RefungibleTokenHandle<T>,370 _who: &T::CrossAccountId,371 ) -> Option<()>372 where373 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,374 {375 use ERC1633Call::*;376377 match call {378 // Readonly379 ERC165Call(_, _) | ParentToken | ParentTokenId => None,380 }381 }382}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 | OwnerOfCross { .. }231 | BalanceOfCross { .. }232 | Properties { .. }233 | NextTokenId234 | TokenContractAddress { .. }235 | CollectionHelperAddress => None,236237 // Not sponsored238 BurnFrom { .. }239 | BurnFromCross { .. }240 | MintBulk { .. }241 | MintBulkWithTokenUri { .. } => None,242243 MintCross { .. } => withdraw_create_item::<T>(244 &collection,245 &who,246 &CreateItemData::NFT(CreateNftData::default()),247 ),248249 TransferCross { token_id, .. }250 | TransferFromCross { token_id, .. }251 | Transfer { token_id, .. } => {252 let token_id = TokenId::try_from(token_id).ok()?;253 withdraw_transfer::<T>(&collection, &who, &token_id)254 }255 }256 }257258 pub fn unique_mintable_call_sponsor<T>(259 call: ERC721UniqueMintableCall<T>,260 collection: CollectionHandle<T>,261 who: &T::CrossAccountId,262 ) -> Option<()>263 where264 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,265 {266 use ERC721UniqueMintableCall::*;267268 match call {269 // Readonly270 ERC165Call(_, _) => None,271272 // Sponsored273 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 AllowanceCross { .. } | BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => {347 None348 }349350 TransferCross { .. } | TransferFromCross { .. } => {351 let RefungibleTokenHandle(handle, token_id) = token;352 let token_id = token_id.try_into().ok()?;353 withdraw_transfer::<T>(&handle, &who, &token_id)354 }355356 ApproveCross { .. } => {357 let RefungibleTokenHandle(handle, token_id) = token;358 let token_id = token_id.try_into().ok()?;359 withdraw_approve::<T>(&handle, who.as_sub(), &token_id)360 }361 }362 }363}364365mod erc1633 {366 use super::*;367368 pub fn call_sponsor<T>(369 call: ERC1633Call<T>,370 _token: RefungibleTokenHandle<T>,371 _who: &T::CrossAccountId,372 ) -> Option<()>373 where374 T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig,375 {376 use ERC1633Call::*;377378 match call {379 // Readonly380 ERC165Call(_, _) | ParentToken | ParentTokenId => None,381 }382 }383}tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -177,6 +177,23 @@
},
{
"inputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct CrossAddress",
+ "name": "owner",
+ "type": "tuple"
+ }
+ ],
+ "name": "balanceOfCross",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }
],
"name": "burn",
@@ -381,42 +398,6 @@
"inputs": [],
"name": "contractAddress",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "components": [
- { "internalType": "address", "name": "eth", "type": "address" },
- { "internalType": "uint256", "name": "sub", "type": "uint256" }
- ],
- "internalType": "struct CrossAddress",
- "name": "owner",
- "type": "tuple"
- }
- ],
- "name": "crossBalanceOf",
- "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
- ],
- "name": "crossOwnerOf",
- "outputs": [
- {
- "components": [
- { "internalType": "address", "name": "eth", "type": "address" },
- { "internalType": "uint256", "name": "sub", "type": "uint256" }
- ],
- "internalType": "struct CrossAddress",
- "name": "",
- "type": "tuple"
- }
- ],
"stateMutability": "view",
"type": "function"
},
@@ -557,6 +538,25 @@
},
{
"inputs": [
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "ownerOfCross",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct CrossAddress",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
{ "internalType": "string[]", "name": "keys", "type": "string[]" }
],
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -159,6 +159,23 @@
},
{
"inputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct CrossAddress",
+ "name": "owner",
+ "type": "tuple"
+ }
+ ],
+ "name": "balanceOfCross",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }
],
"name": "burn",
@@ -368,25 +385,6 @@
},
{
"inputs": [
- { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
- ],
- "name": "crossOwnerOf",
- "outputs": [
- {
- "components": [
- { "internalType": "address", "name": "eth", "type": "address" },
- { "internalType": "uint256", "name": "sub", "type": "uint256" }
- ],
- "internalType": "struct CrossAddress",
- "name": "",
- "type": "tuple"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
{ "internalType": "string[]", "name": "keys", "type": "string[]" }
],
"name": "deleteCollectionProperties",
@@ -522,6 +520,25 @@
},
{
"inputs": [
+ { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+ ],
+ "name": "ownerOfCross",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct CrossAddress",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
{ "internalType": "string[]", "name": "keys", "type": "string[]" }
],
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -533,7 +533,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x323b1db8
+/// @dev the ERC-165 identifier for this interface is 0x307b061a
interface ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -550,21 +550,26 @@
/// or in textual repr: description()
function description() external view returns (string memory);
+ // /// Returns the owner (in cross format) of the token.
+ // ///
+ // /// @param tokenId Id for the token.
+ // /// @dev EVM selector for this function is: 0x2b29dace,
+ // /// or in textual repr: crossOwnerOf(uint256)
+ // function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);
+
/// Returns the owner (in cross format) of the token.
///
/// @param tokenId Id for the token.
- /// @dev EVM selector for this function is: 0x2b29dace,
- /// or in textual repr: crossOwnerOf(uint256)
- function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);
+ /// @dev EVM selector for this function is: 0xcaa3a4d0,
+ /// or in textual repr: ownerOfCross(uint256)
+ function ownerOfCross(uint256 tokenId) external view returns (CrossAddress memory);
/// @notice Count all NFTs assigned to an owner
- /// @dev NFTs assigned to the zero address are considered invalid, and this
- /// function throws for queries about the zero address.
/// @param owner An cross address for whom to query the balance
/// @return The number of NFTs owned by `owner`, possibly zero
- /// @dev EVM selector for this function is: 0x24e52cea,
- /// or in textual repr: crossBalanceOf((address,uint256))
- function crossBalanceOf(CrossAddress memory owner) external view returns (uint256);
+ /// @dev EVM selector for this function is: 0xec069398,
+ /// or in textual repr: balanceOfCross((address,uint256))
+ function balanceOfCross(CrossAddress memory owner) external view returns (uint256);
/// Returns the token properties.
///
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -533,7 +533,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x9780edce
+/// @dev the ERC-165 identifier for this interface is 0x95c0f66c
interface ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -550,21 +550,26 @@
/// or in textual repr: description()
function description() external view returns (string memory);
+ // /// Returns the owner (in cross format) of the token.
+ // ///
+ // /// @param tokenId Id for the token.
+ // /// @dev EVM selector for this function is: 0x2b29dace,
+ // /// or in textual repr: crossOwnerOf(uint256)
+ // function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);
+
/// Returns the owner (in cross format) of the token.
///
/// @param tokenId Id for the token.
- /// @dev EVM selector for this function is: 0x2b29dace,
- /// or in textual repr: crossOwnerOf(uint256)
- function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);
+ /// @dev EVM selector for this function is: 0xcaa3a4d0,
+ /// or in textual repr: ownerOfCross(uint256)
+ function ownerOfCross(uint256 tokenId) external view returns (CrossAddress memory);
/// @notice Count all RFTs assigned to an owner
- /// @dev RFTs assigned to the zero address are considered invalid, and this
- /// function throws for queries about the zero address.
/// @param owner An cross address for whom to query the balance
/// @return The number of RFTs owned by `owner`, possibly zero
- /// @dev EVM selector for this function is: 0x24e52cea,
- /// or in textual repr: crossBalanceOf((address,uint256))
- function crossBalanceOf(CrossAddress memory owner) external view returns (uint256);
+ /// @dev EVM selector for this function is: 0xec069398,
+ /// or in textual repr: balanceOfCross((address,uint256))
+ function balanceOfCross(CrossAddress memory owner) external view returns (uint256);
/// Returns the token properties.
///
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -663,21 +663,21 @@
await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;
}));
- itEth('Check crossBalanceOf()', async ({helper}) => {
+ itEth('Check balanceOfCross()', async ({helper}) => {
const collection = await helper.nft.mintCollection(minter, {});
const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);
- expect(BigInt(await collectionEvm.methods.crossBalanceOf(owner).call({from: owner.eth})) === 0n).to.be.true;
+ expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === 0n).to.be.true;
for (let i = 1n; i < 100n; i++) {
await collection.mintToken(minter, {Ethereum: owner.eth});
- expect(BigInt(await collectionEvm.methods.crossBalanceOf(owner).call({from: owner.eth})) === i).to.be.true;
+ expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === i).to.be.true;
}
});
- itEth('Check crossOwnerOf()', async ({helper}) => {
+ itEth('Check ownerOfCross()', async ({helper}) => {
const collection = await helper.nft.mintCollection(minter, {});
let owner = await helper.ethCrossAccount.createAccountWithBalance(donor);
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
@@ -685,7 +685,7 @@
const {tokenId} = await collection.mintToken(minter, {Ethereum: owner.eth});
for (let i = 1n; i < 100n; i++) {
- const ownerCross = await collectionEvm.methods.crossOwnerOf(tokenId).call({from: owner.eth});
+ const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});
expect(ownerCross.eth).to.be.eq(owner.eth);
expect(ownerCross.sub).to.be.eq(owner.sub);
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -591,15 +591,15 @@
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);
- expect(BigInt(await collectionEvm.methods.crossBalanceOf(owner).call({from: owner.eth})) === 0n).to.be.true;
+ expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === 0n).to.be.true;
for (let i = 1n; i < 100n; i++) {
await collection.mintToken(minter, 100n, {Ethereum: owner.eth});
- expect(BigInt(await collectionEvm.methods.crossBalanceOf(owner).call({from: owner.eth})) === i).to.be.true;
+ expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === i).to.be.true;
}
});
- itEth.only('Check crossOwnerOf()', async ({helper}) => {
+ itEth('Check ownerOfCross()', async ({helper}) => {
const collection = await helper.rft.mintCollection(minter, {});
let owner = await helper.ethCrossAccount.createAccountWithBalance(donor);
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
@@ -607,7 +607,7 @@
const {tokenId} = await collection.mintToken(minter, 100n,{Ethereum: owner.eth});
for (let i = 1n; i < 100n; i++) {
- const ownerCross = await collectionEvm.methods.crossOwnerOf(tokenId).call({from: owner.eth});
+ const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});
expect(ownerCross.eth).to.be.eq(owner.eth);
expect(ownerCross.sub).to.be.eq(owner.sub);
@@ -620,7 +620,7 @@
const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, owner.eth, true);
const newOwner = await helper.ethCrossAccount.createAccountWithBalance(donor);
await tokenContract.methods.transferCross(newOwner, 50).send({from: owner.eth});
- const ownerCross = await collectionEvm.methods.crossOwnerOf(tokenId).call({from: owner.eth});
+ const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});
expect(ownerCross.eth.toUpperCase()).to.be.eq('0XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
expect(ownerCross.sub).to.be.eq('0');
});
tests/src/eth/tokens/minting.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokens/minting.test.ts
+++ b/tests/src/eth/tokens/minting.test.ts
@@ -19,7 +19,7 @@
import {expect, itEth, usingEthPlaygrounds} from '../util';
-describe('Minting tokens', () => {
+describe.only('Minting tokens', () => {
let donor: IKeyringPair;
let alice: IKeyringPair;
@@ -63,7 +63,7 @@
const tokenId = event.returnValues.tokenId;
expect(tokenId).to.be.equal('1');
expect(await helper.collection.getLastTokenId(collection.collectionId)).to.eq(1);
- expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+ expect(await contract.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);
}
});
});
@@ -97,7 +97,7 @@
const tokenId = event.returnValues.tokenId;
expect(tokenId).to.be.equal('1');
expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);
- expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+ expect(await collection.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);
}
});
});
@@ -131,7 +131,7 @@
const tokenId = event.returnValues.tokenId;
expect(tokenId).to.be.equal('1');
expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);
- expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+ expect(await collection.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);
}
});
});
@@ -157,7 +157,7 @@
expect(event.returnValues.to).to.be.equal(receiver);
expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
- expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
+ expect(await contract.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);
// TODO: this wont work right now, need release 919000 first
// await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
// const tokenUri = await contract.methods.tokenURI(nextTokenId).call();