git.delta.rocks / unique-network / refs/commits / 02657310a394

difftreelog

chore change verifyOwnerOrAdmin method

Grigoriy Simonov2022-08-11parent: #b961305.patch.diff
in: master

15 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -412,9 +412,10 @@
 
 	/// Check that account is the owner or admin of the collection
 	///
+	/// @param user account to verify
 	/// @return "true" if account is the owner or admin
-	fn verify_owner_or_admin(&mut self, caller: caller) -> Result<bool> {
-		Ok(check_is_owner_or_admin(caller, self)
+	fn verify_owner_or_admin(&self, user: address) -> Result<bool> {
+		Ok(check_is_owner_or_admin(user, self)
 			.map(|_| true)
 			.unwrap_or(false))
 	}
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -31,103 +31,7 @@
 	);
 }
 
-// Selector: 79cc6790
-contract ERC20UniqueExtensions is Dummy, ERC165 {
-	// Selector: burnFrom(address,uint256) 79cc6790
-	function burnFrom(address from, uint256 amount) public returns (bool) {
-		require(false, stub_error);
-		from;
-		amount;
-		dummy = 0;
-		return false;
-	}
-}
-
-// Selector: 942e8b22
-contract ERC20 is Dummy, ERC165, ERC20Events {
-	// Selector: name() 06fdde03
-	function name() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-
-	// Selector: symbol() 95d89b41
-	function symbol() public view returns (string memory) {
-		require(false, stub_error);
-		dummy;
-		return "";
-	}
-
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-
-	// Selector: decimals() 313ce567
-	function decimals() public view returns (uint8) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-
-	// Selector: balanceOf(address) 70a08231
-	function balanceOf(address owner) public view returns (uint256) {
-		require(false, stub_error);
-		owner;
-		dummy;
-		return 0;
-	}
-
-	// Selector: transfer(address,uint256) a9059cbb
-	function transfer(address to, uint256 amount) public returns (bool) {
-		require(false, stub_error);
-		to;
-		amount;
-		dummy = 0;
-		return false;
-	}
-
-	// Selector: transferFrom(address,address,uint256) 23b872dd
-	function transferFrom(
-		address from,
-		address to,
-		uint256 amount
-	) public returns (bool) {
-		require(false, stub_error);
-		from;
-		to;
-		amount;
-		dummy = 0;
-		return false;
-	}
-
-	// Selector: approve(address,uint256) 095ea7b3
-	function approve(address spender, uint256 amount) public returns (bool) {
-		require(false, stub_error);
-		spender;
-		amount;
-		dummy = 0;
-		return false;
-	}
-
-	// Selector: allowance(address,address) dd62ed3e
-	function allowance(address owner, address spender)
-		public
-		view
-		returns (uint256)
-	{
-		require(false, stub_error);
-		owner;
-		spender;
-		dummy;
-		return 0;
-	}
-}
-
-// Selector: aa7d570d
+// Selector: 6cf113cd
 contract Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -355,12 +259,14 @@
 
 	// Check that account is the owner or admin of the collection
 	//
+	// @param user account to verify
 	// @return "true" if account is the owner or admin
 	//
-	// Selector: verifyOwnerOrAdmin() 04a46053
-	function verifyOwnerOrAdmin() public returns (bool) {
+	// Selector: verifyOwnerOrAdmin(address) c2282493
+	function verifyOwnerOrAdmin(address user) public view returns (bool) {
 		require(false, stub_error);
-		dummy = 0;
+		user;
+		dummy;
 		return false;
 	}
 
@@ -376,6 +282,102 @@
 	}
 }
 
+// Selector: 79cc6790
+contract ERC20UniqueExtensions is Dummy, ERC165 {
+	// Selector: burnFrom(address,uint256) 79cc6790
+	function burnFrom(address from, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		from;
+		amount;
+		dummy = 0;
+		return false;
+	}
+}
+
+// Selector: 942e8b22
+contract ERC20 is Dummy, ERC165, ERC20Events {
+	// Selector: name() 06fdde03
+	function name() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	// Selector: symbol() 95d89b41
+	function symbol() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+
+	// Selector: decimals() 313ce567
+	function decimals() public view returns (uint8) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+
+	// Selector: balanceOf(address) 70a08231
+	function balanceOf(address owner) public view returns (uint256) {
+		require(false, stub_error);
+		owner;
+		dummy;
+		return 0;
+	}
+
+	// Selector: transfer(address,uint256) a9059cbb
+	function transfer(address to, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		to;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
+	// Selector: transferFrom(address,address,uint256) 23b872dd
+	function transferFrom(
+		address from,
+		address to,
+		uint256 amount
+	) public returns (bool) {
+		require(false, stub_error);
+		from;
+		to;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
+	// Selector: approve(address,uint256) 095ea7b3
+	function approve(address spender, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		spender;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
+	// Selector: allowance(address,address) dd62ed3e
+	function allowance(address owner, address spender)
+		public
+		view
+		returns (uint256)
+	{
+		require(false, stub_error);
+		owner;
+		spender;
+		dummy;
+		return 0;
+	}
+}
+
 contract UniqueFungible is
 	Dummy,
 	ERC165,
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -373,49 +373,7 @@
 	}
 }
 
-// Selector: 780e9d63
-contract ERC721Enumerable is Dummy, ERC165 {
-	// @notice Enumerate valid NFTs
-	// @param index A counter less than `totalSupply()`
-	// @return The token identifier for the `index`th NFT,
-	//  (sort order not specified)
-	//
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) public view returns (uint256) {
-		require(false, stub_error);
-		index;
-		dummy;
-		return 0;
-	}
-
-	// @dev Not implemented
-	//
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		public
-		view
-		returns (uint256)
-	{
-		require(false, stub_error);
-		owner;
-		index;
-		dummy;
-		return 0;
-	}
-
-	// @notice Count NFTs tracked by this contract
-	// @return A count of valid NFTs tracked by this contract, where each one of
-	//  them has an assigned and queryable owner not equal to the zero address
-	//
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-}
-
-// Selector: aa7d570d
+// Selector: 6cf113cd
 contract Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -643,12 +601,14 @@
 
 	// Check that account is the owner or admin of the collection
 	//
