difftreelog
Merge pull request #919 from UniqueNetwork/feature/crossBalanceOf
in: master
26 files changed
pallets/fungible/src/erc.rsdiffbeforeafterboth328 Ok(T::ContractAddress::get())328 Ok(T::ContractAddress::get())329 }329 }330331 /// @notice Balance of account332 /// @param owner An cross address for whom to query the balance333 /// @return The number of fingibles owned by `owner`, possibly zero334 fn balance_of_cross(&self, owner: CrossAddress) -> Result<U256> {335 self.consume_store_reads(1)?;336 let balance = <Balance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));337 Ok(balance.into())338 }330}339}331340332#[solidity_interface(341#[solidity_interface(pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth511 bytes value;511 bytes value;512}512}513513514/// @dev the ERC-165 identifier for this interface is 0x85d7dea6514/// @dev the ERC-165 identifier for this interface is 0x69d14d3e515contract ERC20UniqueExtensions is Dummy, ERC165 {515contract ERC20UniqueExtensions is Dummy, ERC165 {516 /// @dev Function to check the amount of tokens that an owner allowed to a spender.516 /// @dev Function to check the amount of tokens that an owner allowed to a spender.517 /// @param owner crossAddress The address which owns the funds.517 /// @param owner crossAddress The address which owns the funds.631 return 0x0000000000000000000000000000000000000000;631 return 0x0000000000000000000000000000000000000000;632 }632 }633634 /// @notice Balance of account635 /// @param owner An cross address for whom to query the balance636 /// @return The number of fingibles owned by `owner`, possibly zero637 /// @dev EVM selector for this function is: 0xec069398,638 /// or in textual repr: balanceOfCross((address,uint256))639 function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {640 require(false, stub_error);641 owner;642 dummy;643 return 0;644 }633}645}634646635struct AmountForAddress {647struct AmountForAddress {pallets/nonfungible/src/erc.rsdiffbeforeafterboth746 .collect::<String>()746 .collect::<String>()747 }747 }748749 /// Returns the owner (in cross format) of the token.750 ///751 /// @param tokenId Id for the token.752 #[solidity(hide)]753 fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {754 Self::owner_of_cross(&self, token_id)755 }748756749 /// Returns the owner (in cross format) of the token.757 /// Returns the owner (in cross format) of the token.750 ///758 ///751 /// @param tokenId Id for the token.759 /// @param tokenId Id for the token.752 fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {760 fn owner_of_cross(&self, token_id: U256) -> Result<eth::CrossAddress> {753 Self::token_owner(&self, token_id.try_into()?)761 Self::token_owner(&self, token_id.try_into()?)754 .map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))762 .map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))755 .map_err(|_| Error::Revert("token not found".into()))763 .map_err(|_| Error::Revert("token not found".into()))756 }764 }765766 /// @notice Count all NFTs assigned to an owner767 /// @param owner An cross address for whom to query the balance768 /// @return The number of NFTs owned by `owner`, possibly zero769 fn balance_of_cross(&self, owner: eth::CrossAddress) -> Result<U256> {770 self.consume_store_reads(1)?;771 let balance = <AccountBalance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));772 Ok(balance.into())773 }757774758 /// Returns the token properties.775 /// Returns the token properties.759 ///776 ///pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth774}774}775775776/// @title Unique extensions for ERC721.776/// @title Unique extensions for ERC721.777/// @dev the ERC-165 identifier for this interface is 0x16de3152777/// @dev the ERC-165 identifier for this interface is 0x307b061a778contract ERC721UniqueExtensions is Dummy, ERC165 {778contract ERC721UniqueExtensions is Dummy, ERC165 {779 /// @notice A descriptive name for a collection of NFTs in this contract779 /// @notice A descriptive name for a collection of NFTs in this contract780 /// @dev EVM selector for this function is: 0x06fdde03,780 /// @dev EVM selector for this function is: 0x06fdde03,803 return "";803 return "";804 }804 }805806 // /// Returns the owner (in cross format) of the token.807 // ///808 // /// @param tokenId Id for the token.809 // /// @dev EVM selector for this function is: 0x2b29dace,810 // /// or in textual repr: crossOwnerOf(uint256)811 // function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {812 // require(false, stub_error);813 // tokenId;814 // dummy;815 // return CrossAddress(0x0000000000000000000000000000000000000000,0);816 // }805817806 /// Returns the owner (in cross format) of the token.818 /// Returns the owner (in cross format) of the token.807 ///819 ///808 /// @param tokenId Id for the token.820 /// @param tokenId Id for the token.809 /// @dev EVM selector for this function is: 0x2b29dace,821 /// @dev EVM selector for this function is: 0xcaa3a4d0,810 /// or in textual repr: crossOwnerOf(uint256)822 /// or in textual repr: ownerOfCross(uint256)811 function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {823 function ownerOfCross(uint256 tokenId) public view returns (CrossAddress memory) {812 require(false, stub_error);824 require(false, stub_error);813 tokenId;825 tokenId;814 dummy;826 dummy;815 return CrossAddress(0x0000000000000000000000000000000000000000, 0);827 return CrossAddress(0x0000000000000000000000000000000000000000, 0);816 }828 }829830 /// @notice Count all NFTs assigned to an owner831 /// @param owner An cross address for whom to query the balance832 /// @return The number of NFTs owned by `owner`, possibly zero833 /// @dev EVM selector for this function is: 0xec069398,834 /// or in textual repr: balanceOfCross((address,uint256))835 function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {836 require(false, stub_error);837 owner;838 dummy;839 return 0;840 }817841818 /// Returns the token properties.842 /// Returns the token properties.819 ///843 ///pallets/refungible/src/erc.rsdiffbeforeafterboth780 .collect::<String>())780 .collect::<String>())781 }781 }782783 /// Returns the owner (in cross format) of the token.784 ///785 /// @param tokenId Id for the token.786 #[solidity(hide)]787 fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {788 Self::owner_of_cross(&self, token_id)789 }782790783 /// Returns the owner (in cross format) of the token.791 /// Returns the owner (in cross format) of the token.784 ///792 ///785 /// @param tokenId Id for the token.793 /// @param tokenId Id for the token.786 fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {794 fn owner_of_cross(&self, token_id: U256) -> Result<eth::CrossAddress> {787 Self::token_owner(&self, token_id.try_into()?)795 Self::token_owner(&self, token_id.try_into()?)788 .map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))796 .map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))789 .or_else(|err| match err {797 .or_else(|err| match err {794 })802 })795 }803 }804805 /// @notice Count all RFTs assigned to an owner806 /// @param owner An cross address for whom to query the balance807 /// @return The number of RFTs owned by `owner`, possibly zero808 fn balance_of_cross(&self, owner: eth::CrossAddress) -> Result<U256> {809 self.consume_store_reads(1)?;810 let balance = <AccountBalance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));811 Ok(balance.into())812 }796813797 /// Returns the token properties.814 /// Returns the token properties.798 ///815 ///pallets/refungible/src/erc_token.rsdiffbeforeafterboth284 Ok(true)284 Ok(true)285 }285 }286287 /// @notice Balance of account288 /// @param owner An cross address for whom to query the balance289 /// @return The number of fingibles owned by `owner`, possibly zero290 fn balance_of_cross(&self, owner: CrossAddress) -> Result<U256> {291 self.consume_store_reads(1)?;292 let balance = <Balance<T>>::get((self.id, self.1, owner.into_sub_cross_account::<T>()?));293 Ok(balance.into())294 }295286 /// @dev Function that changes total amount of the tokens.296 /// @dev Function that changes total amount of the tokens.287 /// Throws if `msg.sender` doesn't owns all of the tokens.297 /// Throws if `msg.sender` doesn't owns all of the tokens.pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth774}774}775775776/// @title Unique extensions for ERC721.776/// @title Unique extensions for ERC721.777/// @dev the ERC-165 identifier for this interface is 0xb365c124777/// @dev the ERC-165 identifier for this interface is 0x95c0f66c778contract ERC721UniqueExtensions is Dummy, ERC165 {778contract ERC721UniqueExtensions is Dummy, ERC165 {779 /// @notice A descriptive name for a collection of NFTs in this contract779 /// @notice A descriptive name for a collection of NFTs in this contract780 /// @dev EVM selector for this function is: 0x06fdde03,780 /// @dev EVM selector for this function is: 0x06fdde03,803 return "";803 return "";804 }804 }805806 // /// Returns the owner (in cross format) of the token.807 // ///808 // /// @param tokenId Id for the token.809 // /// @dev EVM selector for this function is: 0x2b29dace,810 // /// or in textual repr: crossOwnerOf(uint256)811 // function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {812 // require(false, stub_error);813 // tokenId;814 // dummy;815 // return CrossAddress(0x0000000000000000000000000000000000000000,0);816 // }805817806 /// Returns the owner (in cross format) of the token.818 /// Returns the owner (in cross format) of the token.807 ///819 ///808 /// @param tokenId Id for the token.820 /// @param tokenId Id for the token.809 /// @dev EVM selector for this function is: 0x2b29dace,821 /// @dev EVM selector for this function is: 0xcaa3a4d0,810 /// or in textual repr: crossOwnerOf(uint256)822 /// or in textual repr: ownerOfCross(uint256)811 function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {823 function ownerOfCross(uint256 tokenId) public view returns (CrossAddress memory) {812 require(false, stub_error);824 require(false, stub_error);813 tokenId;825 tokenId;814 dummy;826 dummy;815 return CrossAddress(0x0000000000000000000000000000000000000000, 0);827 return CrossAddress(0x0000000000000000000000000000000000000000, 0);816 }828 }829830 /// @notice Count all RFTs assigned to an owner831 /// @param owner An cross address for whom to query the balance832 /// @return The number of RFTs owned by `owner`, possibly zero833 /// @dev EVM selector for this function is: 0xec069398,834 /// or in textual repr: balanceOfCross((address,uint256))835 function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {836 require(false, stub_error);837 owner;838 dummy;839 return 0;840 }817841818 /// Returns the token properties.842 /// Returns the token properties.819 ///843 ///pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth36 }36 }37}37}383839/// @dev the ERC-165 identifier for this interface is 0x01d536fc39/// @dev the ERC-165 identifier for this interface is 0xedd3a56440contract ERC20UniqueExtensions is Dummy, ERC165 {40contract ERC20UniqueExtensions is Dummy, ERC165 {41 /// @dev Function to check the amount of tokens that an owner allowed to a spender.41 /// @dev Function to check the amount of tokens that an owner allowed to a spender.42 /// @param owner crossAddress The address which owns the funds.42 /// @param owner crossAddress The address which owns the funds.97 return false;97 return false;98 }98 }99100 /// @notice Balance of account101 /// @param owner An cross address for whom to query the balance102 /// @return The number of fingibles owned by `owner`, possibly zero103 /// @dev EVM selector for this function is: 0xec069398,104 /// or in textual repr: balanceOfCross((address,uint256))105 function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {106 require(false, stub_error);107 owner;108 dummy;109 return 0;110 }99111100 /// @dev Function that changes total amount of the tokens.112 /// @dev Function that changes total amount of the tokens.101 /// Throws if `msg.sender` doesn't owns all of the tokens.113 /// Throws if `msg.sender` doesn't owns all of the tokens.runtime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth227 | Symbol227 | Symbol228 | Description228 | Description229 | CrossOwnerOf { .. }229 | CrossOwnerOf { .. }230 | OwnerOfCross { .. }231 | BalanceOfCross { .. }230 | Properties { .. }232 | Properties { .. }231 | NextTokenId233 | NextTokenId232 | TokenContractAddress { .. }234 | TokenContractAddress { .. }341 ERC165Call(_, _) => None,343 ERC165Call(_, _) => None,342344343 // Not sponsored345 // Not sponsored344 AllowanceCross { .. } | BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => {346 AllowanceCross { .. }347 | BalanceOfCross { .. }348 | BurnFrom { .. }349 | BurnFromCross { .. }345 None350 | Repartition { .. } => None,346 }347351348 TransferCross { .. } | TransferFromCross { .. } => {352 TransferCross { .. } | TransferFromCross { .. } => {349 let RefungibleTokenHandle(handle, token_id) = token;353 let RefungibleTokenHandle(handle, token_id) = token;tests/src/eth/abi/fungible.jsondiffbeforeafterboth173 "stateMutability": "view",173 "stateMutability": "view",174 "type": "function"174 "type": "function"175 },175 },176 {177 "inputs": [178 {179 "components": [180 { "internalType": "address", "name": "eth", "type": "address" },181 { "internalType": "uint256", "name": "sub", "type": "uint256" }182 ],183 "internalType": "struct CrossAddress",184 "name": "owner",185 "type": "tuple"186 }187 ],188 "name": "balanceOfCross",189 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],190 "stateMutability": "view",191 "type": "function"192 },176 {193 {177 "inputs": [194 "inputs": [178 {195 {tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth175 "stateMutability": "view",175 "stateMutability": "view",176 "type": "function"176 "type": "function"177 },177 },178 {179 "inputs": [180 {181 "components": [182 { "internalType": "address", "name": "eth", "type": "address" },183 { "internalType": "uint256", "name": "sub", "type": "uint256" }184 ],185 "internalType": "struct CrossAddress",186 "name": "owner",187 "type": "tuple"188 }189 ],190 "name": "balanceOfCross",191 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],192 "stateMutability": "view",193 "type": "function"194 },178 {195 {179 "inputs": [196 "inputs": [180 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }197 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }384 "stateMutability": "view",401 "stateMutability": "view",385 "type": "function"402 "type": "function"386 },403 },387 {388 "inputs": [389 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }390 ],391 "name": "crossOwnerOf",392 "outputs": [393 {394 "components": [395 { "internalType": "address", "name": "eth", "type": "address" },396 { "internalType": "uint256", "name": "sub", "type": "uint256" }397 ],398 "internalType": "struct CrossAddress",399 "name": "",400 "type": "tuple"401 }402 ],403 "stateMutability": "view",404 "type": "function"405 },406 {404 {407 "inputs": [405 "inputs": [408 { "internalType": "string[]", "name": "keys", "type": "string[]" }406 { "internalType": "string[]", "name": "keys", "type": "string[]" }538 "stateMutability": "view",536 "stateMutability": "view",539 "type": "function"537 "type": "function"540 },538 },539 {540 "inputs": [541 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }542 ],543 "name": "ownerOfCross",544 "outputs": [545 {546 "components": [547 { "internalType": "address", "name": "eth", "type": "address" },548 { "internalType": "uint256", "name": "sub", "type": "uint256" }549 ],550 "internalType": "struct CrossAddress",551 "name": "",552 "type": "tuple"553 }554 ],555 "stateMutability": "view",556 "type": "function"557 },541 {558 {542 "inputs": [559 "inputs": [543 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },560 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },tests/src/eth/abi/reFungible.jsondiffbeforeafterboth157 "stateMutability": "view",157 "stateMutability": "view",158 "type": "function"158 "type": "function"159 },159 },160 {161 "inputs": [162 {163 "components": [164 { "internalType": "address", "name": "eth", "type": "address" },165 { "internalType": "uint256", "name": "sub", "type": "uint256" }166 ],167 "internalType": "struct CrossAddress",168 "name": "owner",169 "type": "tuple"170 }171 ],172 "name": "balanceOfCross",173 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],174 "stateMutability": "view",175 "type": "function"176 },160 {177 {161 "inputs": [178 "inputs": [162 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }179 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }366 "stateMutability": "view",383 "stateMutability": "view",367 "type": "function"384 "type": "function"368 },385 },369 {370 "inputs": [371 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }372 ],373 "name": "crossOwnerOf",374 "outputs": [375 {376 "components": [377 { "internalType": "address", "name": "eth", "type": "address" },378 { "internalType": "uint256", "name": "sub", "type": "uint256" }379 ],380 "internalType": "struct CrossAddress",381 "name": "",382 "type": "tuple"383 }384 ],385 "stateMutability": "view",386 "type": "function"387 },388 {386 {389 "inputs": [387 "inputs": [390 { "internalType": "string[]", "name": "keys", "type": "string[]" }388 { "internalType": "string[]", "name": "keys", "type": "string[]" }520 "stateMutability": "view",518 "stateMutability": "view",521 "type": "function"519 "type": "function"522 },520 },521 {522 "inputs": [523 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }524 ],525 "name": "ownerOfCross",526 "outputs": [527 {528 "components": [529 { "internalType": "address", "name": "eth", "type": "address" },530 { "internalType": "uint256", "name": "sub", "type": "uint256" }531 ],532 "internalType": "struct CrossAddress",533 "name": "",534 "type": "tuple"535 }536 ],537 "stateMutability": "view",538 "type": "function"539 },523 {540 {524 "inputs": [541 "inputs": [525 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },542 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },tests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth122 "stateMutability": "view",122 "stateMutability": "view",123 "type": "function"123 "type": "function"124 },124 },125 {126 "inputs": [127 {128 "components": [129 { "internalType": "address", "name": "eth", "type": "address" },130 { "internalType": "uint256", "name": "sub", "type": "uint256" }131 ],132 "internalType": "struct CrossAddress",133 "name": "owner",134 "type": "tuple"135 }136 ],137 "name": "balanceOfCross",138 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],139 "stateMutability": "view",140 "type": "function"141 },125 {142 {126 "inputs": [143 "inputs": [127 {144 {tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth353 bytes value;353 bytes value;354}354}355355356/// @dev the ERC-165 identifier for this interface is 0x85d7dea6356/// @dev the ERC-165 identifier for this interface is 0x69d14d3e357interface ERC20UniqueExtensions is Dummy, ERC165 {357interface ERC20UniqueExtensions is Dummy, ERC165 {358 /// @dev Function to check the amount of tokens that an owner allowed to a spender.358 /// @dev Function to check the amount of tokens that an owner allowed to a spender.359 /// @param owner crossAddress The address which owns the funds.359 /// @param owner crossAddress The address which owns the funds.417 /// or in textual repr: collectionHelperAddress()417 /// or in textual repr: collectionHelperAddress()418 function collectionHelperAddress() external view returns (address);418 function collectionHelperAddress() external view returns (address);419420 /// @notice Balance of account421 /// @param owner An cross address for whom to query the balance422 /// @return The number of fingibles owned by `owner`, possibly zero423 /// @dev EVM selector for this function is: 0xec069398,424 /// or in textual repr: balanceOfCross((address,uint256))425 function balanceOfCross(CrossAddress memory owner) external view returns (uint256);419}426}420427421struct AmountForAddress {428struct AmountForAddress {tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth533}533}534534535/// @title Unique extensions for ERC721.535/// @title Unique extensions for ERC721.536/// @dev the ERC-165 identifier for this interface is 0x16de3152536/// @dev the ERC-165 identifier for this interface is 0x307b061a537interface ERC721UniqueExtensions is Dummy, ERC165 {537interface ERC721UniqueExtensions is Dummy, ERC165 {538 /// @notice A descriptive name for a collection of NFTs in this contract538 /// @notice A descriptive name for a collection of NFTs in this contract539 /// @dev EVM selector for this function is: 0x06fdde03,539 /// @dev EVM selector for this function is: 0x06fdde03,550 /// or in textual repr: description()550 /// or in textual repr: description()551 function description() external view returns (string memory);551 function description() external view returns (string memory);552553 // /// Returns the owner (in cross format) of the token.554 // ///555 // /// @param tokenId Id for the token.556 // /// @dev EVM selector for this function is: 0x2b29dace,557 // /// or in textual repr: crossOwnerOf(uint256)558 // function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);552559553 /// Returns the owner (in cross format) of the token.560 /// Returns the owner (in cross format) of the token.554 ///561 ///555 /// @param tokenId Id for the token.562 /// @param tokenId Id for the token.556 /// @dev EVM selector for this function is: 0x2b29dace,563 /// @dev EVM selector for this function is: 0xcaa3a4d0,557 /// or in textual repr: crossOwnerOf(uint256)564 /// or in textual repr: ownerOfCross(uint256)558 function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);565 function ownerOfCross(uint256 tokenId) external view returns (CrossAddress memory);566567 /// @notice Count all NFTs assigned to an owner568 /// @param owner An cross address for whom to query the balance569 /// @return The number of NFTs owned by `owner`, possibly zero570 /// @dev EVM selector for this function is: 0xec069398,571 /// or in textual repr: balanceOfCross((address,uint256))572 function balanceOfCross(CrossAddress memory owner) external view returns (uint256);559573560 /// Returns the token properties.574 /// Returns the token properties.561 ///575 ///tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth533}533}534534535/// @title Unique extensions for ERC721.535/// @title Unique extensions for ERC721.536/// @dev the ERC-165 identifier for this interface is 0xb365c124536/// @dev the ERC-165 identifier for this interface is 0x95c0f66c537interface ERC721UniqueExtensions is Dummy, ERC165 {537interface ERC721UniqueExtensions is Dummy, ERC165 {538 /// @notice A descriptive name for a collection of NFTs in this contract538 /// @notice A descriptive name for a collection of NFTs in this contract539 /// @dev EVM selector for this function is: 0x06fdde03,539 /// @dev EVM selector for this function is: 0x06fdde03,550 /// or in textual repr: description()550 /// or in textual repr: description()551 function description() external view returns (string memory);551 function description() external view returns (string memory);552553 // /// Returns the owner (in cross format) of the token.554 // ///555 // /// @param tokenId Id for the token.556 // /// @dev EVM selector for this function is: 0x2b29dace,557 // /// or in textual repr: crossOwnerOf(uint256)558 // function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);552559553 /// Returns the owner (in cross format) of the token.560 /// Returns the owner (in cross format) of the token.554 ///561 ///555 /// @param tokenId Id for the token.562 /// @param tokenId Id for the token.556 /// @dev EVM selector for this function is: 0x2b29dace,563 /// @dev EVM selector for this function is: 0xcaa3a4d0,557 /// or in textual repr: crossOwnerOf(uint256)564 /// or in textual repr: ownerOfCross(uint256)558 function crossOwnerOf(uint256 tokenId) external view returns (CrossAddress memory);565 function ownerOfCross(uint256 tokenId) external view returns (CrossAddress memory);566567 /// @notice Count all RFTs assigned to an owner568 /// @param owner An cross address for whom to query the balance569 /// @return The number of RFTs owned by `owner`, possibly zero570 /// @dev EVM selector for this function is: 0xec069398,571 /// or in textual repr: balanceOfCross((address,uint256))572 function balanceOfCross(CrossAddress memory owner) external view returns (uint256);559573560 /// Returns the token properties.574 /// Returns the token properties.561 ///575 ///tests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth23 function parentTokenId() external view returns (uint256);23 function parentTokenId() external view returns (uint256);24}24}252526/// @dev the ERC-165 identifier for this interface is 0x01d536fc26/// @dev the ERC-165 identifier for this interface is 0xedd3a56427interface ERC20UniqueExtensions is Dummy, ERC165 {27interface ERC20UniqueExtensions is Dummy, ERC165 {28 /// @dev Function to check the amount of tokens that an owner allowed to a spender.28 /// @dev Function to check the amount of tokens that an owner allowed to a spender.29 /// @param owner crossAddress The address which owns the funds.29 /// @param owner crossAddress The address which owns the funds.60 /// or in textual repr: approveCross((address,uint256),uint256)60 /// or in textual repr: approveCross((address,uint256),uint256)61 function approveCross(CrossAddress memory spender, uint256 amount) external returns (bool);61 function approveCross(CrossAddress memory spender, uint256 amount) external returns (bool);6263 /// @notice Balance of account64 /// @param owner An cross address for whom to query the balance65 /// @return The number of fingibles owned by `owner`, possibly zero66 /// @dev EVM selector for this function is: 0xec069398,67 /// or in textual repr: balanceOfCross((address,uint256))68 function balanceOfCross(CrossAddress memory owner) external view returns (uint256);626963 /// @dev Function that changes total amount of the tokens.70 /// @dev Function that changes total amount of the tokens.64 /// Throws if `msg.sender` doesn't owns all of the tokens.71 /// Throws if `msg.sender` doesn't owns all of the tokens.tests/src/eth/fungible.test.tsdiffbeforeafterboth428 expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);428 expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);429 });429 });430431 itEth('Check balanceOfCross()', async ({helper}) => {432 const collection = await helper.ft.mintCollection(alice, {});433 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);434 const other = await helper.ethCrossAccount.createAccountWithBalance(donor);435 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);436 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner.eth);437438 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('0');439 expect(await collectionEvm.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('0');440441 await collection.mint(alice, 100n, {Ethereum: owner.eth});442 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('100');443 expect(await collectionEvm.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('0');444445 await collectionEvm.methods.transferCross(other, 50n).send({from: owner.eth});446 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('50');447 expect(await collectionEvm.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('50');448449 await collectionEvm.methods.transferCross(other, 50n).send({from: owner.eth});450 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('0');451 expect(await collectionEvm.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('100');452453 await collectionEvm.methods.transferCross(owner, 100n).send({from: other.eth});454 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('100');455 expect(await collectionEvm.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('0');456 });430});457});431458432describe('Fungible: Fees', () => {459describe('Fungible: Fees', () => {tests/src/eth/nonFungible.test.tsdiffbeforeafterboth663 await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;663 await expect(collectionEvm.methods[testCase](receiver, 999999).send({from: sender})).to.be.rejected;664 }));664 }));665666 itEth('Check balanceOfCross()', async ({helper}) => {667 const collection = await helper.nft.mintCollection(minter, {});668 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);669 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);670 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);671672 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('0');673674 for (let i = 1; i < 10; i++) {675 await collection.mintToken(minter, {Ethereum: owner.eth});676 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq(i.toString());677 }678 });679680 itEth('Check ownerOfCross()', async ({helper}) => {681 const collection = await helper.nft.mintCollection(minter, {});682 let owner = await helper.ethCrossAccount.createAccountWithBalance(donor);683 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);684 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);685 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner.eth});686687 for (let i = 1n; i < 10n; i++) {688 const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});689 expect(ownerCross.eth).to.be.eq(owner.eth);690 expect(ownerCross.sub).to.be.eq(owner.sub);691692 const newOwner = await helper.ethCrossAccount.createAccountWithBalance(donor);693 await collectionEvm.methods.transferCross(newOwner, tokenId).send({from: owner.eth});694 owner = newOwner;695 }696 });665});697});666698667describe('NFT: Fees', () => {699describe('NFT: Fees', () => {tests/src/eth/reFungible.test.tsdiffbeforeafterboth585 expect(event.returnValues.tokenId).to.equal(tokenId.toString());585 expect(event.returnValues.tokenId).to.equal(tokenId.toString());586 });586 });587588 itEth('Check balanceOfCross()', async ({helper}) => {589 const collection = await helper.rft.mintCollection(minter, {});590 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);591 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);592 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);593594 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('0');595596 for (let i = 1n; i < 10n; i++) {597 await collection.mintToken(minter, 100n, {Ethereum: owner.eth});598 expect(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq(i.toString());599 }600 });601602 itEth('Check ownerOfCross()', async ({helper}) => {603 const collection = await helper.rft.mintCollection(minter, {});604 let owner = await helper.ethCrossAccount.createAccountWithBalance(donor);605 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);606 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner.eth);607 const {tokenId} = await collection.mintToken(minter, 100n,{Ethereum: owner.eth});608609 for (let i = 1n; i < 10n; i++) {610 const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});611 expect(ownerCross.eth).to.be.eq(owner.eth);612 expect(ownerCross.sub).to.be.eq(owner.sub);613614 const newOwner = await helper.ethCrossAccount.createAccountWithBalance(donor);615 await collectionEvm.methods.transferCross(newOwner, tokenId).send({from: owner.eth});616 owner = newOwner;617 }618619 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);620 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, owner.eth, true);621 const newOwner = await helper.ethCrossAccount.createAccountWithBalance(donor);622 await tokenContract.methods.transferCross(newOwner, 50).send({from: owner.eth});623 const ownerCross = await collectionEvm.methods.ownerOfCross(tokenId).call({from: owner.eth});624 expect(ownerCross.eth.toUpperCase()).to.be.eq('0XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');625 expect(ownerCross.sub).to.be.eq('0');626 });587});627});588628589describe('RFT: Fees', () => {629describe('RFT: Fees', () => {tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth467 }467 }468 });468 });469470 itEth('Check balanceOfCross()', async ({helper}) => {471 const collection = await helper.rft.mintCollection(alice, {});472 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);473 const other = await helper.ethCrossAccount.createAccountWithBalance(donor);474 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner.eth});475 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);476 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, owner.eth);477478 expect(await tokenContract.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('200');479 expect(await tokenContract.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('0');480481 await tokenContract.methods.repartition(100n).send({from: owner.eth});482 expect(await tokenContract.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('100');483 expect(await tokenContract.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('0');484485 await tokenContract.methods.transferCross(other, 50n).send({from: owner.eth});486 expect(await tokenContract.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('50');487 expect(await tokenContract.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('50');488489 await tokenContract.methods.transferCross(other, 50n).send({from: owner.eth});490 expect(await tokenContract.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('0');491 expect(await tokenContract.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('100');492493 await tokenContract.methods.repartition(1000n).send({from: other.eth});494 await tokenContract.methods.transferCross(owner, 500n).send({from: other.eth});495 expect(await tokenContract.methods.balanceOfCross(owner).call({from: owner.eth})).to.be.eq('500');496 expect(await tokenContract.methods.balanceOfCross(other).call({from: owner.eth})).to.be.eq('500');497 });469});498});470499471describe('Refungible: Fees', () => {500describe('Refungible: Fees', () => {tests/src/eth/tokens/minting.test.tsdiffbeforeafterboth63 const tokenId = event.returnValues.tokenId;63 const tokenId = event.returnValues.tokenId;64 expect(tokenId).to.be.equal('1');64 expect(tokenId).to.be.equal('1');65 expect(await helper.collection.getLastTokenId(collection.collectionId)).to.eq(1);65 expect(await helper.collection.getLastTokenId(collection.collectionId)).to.eq(1);66 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);66 expect(await contract.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);67 }67 }68 });68 });69 });69 });97 const tokenId = event.returnValues.tokenId;97 const tokenId = event.returnValues.tokenId;98 expect(tokenId).to.be.equal('1');98 expect(tokenId).to.be.equal('1');99 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);99 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);100 expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);100 expect(await collection.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);101 }101 }102 });102 });103 });103 });131 const tokenId = event.returnValues.tokenId;131 const tokenId = event.returnValues.tokenId;132 expect(tokenId).to.be.equal('1');132 expect(tokenId).to.be.equal('1');133 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);133 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);134 expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);134 expect(await collection.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);135 }135 }136 });136 });137 });137 });157 expect(event.returnValues.to).to.be.equal(receiver);157 expect(event.returnValues.to).to.be.equal(receiver);158158159 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');159 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');160 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);160 expect(await contract.methods.ownerOfCross(tokenId).call()).to.be.like([receiver, '0']);161 // TODO: this wont work right now, need release 919000 first161 // TODO: this wont work right now, need release 919000 first162 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();162 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();163 // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();163 // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();