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

difftreelog

feature(common-pallet): add changeOwner method

Grigoriy Simonov2022-08-23parent: #565dfea.patch.diff
in: master

14 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -431,6 +431,27 @@
 		};
 		Ok(mode.into())
 	}
+
+	/// Changes collection owner
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner
+	fn change_owner(&mut self, caller: caller, new_owner: address) -> Result<void> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let new_owner = T::CrossAccountId::from_eth(new_owner);
+		self.change_owner_internal(caller, new_owner)
+	}
+
+impl<T: Config> CollectionHandle<T>
+where
+	T::AccountId: From<[u8; 32]>,
+{
+
+	fn change_owner_internal(&mut self, caller: T::CrossAccountId, new_owner: T::CrossAccountId) -> Result<void> {
+		self.check_is_owner(&caller).map_err(dispatch_to_evm::<T>)?;
+		self.collection.owner = new_owner.as_sub().clone();
+		save(self)
+	}
 }
 
 fn check_is_owner_or_admin<T: Config>(
@@ -440,12 +461,13 @@
 	let caller = T::CrossAccountId::from_eth(caller);
 	collection
 		.check_is_owner_or_admin(&caller)
-		.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
+		.map_err(dispatch_to_evm::<T>)?;
 	Ok(caller)
 }
 
 fn save<T: Config>(collection: &CollectionHandle<T>) -> Result<void> {
 	// TODO possibly delete for the lack of transaction
+	collection.consume_store_writes(1)?;
 	collection
 		.check_is_internal()
 		.map_err(dispatch_to_evm::<T>)?;
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,7 +31,103 @@
 	);
 }
 
-// Selector: 6cf113cd
+// 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: ca08c92c
 contract Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -276,105 +372,21 @@
 	//
 	// Selector: uniqueCollectionType() d34b55b8
 	function uniqueCollectionType() public returns (string memory) {
-		require(false, stub_error);
-		dummy = 0;
-		return "";
-	}
-}
-
-// 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) {
+	// Changes collection owner
+	//
+	// @dev Owner can be changed only by current owner
+	// @param newOwner new owner
+	//
+	// Selector: changeOwner(address) a6f9dae1
+	function changeOwner(address newOwner) public {
 		require(false, stub_error);
-		spender;
-		amount;
+		newOwner;
 		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;
 	}
 }
 
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,7 +373,49 @@
 	}
 }
 
-// Selector: 6cf113cd
+// 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: ca08c92c
 contract Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -622,47 +664,17 @@
 		dummy = 0;
 		return "";
 	}
-}
 
-// 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)
+	// Changes collection owner
 	//
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) public view returns (uint256) {
-		require(false, stub_error);
-		index;
-		dummy;
-		return 0;
-	}
-
-	// @dev Not implemented
+	// @dev Owner can be changed only by current owner
+	// @param newOwner new owner
 	//
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		public
-		view
-		returns (uint256)
-	{
+	// Selector: changeOwner(address) a6f9dae1
+	function changeOwner(address newOwner) public {
 		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;
+		newOwner;
+		dummy = 0;
 	}
 }
 
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,7 +371,142 @@
 	}
 }
 
-// Selector: 6cf113cd
+// 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: ca08c92c
 contract Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -620,140 +755,17 @@
 		dummy = 0;
 		return "";
 	}
-}
 
-// 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)
+	// Changes collection owner
 	//
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) public view returns (uint256) {
-		require(false, stub_error);
-		index;
-		dummy;
-		return 0;
-	}
-
-	// Not implemented
+	// @dev Owner can be changed only by current owner
+	// @param newOwner new owner
 	//
-	// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
-	function tokenOfOwnerByIndex(address owner, uint256 index)
-		public
-		view
-		returns (uint256)
-	{
+	// Selector: changeOwner(address) a6f9dae1
+	function changeOwner(address newOwner) public {
 		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;
+		newOwner;
 		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;
 	}
 }
 
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -22,7 +22,50 @@
 	);
 }
 