+	// @param user account to verify
 	// @return "true" if account is the owner or admin
 	//
-	// Selector: verifyOwnerOrAdmin() 04a46053
-	function verifyOwnerOrAdmin() public returns (bool) {
+	// Selector: verifyOwnerOrAdmin(address) c2282493
+	function verifyOwnerOrAdmin(address user) public view returns (bool) {
 		require(false, stub_error);
-		dummy = 0;
+		user;
+		dummy;
 		return false;
 	}
 
@@ -664,6 +624,48 @@
 	}
 }
 
+// Selector: 780e9d63
+contract ERC721Enumerable is Dummy, ERC165 {
+	// @notice Enumerate valid NFTs
+	// @param index A counter less than `totalSupply()`
+	// @return The token identifier for the `index`th NFT,
+	//  (sort order not specified)
+	//
+	// Selector: tokenByIndex(uint256) 4f6ccce7
+	function tokenByIndex(uint256 index) public view returns (uint256) {
+		require(false, stub_error);
+		index;
+		dummy;
+		return 0;
+	}
+
+	// @dev Not implemented
+	//
+	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
+	function tokenOfOwnerByIndex(address owner, uint256 index)
+		public
+		view
+		returns (uint256)
+	{
+		require(false, stub_error);
+		owner;
+		index;
+		dummy;
+		return 0;
+	}
+
+	// @notice Count NFTs tracked by this contract
+	// @return A count of valid NFTs tracked by this contract, where each one of
+	//  them has an assigned and queryable owner not equal to the zero address
+	//
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+}
+
 // Selector: d74d154f
 contract ERC721UniqueExtensions is Dummy, ERC165 {
 	// @notice Transfer ownership of an NFT
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -371,142 +371,7 @@
 	}
 }
 
-// Selector: 780e9d63
-contract ERC721Enumerable is Dummy, ERC165 {
-	// @notice Enumerate valid RFTs
-	// @param index A counter less than `totalSupply()`
-	// @return The token identifier for the `index`th NFT,
-	//  (sort order not specified)
-	//
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) public view returns (uint256) {
-		require(false, stub_error);
-		index;
-		dummy;
-		return 0;
-	}
-
-	// Not implemented
-	//
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		public
-		view
-		returns (uint256)
-	{
-		require(false, stub_error);
-		owner;
-		index;
-		dummy;
-		return 0;
-	}
-
-	// @notice Count RFTs tracked by this contract
-	// @return A count of valid RFTs tracked by this contract, where each one of
-	//  them has an assigned and queryable owner not equal to the zero address
-	//
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-}
-
-// Selector: 7c3bef89
-contract ERC721UniqueExtensions is Dummy, ERC165 {
-	// @notice Transfer ownership of an RFT
-	// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
-	//  is the zero address. Throws if `tokenId` is not a valid RFT.
-	//  Throws if RFT pieces have multiple owners.
-	// @param to The new owner
-	// @param tokenId The RFT to transfer
-	// @param _value Not used for an RFT
-	//
-	// Selector: transfer(address,uint256) a9059cbb
-	function transfer(address to, uint256 tokenId) public {
-		require(false, stub_error);
-		to;
-		tokenId;
-		dummy = 0;
-	}
-
-	// @notice Burns a specific ERC721 token.
-	// @dev Throws unless `msg.sender` is the current owner or an authorized
-	//  operator for this RFT. Throws if `from` is not the current owner. Throws
-	//  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
-	//  Throws if RFT pieces have multiple owners.
-	// @param from The current owner of the RFT
-	// @param tokenId The RFT to transfer
-	// @param _value Not used for an RFT
-	//
-	// Selector: burnFrom(address,uint256) 79cc6790
-	function burnFrom(address from, uint256 tokenId) public {
-		require(false, stub_error);
-		from;
-		tokenId;
-		dummy = 0;
-	}
-
-	// @notice Returns next free RFT ID.
-	//
-	// Selector: nextTokenId() 75794a3c
-	function nextTokenId() public view returns (uint256) {
-		require(false, stub_error);
-		dummy;
-		return 0;
-	}
-
-	// @notice Function to mint multiple tokens.
-	// @dev `tokenIds` should be an array of consecutive numbers and first number
-	//  should be obtained with `nextTokenId` method
-	// @param to The new owner
-	// @param tokenIds IDs of the minted RFTs
-	//
-	// 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;
-	}
-
-	// @notice Function to mint multiple tokens with the given tokenUris.
-	// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
-	//  numbers and first number should be obtained with `nextTokenId` method
-	// @param to The new owner
-	// @param tokens array of pairs of token ID and token URI for minted tokens
-	//
-	// 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;
-	}
-
-	// Returns EVM address for refungible token
-	//
-	// @param token ID of the token
-	//
-	// Selector: tokenContractAddress(uint256) ab76fac6
-	function tokenContractAddress(uint256 token) public view returns (address) {
-		require(false, stub_error);
-		token;
-		dummy;
-		return 0x0000000000000000000000000000000000000000;
-	}
-}
-
-// Selector: aa7d570d
+// Selector: 6cf113cd
 contract Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -734,12 +599,14 @@
 
 	// Check that account is the owner or admin of the collection
 	//
+	// @param user account to verify
 	// @return "true" if account is the owner or admin
 	//
