difftreelog
CORE-386 Add admin tests
in: master
5 files changed
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -330,57 +330,7 @@
}
}
-// Selector: d74d154f
-contract ERC721UniqueExtensions is Dummy, ERC165 {
- // Selector: transfer(address,uint256) a9059cbb
- function transfer(address to, uint256 tokenId) public {
- require(false, stub_error);
- to;
- tokenId;
- dummy = 0;
- }
-
- // Selector: burnFrom(address,uint256) 79cc6790
- function burnFrom(address from, uint256 tokenId) public {
- require(false, stub_error);
- from;
- tokenId;
- dummy = 0;
- }
-
- // Selector: nextTokenId() 75794a3c
- function nextTokenId() public view returns (uint256) {
- require(false, stub_error);
- dummy;
- return 0;
- }
-
- // Selector: mintBulk(address,uint256[]) 44a9945e
- function mintBulk(address to, uint256[] memory tokenIds)
- public
- returns (bool)
- {
- require(false, stub_error);
- to;
- tokenIds;
- dummy = 0;
- return false;
- }
-
- // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
- function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
- public
- returns (bool)
- {
- require(false, stub_error);
- to;
- tokens;
- dummy = 0;
- return false;
- }
-}
-
-// Selector: f56cd7fa
+// Selector: 7d9262e6
contract Collection is Dummy, ERC165 {
// Selector: setCollectionProperty(string,bytes) 2f073f66
function setCollectionProperty(string memory key, bytes memory value)
@@ -449,8 +399,22 @@
return 0x0000000000000000000000000000000000000000;
}
- // Selector: addAdmin(address) 70480275
- function addAdmin(address newAdmin) public view {
+ // Selector: addCollectionAdminSubstrate(uint256) 5730062b
+ function addCollectionAdminSubstrate(uint256 newAdmin) public view {
+ require(false, stub_error);
+ newAdmin;
+ dummy;
+ }
+
+ // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+ function removeCollectionAdminSubstrate(uint256 newAdmin) public view {
+ require(false, stub_error);
+ newAdmin;
+ dummy;
+ }
+
+ // Selector: addCollectionAdmin(address) 92e462c7
+ function addCollectionAdmin(address newAdmin) public view {
require(false, stub_error);
newAdmin;
dummy;
@@ -507,6 +471,56 @@
}
}
+// Selector: d74d154f
+contract ERC721UniqueExtensions is Dummy, ERC165 {
+ // Selector: transfer(address,uint256) a9059cbb
+ function transfer(address to, uint256 tokenId) public {
+ require(false, stub_error);
+ to;
+ tokenId;
+ dummy = 0;
+ }
+
+ // Selector: burnFrom(address,uint256) 79cc6790
+ function burnFrom(address from, uint256 tokenId) public {
+ require(false, stub_error);
+ from;
+ tokenId;
+ dummy = 0;
+ }
+
+ // Selector: nextTokenId() 75794a3c
+ function nextTokenId() public view returns (uint256) {
+ require(false, stub_error);
+ dummy;
+ return 0;
+ }
+
+ // Selector: mintBulk(address,uint256[]) 44a9945e
+ function mintBulk(address to, uint256[] memory tokenIds)
+ public
+ returns (bool)
+ {
+ require(false, stub_error);
+ to;
+ tokenIds;
+ dummy = 0;
+ return false;
+ }
+
+ // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
+ function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
+ public
+ returns (bool)
+ {
+ require(false, stub_error);
+ to;
+ tokens;
+ dummy = 0;
+ return false;
+ }
+}
+
contract UniqueNFT is
Dummy,
ERC165,
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -191,6 +191,70 @@
function totalSupply() external view returns (uint256);
}
+// Selector: 7d9262e6
+interface Collection is Dummy, ERC165 {
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ external;
+
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) external;
+
+ // Throws error if key not found
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ external
+ view
+ returns (bytes memory);
+
+ // Selector: setCollectionSponsor(address) 7623402e
+ function setCollectionSponsor(address sponsor) external;
+
+ // Selector: confirmCollectionSponsorship() 3c50e97a
+ function confirmCollectionSponsorship() external;
+
+ // Selector: setCollectionLimit(string,uint32) 6a3841db
+ function setCollectionLimit(string memory limit, uint32 value) external;
+
+ // Selector: setCollectionLimit(string,bool) 993b7fba
+ function setCollectionLimit(string memory limit, bool value) external;
+
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() external view returns (address);
+
+ // Selector: addCollectionAdminSubstrate(uint256) 5730062b
+ function addCollectionAdminSubstrate(uint256 newAdmin) external view;
+
+ // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+ function removeCollectionAdminSubstrate(uint256 newAdmin) external view;
+
+ // Selector: addCollectionAdmin(address) 92e462c7
+ function addCollectionAdmin(address newAdmin) external view;
+
+ // Selector: removeCollectionAdmin(address) fafd7b42
+ function removeCollectionAdmin(address admin) external view;
+
+ // Selector: setCollectionNesting(bool) 112d4586
+ function setCollectionNesting(bool enable) external;
+
+ // Selector: setCollectionNesting(bool,address[]) 64872396
+ function setCollectionNesting(bool enable, address[] memory collections)
+ external;
+
+ // Selector: setCollectionAccess(uint8) 41835d4c
+ function setCollectionAccess(uint8 mode) external;
+
+ // Selector: addToCollectionAllowList(address) 67844fe6
+ function addToCollectionAllowList(address user) external view;
+
+ // Selector: removeFromCollectionAllowList(address) 85c51acb
+ function removeFromCollectionAllowList(address user) external view;
+
+ // Selector: setCollectionMintMode(bool) 00018e84
+ function setCollectionMintMode(bool mode) external;
+}
+
// Selector: d74d154f
interface ERC721UniqueExtensions is Dummy, ERC165 {
// Selector: transfer(address,uint256) a9059cbb
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34import {expect} from 'chai';5import privateKey from '../substrate/privateKey';6import {7 createEthAccount,8 createEthAccountWithBalance, 9 evmCollection, 10 evmCollectionHelpers, 11 getCollectionAddressFromResult, 12 itWeb3,13} from './util/helpers';1415// Unique Network is free software: you can redistribute it and/or modify16// it under the terms of the GNU General Public License as published by17// the Free Software Foundation, either version 3 of the License, or18// (at your option) any later version.19//20// Unique Network is distributed in the hope that it will be useful,21// but WITHOUT ANY WARRANTY; without even the implied warranty of22// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the23// GNU General Public License for more details.2425// You should have received a copy of the GNU General Public License26// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.2728describe.only('Add collection admins', () => {29 itWeb3('Add admin by owner', async ({api, web3}) => {30 const owner = await createEthAccountWithBalance(api, web3);31 const collectionHelper = evmCollectionHelpers(web3, owner);32 33 const result = await collectionHelper.methods34 .createNonfungibleCollection('A', 'B', 'C')35 .send();36 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);3738 const newAdmin = await createEthAccount(web3);39 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);40 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();41 const adminList = await api.rpc.unique.adminlist(collectionId);42 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())43 .to.be.eq(newAdmin.toLocaleLowerCase());44 });4546 itWeb3('Add substrate admin by owner', async ({api, web3}) => {47 const owner = await createEthAccountWithBalance(api, web3);48 const collectionHelper = evmCollectionHelpers(web3, owner);49 50 const result = await collectionHelper.methods51 .createNonfungibleCollection('A', 'B', 'C')52 .send();53 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);5455 const newAdmin = privateKey('//Alice');56 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);57 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();58 const adminList = await api.rpc.unique.adminlist(collectionId);59 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())60 .to.be.eq(newAdmin.address.toLocaleLowerCase());61 });6263 itWeb3('(!negative tests!) Add admin by admin is not allowed', async ({api, web3}) => {64 const owner = await createEthAccountWithBalance(api, web3);65 const collectionHelper = evmCollectionHelpers(web3, owner);66 67 const result = await collectionHelper.methods68 .createNonfungibleCollection('A', 'B', 'C')69 .send();70 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);7172 const admin = await createEthAccountWithBalance(api, web3);73 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);74 await collectionEvm.methods.addCollectionAdmin(admin).send();75 {76 const adminList = await api.rpc.unique.adminlist(collectionId);77 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())78 .to.be.eq(admin.toLocaleLowerCase());79 }80 81 const user = await createEthAccount(web3);82 await collectionEvm.methods.addCollectionAdmin(user).send({from: admin});83 const adminList = await api.rpc.unique.adminlist(collectionId);84 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())85 .to.be.eq(admin.toLocaleLowerCase());86 expect(adminList.length).to.be.eq(1);87 });88});tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -91,6 +91,15 @@
},
{
"inputs": [
+ { "internalType": "uint256", "name": "newAdmin", "type": "uint256" }
+ ],
+ "name": "addCollectionAdminSubstrate",
+ "outputs": [],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "addToAllowList",
@@ -300,6 +309,15 @@
},
{
"inputs": [
+ { "internalType": "uint256", "name": "newAdmin", "type": "uint256" }
+ ],
+ "name": "removeCollectionAdminSubstrate",
+ "outputs": [],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "user", "type": "address" }
],
"name": "removeFromAllowList",