difftreelog
feat balanceOfCross for RFT token
in: master
7 files changed
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/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.rsdiffbeforeafterboth343 ERC165Call(_, _) => None,343 ERC165Call(_, _) => None,344344345 // Not sponsored345 // Not sponsored346 AllowanceCross { .. } | BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => {346 AllowanceCross { .. }347 | BalanceOfCross { .. }348 | BurnFrom { .. }349 | BurnFromCross { .. }347 None350 | Repartition { .. } => None,348 }349351350 TransferCross { .. } | TransferFromCross { .. } => {352 TransferCross { .. } | TransferFromCross { .. } => {351 let RefungibleTokenHandle(handle, token_id) = token;353 let RefungibleTokenHandle(handle, token_id) = token;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/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/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 {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner.eth});474 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);475 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, owner.eth);476477 expect(BigInt(await tokenContract.methods.balanceOfCross(owner).call({from: owner.eth})) === 200n).to.be.true;478479 for (let i = 1n; i < 100n; i++) {480 await tokenContract.methods.repartition(i).send({from: owner.eth});481 expect(BigInt(await tokenContract.methods.balanceOfCross(owner).call({from: owner.eth})) === i).to.be.true;482 }483 });469});484});470485471describe('Refungible: Fees', () => {486describe('Refungible: Fees', () => {