difftreelog
feat add allowanceCross method
in: master
22 files changed
Cargo.lockdiffbeforeafterboth636063606361[[package]]6361[[package]]6362name = "pallet-fungible"6362name = "pallet-fungible"6363version = "0.1.9"6363version = "0.1.10"6364dependencies = [6364dependencies = [6365 "evm-coder",6365 "evm-coder",6366 "frame-benchmarking",6366 "frame-benchmarking",677367736774[[package]]6774[[package]]6775name = "pallet-refungible"6775name = "pallet-refungible"6776version = "0.2.12"6776version = "0.2.13"6777dependencies = [6777dependencies = [6778 "evm-coder",6778 "evm-coder",6779 "frame-benchmarking",6779 "frame-benchmarking",pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/CHANGELOG.mddiffbeforeafterboth445<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->667## [0.1.10] - 2023-02-0189### Added1011- The functions `allowanceCross` to `ERC20UniqueExtensions` interface.127## [0.1.9] - 2022-12-0113## [0.1.9] - 2022-12-018149### Added15### Addedpallets/fungible/Cargo.tomldiffbeforeafterboth2edition = "2021"2edition = "2021"3license = "GPLv3"3license = "GPLv3"4name = "pallet-fungible"4name = "pallet-fungible"5version = "0.1.9"5version = "0.1.10"667[dependencies]7[dependencies]8# Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.8# Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.pallets/fungible/src/erc.rsdiffbeforeafterboth161where161where162 T::AccountId: From<[u8; 32]>,162 T::AccountId: From<[u8; 32]>,163{163{164 /// @dev Function to check the amount of tokens that an owner allowed to a spender.165 /// @param owner crossAddress The address which owns the funds.166 /// @param spender crossAddress The address which will spend the funds.167 /// @return A uint256 specifying the amount of tokens still available for the spender.168 fn allowance_cross(169 &self,170 owner: pallet_common::eth::CrossAddress,171 spender: pallet_common::eth::CrossAddress,172 ) -> Result<U256> {173 let owner = owner.into_sub_cross_account::<T>()?;174 let spender = spender.into_sub_cross_account::<T>()?;175176 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())177 }178164 /// @notice A description for the collection.179 /// @notice A description for the collection.165 fn description(&self) -> Result<String> {180 fn description(&self) -> Result<String> {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 0x65789571514/// @dev the ERC-165 identifier for this interface is 0x85d7dea6515contract 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.517 /// @param owner crossAddress The address which owns the funds.518 /// @param spender crossAddress The address which will spend the funds.519 /// @return A uint256 specifying the amount of tokens still available for the spender.520 /// @dev EVM selector for this function is: 0xe0af4bd7,521 /// or in textual repr: allowanceCross((address,uint256),(address,uint256))522 function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) public view returns (uint256) {523 require(false, stub_error);524 owner;525 spender;526 dummy;527 return 0;528 }529516 /// @notice A description for the collection.530 /// @notice A description for the collection.517 /// @dev EVM selector for this function is: 0x7284e416,531 /// @dev EVM selector for this function is: 0x7284e416,576 /// @param amounts array of pairs of account address and amount590 /// @param amounts array of pairs of account address and amount577 /// @dev EVM selector for this function is: 0x1acf2d55,591 /// @dev EVM selector for this function is: 0x1acf2d55,578 /// or in textual repr: mintBulk((address,uint256)[])592 /// or in textual repr: mintBulk((address,uint256)[])579 function mintBulk(Tuple9[] memory amounts) public returns (bool) {593 function mintBulk(Tuple11[] memory amounts) public returns (bool) {580 require(false, stub_error);594 require(false, stub_error);581 amounts;595 amounts;582 dummy = 0;596 dummy = 0;619}633}620634621/// @dev anonymous struct635/// @dev anonymous struct622struct Tuple9 {636struct Tuple11 {623 address field_0;637 address field_0;624 uint256 field_1;638 uint256 field_1;625}639}pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/CHANGELOG.mddiffbeforeafterboth445<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->667## [0.2.13] - 2023-02-0189### Added1011- The functions `allowanceCross` to `ERC20UniqueExtensions` interface.127## [0.2.12] - 2023-01-2013## [0.2.12] - 2023-01-208149### Fixed15### Fixedpallets/refungible/Cargo.tomldiffbeforeafterboth2edition = "2021"2edition = "2021"3license = "GPLv3"3license = "GPLv3"4name = "pallet-refungible"4name = "pallet-refungible"5version = "0.2.12"5version = "0.2.13"667[dependencies]7[dependencies]8# Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.8# Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.pallets/refungible/src/erc_token.rsdiffbeforeafterboth203where203where204 T::AccountId: From<[u8; 32]>,204 T::AccountId: From<[u8; 32]>,205{205{206 /// @dev Function to check the amount of tokens that an owner allowed to a spender.207 /// @param owner crossAddress The address which owns the funds.208 /// @param spender crossAddress The address which will spend the funds.209 /// @return A uint256 specifying the amount of tokens still available for the spender.210 fn allowance_cross(211 &self,212 owner: pallet_common::eth::CrossAddress,213 spender: pallet_common::eth::CrossAddress,214 ) -> Result<U256> {215 let owner = owner.into_sub_cross_account::<T>()?;216 let spender = spender.into_sub_cross_account::<T>()?;217218 Ok(<Allowance<T>>::get((self.id, self.1, owner, spender)).into())219 }220206 /// @dev Function that burns an amount of the token of a given account,221 /// @dev Function that burns an amount of the token of a given account,207 /// deducting from the sender's allowance for said account.222 /// deducting from the sender's allowance for said account.pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
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 0xe17a7d2b39/// @dev the ERC-165 identifier for this interface is 0x01d536fc40contract 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.42 /// @param owner crossAddress The address which owns the funds.43 /// @param spender crossAddress The address which will spend the funds.44 /// @return A uint256 specifying the amount of tokens still available for the spender.45 /// @dev EVM selector for this function is: 0xe0af4bd7,46 /// or in textual repr: allowanceCross((address,uint256),(address,uint256))47 function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) public view returns (uint256) {48 require(false, stub_error);49 owner;50 spender;51 dummy;52 return 0;53 }5441 // /// @dev Function that burns an amount of the token of a given account,55 // /// @dev Function that burns an amount of the token of a given account,42 // /// deducting from the sender's allowance for said account.56 // /// deducting from the sender's allowance for said account.pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
runtime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth341 ERC165Call(_, _) => None,341 ERC165Call(_, _) => None,342342343 // Not sponsored343 // Not sponsored344 BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => None,344 AllowanceCross { .. } | BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => {345 None346 }345347346 TransferCross { .. } | TransferFromCross { .. } => {348 TransferCross { .. } | TransferFromCross { .. } => {347 let RefungibleTokenHandle(handle, token_id) = token;349 let RefungibleTokenHandle(handle, token_id) = token;tests/src/eth/abi/fungible.jsondiffbeforeafterboth93 "stateMutability": "view",93 "stateMutability": "view",94 "type": "function"94 "type": "function"95 },95 },96 {97 "inputs": [98 {99 "components": [100 { "internalType": "address", "name": "eth", "type": "address" },101 { "internalType": "uint256", "name": "sub", "type": "uint256" }102 ],103 "internalType": "struct CrossAddress",104 "name": "owner",105 "type": "tuple"106 },107 {108 "components": [109 { "internalType": "address", "name": "eth", "type": "address" },110 { "internalType": "uint256", "name": "sub", "type": "uint256" }111 ],112 "internalType": "struct CrossAddress",113 "name": "spender",114 "type": "tuple"115 }116 ],117 "name": "allowanceCross",118 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],119 "stateMutability": "view",120 "type": "function"121 },96 {122 {97 "inputs": [123 "inputs": [98 {124 {411 { "internalType": "address", "name": "field_0", "type": "address" },437 { "internalType": "address", "name": "field_0", "type": "address" },412 { "internalType": "uint256", "name": "field_1", "type": "uint256" }438 { "internalType": "uint256", "name": "field_1", "type": "uint256" }413 ],439 ],414 "internalType": "struct Tuple9[]",440 "internalType": "struct Tuple11[]",415 "name": "amounts",441 "name": "amounts",416 "type": "tuple[]"442 "type": "tuple[]"417 }443 }tests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth59 "stateMutability": "view",59 "stateMutability": "view",60 "type": "function"60 "type": "function"61 },61 },62 {63 "inputs": [64 {65 "components": [66 { "internalType": "address", "name": "eth", "type": "address" },67 { "internalType": "uint256", "name": "sub", "type": "uint256" }68 ],69 "internalType": "struct CrossAddress",70 "name": "owner",71 "type": "tuple"72 },73 {74 "components": [75 { "internalType": "address", "name": "eth", "type": "address" },76 { "internalType": "uint256", "name": "sub", "type": "uint256" }77 ],78 "internalType": "struct CrossAddress",79 "name": "spender",80 "type": "tuple"81 }82 ],83 "name": "allowanceCross",84 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],85 "stateMutability": "view",86 "type": "function"87 },62 {88 {63 "inputs": [89 "inputs": [64 { "internalType": "address", "name": "spender", "type": "address" },90 { "internalType": "address", "name": "spender", "type": "address" },tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth353 bytes value;353 bytes value;354}354}355355356/// @dev the ERC-165 identifier for this interface is 0x65789571356/// @dev the ERC-165 identifier for this interface is 0x85d7dea6357interface 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.359 /// @param owner crossAddress The address which owns the funds.360 /// @param spender crossAddress The address which will spend the funds.361 /// @return A uint256 specifying the amount of tokens still available for the spender.362 /// @dev EVM selector for this function is: 0xe0af4bd7,363 /// or in textual repr: allowanceCross((address,uint256),(address,uint256))364 function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) external view returns (uint256);365358 /// @notice A description for the collection.366 /// @notice A description for the collection.359 /// @dev EVM selector for this function is: 0x7284e416,367 /// @dev EVM selector for this function is: 0x7284e416,390 /// @param amounts array of pairs of account address and amount398 /// @param amounts array of pairs of account address and amount391 /// @dev EVM selector for this function is: 0x1acf2d55,399 /// @dev EVM selector for this function is: 0x1acf2d55,392 /// or in textual repr: mintBulk((address,uint256)[])400 /// or in textual repr: mintBulk((address,uint256)[])393 function mintBulk(Tuple9[] memory amounts) external returns (bool);401 function mintBulk(Tuple11[] memory amounts) external returns (bool);394402395 /// @dev EVM selector for this function is: 0x2ada85ff,403 /// @dev EVM selector for this function is: 0x2ada85ff,396 /// or in textual repr: transferCross((address,uint256),uint256)404 /// or in textual repr: transferCross((address,uint256),uint256)411}419}412420413/// @dev anonymous struct421/// @dev anonymous struct414struct Tuple9 {422struct Tuple11 {415 address field_0;423 address field_0;416 uint256 field_1;424 uint256 field_1;417}425}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 0xe17a7d2b26/// @dev the ERC-165 identifier for this interface is 0x01d536fc27interface 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.29 /// @param owner crossAddress The address which owns the funds.30 /// @param spender crossAddress The address which will spend the funds.31 /// @return A uint256 specifying the amount of tokens still available for the spender.32 /// @dev EVM selector for this function is: 0xe0af4bd7,33 /// or in textual repr: allowanceCross((address,uint256),(address,uint256))34 function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) external view returns (uint256);3528 // /// @dev Function that burns an amount of the token of a given account,36 // /// @dev Function that burns an amount of the token of a given account,29 // /// deducting from the sender's allowance for said account.37 // /// deducting from the sender's allowance for said account.tests/src/eth/fungible.test.tsdiffbeforeafterboth134 const allowance = await contract.methods.allowance(owner, spender).call();134 const allowance = await contract.methods.allowance(owner, spender).call();135 expect(+allowance).to.equal(100);135 expect(+allowance).to.equal(100);136 }136 }137 {138 const ownerCross = helper.ethCrossAccount.fromAddress(owner);139 const spenderCross = helper.ethCrossAccount.fromAddress(spender);140 const allowance = await contract.methods.allowanceCross(ownerCross, spenderCross).call();141 expect(+allowance).to.equal(100);142 }137 });143 });138144139 itEth('Can perform approveCross()', async ({helper}) => {145 itEth('Can perform approveCross()', async ({helper}) => {tests/src/eth/reFungible.test.tsdiffbeforeafterboth215215216 const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner, true);216 const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner, true);217217218 {218 {219 await rftToken.methods.approve(operator, 15n).send({from: owner});219 await rftToken.methods.approve(operator, 15n).send({from: owner});220 await contract.methods.setApprovalForAll(operator, true).send({from: owner});220 await contract.methods.setApprovalForAll(operator, true).send({from: owner});221 await rftToken.methods.burnFrom(owner, 10n).send({from: operator});221 await rftToken.methods.burnFrom(owner, 10n).send({from: operator});222 }223 {222 const allowance = await rftToken.methods.allowance(owner, operator).call();224 const allowance = await rftToken.methods.allowance(owner, operator).call();223 expect(allowance).to.be.equal('5');225 expect(+allowance).to.be.equal(5);224 }226 }227 {228 const ownerCross = helper.ethCrossAccount.fromAddress(owner);229 const operatorCross = helper.ethCrossAccount.fromAddress(operator);230 const allowance = await rftToken.methods.allowanceCross(ownerCross, operatorCross).call();231 expect(+allowance).to.equal(5);232 }225 });233 });226234227 itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {235 itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {