git.delta.rocks / unique-network / refs/commits / e0f86c78a536

difftreelog

feat add allowanceCross method

Trubnikov Sergey2023-02-01parent: #0ba1adb.patch.diff
in: master

22 files changed

modifiedCargo.lockdiffbeforeafterboth
63606360
6361[[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",
67736773
6774[[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",
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/CHANGELOG.mddiffbeforeafterboth
44
5<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->
66
7## [0.1.10] - 2023-02-01
8
9### Added
10
11- The functions `allowanceCross` to `ERC20UniqueExtensions` interface.
12
7## [0.1.9] - 2022-12-0113## [0.1.9] - 2022-12-01
814
9### Added15### Added
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
2edition = "2021"2edition = "2021"
3license = "GPLv3"3license = "GPLv3"
4name = "pallet-fungible"4name = "pallet-fungible"
5version = "0.1.9"5version = "0.1.10"
66
7[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.
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
161where161where
162 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>()?;
175
176 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())
177 }
178
164 /// @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> {
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
511 bytes value;511 bytes value;
512}512}
513513
514/// @dev the ERC-165 identifier for this interface is 0x65789571514/// @dev the ERC-165 identifier for this interface is 0x85d7dea6
515contract 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 }
529
516 /// @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 amount
577 /// @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}
620634
621/// @dev anonymous struct635/// @dev anonymous struct
622struct Tuple9 {636struct Tuple11 {
623 address field_0;637 address field_0;
624 uint256 field_1;638 uint256 field_1;
625}639}
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/CHANGELOG.mddiffbeforeafterboth
44
5<!-- bureaucrate goes here -->5<!-- bureaucrate goes here -->
66
7## [0.2.13] - 2023-02-01
8
9### Added
10
11- The functions `allowanceCross` to `ERC20UniqueExtensions` interface.
12
7## [0.2.12] - 2023-01-2013## [0.2.12] - 2023-01-20
814
9### Fixed15### Fixed
modifiedpallets/refungible/Cargo.tomldiffbeforeafterboth
2edition = "2021"2edition = "2021"
3license = "GPLv3"3license = "GPLv3"
4name = "pallet-refungible"4name = "pallet-refungible"
5version = "0.2.12"5version = "0.2.13"
66
7[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.
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
203where203where
204 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>()?;
217
218 Ok(<Allowance<T>>::get((self.id, self.1, owner, spender)).into())
219 }
220
206 /// @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.
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth
36 }36 }
37}37}
3838
39/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b39/// @dev the ERC-165 identifier for this interface is 0x01d536fc
40contract 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 }
54
41 // /// @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.
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedruntime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth
341 ERC165Call(_, _) => None,341 ERC165Call(_, _) => None,
342342
343 // Not sponsored343 // Not sponsored
344 BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => None,344 AllowanceCross { .. } | BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => {
345 None
346 }
345347
346 TransferCross { .. } | TransferFromCross { .. } => {348 TransferCross { .. } | TransferFromCross { .. } => {
347 let RefungibleTokenHandle(handle, token_id) = token;349 let RefungibleTokenHandle(handle, token_id) = token;
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
93 "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 }
modifiedtests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth
59 "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" },
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
353 bytes value;353 bytes value;
354}354}
355355
356/// @dev the ERC-165 identifier for this interface is 0x65789571356/// @dev the ERC-165 identifier for this interface is 0x85d7dea6
357interface 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);
365
358 /// @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 amount
391 /// @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);
394402
395 /// @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}
412420
413/// @dev anonymous struct421/// @dev anonymous struct
414struct Tuple9 {422struct Tuple11 {
415 address field_0;423 address field_0;
416 uint256 field_1;424 uint256 field_1;
417}425}
modifiedtests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth
23 function parentTokenId() external view returns (uint256);23 function parentTokenId() external view returns (uint256);
24}24}
2525
26/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b26/// @dev the ERC-165 identifier for this interface is 0x01d536fc
27interface 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);
35
28 // /// @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.
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
134 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 });
138144
139 itEth('Can perform approveCross()', async ({helper}) => {145 itEth('Can perform approveCross()', async ({helper}) => {
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
215215
216 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);
217217
218 {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 });
226234
227 itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {235 itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {