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

difftreelog

Merge branch 'develop' into tests/generalization

Max Andreev2023-01-24parents: #8cb9477 #35f818f.patch.diff
in: master

30 files changed

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
57 },57 },
58}58}
5959
60#[solidity_interface(name = ERC20, events(ERC20Events))]60#[solidity_interface(name = ERC20, events(ERC20Events), expect_selector = 0x942e8b22)]
61impl<T: Config> FungibleHandle<T> {61impl<T: Config> FungibleHandle<T> {
62 fn name(&self) -> Result<String> {62 fn name(&self) -> Result<String> {
63 Ok(decode_utf16(self.name.iter().copied())63 Ok(decode_utf16(self.name.iter().copied())
136 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())136 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())
137 }137 }
138
139 /// @notice Returns collection helper contract address
140 fn collection_helper_address(&self) -> Result<Address> {
141 Ok(T::ContractAddress::get())
142 }
143}138}
144139
145#[solidity_interface(name = ERC20Mintable)]140#[solidity_interface(name = ERC20Mintable)]
313 Ok(true)308 Ok(true)
314 }309 }
310
311 /// @notice Returns collection helper contract address
312 fn collection_helper_address(&self) -> Result<Address> {
313 Ok(T::ContractAddress::get())
314 }
315}315}
316316
317#[solidity_interface(317#[solidity_interface(
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 0x7dee5997514/// @dev the ERC-165 identifier for this interface is 0x65789571
515contract ERC20UniqueExtensions is Dummy, ERC165 {515contract ERC20UniqueExtensions is Dummy, ERC165 {
516 /// @notice A description for the collection.516 /// @notice A description for the collection.
517 /// @dev EVM selector for this function is: 0x7284e416,517 /// @dev EVM selector for this function is: 0x7284e416,
608 return false;608 return false;
609 }609 }
610
611 /// @notice Returns collection helper contract address
612 /// @dev EVM selector for this function is: 0x1896cce6,
613 /// or in textual repr: collectionHelperAddress()
614 function collectionHelperAddress() public view returns (address) {
615 require(false, stub_error);
616 dummy;
617 return 0x0000000000000000000000000000000000000000;
618 }
610}619}
611620
612/// @dev anonymous struct621/// @dev anonymous struct
637 event Approval(address indexed owner, address indexed spender, uint256 value);646 event Approval(address indexed owner, address indexed spender, uint256 value);
638}647}
639648
640/// @dev the ERC-165 identifier for this interface is 0x8cb847c4649/// @dev the ERC-165 identifier for this interface is 0x942e8b22
641contract ERC20 is Dummy, ERC165, ERC20Events {650contract ERC20 is Dummy, ERC165, ERC20Events {
642 /// @dev EVM selector for this function is: 0x06fdde03,651 /// @dev EVM selector for this function is: 0x06fdde03,
643 /// or in textual repr: name()652 /// or in textual repr: name()
725 return 0;734 return 0;
726 }735 }
727
728 /// @notice Returns collection helper contract address
729 /// @dev EVM selector for this function is: 0x1896cce6,
730 /// or in textual repr: collectionHelperAddress()
731 function collectionHelperAddress() public view returns (address) {
732 require(false, stub_error);
733 dummy;
734 return 0x0000000000000000000000000000000000000000;
735 }
736}736}
737737
738contract UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}738contract UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedtests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth
1import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';1import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';
2import {readFile} from 'fs/promises';2import {readFile} from 'fs/promises';
3import {ContractImports} from '../../eth/util/playgrounds/types';3import {ContractImports, TokenPermissionField} from '../../eth/util/playgrounds/types';
4import {4import {
5 ICrossAccountId,5 ICrossAccountId,
6 ITokenPropertyPermission,6 ITokenPropertyPermission,
58 substrateFee: number;58 substrateFee: number;
59 ethFee: number;59 ethFee: number;
60 ethBulkFee: number;60 ethBulkFee: number;
61 ethMintCrossFee: number;
61 evmProxyContractFee: number;62 evmProxyContractFee: number;
62 evmProxyContractBulkFee: number;63 evmProxyContractBulkFee: number;
63}64}
6465interface IBenchmarkCollection {
66 createFee: number,
67 mintFee: number,
68 transferFee: number,
69}
65const main = async () => {70const main = async () => {
66 const benchmarks = [71 const benchmarks = [
67 'substrateFee',72 'substrateFee',
68 'ethFee',73 'ethFee',
69 'ethBulkFee',74 'ethBulkFee',
75 'ethMintCrossFee',
70 'evmProxyContractFee',76 'evmProxyContractFee',
71 'evmProxyContractBulkFee',77 'evmProxyContractBulkFee',
72 ];78 ];
82 });88 });
8389
84 await usingEthPlaygrounds(async (helper, privateKey) => {90 await usingEthPlaygrounds(async (helper, privateKey) => {
91 const NOMINAL = helper.balance.getOneTokenNominal();
85 const CONTRACT_SOURCE = (92 const CONTRACT_SOURCE = (
86 await readFile(`${__dirname}/proxyContract.sol`)93 await readFile(`${__dirname}/proxyContract.sol`)
87 ).toString();94 ).toString();
95 const ZEPPELIN_OBJECT = '0x' + (await readFile(`${__dirname}/openZeppelin/bin/ZeppelinContract.bin`)).toString();
96 const ZEPPELIN_ABI = JSON.parse((await readFile(`${__dirname}/openZeppelin/bin/ZeppelinContract.abi`)).toString());
8897
89 const donor = await privateKey('//Alice'); // Seed from account with balance on this network98 const donor = await privateKey('//Alice'); // Seed from account with balance on this network
99 const [substrateReceiver] = await helper.arrange.createAccounts([10n], donor);
100
90 const ethSigner = await helper.eth.createAccountWithBalance(donor, 100n);101 const ethSigner = await helper.eth.createAccountWithBalance(donor, 100n);
102 const ethReceiver = await helper.eth.createAccountWithBalance(donor, 5n);
103
104 let susbtrateCollection: UniqueNFTCollection | null;
105 const createCollectionSubstrateFee = convertToTokens(
106 await helper.arrange.calculcateFee({Substrate: donor.address}, async () => {
107 susbtrateCollection = await helper.nft.mintCollection(donor, {tokenPropertyPermissions: [
108 {
109 key: 'url',
110 permission: {
111 tokenOwner: true,
112 collectionAdmin: true,
113 mutable: true,
114 },
115 },
116 ]});
117 }),
118 NOMINAL,
119 );
120
121 const susbstrateMintFee = convertToTokens(
122 await helper.arrange.calculcateFee(
123 {Substrate: donor.address},
124 () => susbtrateCollection!.mintToken(donor, {Substrate: substrateReceiver.address}, [{key: 'url', value: 'test'}]),
125 ),
126 NOMINAL,
127 );
128 const susbstrateTransferFee = convertToTokens(
129 await helper.arrange.calculcateFee(
130 {Substrate: substrateReceiver.address},
131 () => susbtrateCollection!.transferToken(substrateReceiver, 1, {Substrate: donor.address}),
132 ),
133 NOMINAL,
134 );
135 const substrateFee: IBenchmarkCollection = {
136 createFee: createCollectionSubstrateFee,
137 mintFee: susbstrateMintFee,
138 transferFee: susbstrateTransferFee,
139 };
140
141 const helperContract = await helper.ethNativeContract.collectionHelpers(ethSigner);
142
143 let ethContract: Contract | null = null;
144
145 const createCollectionEthFee = convertToTokens(
146 await helper.arrange.calculcateFee({Ethereum: ethSigner}, async () => {
147 const result = await helperContract.methods.createNFTCollection('a', 'b', 'c').send({from: ethSigner, value: Number(2n * helper.balance.getOneTokenNominal())});
148 ethContract = await helper.ethNativeContract.collection(helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId), 'nft', ethSigner);
149 }),
150 NOMINAL,
151 );
152
153 await ethContract!.methods.setTokenPropertyPermissions([
154 ['url', [
155 [TokenPermissionField.Mutable, true],
156 [TokenPermissionField.TokenOwner, true],
157 [TokenPermissionField.CollectionAdmin, true]],
158 ],
159 ]).send({from: ethSigner});
160
161 const ethMintFee = convertToTokens(await helper.arrange.calculcateFee(
162 {Ethereum: ethSigner},
163 () => ethContract!.methods.mintCross(
164 helper.ethCrossAccount.fromAddress(ethReceiver),
165 [{key: 'url', value: Buffer.from('test')}],
166 )
167 .send({from: ethSigner}),
168 ), NOMINAL);
169
170 const ethTransferFee = convertToTokens(await helper.arrange.calculcateFee(
171 {Ethereum: ethReceiver},
172 () => ethContract!.methods.transferFrom(ethReceiver, ethSigner, 1)
173 .send({from: ethReceiver}),
174 ), NOMINAL);
175
176 const ethFee: IBenchmarkCollection = {
177 createFee: createCollectionEthFee,
178 mintFee: ethMintFee,
179 transferFee: ethTransferFee,
180 };
181
182 let zeppelelinContract: Contract | null = null;
183
184 const zeppelinDeployFee = convertToTokens(
185 await helper.arrange.calculcateFee({Ethereum: ethSigner}, async () => {
186 zeppelelinContract = await helper.ethContract.deployByAbi(
187 ethSigner,
188 ZEPPELIN_ABI,
189 ZEPPELIN_OBJECT,
190 );
191 }),
192 NOMINAL,
193 );
194
195 const zeppelinMintFee = convertToTokens(await helper.arrange.calculcateFee(
196 {Ethereum: ethSigner},
197 () => zeppelelinContract!.methods.safeMint(ethReceiver, 'test').send({from: ethSigner}),
198 ), NOMINAL);
199
200
201 const zeppelinTransferFee = convertToTokens(await helper.arrange.calculcateFee(
202 {Ethereum: ethReceiver},
203 () => zeppelelinContract!.methods.safeTransferFrom(ethReceiver, ethSigner, 0).send({from: ethReceiver}),
204 ), NOMINAL);
205
206 const zeppelinFee: IBenchmarkCollection = {
207 createFee: zeppelinDeployFee,
208 mintFee: zeppelinMintFee,
209 transferFee: zeppelinTransferFee,
210 };
211
212 console.log('collection ops fees');
213 const results = {substrate: substrateFee, eth: ethFee, zeppelin: zeppelinFee};
214 console.table(results);
91215
92 const contract = await helper.ethContract.deployByCode(216 const contract = await helper.ethContract.deployByCode(
93 ethSigner,217 ethSigner,
366 },490 },
367 );491 );
492
493 const ethMintCrossFee = await calculateFeeNftMintWithProperties(
494 helper,
495 privateKey,
496 {Ethereum: ethSigner},
497 ethSigner,
498 proxyContract.options.address,
499 async (collection) => {
500 const evmContract = await helper.ethNativeContract.collection(
501 helper.ethAddress.fromCollectionId(collection.collectionId),
502 'nft',
503 );
504
505 await evmContract.methods.mintCross(
506 helper.ethCrossAccount.fromAddress(receiverEthAddress),
507 PROPERTIES.slice(0, setup.propertiesNumber),
508 )
509 .send({from: ethSigner});
510 },
511 );
368512
369 const proxyContractFee = await calculateFeeNftMintWithProperties(513 const proxyContractFee = await calculateFeeNftMintWithProperties(
370 helper,514 helper,
405 substrateFee: convertToTokens(substrateFee, nominal),549 substrateFee: convertToTokens(substrateFee, nominal),
406 ethFee: convertToTokens(ethFee, nominal),550 ethFee: convertToTokens(ethFee, nominal),
407 ethBulkFee: convertToTokens(ethBulkFee, nominal),551 ethBulkFee: convertToTokens(ethBulkFee, nominal),
552 ethMintCrossFee: convertToTokens(ethMintCrossFee, nominal),
408 evmProxyContractFee: convertToTokens(proxyContractFee, nominal),553 evmProxyContractFee: convertToTokens(proxyContractFee, nominal),
409 evmProxyContractBulkFee: convertToTokens(proxyContractBulkFee, nominal),554 evmProxyContractBulkFee: convertToTokens(proxyContractBulkFee, nominal),
410 };555 };
addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/README.mddiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/ERC721.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721Receiver.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Address.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Context.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/ERC165.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/IERC165.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/ZeppelinContract.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.abidiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.bindiffbeforeafterboth

no changes

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 0x7dee5997356/// @dev the ERC-165 identifier for this interface is 0x65789571
357interface ERC20UniqueExtensions is Dummy, ERC165 {357interface ERC20UniqueExtensions is Dummy, ERC165 {
358 /// @notice A description for the collection.358 /// @notice A description for the collection.
359 /// @dev EVM selector for this function is: 0x7284e416,359 /// @dev EVM selector for this function is: 0x7284e416,
404 uint256 amount404 uint256 amount
405 ) external returns (bool);405 ) external returns (bool);
406
407 /// @notice Returns collection helper contract address
408 /// @dev EVM selector for this function is: 0x1896cce6,
409 /// or in textual repr: collectionHelperAddress()
410 function collectionHelperAddress() external view returns (address);
406}411}
407412
408/// @dev anonymous struct413/// @dev anonymous struct
427 event Approval(address indexed owner, address indexed spender, uint256 value);432 event Approval(address indexed owner, address indexed spender, uint256 value);
428}433}
429434
430/// @dev the ERC-165 identifier for this interface is 0x8cb847c4435/// @dev the ERC-165 identifier for this interface is 0x942e8b22
431interface ERC20 is Dummy, ERC165, ERC20Events {436interface ERC20 is Dummy, ERC165, ERC20Events {
432 /// @dev EVM selector for this function is: 0x06fdde03,437 /// @dev EVM selector for this function is: 0x06fdde03,
433 /// or in textual repr: name()438 /// or in textual repr: name()
469 /// or in textual repr: allowance(address,address)474 /// or in textual repr: allowance(address,address)
470 function allowance(address owner, address spender) external view returns (uint256);475 function allowance(address owner, address spender) external view returns (uint256);
471
472 /// @notice Returns collection helper contract address
473 /// @dev EVM selector for this function is: 0x1896cce6,
474 /// or in textual repr: collectionHelperAddress()
475 function collectionHelperAddress() external view returns (address);
476}476}
477477
478interface UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}478interface UniqueFungible is Dummy, ERC165, ERC20, ERC20Mintable, ERC20UniqueExtensions, Collection {}