-	// Selector: verifyOwnerOrAdmin() 04a46053
-	function verifyOwnerOrAdmin() public returns (bool) {
+	// Selector: verifyOwnerOrAdmin(address) c2282493
+	function verifyOwnerOrAdmin(address user) public view returns (bool) {
 		require(false, stub_error);
-		dummy = 0;
+		user;
+		dummy;
 		return false;
 	}
 
@@ -755,6 +622,141 @@
 	}
 }
 
+// Selector: 780e9d63
+contract ERC721Enumerable is Dummy, ERC165 {
+	// @notice Enumerate valid RFTs
+	// @param index A counter less than `totalSupply()`
+	// @return The token identifier for the `index`th NFT,
+	//  (sort order not specified)
+	//
+	// Selector: tokenByIndex(uint256) 4f6ccce7
+	function tokenByIndex(uint256 index) public view returns (uint256) {
+		require(false, stub_error);
+		index;
+		dummy;
+		return 0;
+	}
+
+	// Not implemented
+	//
+	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
+	function tokenOfOwnerByIndex(address owner, uint256 index)
+		public
+		view
+		returns (uint256)
+	{
+		require(false, stub_error);
+		owner;
+		index;
+		dummy;
+		return 0;
+	}
+
+	// @notice Count RFTs tracked by this contract
+	// @return A count of valid RFTs tracked by this contract, where each one of
+	//  them has an assigned and queryable owner not equal to the zero address
+	//
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+}
+
+// Selector: 7c3bef89
+contract ERC721UniqueExtensions is Dummy, ERC165 {
+	// @notice Transfer ownership of an RFT
+	// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+	//  is the zero address. Throws if `tokenId` is not a valid RFT.
+	//  Throws if RFT pieces have multiple owners.
+	// @param to The new owner
+	// @param tokenId The RFT to transfer
+	// @param _value Not used for an RFT
+	//
+	// Selector: transfer(address,uint256) a9059cbb
+	function transfer(address to, uint256 tokenId) public {
+		require(false, stub_error);
+		to;
+		tokenId;
+		dummy = 0;
+	}
+
+	// @notice Burns a specific ERC721 token.
+	// @dev Throws unless `msg.sender` is the current owner or an authorized
+	//  operator for this RFT. Throws if `from` is not the current owner. Throws
+	//  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+	//  Throws if RFT pieces have multiple owners.
+	// @param from The current owner of the RFT
+	// @param tokenId The RFT to transfer
+	// @param _value Not used for an RFT
+	//
+	// Selector: burnFrom(address,uint256) 79cc6790
+	function burnFrom(address from, uint256 tokenId) public {
+		require(false, stub_error);
+		from;
+		tokenId;
+		dummy = 0;
+	}
+
+	// @notice Returns next free RFT ID.
+	//
+	// Selector: nextTokenId() 75794a3c
+	function nextTokenId() public view returns (uint256) {
+		require(false, stub_error);
+		dummy;
+		return 0;
+	}
+
+	// @notice Function to mint multiple tokens.
+	// @dev `tokenIds` should be an array of consecutive numbers and first number
+	//  should be obtained with `nextTokenId` method
+	// @param to The new owner
+	// @param tokenIds IDs of the minted RFTs
+	//
+	// 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;
+	}
+
+	// @notice Function to mint multiple tokens with the given tokenUris.
+	// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+	//  numbers and first number should be obtained with `nextTokenId` method
+	// @param to The new owner
+	// @param tokens array of pairs of token ID and token URI for minted tokens
+	//
+	// 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;
+	}
+
+	// Returns EVM address for refungible token
+	//
+	// @param token ID of the token
+	//
+	// Selector: tokenContractAddress(uint256) ab76fac6
+	function tokenContractAddress(uint256 token) public view returns (address) {
+		require(false, stub_error);
+		token;
+		dummy;
+		return 0x0000000000000000000000000000000000000000;
+	}
+}
+
 contract UniqueRefungible is
 	Dummy,
 	ERC165,
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -22,50 +22,7 @@
 	);
 }
 
-// Selector: 79cc6790
-interface ERC20UniqueExtensions is Dummy, ERC165 {
-	// Selector: burnFrom(address,uint256) 79cc6790
-	function burnFrom(address from, uint256 amount) external returns (bool);
-}
-
-// Selector: 942e8b22
-interface ERC20 is Dummy, ERC165, ERC20Events {
-	// Selector: name() 06fdde03
-	function name() external view returns (string memory);
-
-	// Selector: symbol() 95d89b41
-	function symbol() external view returns (string memory);
-
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() external view returns (uint256);
-
-	// Selector: decimals() 313ce567
-	function decimals() external view returns (uint8);
-
-	// Selector: balanceOf(address) 70a08231
-	function balanceOf(address owner) external view returns (uint256);
-
-	// Selector: transfer(address,uint256) a9059cbb
-	function transfer(address to, uint256 amount) external returns (bool);
-
-	// Selector: transferFrom(address,address,uint256) 23b872dd
-	function transferFrom(
-		address from,
-		address to,
-		uint256 amount
-	) external returns (bool);
-
-	// Selector: approve(address,uint256) 095ea7b3
-	function approve(address spender, uint256 amount) external returns (bool);
-
-	// Selector: allowance(address,address) dd62ed3e
-	function allowance(address owner, address spender)
-		external
-		view
-		returns (uint256);
-}
-
-// Selector: aa7d570d
+// Selector: 6cf113cd
 interface Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -214,10 +171,11 @@
 
 	// Check that account is the owner or admin of the collection
 	//
+	// @param user account to verify
 	// @return "true" if account is the owner or admin
 	//
-	// Selector: verifyOwnerOrAdmin() 04a46053
-	function verifyOwnerOrAdmin() external returns (bool);
+	// Selector: verifyOwnerOrAdmin(address) c2282493
+	function verifyOwnerOrAdmin(address user) external view returns (bool);
 
 	// Returns collection type
 	//