-// Selector: 6cf113cd
+// 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: ca08c92c
 interface Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -183,49 +226,14 @@
 	//
 	// Selector: uniqueCollectionType() d34b55b8
 	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);
+	// Changes collection owner
+	//
+	// @dev Owner can be changed only by current owner
+	// @param newOwner new owner
+	//
+	// Selector: changeOwner(address) a6f9dae1
+	function changeOwner(address newOwner) external;
 }
 
 interface UniqueFungible is
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -250,7 +250,33 @@
 	function finishMinting() external returns (bool);
 }
 
-// Selector: 6cf113cd
+// 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: ca08c92c
 interface Collection is Dummy, ERC165 {
 	// Set collection property.
 	//
@@ -411,32 +437,14 @@
 	//
 	// Selector: uniqueCollectionType() d34b55b8
 	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)
+	// Changes collection owner
 	//
-	// Selector: tokenByIndex(uint256) 4f6ccce7
-	function tokenByIndex(uint256 index) external view returns (uint256);
-
-	// @dev Not implemented
+	// @dev Owner can be changed only by current owner
+	// @param newOwner new owner
 	//
-	// 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: changeOwner(address) a6f9dae1
+	function changeOwner(address newOwner) external;
 }
 
 // Selector: d74d154f
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
248 function finishMinting() external returns (bool);248 function finishMinting() external returns (bool);
249}249}
250
251// Selector: 6cf113cd
252interface Collection is Dummy, ERC165 {
253 // Set collection property.
254 //
255 // @param key Property key.
256 // @param value Propery value.
257 //
258 // Selector: setCollectionProperty(string,bytes) 2f073f66
259 function setCollectionProperty(string memory key, bytes memory value)
260 external;
261
262 // Delete collection property.
263 //
264 // @param key Property key.
265 //
266 // Selector: deleteCollectionProperty(string) 7b7debce
267 function deleteCollectionProperty(string memory key) external;
268
269 // Get collection property.
270 //
271 // @dev Throws error if key not found.
272 //
273 // @param key Property key.
274 // @return bytes The property corresponding to the key.
275 //
276 // Selector: collectionProperty(string) cf24fd6d
277 function collectionProperty(string memory key)
278 external
279 view
280 returns (bytes memory);
281
282 // Set the sponsor of the collection.
283 //
284 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
285 //
286 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
287 //
288 // Selector: setCollectionSponsor(address) 7623402e
289 function setCollectionSponsor(address sponsor) external;
290
291 // Collection sponsorship confirmation.
292 //
293 // @dev After setting the sponsor for the collection, it must be confirmed with this function.
294 //
295 // Selector: confirmCollectionSponsorship() 3c50e97a
296 function confirmCollectionSponsorship() external;
297
298 // Set limits for the collection.
299 // @dev Throws error if limit not found.
300 // @param limit Name of the limit. Valid names:
301 // "accountTokenOwnershipLimit",
302 // "sponsoredDataSize",
303 // "sponsoredDataRateLimit",
304 // "tokenLimit",
305 // "sponsorTransferTimeout",
306 // "sponsorApproveTimeout"
307 // @param value Value of the limit.
308 //
309 // Selector: setCollectionLimit(string,uint32) 6a3841db
310 function setCollectionLimit(string memory limit, uint32 value) external;
311
312 // Set limits for the collection.
313 // @dev Throws error if limit not found.
314 // @param limit Name of the limit. Valid names:
315 // "ownerCanTransfer",
316 // "ownerCanDestroy",
317 // "transfersEnabled"
318 // @param value Value of the limit.
319 //
320 // Selector: setCollectionLimit(string,bool) 993b7fba
321 function setCollectionLimit(string memory limit, bool value) external;
322
323 // Get contract address.
324 //
325 // Selector: contractAddress() f6b4dfb4
326 function contractAddress() external view returns (address);
327
328 // Add collection admin by substrate address.
329 // @param new_admin Substrate administrator address.
330 //
331 // Selector: addCollectionAdminSubstrate(uint256) 5730062b
332 function addCollectionAdminSubstrate(uint256 newAdmin) external;
333
334 // Remove collection admin by substrate address.
335 // @param admin Substrate administrator address.
336 //
337 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
338 function removeCollectionAdminSubstrate(uint256 admin) external;
339
340 // Add collection admin.
341 // @param new_admin Address of the added administrator.
342 //
343 // Selector: addCollectionAdmin(address) 92e462c7
344 function addCollectionAdmin(address newAdmin) external;
345
346 // Remove collection admin.
347 //
348 // @param new_admin Address of the removed administrator.
349 //
350 // Selector: removeCollectionAdmin(address) fafd7b42
351 function removeCollectionAdmin(address admin) external;
352
353 // Toggle accessibility of collection nesting.
354 //
355 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
356 //
357 // Selector: setCollectionNesting(bool) 112d4586
358 function setCollectionNesting(bool enable) external;
359
360 // Toggle accessibility of collection nesting.
361 //
362 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
363 // @param collections Addresses of collections that will be available for nesting.
364 //
365 // Selector: setCollectionNesting(bool,address[]) 64872396
366 function setCollectionNesting(bool enable, address[] memory collections)
367 external;
368
369 // Set the collection access method.
370 // @param mode Access mode
371 // 0 for Normal
372 // 1 for AllowList
373 //
374 // Selector: setCollectionAccess(uint8) 41835d4c
375 function setCollectionAccess(uint8 mode) external;
376
377 // Add the user to the allowed list.
378 //
379 // @param user Address of a trusted user.
380 //
381 // Selector: addToCollectionAllowList(address) 67844fe6
382 function addToCollectionAllowList(address user) external;
383
384 // Remove the user from the allowed list.
385 //
386 // @param user Address of a removed user.
387 //
388 // Selector: removeFromCollectionAllowList(address) 85c51acb
389 function removeFromCollectionAllowList(address user) external;
390
391 // Switch permission for minting.
392 //
393 // @param mode Enable if "true".
394 //
395 // Selector: setCollectionMintMode(bool) 00018e84
396 function setCollectionMintMode(bool mode) external;
397
398 // Check that account is the owner or admin of the collection
399 //
400 // @param user account to verify
401 // @return "true" if account is the owner or admin
402 //
403 // Selector: verifyOwnerOrAdmin(address) c2282493
404 function verifyOwnerOrAdmin(address user) external view returns (bool);
405
406 // Returns collection type
407 //
408 // @return `Fungible` or `NFT` or `ReFungible`
409 //
410 // Selector: uniqueCollectionType() d34b55b8
411 function uniqueCollectionType() external returns (string memory);
412}
413250
414// Selector: 780e9d63251// Selector: 780e9d63
415interface ERC721Enumerable is Dummy, ERC165 {252interface ERC721Enumerable is Dummy, ERC165 {
500 returns (address);337 returns (address);
501}338}
339
340// Selector: ca08c92c
341interface Collection is Dummy, ERC165 {
342 // Set collection property.
343 //
344 // @param key Property key.
345 // @param value Propery value.
346 //
347 // Selector: setCollectionProperty(string,bytes) 2f073f66
348 function setCollectionProperty(string memory key, bytes memory value)
349 external;
350
351 // Delete collection property.
352 //
353 // @param key Property key.
354 //
355 // Selector: deleteCollectionProperty(string) 7b7debce
356 function deleteCollectionProperty(string memory key) external;
357
358 // Get collection property.
359 //
360 // @dev Throws error if key not found.
361 //
362 // @param key Property key.
363 // @return bytes The property corresponding to the key.
364 //
365 // Selector: collectionProperty(string) cf24fd6d
366 function collectionProperty(string memory key)
367 external
368 view
369 returns (bytes memory);
370
371 // Set the sponsor of the collection.
372 //
373 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
374 //
375 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
376 //
377 // Selector: setCollectionSponsor(address) 7623402e
378 function setCollectionSponsor(address sponsor) external;
379
380 // Collection sponsorship confirmation.
381 //
382 // @dev After setting the sponsor for the collection, it must be confirmed with this function.
383 //
384 // Selector: confirmCollectionSponsorship() 3c50e97a
385 function confirmCollectionSponsorship() external;
386
387 // Set limits for the collection.
388 // @dev Throws error if limit not found.
389 // @param limit Name of the limit. Valid names:
390 // "accountTokenOwnershipLimit",
391 // "sponsoredDataSize",
392 // "sponsoredDataRateLimit",
393 // "tokenLimit",
394 // "sponsorTransferTimeout",
395 // "sponsorApproveTimeout"
396 // @param value Value of the limit.
397 //
398 // Selector: setCollectionLimit(string,uint32) 6a3841db
399 function setCollectionLimit(string memory limit, uint32 value) external;
400
401 // Set limits for the collection.
402 // @dev Throws error if limit not found.
403 // @param limit Name of the limit. Valid names:
404 // "ownerCanTransfer",
405 // "ownerCanDestroy",
406 // "transfersEnabled"
407 // @param value Value of the limit.
408 //
409 // Selector: setCollectionLimit(string,bool) 993b7fba
410 function setCollectionLimit(string memory limit, bool value) external;
411
412 // Get contract address.
413 //
414 // Selector: contractAddress() f6b4dfb4
415 function contractAddress() external view returns (address);
416
417 // Add collection admin by substrate address.
418 // @param new_admin Substrate administrator address.
419 //
420 // Selector: addCollectionAdminSubstrate(uint256) 5730062b
421 function addCollectionAdminSubstrate(uint256 newAdmin) external;
422
423 // Remove collection admin by substrate address.
424 // @param admin Substrate administrator address.
425 //
426 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
427 function removeCollectionAdminSubstrate(uint256 admin) external;
428
429 // Add collection admin.
430 // @param new_admin Address of the added administrator.
431 //
432 // Selector: addCollectionAdmin(address) 92e462c7
433 function addCollectionAdmin(address newAdmin) external;
434
435 // Remove collection admin.
436 //
437 // @param new_admin Address of the removed administrator.
438 //
439 // Selector: removeCollectionAdmin(address) fafd7b42
440 function removeCollectionAdmin(address admin) external;
441
442 // Toggle accessibility of collection nesting.
443 //
444 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
445 //
446 // Selector: setCollectionNesting(bool) 112d4586
447 function setCollectionNesting(bool enable) external;
448
449 // Toggle accessibility of collection nesting.
450 //
451 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
452 // @param collections Addresses of collections that will be available for nesting.
453 //
454 // Selector: setCollectionNesting(bool,address[]) 64872396
455 function setCollectionNesting(bool enable, address[] memory collections)
456 external;
457
458 // Set the collection access method.
459 // @param mode Access mode
460 // 0 for Normal
461 // 1 for AllowList
462 //
463 // Selector: setCollectionAccess(uint8) 41835d4c
464 function setCollectionAccess(uint8 mode) external;
465
466 // Add the user to the allowed list.
467 //
468 // @param user Address of a trusted user.
469 //
470 // Selector: addToCollectionAllowList(address) 67844fe6
471 function addToCollectionAllowList(address user) external;
472
473 // Remove the user from the allowed list.
474 //
475 // @param user Address of a removed user.
476 //
477 // Selector: removeFromCollectionAllowList(address) 85c51acb
478 function removeFromCollectionAllowList(address user) external;
479
480 // Switch permission for minting.
481 //
482 // @param mode Enable if "true".
483 //
484 // Selector: setCollectionMintMode(bool) 00018e84
485 function setCollectionMintMode(bool mode) external;
486
487 // Check that account is the owner or admin of the collection
488 //
489 // @param user account to verify
490 // @return "true" if account is the owner or admin
491 //
492 // Selector: verifyOwnerOrAdmin(address) c2282493
493 function verifyOwnerOrAdmin(address user) external view returns (bool);
494
495 // Returns collection type
496 //
497 // @return `Fungible` or `NFT` or `ReFungible`
498 //
499 // Selector: uniqueCollectionType() d34b55b8
500 function uniqueCollectionType() external returns (string memory);
501
502 // Changes collection owner
503 //
504 // @dev Owner can be changed only by current owner
505 // @param newOwner new owner
506 //
507 // Selector: changeOwner(address) a6f9dae1
508 function changeOwner(address newOwner) external;
509}
502510
503interface UniqueRefungible is511interface UniqueRefungible is
504 Dummy,512 Dummy,
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -15,6 +15,7 @@
 
 import {expect} from 'chai';
 import privateKey from '../substrate/privateKey';
