difftreelog
feat balanceOfCross for fingible
in: master
8 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 {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/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/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 collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);435 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner.eth);436437 expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === 0n).to.be.true;438439 let sum = 0n;440 for (let i = 1n; i < 100n; i++) {441 await collection.mint(alice, 100n, {Ethereum: owner.eth});442 sum += 100n;443 expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === sum).to.be.true;444 }445 });430});446});431447432describe('Fungible: Fees', () => {448describe('Fungible: 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 });587587588 itEth('Check crossBalanceOf()', async ({helper}) => {588 itEth('Check balanceOfCross()', async ({helper}) => {589 const collection = await helper.rft.mintCollection(minter, {});589 const collection = await helper.rft.mintCollection(minter, {});590 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);590 const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);591 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);591 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);tests/src/eth/tokens/minting.test.tsdiffbeforeafterboth19import {expect, itEth, usingEthPlaygrounds} from '../util';19import {expect, itEth, usingEthPlaygrounds} from '../util';2020212122describe.only('Minting tokens', () => {22describe('Minting tokens', () => {23 let donor: IKeyringPair;23 let donor: IKeyringPair;24 let alice: IKeyringPair;24 let alice: IKeyringPair;2525