@@ -227,6 +185,49 @@
 	function uniqueCollectionType() external returns (string memory);
 }
 
+// Selector: 79cc6790
+interface ERC20UniqueExtensions is Dummy, ERC165 {
+	// Selector: burnFrom(address,uint256) 79cc6790
+	function burnFrom(address from, uint256 amount) external returns (bool);
+}
+
+// Selector: 942e8b22
+interface ERC20 is Dummy, ERC165, ERC20Events {
+	// Selector: name() 06fdde03
+	function name() external view returns (string memory);
+
+	// Selector: symbol() 95d89b41
+	function symbol() external view returns (string memory);
+
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() external view returns (uint256);
+
+	// Selector: decimals() 313ce567
+	function decimals() external view returns (uint8);
+
+	// Selector: balanceOf(address) 70a08231
+	function balanceOf(address owner) external view returns (uint256);
+
+	// Selector: transfer(address,uint256) a9059cbb
+	function transfer(address to, uint256 amount) external returns (bool);
+
+	// Selector: transferFrom(address,address,uint256) 23b872dd
+	function transferFrom(
+		address from,
+		address to,
+		uint256 amount
+	) external returns (bool);
+
+	// Selector: approve(address,uint256) 095ea7b3
+	function approve(address spender, uint256 amount) external returns (bool);
+
+	// Selector: allowance(address,address) dd62ed3e
+	function allowance(address owner, address spender)
+		external
+		view
+		returns (uint256);
+}
+
 interface UniqueFungible is
 	Dummy,
 	ERC165,
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -250,33 +250,7 @@
 	function finishMinting() external returns (bool);
 }
 
-// Selector: 780e9d63
-interface ERC721Enumerable is Dummy, ERC165 {
-	// @notice Enumerate valid NFTs
-	// @param index A counter less than `totalSupply()`
-	// @return The token identifier for the `index`th NFT,
-	//  (sort order not specified)
-	//
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) external view returns (uint256);
-
-	// @dev Not implemented
-	//
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		external
-		view
-		returns (uint256);
-
-	// @notice Count NFTs tracked by this contract
-	// @return A count of valid NFTs tracked by this contract, where each one of
-	//  them has an assigned and queryable owner not equal to the zero address
-	//
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() external view returns (uint256);
-}
-
-// Selector: aa7d570d
+// Selector: 6cf113cd
 interface Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -425,10 +399,11 @@
 
 	// Check that account is the owner or admin of the collection
 	//
+	// @param user account to verify
 	// @return "true" if account is the owner or admin
 	//
-	// Selector: verifyOwnerOrAdmin() 04a46053
-	function verifyOwnerOrAdmin() external returns (bool);
+	// Selector: verifyOwnerOrAdmin(address) c2282493
+	function verifyOwnerOrAdmin(address user) external view returns (bool);
 
 	// Returns collection type
 	//
@@ -438,6 +413,32 @@
 	function uniqueCollectionType() external returns (string memory);
 }
 
+// Selector: 780e9d63
+interface ERC721Enumerable is Dummy, ERC165 {
+	// @notice Enumerate valid NFTs
+	// @param index A counter less than `totalSupply()`
+	// @return The token identifier for the `index`th NFT,
+	//  (sort order not specified)
+	//
+	// Selector: tokenByIndex(uint256) 4f6ccce7
+	function tokenByIndex(uint256 index) external view returns (uint256);
+
+	// @dev Not implemented
+	//
+	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
+	function tokenOfOwnerByIndex(address owner, uint256 index)
+		external
+		view
+		returns (uint256);
+
+	// @notice Count NFTs tracked by this contract
+	// @return A count of valid NFTs tracked by this contract, where each one of
+	//  them has an assigned and queryable owner not equal to the zero address
+	//
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() external view returns (uint256);
+}
+
 // Selector: d74d154f
 interface ERC721UniqueExtensions is Dummy, ERC165 {
 	// @notice Transfer ownership of an NFT
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -248,96 +248,7 @@
 	function finishMinting() external returns (bool);
 }
 
-// Selector: 780e9d63
-interface ERC721Enumerable is Dummy, ERC165 {
-	// @notice Enumerate valid RFTs
-	// @param index A counter less than `totalSupply()`
-	// @return The token identifier for the `index`th NFT,
-	//  (sort order not specified)
-	//
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) external view returns (uint256);
-
-	// Not implemented
-	//
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		external
-		view
-		returns (uint256);
-
-	// @notice Count RFTs tracked by this contract
-	// @return A count of valid RFTs tracked by this contract, where each one of
-	//  them has an assigned and queryable owner not equal to the zero address
-	//
-	// Selector: totalSupply() 18160ddd
-	function totalSupply() external view returns (uint256);
-}
-
-// Selector: 7c3bef89
-interface ERC721UniqueExtensions is Dummy, ERC165 {
-	// @notice Transfer ownership of an RFT
-	// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
-	//  is the zero address. Throws if `tokenId` is not a valid RFT.
-	//  Throws if RFT pieces have multiple owners.
-	// @param to The new owner
-	// @param tokenId The RFT to transfer
-	// @param _value Not used for an RFT
-	//
-	// Selector: transfer(address,uint256) a9059cbb
-	function transfer(address to, uint256 tokenId) external;
-
-	// @notice Burns a specific ERC721 token.
-	// @dev Throws unless `msg.sender` is the current owner or an authorized
-	//  operator for this RFT. Throws if `from` is not the current owner. Throws
-	//  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
-	//  Throws if RFT pieces have multiple owners.
-	// @param from The current owner of the RFT
-	// @param tokenId The RFT to transfer
-	// @param _value Not used for an RFT
-	//
-	// Selector: burnFrom(address,uint256) 79cc6790
-	function burnFrom(address from, uint256 tokenId) external;
-
-	// @notice Returns next free RFT ID.
-	//
-	// Selector: nextTokenId() 75794a3c
-	function nextTokenId() external view returns (uint256);
-
-	// @notice Function to mint multiple tokens.
-	// @dev `tokenIds` should be an array of consecutive numbers and first number
-	//  should be obtained with `nextTokenId` method
-	// @param to The new owner
-	// @param tokenIds IDs of the minted RFTs
-	//
-	// Selector: mintBulk(address,uint256[]) 44a9945e
-	function mintBulk(address to, uint256[] memory tokenIds)
-		external
-		returns (bool);
-
-	// @notice Function to mint multiple tokens with the given tokenUris.
-	// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
-	//  numbers and first number should be obtained with `nextTokenId` method
-	// @param to The new owner
-	// @param tokens array of pairs of token ID and token URI for minted tokens
-	//
-	// Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
-	function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
-		external
-		returns (bool);
-
-	// Returns EVM address for refungible token
-	//
-	// @param token ID of the token
-	//
-	// Selector: tokenContractAddress(uint256) ab76fac6
-	function tokenContractAddress(uint256 token)
-		external
-		view
-		returns (address);
-}
-
-// Selector: aa7d570d
+// Selector: 6cf113cd
 interface Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -486,10 +397,11 @@
 
 	// Check that account is the owner or admin of the collection
 	//