+import { UNIQUE } from '../util/helpers';
 import {
   createEthAccount,
   createEthAccountWithBalance, 
@@ -22,6 +23,7 @@
   evmCollectionHelpers, 
   getCollectionAddressFromResult, 
   itWeb3,
+  recordEthFee,
 } from './util/helpers';
 
 describe('Add collection admins', () => {
@@ -309,4 +311,51 @@
     expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())
       .to.be.eq(adminSub.address.toLocaleLowerCase());
   });
+});
+
+describe('Change owner tests', () => {
+  itWeb3('Change owner', async ({api, web3, privateKeyWrapper}) => {
+    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const collectionHelper = evmCollectionHelpers(web3, owner);
+    const result = await collectionHelper.methods
+      .createNonfungibleCollection('A', 'B', 'C')
+      .send();
+    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
+  
+    await collectionEvm.methods.changeOwner(newOwner).send();
+  
+    expect(await collectionEvm.methods.verifyOwnerOrAdmin(owner).call()).to.be.false;
+    expect(await collectionEvm.methods.verifyOwnerOrAdmin(newOwner).call()).to.be.true;
+  });
+
+  itWeb3('change owner call fee', async ({web3, api, privateKeyWrapper}) => {
+    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const collectionHelper = evmCollectionHelpers(web3, owner);
+    const result = await collectionHelper.methods
+      .createNonfungibleCollection('A', 'B', 'C')
+      .send();
+    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
+
+    const cost = await recordEthFee(api, owner, () => collectionEvm.methods.changeOwner(newOwner).send());
+    expect(cost < BigInt(0.2 * Number(UNIQUE)));
+    expect(cost > 0);
+  });
+
+  itWeb3('(!negative tests!) call changeOwner by not owner', async ({api, web3, privateKeyWrapper}) => {
+    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const collectionHelper = evmCollectionHelpers(web3, owner);
+    const result = await collectionHelper.methods
+      .createNonfungibleCollection('A', 'B', 'C')
+      .send();
+    const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+    const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
+  
+    await expect(collectionEvm.methods.changeOwner(newOwner).send({from: newOwner})).to.be.rejected;
+    expect(await collectionEvm.methods.verifyOwnerOrAdmin(newOwner).call()).to.be.false;
+  });
 });
\ No newline at end of file
modifiedtests/src/eth/fungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -116,6 +116,15 @@
     "type": "function"
   },
   {
+    "inputs": [
+      { "internalType": "address", "name": "newOwner", "type": "address" }
+    ],
+    "name": "changeOwner",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
     "name": "collectionProperty",
     "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -146,6 +146,15 @@
     "type": "function"
   },
   {
+    "inputs": [
+      { "internalType": "address", "name": "newOwner", "type": "address" }
+    ],
+    "name": "changeOwner",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
     "name": "collectionProperty",
     "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
modifiedtests/src/eth/reFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -146,6 +146,15 @@
     "type": "function"
   },
   {
+    "inputs": [
+      { "internalType": "address", "name": "newOwner", "type": "address" }
+    ],
+    "name": "changeOwner",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
     "name": "collectionProperty",
     "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],