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

difftreelog

chore add `collectionCreationFee` method to CollectionHelpers

Grigoriy Simonov2022-09-27parent: #413ee13.patch.diff
in: master

6 files changed

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

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth
before · pallets/unique/src/eth/stubs/CollectionHelpers.sol
1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7contract Dummy {8	uint8 dummy;9	string stub_error = "this contract is implemented in native";10}1112contract ERC165 is Dummy {13	function supportsInterface(bytes4 interfaceID) external view returns (bool) {14		require(false, stub_error);15		interfaceID;16		return true;17	}18}1920/// @dev inlined interface21contract CollectionHelpersEvents {22	event CollectionCreated(address indexed owner, address indexed collectionId);23}2425/// @title Contract, which allows users to operate with collections26/// @dev the ERC-165 identifier for this interface is 0x88ee8ef127contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {28	/// Create an NFT collection29	/// @param name Name of the collection30	/// @param description Informative description of the collection31	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications32	/// @return address Address of the newly created collection33	/// @dev EVM selector for this function is: 0xe34a6844,34	///  or in textual repr: createNonfungibleCollection(string,string,string)35	function createNonfungibleCollection(36		string memory name,37		string memory description,38		string memory tokenPrefix39	) public payable returns (address) {40		require(false, stub_error);41		name;42		description;43		tokenPrefix;44		dummy = 0;45		return 0x0000000000000000000000000000000000000000;46	}4748	/// @dev EVM selector for this function is: 0xa634a5f9,49	///  or in textual repr: createERC721MetadataCompatibleCollection(string,string,string,string)50	function createERC721MetadataCompatibleCollection(51		string memory name,52		string memory description,53		string memory tokenPrefix,54		string memory baseUri55	) public payable returns (address) {56		require(false, stub_error);57		name;58		description;59		tokenPrefix;60		baseUri;61		dummy = 0;62		return 0x0000000000000000000000000000000000000000;63	}6465	/// @dev EVM selector for this function is: 0xab173450,66	///  or in textual repr: createRFTCollection(string,string,string)67	function createRFTCollection(68		string memory name,69		string memory description,70		string memory tokenPrefix71	) public payable returns (address) {72		require(false, stub_error);73		name;74		description;75		tokenPrefix;76		dummy = 0;77		return 0x0000000000000000000000000000000000000000;78	}7980	/// @dev EVM selector for this function is: 0xa5596388,81	///  or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)82	function createERC721MetadataCompatibleRFTCollection(83		string memory name,84		string memory description,85		string memory tokenPrefix,86		string memory baseUri87	) public payable returns (address) {88		require(false, stub_error);89		name;90		description;91		tokenPrefix;92		baseUri;93		dummy = 0;94		return 0x0000000000000000000000000000000000000000;95	}9697	/// Check if a collection exists98	/// @param collectionAddress Address of the collection in question99	/// @return bool Does the collection exist?100	/// @dev EVM selector for this function is: 0xc3de1494,101	///  or in textual repr: isCollectionExist(address)102	function isCollectionExist(address collectionAddress) public view returns (bool) {103		require(false, stub_error);104		collectionAddress;105		dummy;106		return false;107	}108}
modifiedtests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/CollectionHelpers.sol
+++ b/tests/src/eth/api/CollectionHelpers.sol
@@ -18,7 +18,7 @@
 }
 
 /// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x88ee8ef1
+/// @dev the ERC-165 identifier for this interface is 0x5ad4f440
 interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
 	/// Create an NFT collection
 	/// @param name Name of the collection
@@ -65,4 +65,8 @@
 	/// @dev EVM selector for this function is: 0xc3de1494,
 	///  or in textual repr: isCollectionExist(address)
 	function isCollectionExist(address collectionAddress) external view returns (bool);
+
+	/// @dev EVM selector for this function is: 0xd23a7ab1,
+	///  or in textual repr: collectionCreationFee()
+	function collectionCreationFee() external view returns (uint256);
 }
modifiedtests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/collectionHelpersAbi.json
+++ b/tests/src/eth/collectionHelpersAbi.json
@@ -19,6 +19,13 @@
     "type": "event"
   },
   {
+    "inputs": [],
+    "name": "collectionCreationFee",
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
     "inputs": [
       { "internalType": "string", "name": "name", "type": "string" },
       { "internalType": "string", "name": "description", "type": "string" },
modifiedtests/src/eth/payable.test.tsdiffbeforeafterboth
--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -171,6 +171,11 @@
     expect(finalContractBalance == initialContractBalance).to.be.true;
   });
 
+  itEth('Get collection creation fee', async({helper}) => {
+    const deployer = await helper.eth.createAccountWithBalance(donor);
+    expect(await helper.eth.getCollectionCreationFee(deployer)).to.be.equal(String(2n * helper.balance.getOneTokenNominal()));
+  });
+
   async function deployProxyContract(helper: EthUniqueHelper, deployer: string) {
     return await helper.ethContract.deployByCode(
       deployer,
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -152,6 +152,11 @@
   async transferBalanceFromSubstrate(donor: IKeyringPair, recepient: string, amount=1000n, inTokens=true) {
     return await this.helper.balance.transferToSubstrate(donor, evmToAddress(recepient), amount * (inTokens ? this.helper.balance.getOneTokenNominal() : 1n));
   }
+  
+  async getCollectionCreationFee(signer: string) {
+    const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
+    return await collectionHelper.methods.collectionCreationFee().call();
+  }
 
   async sendEVM(signer: IKeyringPair, contractAddress: string, abi: string, value: string, gasLimit?: number) {
     if(!gasLimit) gasLimit = this.DEFAULT_GAS;