+	// @param user account to verify
 	// @return "true" if account is the owner or admin
 	//
-	// Selector: verifyOwnerOrAdmin() 04a46053
-	function verifyOwnerOrAdmin() external returns (bool);
+	// Selector: verifyOwnerOrAdmin(address) c2282493
+	function verifyOwnerOrAdmin(address user) external view returns (bool);
 
 	// Returns collection type
 	//
@@ -499,6 +411,95 @@
 	function uniqueCollectionType() external returns (string memory);
 }
 
+// Selector: 780e9d63
+interface ERC721Enumerable is Dummy, ERC165 {
+	// @notice Enumerate valid RFTs
+	// @param index A counter less than `totalSupply()`
+	// @return The token identifier for the `index`th NFT,
+	//  (sort order not specified)
+	//
+	// Selector: tokenByIndex(uint256) 4f6ccce7
+	function tokenByIndex(uint256 index) external view returns (uint256);
+
+	// Not implemented
+	//
+	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
+	function tokenOfOwnerByIndex(address owner, uint256 index)
+		external
+		view
+		returns (uint256);
+
+	// @notice Count RFTs tracked by this contract
+	// @return A count of valid RFTs tracked by this contract, where each one of
+	//  them has an assigned and queryable owner not equal to the zero address
+	//
+	// Selector: totalSupply() 18160ddd
+	function totalSupply() external view returns (uint256);
+}
+
+// Selector: 7c3bef89
+interface ERC721UniqueExtensions is Dummy, ERC165 {
+	// @notice Transfer ownership of an RFT
+	// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+	//  is the zero address. Throws if `tokenId` is not a valid RFT.
+	//  Throws if RFT pieces have multiple owners.
+	// @param to The new owner
+	// @param tokenId The RFT to transfer
+	// @param _value Not used for an RFT
+	//
+	// Selector: transfer(address,uint256) a9059cbb
+	function transfer(address to, uint256 tokenId) external;
+
+	// @notice Burns a specific ERC721 token.
+	// @dev Throws unless `msg.sender` is the current owner or an authorized
+	//  operator for this RFT. Throws if `from` is not the current owner. Throws
+	//  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+	//  Throws if RFT pieces have multiple owners.
+	// @param from The current owner of the RFT
+	// @param tokenId The RFT to transfer
+	// @param _value Not used for an RFT
+	//
+	// Selector: burnFrom(address,uint256) 79cc6790
+	function burnFrom(address from, uint256 tokenId) external;
+
+	// @notice Returns next free RFT ID.
+	//
+	// Selector: nextTokenId() 75794a3c
+	function nextTokenId() external view returns (uint256);
+
+	// @notice Function to mint multiple tokens.
+	// @dev `tokenIds` should be an array of consecutive numbers and first number
+	//  should be obtained with `nextTokenId` method
+	// @param to The new owner
+	// @param tokenIds IDs of the minted RFTs
+	//
+	// Selector: mintBulk(address,uint256[]) 44a9945e
+	function mintBulk(address to, uint256[] memory tokenIds)
+		external
+		returns (bool);
+
+	// @notice Function to mint multiple tokens with the given tokenUris.
+	// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+	//  numbers and first number should be obtained with `nextTokenId` method
+	// @param to The new owner
+	// @param tokens array of pairs of token ID and token URI for minted tokens
+	//
+	// Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
+	function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
+		external
+		returns (bool);
+
+	// Returns EVM address for refungible token
+	//
+	// @param token ID of the token
+	//
+	// Selector: tokenContractAddress(uint256) ab76fac6
+	function tokenContractAddress(uint256 token)
+		external
+		view
+		returns (address);
+}
+
 interface UniqueRefungible is
 	Dummy,
 	ERC165,
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
before · tests/src/eth/collectionAdmin.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.3// Unique Network is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// Unique Network is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the11// GNU General Public License for more details.1213// You should have received a copy of the GNU General Public License14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1516import {expect} from 'chai';17import privateKey from '../substrate/privateKey';18import {19  createEthAccount,20  createEthAccountWithBalance, 21  evmCollection, 22  evmCollectionHelpers, 23  getCollectionAddressFromResult, 24  itWeb3,25} from './util/helpers';2627describe('Add collection admins', () => {28  itWeb3('Add admin by owner', async ({api, web3, privateKeyWrapper}) => {29    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);30    const collectionHelper = evmCollectionHelpers(web3, owner);31        32    const result = await collectionHelper.methods33      .createNonfungibleCollection('A', 'B', 'C')34      .send();35    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);3637    const newAdmin = await createEthAccount(web3);38    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);39    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();40    const adminList = await api.rpc.unique.adminlist(collectionId);41    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())42      .to.be.eq(newAdmin.toLocaleLowerCase());43  });4445  itWeb3('Add substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {46    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);47    const collectionHelper = evmCollectionHelpers(web3, owner);48        49    const result = await collectionHelper.methods50      .createNonfungibleCollection('A', 'B', 'C')51      .send();52    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);5354    const newAdmin = privateKeyWrapper('//Alice');55    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);56    await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();5758    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, privateKeyWrapper}) => {64    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);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, privateKeyWrapper);73    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);74    await collectionEvm.methods.addCollectionAdmin(admin).send();75    76    const user = await createEthAccount(web3);77    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))78      .to.be.rejectedWith('NoPermission');7980    const adminList = await api.rpc.unique.adminlist(collectionId);81    expect(adminList.length).to.be.eq(1);82    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())83      .to.be.eq(admin.toLocaleLowerCase());84  });8586  itWeb3('(!negative tests!) Add admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {87    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);88    const collectionHelper = evmCollectionHelpers(web3, owner);89        90    const result = await collectionHelper.methods91      .createNonfungibleCollection('A', 'B', 'C')92      .send();93    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);9495    const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);96    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);97    98    const user = await createEthAccount(web3);99    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))100      .to.be.rejectedWith('NoPermission');101102    const adminList = await api.rpc.unique.adminlist(collectionId);103    expect(adminList.length).to.be.eq(0);104  });105106  itWeb3('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {107    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);108    const collectionHelper = evmCollectionHelpers(web3, owner);109        110    const result = await collectionHelper.methods111      .createNonfungibleCollection('A', 'B', 'C')112      .send();113    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);114115    const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);116    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);117    await collectionEvm.methods.addCollectionAdmin(admin).send();118119    const notAdmin = privateKey('//Alice');120    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))121      .to.be.rejectedWith('NoPermission');122123    const adminList = await api.rpc.unique.adminlist(collectionId);124    expect(adminList.length).to.be.eq(1);125    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())126      .to.be.eq(admin.toLocaleLowerCase());127  });128  129  itWeb3('(!negative tests!) Add substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {130    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);131    const collectionHelper = evmCollectionHelpers(web3, owner);132        133    const result = await collectionHelper.methods134      .createNonfungibleCollection('A', 'B', 'C')135      .send();136    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);137138    const notAdmin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);139    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);140    const notAdmin1 = privateKey('//Alice');141    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))142      .to.be.rejectedWith('NoPermission');143144    const adminList = await api.rpc.unique.adminlist(collectionId);145    expect(adminList.length).to.be.eq(0);146  });147});148149describe('Remove collection admins', () => {150  itWeb3('Remove admin by owner', async ({api, web3, privateKeyWrapper}) => {151    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);152    const collectionHelper = evmCollectionHelpers(web3, owner);153        154    const result = await collectionHelper.methods155      .createNonfungibleCollection('A', 'B', 'C')156      .send();157    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);158159    const newAdmin = await createEthAccount(web3);160    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);161    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();162    {163      const adminList = await api.rpc.unique.adminlist(collectionId);164      expect(adminList.length).to.be.eq(1);165      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())166        .to.be.eq(newAdmin.toLocaleLowerCase());167    }168169    await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();170    const adminList = await api.rpc.unique.adminlist(collectionId);171    expect(adminList.length).to.be.eq(0);172  });173174  itWeb3('Remove substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {175    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);176    const collectionHelper = evmCollectionHelpers(web3, owner);177        178    const result = await collectionHelper.methods179      .createNonfungibleCollection('A', 'B', 'C')180      .send();181    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);182183    const newAdmin = privateKeyWrapper('//Alice');184    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);185    await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();186    {187      const adminList = await api.rpc.unique.adminlist(collectionId);188      expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())189        .to.be.eq(newAdmin.address.toLocaleLowerCase());190    }191    192    await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();193    const adminList = await api.rpc.unique.adminlist(collectionId);194    expect(adminList.length).to.be.eq(0);195  });196197  itWeb3('(!negative tests!) Remove admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {198    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);199    const collectionHelper = evmCollectionHelpers(web3, owner);200        201    const result = await collectionHelper.methods202      .createNonfungibleCollection('A', 'B', 'C')203      .send();204    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);205206    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);207208    const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);209    await collectionEvm.methods.addCollectionAdmin(admin0).send();210    const admin1 = await createEthAccount(web3);211    await collectionEvm.methods.addCollectionAdmin(admin1).send();212213    await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))214      .to.be.rejectedWith('NoPermission');215    {216      const adminList = await api.rpc.unique.adminlist(collectionId);217      expect(adminList.length).to.be.eq(2);218      expect(adminList.toString().toLocaleLowerCase())219        .to.be.deep.contains(admin0.toLocaleLowerCase())220        .to.be.deep.contains(admin1.toLocaleLowerCase());221    }222  });223224  itWeb3('(!negative tests!) Remove admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {225    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);226    const collectionHelper = evmCollectionHelpers(web3, owner);227        228    const result = await collectionHelper.methods229      .createNonfungibleCollection('A', 'B', 'C')230      .send();231    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);232233    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);234235    const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);236    await collectionEvm.methods.addCollectionAdmin(admin).send();237    const notAdmin = await createEthAccount(web3);238239    await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))240      .to.be.rejectedWith('NoPermission');241    {242      const adminList = await api.rpc.unique.adminlist(collectionId);243      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())244        .to.be.eq(admin.toLocaleLowerCase());245      expect(adminList.length).to.be.eq(1);246    }247  });248249  itWeb3('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {250    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);251    const collectionHelper = evmCollectionHelpers(web3, owner);252        253    const result = await collectionHelper.methods254      .createNonfungibleCollection('A', 'B', 'C')255      .send();256    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);257258    const adminSub = privateKeyWrapper('//Alice');259    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);260    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();261    const adminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);262    await collectionEvm.methods.addCollectionAdmin(adminEth).send();263264    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))265      .to.be.rejectedWith('NoPermission');266267    const adminList = await api.rpc.unique.adminlist(collectionId);268    expect(adminList.length).to.be.eq(2);269    expect(adminList.toString().toLocaleLowerCase())270      .to.be.deep.contains(adminSub.address.toLocaleLowerCase())271      .to.be.deep.contains(adminEth.toLocaleLowerCase());272  });273274  itWeb3('(!negative tests!) Remove substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {275    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);276    const collectionHelper = evmCollectionHelpers(web3, owner);277        278    const result = await collectionHelper.methods279      .createNonfungibleCollection('A', 'B', 'C')280      .send();281    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);282283    const adminSub = privateKeyWrapper('//Alice');284    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);285    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();286    const notAdminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);287288    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))289      .to.be.rejectedWith('NoPermission');290291    const adminList = await api.rpc.unique.adminlist(collectionId);292    expect(adminList.length).to.be.eq(1);293    expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())294      .to.be.eq(adminSub.address.toLocaleLowerCase());295  });296});
after · tests/src/eth/collectionAdmin.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.3// Unique Network is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// Unique Network is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the11// GNU General Public License for more details.1213// You should have received a copy of the GNU General Public License14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1516import {expect} from 'chai';17import privateKey from '../substrate/privateKey';18import {19  createEthAccount,20  createEthAccountWithBalance, 21  evmCollection, 22  evmCollectionHelpers, 23  getCollectionAddressFromResult, 24  itWeb3,25} from './util/helpers';2627describe('Add collection admins', () => {28  itWeb3('Add admin by owner', async ({api, web3, privateKeyWrapper}) => {29    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);30    const collectionHelper = evmCollectionHelpers(web3, owner);31        32    const result = await collectionHelper.methods33      .createNonfungibleCollection('A', 'B', 'C')34      .send();35    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);3637    const newAdmin = await createEthAccount(web3);38    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);39    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();40    const adminList = await api.rpc.unique.adminlist(collectionId);41    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())42      .to.be.eq(newAdmin.toLocaleLowerCase());43  });4445  itWeb3('Add substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {46    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);47    const collectionHelper = evmCollectionHelpers(web3, owner);48        49    const result = await collectionHelper.methods50      .createNonfungibleCollection('A', 'B', 'C')51      .send();52    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);5354    const newAdmin = privateKeyWrapper('//Alice');55    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);56    await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();5758    const adminList = await api.rpc.unique.adminlist(collectionId);59    expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())60      .to.be.eq(newAdmin.address.toLocaleLowerCase());61  });62  63  itWeb3('Verify owner or admin', async ({api, web3, privateKeyWrapper}) => {64    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);65    const collectionHelper = evmCollectionHelpers(web3, owner);66        67    const result = await collectionHelper.methods68      .createNonfungibleCollection('A', 'B', 'C')69      .send();70    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);7172    const newAdmin = createEthAccount(web3);73    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);74    expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.false;75    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();76    expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.true;77  });7879  itWeb3('(!negative tests!) Add admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {80    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);81    const collectionHelper = evmCollectionHelpers(web3, owner);82        83    const result = await collectionHelper.methods84      .createNonfungibleCollection('A', 'B', 'C')85      .send();86    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);8788    const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);89    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);90    await collectionEvm.methods.addCollectionAdmin(admin).send();91    92    const user = await createEthAccount(web3);93    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))94      .to.be.rejectedWith('NoPermission');9596    const adminList = await api.rpc.unique.adminlist(collectionId);97    expect(adminList.length).to.be.eq(1);98    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())99      .to.be.eq(admin.toLocaleLowerCase());100  });101102  itWeb3('(!negative tests!) Add admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {103    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);104    const collectionHelper = evmCollectionHelpers(web3, owner);105        106    const result = await collectionHelper.methods107      .createNonfungibleCollection('A', 'B', 'C')108      .send();109    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);110111    const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);112    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);113    114    const user = await createEthAccount(web3);115    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))116      .to.be.rejectedWith('NoPermission');117118    const adminList = await api.rpc.unique.adminlist(collectionId);119    expect(adminList.length).to.be.eq(0);120  });121122  itWeb3('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {123    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);124    const collectionHelper = evmCollectionHelpers(web3, owner);125        126    const result = await collectionHelper.methods127      .createNonfungibleCollection('A', 'B', 'C')128      .send();129    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);130131    const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);132    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);133    await collectionEvm.methods.addCollectionAdmin(admin).send();134135    const notAdmin = privateKey('//Alice');136    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))137      .to.be.rejectedWith('NoPermission');138139    const adminList = await api.rpc.unique.adminlist(collectionId);140    expect(adminList.length).to.be.eq(1);141    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())142      .to.be.eq(admin.toLocaleLowerCase());143  });144  145  itWeb3('(!negative tests!) Add substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {146    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);147    const collectionHelper = evmCollectionHelpers(web3, owner);148        149    const result = await collectionHelper.methods150      .createNonfungibleCollection('A', 'B', 'C')151      .send();152    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);153154    const notAdmin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);155    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);156    const notAdmin1 = privateKey('//Alice');157    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))158      .to.be.rejectedWith('NoPermission');159160    const adminList = await api.rpc.unique.adminlist(collectionId);161    expect(adminList.length).to.be.eq(0);162  });163});164165describe('Remove collection admins', () => {166  itWeb3('Remove admin by owner', async ({api, web3, privateKeyWrapper}) => {167    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);168    const collectionHelper = evmCollectionHelpers(web3, owner);169        170    const result = await collectionHelper.methods171      .createNonfungibleCollection('A', 'B', 'C')172      .send();173    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);174175    const newAdmin = await createEthAccount(web3);176    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);177    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();178    {179      const adminList = await api.rpc.unique.adminlist(collectionId);180      expect(adminList.length).to.be.eq(1);181      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())182        .to.be.eq(newAdmin.toLocaleLowerCase());183    }184185    await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();186    const adminList = await api.rpc.unique.adminlist(collectionId);187    expect(adminList.length).to.be.eq(0);188  });189190  itWeb3('Remove substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {191    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);192    const collectionHelper = evmCollectionHelpers(web3, owner);193        194    const result = await collectionHelper.methods195      .createNonfungibleCollection('A', 'B', 'C')196      .send();197    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);198199    const newAdmin = privateKeyWrapper('//Alice');200    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);201    await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();202    {203      const adminList = await api.rpc.unique.adminlist(collectionId);204      expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())205        .to.be.eq(newAdmin.address.toLocaleLowerCase());206    }207    208    await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();209    const adminList = await api.rpc.unique.adminlist(collectionId);210    expect(adminList.length).to.be.eq(0);211  });212213  itWeb3('(!negative tests!) Remove admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {214    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);215    const collectionHelper = evmCollectionHelpers(web3, owner);216        217    const result = await collectionHelper.methods218      .createNonfungibleCollection('A', 'B', 'C')219      .send();220    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);221222    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);223224    const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);225    await collectionEvm.methods.addCollectionAdmin(admin0).send();226    const admin1 = await createEthAccount(web3);227    await collectionEvm.methods.addCollectionAdmin(admin1).send();228229    await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))230      .to.be.rejectedWith('NoPermission');231    {232      const adminList = await api.rpc.unique.adminlist(collectionId);233      expect(adminList.length).to.be.eq(2);234      expect(adminList.toString().toLocaleLowerCase())235        .to.be.deep.contains(admin0.toLocaleLowerCase())236        .to.be.deep.contains(admin1.toLocaleLowerCase());237    }238  });239240  itWeb3('(!negative tests!) Remove admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {241    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);242    const collectionHelper = evmCollectionHelpers(web3, owner);243        244    const result = await collectionHelper.methods245      .createNonfungibleCollection('A', 'B', 'C')246      .send();247    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);248249    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);250251    const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);252    await collectionEvm.methods.addCollectionAdmin(admin).send();253    const notAdmin = await createEthAccount(web3);254255    await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))256      .to.be.rejectedWith('NoPermission');257    {258      const adminList = await api.rpc.unique.adminlist(collectionId);259      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())260        .to.be.eq(admin.toLocaleLowerCase());261      expect(adminList.length).to.be.eq(1);262    }263  });264265  itWeb3('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {266    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);267    const collectionHelper = evmCollectionHelpers(web3, owner);268        269    const result = await collectionHelper.methods270      .createNonfungibleCollection('A', 'B', 'C')271      .send();272    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);273274    const adminSub = privateKeyWrapper('//Alice');275    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);276    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();277    const adminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);278    await collectionEvm.methods.addCollectionAdmin(adminEth).send();279280    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))281      .to.be.rejectedWith('NoPermission');282283    const adminList = await api.rpc.unique.adminlist(collectionId);284    expect(adminList.length).to.be.eq(2);285    expect(adminList.toString().toLocaleLowerCase())286      .to.be.deep.contains(adminSub.address.toLocaleLowerCase())287      .to.be.deep.contains(adminEth.toLocaleLowerCase());288  });289290  itWeb3('(!negative tests!) Remove substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {291    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);292    const collectionHelper = evmCollectionHelpers(web3, owner);293        294    const result = await collectionHelper.methods295      .createNonfungibleCollection('A', 'B', 'C')296      .send();297    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);298299    const adminSub = privateKeyWrapper('//Alice');300    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);301    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();302    const notAdminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);303304    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))305      .to.be.rejectedWith('NoPermission');306307    const adminList = await api.rpc.unique.adminlist(collectionId);308    expect(adminList.length).to.be.eq(1);309    expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())310      .to.be.eq(adminSub.address.toLocaleLowerCase());311  });312});
modifiedtests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -64,7 +64,7 @@
             "Wrong collection type. Collection is not refungible."
         );
         require(
-            refungibleContract.verifyOwnerOrAdmin(),
+            refungibleContract.verifyOwnerOrAdmin(address(this)),
             "Fractionalizer contract should be an admin of the collection"
         );
         rftCollection = _collection;
modifiedtests/src/eth/fungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -310,10 +310,12 @@
     "type": "function"
   },
   {
-    "inputs": [],
+    "inputs": [
+      { "internalType": "address", "name": "user", "type": "address" }
+    ],
     "name": "verifyOwnerOrAdmin",
     "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
+    "stateMutability": "view",
     "type": "function"
   }
 ]
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -535,10 +535,12 @@
     "type": "function"
   },
   {
-    "inputs": [],
+    "inputs": [
+      { "internalType": "address", "name": "user", "type": "address" }
+    ],
     "name": "verifyOwnerOrAdmin",
     "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
+    "stateMutability": "view",
     "type": "function"
   }
 ]
modifiedtests/src/eth/reFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -544,10 +544,12 @@
     "type": "function"
   },
   {
-    "inputs": [],
+    "inputs": [
+      { "internalType": "address", "name": "user", "type": "address" }
+    ],
     "name": "verifyOwnerOrAdmin",
     "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "nonpayable",
+    "stateMutability": "view",
     "type": "function"
   }
 ]