difftreelog
chore fix code review
in: master
20 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -12473,7 +12473,7 @@
[[package]]
name = "up-common"
-version = "0.9.25"
+version = "0.9.27"
dependencies = [
"fp-rpc",
"frame-support",
pallets/common/CHANGELOG.mddiffbeforeafterboth--- a/pallets/common/CHANGELOG.md
+++ b/pallets/common/CHANGELOG.md
@@ -5,7 +5,7 @@
## [0.1.6] - 2022-08-16
### Added
-- New Ethereum API methods: changeOwner, changeOwnerSubstrate and verifyOwnerOrAdminSubstrate.
+- New Ethereum API methods: changeOwner, changeOwner(Substrate) and verifyOwnerOrAdmin(Substrate).
<!-- bureaucrate goes here -->
## [v0.1.5] 2022-08-16
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -420,6 +420,7 @@
///
/// @param user account to verify
/// @return "true" if account is the owner or admin
+ #[solidity(rename_selector = "verifyOwnerOrAdmin")]
fn verify_owner_or_admin_substrate(&self, user: uint256) -> Result<bool> {
let user = convert_substrate_address_to_cross_account_id::<T>(user);
Ok(self
@@ -455,6 +456,7 @@
///
/// @dev Owner can be changed only by current owner
/// @param newOwner new owner substrate account
+ #[solidity(rename_selector = "changeOwner")]
fn change_owner_substrate(&mut self, caller: caller, new_owner: uint256) -> Result<void> {
let caller = T::CrossAccountId::from_eth(caller);
let new_owner = convert_substrate_address_to_cross_account_id::<T>(new_owner);
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -204,7 +204,7 @@
/// Save collection to storage.
pub fn save(&self) -> DispatchResult {
- <CollectionById<T>>::insert(self.id, self.collection.clone());
+ <CollectionById<T>>::insert(self.id, &self.collection);
Ok(())
}
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -31,7 +31,103 @@
);
}
-// Selector: 07f76b0c
+// 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: f077f83e
contract Collection is Dummy, ERC165 {
// Set collection property.
//
@@ -275,12 +371,8 @@
// @param user account to verify
// @return "true" if account is the owner or admin
//
- // Selector: verifyOwnerOrAdminSubstrate(uint256) fe818e40
- function verifyOwnerOrAdminSubstrate(uint256 user)
- public
- view
- returns (bool)
- {
+ // Selector: verifyOwnerOrAdmin(uint256) a83328e5
+ function verifyOwnerOrAdmin(uint256 user) public view returns (bool) {
require(false, stub_error);
user;
dummy;
@@ -315,107 +407,11 @@
// @dev Owner can be changed only by current owner
// @param newOwner new owner substrate account
//
- // Selector: changeOwnerSubstrate(uint256) 337e2c60
- function changeOwnerSubstrate(uint256 newOwner) public {
+ // Selector: changeOwner(uint256) 924c19f7
+ function changeOwner(uint256 newOwner) public {
require(false, stub_error);
newOwner;
- dummy = 0;
- }
-}
-
-// 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;
}
}
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -51,298 +51,6 @@
event MintingFinished();
}
-// Selector: 07f76b0c
-contract Collection is Dummy, ERC165 {
- // Set collection property.
- //
- // @param key Property key.
- // @param value Propery value.
- //
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- public
- {
- require(false, stub_error);
- key;
- value;
- dummy = 0;
- }
-
- // Delete collection property.
- //
- // @param key Property key.
- //
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) public {
- require(false, stub_error);
- key;
- dummy = 0;
- }
-
- // Get collection property.
- //
- // @dev Throws error if key not found.
- //
- // @param key Property key.
- // @return bytes The property corresponding to the key.
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- public
- view
- returns (bytes memory)
- {
- require(false, stub_error);
- key;
- dummy;
- return hex"";
- }
-
- // Set the sponsor of the collection.
- //
- // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
- //
- // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
- //
- // Selector: setCollectionSponsor(address) 7623402e
- function setCollectionSponsor(address sponsor) public {
- require(false, stub_error);
- sponsor;
- dummy = 0;
- }
-
- // Collection sponsorship confirmation.
- //
- // @dev After setting the sponsor for the collection, it must be confirmed with this function.
- //
- // Selector: confirmCollectionSponsorship() 3c50e97a
- function confirmCollectionSponsorship() public {
- require(false, stub_error);
- dummy = 0;
- }
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "accountTokenOwnershipLimit",
- // "sponsoredDataSize",
- // "sponsoredDataRateLimit",
- // "tokenLimit",
- // "sponsorTransferTimeout",
- // "sponsorApproveTimeout"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,uint32) 6a3841db
- function setCollectionLimit(string memory limit, uint32 value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "ownerCanTransfer",
- // "ownerCanDestroy",
- // "transfersEnabled"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,bool) 993b7fba
- function setCollectionLimit(string memory limit, bool value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Get contract address.
- //
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() public view returns (address) {
- require(false, stub_error);
- dummy;
- return 0x0000000000000000000000000000000000000000;
- }
-
- // Add collection admin by substrate address.
- // @param new_admin Substrate administrator address.
- //
- // Selector: addCollectionAdminSubstrate(uint256) 5730062b
- function addCollectionAdminSubstrate(uint256 newAdmin) public {
- require(false, stub_error);
- newAdmin;
- dummy = 0;
- }
-
- // Remove collection admin by substrate address.
- // @param admin Substrate administrator address.
- //
- // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
- function removeCollectionAdminSubstrate(uint256 admin) public {
- require(false, stub_error);
- admin;
- dummy = 0;
- }
-
- // Add collection admin.
- // @param new_admin Address of the added administrator.
- //
- // Selector: addCollectionAdmin(address) 92e462c7
- function addCollectionAdmin(address newAdmin) public {
- require(false, stub_error);
- newAdmin;
- dummy = 0;
- }
-
- // Remove collection admin.
- //
- // @param new_admin Address of the removed administrator.
- //
- // Selector: removeCollectionAdmin(address) fafd7b42
- function removeCollectionAdmin(address admin) public {
- require(false, stub_error);
- admin;
- dummy = 0;
- }
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
- //
- // Selector: setCollectionNesting(bool) 112d4586
- function setCollectionNesting(bool enable) public {
- require(false, stub_error);
- enable;
- dummy = 0;
- }
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
- // @param collections Addresses of collections that will be available for nesting.
- //
- // Selector: setCollectionNesting(bool,address[]) 64872396
- function setCollectionNesting(bool enable, address[] memory collections)
- public
- {
- require(false, stub_error);
- enable;
- collections;
- dummy = 0;
- }
-
- // Set the collection access method.
- // @param mode Access mode
- // 0 for Normal
- // 1 for AllowList
- //
- // Selector: setCollectionAccess(uint8) 41835d4c
- function setCollectionAccess(uint8 mode) public {
- require(false, stub_error);
- mode;
- dummy = 0;
- }
-
- // Add the user to the allowed list.
- //
- // @param user Address of a trusted user.
- //
- // Selector: addToCollectionAllowList(address) 67844fe6
- function addToCollectionAllowList(address user) public {
- require(false, stub_error);
- user;
- dummy = 0;
- }
-
- // Remove the user from the allowed list.
- //
- // @param user Address of a removed user.
- //
- // Selector: removeFromCollectionAllowList(address) 85c51acb
- function removeFromCollectionAllowList(address user) public {
- require(false, stub_error);
- user;
- dummy = 0;
- }
-
- // Switch permission for minting.
- //
- // @param mode Enable if "true".
- //
- // Selector: setCollectionMintMode(bool) 00018e84
- function setCollectionMintMode(bool mode) public {
- require(false, stub_error);
- mode;
- dummy = 0;
- }
-
- // 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(address) c2282493
- function verifyOwnerOrAdmin(address user) public view returns (bool) {
- require(false, stub_error);
- user;
- dummy;
- return false;
- }
-
- // Check that substrate account is the owner or admin of the collection
- //
- // @param user account to verify
- // @return "true" if account is the owner or admin
- //
- // Selector: verifyOwnerOrAdminSubstrate(uint256) fe818e40
- function verifyOwnerOrAdminSubstrate(uint256 user)
- public
- view
- returns (bool)
- {
- require(false, stub_error);
- user;
- dummy;
- return false;
- }
-
- // Returns collection type
- //
- // @return `Fungible` or `NFT` or `ReFungible`
- //
- // Selector: uniqueCollectionType() d34b55b8
- function uniqueCollectionType() public returns (string memory) {
- require(false, stub_error);
- dummy = 0;
- return "";
- }
-
- // Changes collection owner to another account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner account
- //
- // Selector: changeOwner(address) a6f9dae1
- function changeOwner(address newOwner) public {
- require(false, stub_error);
- newOwner;
- dummy = 0;
- }
-
- // Changes collection owner to another substrate account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner substrate account
- //
- // Selector: changeOwnerSubstrate(uint256) 337e2c60
- function changeOwnerSubstrate(uint256 newOwner) public {
- require(false, stub_error);
- newOwner;
- dummy = 0;
- }
-}
-
// Selector: 41369377
contract TokenProperties is Dummy, ERC165 {
// @notice Set permissions for token property.
@@ -786,6 +494,294 @@
}
}
+// Selector: f077f83e
+contract Collection is Dummy, ERC165 {
+ // Set collection property.
+ //
+ // @param key Property key.
+ // @param value Propery value.
+ //
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ public
+ {
+ require(false, stub_error);
+ key;
+ value;
+ dummy = 0;
+ }
+
+ // Delete collection property.
+ //
+ // @param key Property key.
+ //
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) public {
+ require(false, stub_error);
+ key;
+ dummy = 0;
+ }
+
+ // Get collection property.
+ //
+ // @dev Throws error if key not found.
+ //
+ // @param key Property key.
+ // @return bytes The property corresponding to the key.
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ public
+ view
+ returns (bytes memory)
+ {
+ require(false, stub_error);
+ key;
+ dummy;
+ return hex"";
+ }
+
+ // Set the sponsor of the collection.
+ //
+ // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ //
+ // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
+ //
+ // Selector: setCollectionSponsor(address) 7623402e
+ function setCollectionSponsor(address sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ // Collection sponsorship confirmation.
+ //
+ // @dev After setting the sponsor for the collection, it must be confirmed with this function.
+ //
+ // Selector: confirmCollectionSponsorship() 3c50e97a
+ function confirmCollectionSponsorship() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "accountTokenOwnershipLimit",
+ // "sponsoredDataSize",
+ // "sponsoredDataRateLimit",
+ // "tokenLimit",
+ // "sponsorTransferTimeout",
+ // "sponsorApproveTimeout"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,uint32) 6a3841db
+ function setCollectionLimit(string memory limit, uint32 value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "ownerCanTransfer",
+ // "ownerCanDestroy",
+ // "transfersEnabled"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,bool) 993b7fba
+ function setCollectionLimit(string memory limit, bool value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Get contract address.
+ //
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() public view returns (address) {
+ require(false, stub_error);
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+
+ // Add collection admin by substrate address.
+ // @param new_admin Substrate administrator address.
+ //
+ // Selector: addCollectionAdminSubstrate(uint256) 5730062b
+ function addCollectionAdminSubstrate(uint256 newAdmin) public {
+ require(false, stub_error);
+ newAdmin;
+ dummy = 0;
+ }
+
+ // Remove collection admin by substrate address.
+ // @param admin Substrate administrator address.
+ //
+ // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+ function removeCollectionAdminSubstrate(uint256 admin) public {
+ require(false, stub_error);
+ admin;
+ dummy = 0;
+ }
+
+ // Add collection admin.
+ // @param new_admin Address of the added administrator.
+ //
+ // Selector: addCollectionAdmin(address) 92e462c7
+ function addCollectionAdmin(address newAdmin) public {
+ require(false, stub_error);
+ newAdmin;
+ dummy = 0;
+ }
+
+ // Remove collection admin.
+ //
+ // @param new_admin Address of the removed administrator.
+ //
+ // Selector: removeCollectionAdmin(address) fafd7b42
+ function removeCollectionAdmin(address admin) public {
+ require(false, stub_error);
+ admin;
+ dummy = 0;
+ }
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
+ //
+ // Selector: setCollectionNesting(bool) 112d4586
+ function setCollectionNesting(bool enable) public {
+ require(false, stub_error);
+ enable;
+ dummy = 0;
+ }
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
+ // @param collections Addresses of collections that will be available for nesting.
+ //
+ // Selector: setCollectionNesting(bool,address[]) 64872396
+ function setCollectionNesting(bool enable, address[] memory collections)
+ public
+ {
+ require(false, stub_error);
+ enable;
+ collections;
+ dummy = 0;
+ }
+
+ // Set the collection access method.
+ // @param mode Access mode
+ // 0 for Normal
+ // 1 for AllowList
+ //
+ // Selector: setCollectionAccess(uint8) 41835d4c
+ function setCollectionAccess(uint8 mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+
+ // Add the user to the allowed list.
+ //
+ // @param user Address of a trusted user.
+ //
+ // Selector: addToCollectionAllowList(address) 67844fe6
+ function addToCollectionAllowList(address user) public {
+ require(false, stub_error);
+ user;
+ dummy = 0;
+ }
+
+ // Remove the user from the allowed list.
+ //
+ // @param user Address of a removed user.
+ //
+ // Selector: removeFromCollectionAllowList(address) 85c51acb
+ function removeFromCollectionAllowList(address user) public {
+ require(false, stub_error);
+ user;
+ dummy = 0;
+ }
+
+ // Switch permission for minting.
+ //
+ // @param mode Enable if "true".
+ //
+ // Selector: setCollectionMintMode(bool) 00018e84
+ function setCollectionMintMode(bool mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+
+ // 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(address) c2282493
+ function verifyOwnerOrAdmin(address user) public view returns (bool) {
+ require(false, stub_error);
+ user;
+ dummy;
+ return false;
+ }
+
+ // Check that substrate 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(uint256) a83328e5
+ function verifyOwnerOrAdmin(uint256 user) public view returns (bool) {
+ require(false, stub_error);
+ user;
+ dummy;
+ return false;
+ }
+
+ // Returns collection type
+ //
+ // @return `Fungible` or `NFT` or `ReFungible`
+ //
+ // Selector: uniqueCollectionType() d34b55b8
+ function uniqueCollectionType() public returns (string memory) {
+ require(false, stub_error);
+ dummy = 0;
+ return "";
+ }
+
+ // Changes collection owner to another account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner account
+ //
+ // Selector: changeOwner(address) a6f9dae1
+ function changeOwner(address newOwner) public {
+ require(false, stub_error);
+ newOwner;
+ dummy = 0;
+ }
+
+ // Changes collection owner to another substrate account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner substrate account
+ //
+ // Selector: changeOwner(uint256) 924c19f7
+ function changeOwner(uint256 newOwner) public {
+ require(false, stub_error);
+ newOwner;
+ dummy = 0;
+ }
+}
+
contract UniqueNFT is
Dummy,
ERC165,
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -51,298 +51,6 @@
event MintingFinished();
}
-// Selector: 07f76b0c
-contract Collection is Dummy, ERC165 {
- // Set collection property.
- //
- // @param key Property key.
- // @param value Propery value.
- //
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- public
- {
- require(false, stub_error);
- key;
- value;
- dummy = 0;
- }
-
- // Delete collection property.
- //
- // @param key Property key.
- //
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) public {
- require(false, stub_error);
- key;
- dummy = 0;
- }
-
- // Get collection property.
- //
- // @dev Throws error if key not found.
- //
- // @param key Property key.
- // @return bytes The property corresponding to the key.
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- public
- view
- returns (bytes memory)
- {
- require(false, stub_error);
- key;
- dummy;
- return hex"";
- }
-
- // Set the sponsor of the collection.
- //
- // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
- //
- // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
- //
- // Selector: setCollectionSponsor(address) 7623402e
- function setCollectionSponsor(address sponsor) public {
- require(false, stub_error);
- sponsor;
- dummy = 0;
- }
-
- // Collection sponsorship confirmation.
- //
- // @dev After setting the sponsor for the collection, it must be confirmed with this function.
- //
- // Selector: confirmCollectionSponsorship() 3c50e97a
- function confirmCollectionSponsorship() public {
- require(false, stub_error);
- dummy = 0;
- }
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "accountTokenOwnershipLimit",
- // "sponsoredDataSize",
- // "sponsoredDataRateLimit",
- // "tokenLimit",
- // "sponsorTransferTimeout",
- // "sponsorApproveTimeout"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,uint32) 6a3841db
- function setCollectionLimit(string memory limit, uint32 value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "ownerCanTransfer",
- // "ownerCanDestroy",
- // "transfersEnabled"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,bool) 993b7fba
- function setCollectionLimit(string memory limit, bool value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Get contract address.
- //
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() public view returns (address) {
- require(false, stub_error);
- dummy;
- return 0x0000000000000000000000000000000000000000;
- }
-
- // Add collection admin by substrate address.
- // @param new_admin Substrate administrator address.
- //
- // Selector: addCollectionAdminSubstrate(uint256) 5730062b
- function addCollectionAdminSubstrate(uint256 newAdmin) public {
- require(false, stub_error);
- newAdmin;
- dummy = 0;
- }
-
- // Remove collection admin by substrate address.
- // @param admin Substrate administrator address.
- //
- // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
- function removeCollectionAdminSubstrate(uint256 admin) public {
- require(false, stub_error);
- admin;
- dummy = 0;
- }
-
- // Add collection admin.
- // @param new_admin Address of the added administrator.
- //
- // Selector: addCollectionAdmin(address) 92e462c7
- function addCollectionAdmin(address newAdmin) public {
- require(false, stub_error);
- newAdmin;
- dummy = 0;
- }
-
- // Remove collection admin.
- //
- // @param new_admin Address of the removed administrator.
- //
- // Selector: removeCollectionAdmin(address) fafd7b42
- function removeCollectionAdmin(address admin) public {
- require(false, stub_error);
- admin;
- dummy = 0;
- }
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
- //
- // Selector: setCollectionNesting(bool) 112d4586
- function setCollectionNesting(bool enable) public {
- require(false, stub_error);
- enable;
- dummy = 0;
- }
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
- // @param collections Addresses of collections that will be available for nesting.
- //
- // Selector: setCollectionNesting(bool,address[]) 64872396
- function setCollectionNesting(bool enable, address[] memory collections)
- public
- {
- require(false, stub_error);
- enable;
- collections;
- dummy = 0;
- }
-
- // Set the collection access method.
- // @param mode Access mode
- // 0 for Normal
- // 1 for AllowList
- //
- // Selector: setCollectionAccess(uint8) 41835d4c
- function setCollectionAccess(uint8 mode) public {
- require(false, stub_error);
- mode;
- dummy = 0;
- }
-
- // Add the user to the allowed list.
- //
- // @param user Address of a trusted user.
- //
- // Selector: addToCollectionAllowList(address) 67844fe6
- function addToCollectionAllowList(address user) public {
- require(false, stub_error);
- user;
- dummy = 0;
- }
-
- // Remove the user from the allowed list.
- //
- // @param user Address of a removed user.
- //
- // Selector: removeFromCollectionAllowList(address) 85c51acb
- function removeFromCollectionAllowList(address user) public {
- require(false, stub_error);
- user;
- dummy = 0;
- }
-
- // Switch permission for minting.
- //
- // @param mode Enable if "true".
- //
- // Selector: setCollectionMintMode(bool) 00018e84
- function setCollectionMintMode(bool mode) public {
- require(false, stub_error);
- mode;
- dummy = 0;
- }
-
- // 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(address) c2282493
- function verifyOwnerOrAdmin(address user) public view returns (bool) {
- require(false, stub_error);
- user;
- dummy;
- return false;
- }
-
- // Check that substrate account is the owner or admin of the collection
- //
- // @param user account to verify
- // @return "true" if account is the owner or admin
- //
- // Selector: verifyOwnerOrAdminSubstrate(uint256) fe818e40
- function verifyOwnerOrAdminSubstrate(uint256 user)
- public
- view
- returns (bool)
- {
- require(false, stub_error);
- user;
- dummy;
- return false;
- }
-
- // Returns collection type
- //
- // @return `Fungible` or `NFT` or `ReFungible`
- //
- // Selector: uniqueCollectionType() d34b55b8
- function uniqueCollectionType() public returns (string memory) {
- require(false, stub_error);
- dummy = 0;
- return "";
- }
-
- // Changes collection owner to another account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner account
- //
- // Selector: changeOwner(address) a6f9dae1
- function changeOwner(address newOwner) public {
- require(false, stub_error);
- newOwner;
- dummy = 0;
- }
-
- // Changes collection owner to another substrate account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner substrate account
- //
- // Selector: changeOwnerSubstrate(uint256) 337e2c60
- function changeOwnerSubstrate(uint256 newOwner) public {
- require(false, stub_error);
- newOwner;
- dummy = 0;
- }
-}
-
// Selector: 41369377
contract TokenProperties is Dummy, ERC165 {
// @notice Set permissions for token property.
@@ -798,6 +506,294 @@
}
}
+// Selector: f077f83e
+contract Collection is Dummy, ERC165 {
+ // Set collection property.
+ //
+ // @param key Property key.
+ // @param value Propery value.
+ //
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ public
+ {
+ require(false, stub_error);
+ key;
+ value;
+ dummy = 0;
+ }
+
+ // Delete collection property.
+ //
+ // @param key Property key.
+ //
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) public {
+ require(false, stub_error);
+ key;
+ dummy = 0;
+ }
+
+ // Get collection property.
+ //
+ // @dev Throws error if key not found.
+ //
+ // @param key Property key.
+ // @return bytes The property corresponding to the key.
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ public
+ view
+ returns (bytes memory)
+ {
+ require(false, stub_error);
+ key;
+ dummy;
+ return hex"";
+ }
+
+ // Set the sponsor of the collection.
+ //
+ // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ //
+ // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
+ //
+ // Selector: setCollectionSponsor(address) 7623402e
+ function setCollectionSponsor(address sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ // Collection sponsorship confirmation.
+ //
+ // @dev After setting the sponsor for the collection, it must be confirmed with this function.
+ //
+ // Selector: confirmCollectionSponsorship() 3c50e97a
+ function confirmCollectionSponsorship() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "accountTokenOwnershipLimit",
+ // "sponsoredDataSize",
+ // "sponsoredDataRateLimit",
+ // "tokenLimit",
+ // "sponsorTransferTimeout",
+ // "sponsorApproveTimeout"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,uint32) 6a3841db
+ function setCollectionLimit(string memory limit, uint32 value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "ownerCanTransfer",
+ // "ownerCanDestroy",
+ // "transfersEnabled"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,bool) 993b7fba
+ function setCollectionLimit(string memory limit, bool value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Get contract address.
+ //
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() public view returns (address) {
+ require(false, stub_error);
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+
+ // Add collection admin by substrate address.
+ // @param new_admin Substrate administrator address.
+ //
+ // Selector: addCollectionAdminSubstrate(uint256) 5730062b
+ function addCollectionAdminSubstrate(uint256 newAdmin) public {
+ require(false, stub_error);
+ newAdmin;
+ dummy = 0;
+ }
+
+ // Remove collection admin by substrate address.
+ // @param admin Substrate administrator address.
+ //
+ // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+ function removeCollectionAdminSubstrate(uint256 admin) public {
+ require(false, stub_error);
+ admin;
+ dummy = 0;
+ }
+
+ // Add collection admin.
+ // @param new_admin Address of the added administrator.
+ //
+ // Selector: addCollectionAdmin(address) 92e462c7
+ function addCollectionAdmin(address newAdmin) public {
+ require(false, stub_error);
+ newAdmin;
+ dummy = 0;
+ }
+
+ // Remove collection admin.
+ //
+ // @param new_admin Address of the removed administrator.
+ //
+ // Selector: removeCollectionAdmin(address) fafd7b42
+ function removeCollectionAdmin(address admin) public {
+ require(false, stub_error);
+ admin;
+ dummy = 0;
+ }
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
+ //
+ // Selector: setCollectionNesting(bool) 112d4586
+ function setCollectionNesting(bool enable) public {
+ require(false, stub_error);
+ enable;
+ dummy = 0;
+ }
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
+ // @param collections Addresses of collections that will be available for nesting.
+ //
+ // Selector: setCollectionNesting(bool,address[]) 64872396
+ function setCollectionNesting(bool enable, address[] memory collections)
+ public
+ {
+ require(false, stub_error);
+ enable;
+ collections;
+ dummy = 0;
+ }
+
+ // Set the collection access method.
+ // @param mode Access mode
+ // 0 for Normal
+ // 1 for AllowList
+ //
+ // Selector: setCollectionAccess(uint8) 41835d4c
+ function setCollectionAccess(uint8 mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+
+ // Add the user to the allowed list.
+ //
+ // @param user Address of a trusted user.
+ //
+ // Selector: addToCollectionAllowList(address) 67844fe6
+ function addToCollectionAllowList(address user) public {
+ require(false, stub_error);
+ user;
+ dummy = 0;
+ }
+
+ // Remove the user from the allowed list.
+ //
+ // @param user Address of a removed user.
+ //
+ // Selector: removeFromCollectionAllowList(address) 85c51acb
+ function removeFromCollectionAllowList(address user) public {
+ require(false, stub_error);
+ user;
+ dummy = 0;
+ }
+
+ // Switch permission for minting.
+ //
+ // @param mode Enable if "true".
+ //
+ // Selector: setCollectionMintMode(bool) 00018e84
+ function setCollectionMintMode(bool mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+
+ // 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(address) c2282493
+ function verifyOwnerOrAdmin(address user) public view returns (bool) {
+ require(false, stub_error);
+ user;
+ dummy;
+ return false;
+ }
+
+ // Check that substrate 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(uint256) a83328e5
+ function verifyOwnerOrAdmin(uint256 user) public view returns (bool) {
+ require(false, stub_error);
+ user;
+ dummy;
+ return false;
+ }
+
+ // Returns collection type
+ //
+ // @return `Fungible` or `NFT` or `ReFungible`
+ //
+ // Selector: uniqueCollectionType() d34b55b8
+ function uniqueCollectionType() public returns (string memory) {
+ require(false, stub_error);
+ dummy = 0;
+ return "";
+ }
+
+ // Changes collection owner to another account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner account
+ //
+ // Selector: changeOwner(address) a6f9dae1
+ function changeOwner(address newOwner) public {
+ require(false, stub_error);
+ newOwner;
+ dummy = 0;
+ }
+
+ // Changes collection owner to another substrate account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner substrate account
+ //
+ // Selector: changeOwner(uint256) 924c19f7
+ function changeOwner(uint256 newOwner) public {
+ require(false, stub_error);
+ newOwner;
+ dummy = 0;
+ }
+}
+
contract UniqueRefungible is
Dummy,
ERC165,
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -22,7 +22,50 @@
);
}
-// Selector: 07f76b0c
+// 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: f077f83e
interface Collection is Dummy, ERC165 {
// Set collection property.
//
@@ -182,11 +225,8 @@
// @param user account to verify
// @return "true" if account is the owner or admin
//
- // Selector: verifyOwnerOrAdminSubstrate(uint256) fe818e40
- function verifyOwnerOrAdminSubstrate(uint256 user)
- external
- view
- returns (bool);
+ // Selector: verifyOwnerOrAdmin(uint256) a83328e5
+ function verifyOwnerOrAdmin(uint256 user) external view returns (bool);
// Returns collection type
//
@@ -208,51 +248,8 @@
// @dev Owner can be changed only by current owner
// @param newOwner new owner substrate account
//
- // Selector: changeOwnerSubstrate(uint256) 337e2c60
- function changeOwnerSubstrate(uint256 newOwner) external;
-}
-
-// 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: changeOwner(uint256) 924c19f7
+ function changeOwner(uint256 newOwner) external;
}
interface UniqueFungible is
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -42,196 +42,6 @@
event MintingFinished();
}
-// Selector: 07f76b0c
-interface Collection is Dummy, ERC165 {
- // Set collection property.
- //
- // @param key Property key.
- // @param value Propery value.
- //
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- external;
-
- // Delete collection property.
- //
- // @param key Property key.
- //
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) external;
-
- // Get collection property.
- //
- // @dev Throws error if key not found.
- //
- // @param key Property key.
- // @return bytes The property corresponding to the key.
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- external
- view
- returns (bytes memory);
-
- // Set the sponsor of the collection.
- //
- // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
- //
- // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
- //
- // Selector: setCollectionSponsor(address) 7623402e
- function setCollectionSponsor(address sponsor) external;
-
- // Collection sponsorship confirmation.
- //
- // @dev After setting the sponsor for the collection, it must be confirmed with this function.
- //
- // Selector: confirmCollectionSponsorship() 3c50e97a
- function confirmCollectionSponsorship() external;
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "accountTokenOwnershipLimit",
- // "sponsoredDataSize",
- // "sponsoredDataRateLimit",
- // "tokenLimit",
- // "sponsorTransferTimeout",
- // "sponsorApproveTimeout"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,uint32) 6a3841db
- function setCollectionLimit(string memory limit, uint32 value) external;
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "ownerCanTransfer",
- // "ownerCanDestroy",
- // "transfersEnabled"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,bool) 993b7fba
- function setCollectionLimit(string memory limit, bool value) external;
-
- // Get contract address.
- //
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() external view returns (address);
-
- // Add collection admin by substrate address.
- // @param new_admin Substrate administrator address.
- //
- // Selector: addCollectionAdminSubstrate(uint256) 5730062b
- function addCollectionAdminSubstrate(uint256 newAdmin) external;
-
- // Remove collection admin by substrate address.
- // @param admin Substrate administrator address.
- //
- // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
- function removeCollectionAdminSubstrate(uint256 admin) external;
-
- // Add collection admin.
- // @param new_admin Address of the added administrator.
- //
- // Selector: addCollectionAdmin(address) 92e462c7
- function addCollectionAdmin(address newAdmin) external;
-
- // Remove collection admin.
- //
- // @param new_admin Address of the removed administrator.
- //
- // Selector: removeCollectionAdmin(address) fafd7b42
- function removeCollectionAdmin(address admin) external;
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
- //
- // Selector: setCollectionNesting(bool) 112d4586
- function setCollectionNesting(bool enable) external;
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
- // @param collections Addresses of collections that will be available for nesting.
- //
- // Selector: setCollectionNesting(bool,address[]) 64872396
- function setCollectionNesting(bool enable, address[] memory collections)
- external;
-
- // Set the collection access method.
- // @param mode Access mode
- // 0 for Normal
- // 1 for AllowList
- //
- // Selector: setCollectionAccess(uint8) 41835d4c
- function setCollectionAccess(uint8 mode) external;
-
- // Add the user to the allowed list.
- //
- // @param user Address of a trusted user.
- //
- // Selector: addToCollectionAllowList(address) 67844fe6
- function addToCollectionAllowList(address user) external;
-
- // Remove the user from the allowed list.
- //
- // @param user Address of a removed user.
- //
- // Selector: removeFromCollectionAllowList(address) 85c51acb
- function removeFromCollectionAllowList(address user) external;
-
- // Switch permission for minting.
- //
- // @param mode Enable if "true".
- //
- // Selector: setCollectionMintMode(bool) 00018e84
- function setCollectionMintMode(bool mode) external;
-
- // 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(address) c2282493
- function verifyOwnerOrAdmin(address user) external view returns (bool);
-
- // Check that substrate account is the owner or admin of the collection
- //
- // @param user account to verify
- // @return "true" if account is the owner or admin
- //
- // Selector: verifyOwnerOrAdminSubstrate(uint256) fe818e40
- function verifyOwnerOrAdminSubstrate(uint256 user)
- external
- view
- returns (bool);
-
- // Returns collection type
- //
- // @return `Fungible` or `NFT` or `ReFungible`
- //
- // Selector: uniqueCollectionType() d34b55b8
- function uniqueCollectionType() external returns (string memory);
-
- // Changes collection owner to another account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner account
- //
- // Selector: changeOwner(address) a6f9dae1
- function changeOwner(address newOwner) external;
-
- // Changes collection owner to another substrate account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner substrate account
- //
- // Selector: changeOwnerSubstrate(uint256) 337e2c60
- function changeOwnerSubstrate(uint256 newOwner) external;
-}
-
// Selector: 41369377
interface TokenProperties is Dummy, ERC165 {
// @notice Set permissions for token property.
@@ -517,6 +327,193 @@
returns (bool);
}
+// Selector: f077f83e
+interface Collection is Dummy, ERC165 {
+ // Set collection property.
+ //
+ // @param key Property key.
+ // @param value Propery value.
+ //
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ external;
+
+ // Delete collection property.
+ //
+ // @param key Property key.
+ //
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) external;
+
+ // Get collection property.
+ //
+ // @dev Throws error if key not found.
+ //
+ // @param key Property key.
+ // @return bytes The property corresponding to the key.
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ external
+ view
+ returns (bytes memory);
+
+ // Set the sponsor of the collection.
+ //
+ // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ //
+ // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
+ //
+ // Selector: setCollectionSponsor(address) 7623402e
+ function setCollectionSponsor(address sponsor) external;
+
+ // Collection sponsorship confirmation.
+ //
+ // @dev After setting the sponsor for the collection, it must be confirmed with this function.
+ //
+ // Selector: confirmCollectionSponsorship() 3c50e97a
+ function confirmCollectionSponsorship() external;
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "accountTokenOwnershipLimit",
+ // "sponsoredDataSize",
+ // "sponsoredDataRateLimit",
+ // "tokenLimit",
+ // "sponsorTransferTimeout",
+ // "sponsorApproveTimeout"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,uint32) 6a3841db
+ function setCollectionLimit(string memory limit, uint32 value) external;
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "ownerCanTransfer",
+ // "ownerCanDestroy",
+ // "transfersEnabled"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,bool) 993b7fba
+ function setCollectionLimit(string memory limit, bool value) external;
+
+ // Get contract address.
+ //
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() external view returns (address);
+
+ // Add collection admin by substrate address.
+ // @param new_admin Substrate administrator address.
+ //
+ // Selector: addCollectionAdminSubstrate(uint256) 5730062b
+ function addCollectionAdminSubstrate(uint256 newAdmin) external;
+
+ // Remove collection admin by substrate address.
+ // @param admin Substrate administrator address.
+ //
+ // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+ function removeCollectionAdminSubstrate(uint256 admin) external;
+
+ // Add collection admin.
+ // @param new_admin Address of the added administrator.
+ //
+ // Selector: addCollectionAdmin(address) 92e462c7
+ function addCollectionAdmin(address newAdmin) external;
+
+ // Remove collection admin.
+ //
+ // @param new_admin Address of the removed administrator.
+ //
+ // Selector: removeCollectionAdmin(address) fafd7b42
+ function removeCollectionAdmin(address admin) external;
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
+ //
+ // Selector: setCollectionNesting(bool) 112d4586
+ function setCollectionNesting(bool enable) external;
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
+ // @param collections Addresses of collections that will be available for nesting.
+ //
+ // Selector: setCollectionNesting(bool,address[]) 64872396
+ function setCollectionNesting(bool enable, address[] memory collections)
+ external;
+
+ // Set the collection access method.
+ // @param mode Access mode
+ // 0 for Normal
+ // 1 for AllowList
+ //
+ // Selector: setCollectionAccess(uint8) 41835d4c
+ function setCollectionAccess(uint8 mode) external;
+
+ // Add the user to the allowed list.
+ //
+ // @param user Address of a trusted user.
+ //
+ // Selector: addToCollectionAllowList(address) 67844fe6
+ function addToCollectionAllowList(address user) external;
+
+ // Remove the user from the allowed list.
+ //
+ // @param user Address of a removed user.
+ //
+ // Selector: removeFromCollectionAllowList(address) 85c51acb
+ function removeFromCollectionAllowList(address user) external;
+
+ // Switch permission for minting.
+ //
+ // @param mode Enable if "true".
+ //
+ // Selector: setCollectionMintMode(bool) 00018e84
+ function setCollectionMintMode(bool mode) external;
+
+ // 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(address) c2282493
+ function verifyOwnerOrAdmin(address user) external view returns (bool);
+
+ // Check that substrate 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(uint256) a83328e5
+ function verifyOwnerOrAdmin(uint256 user) external view returns (bool);
+
+ // Returns collection type
+ //
+ // @return `Fungible` or `NFT` or `ReFungible`
+ //
+ // Selector: uniqueCollectionType() d34b55b8
+ function uniqueCollectionType() external returns (string memory);
+
+ // Changes collection owner to another account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner account
+ //
+ // Selector: changeOwner(address) a6f9dae1
+ function changeOwner(address newOwner) external;
+
+ // Changes collection owner to another substrate account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner substrate account
+ //
+ // Selector: changeOwner(uint256) 924c19f7
+ function changeOwner(uint256 newOwner) external;
+}
+
interface UniqueNFT is
Dummy,
ERC165,
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -42,196 +42,6 @@
event MintingFinished();
}
-// Selector: 07f76b0c
-interface Collection is Dummy, ERC165 {
- // Set collection property.
- //
- // @param key Property key.
- // @param value Propery value.
- //
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- external;
-
- // Delete collection property.
- //
- // @param key Property key.
- //
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) external;
-
- // Get collection property.
- //
- // @dev Throws error if key not found.
- //
- // @param key Property key.
- // @return bytes The property corresponding to the key.
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- external
- view
- returns (bytes memory);
-
- // Set the sponsor of the collection.
- //
- // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
- //
- // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
- //
- // Selector: setCollectionSponsor(address) 7623402e
- function setCollectionSponsor(address sponsor) external;
-
- // Collection sponsorship confirmation.
- //
- // @dev After setting the sponsor for the collection, it must be confirmed with this function.
- //
- // Selector: confirmCollectionSponsorship() 3c50e97a
- function confirmCollectionSponsorship() external;
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "accountTokenOwnershipLimit",
- // "sponsoredDataSize",
- // "sponsoredDataRateLimit",
- // "tokenLimit",
- // "sponsorTransferTimeout",
- // "sponsorApproveTimeout"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,uint32) 6a3841db
- function setCollectionLimit(string memory limit, uint32 value) external;
-
- // Set limits for the collection.
- // @dev Throws error if limit not found.
- // @param limit Name of the limit. Valid names:
- // "ownerCanTransfer",
- // "ownerCanDestroy",
- // "transfersEnabled"
- // @param value Value of the limit.
- //
- // Selector: setCollectionLimit(string,bool) 993b7fba
- function setCollectionLimit(string memory limit, bool value) external;
-
- // Get contract address.
- //
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() external view returns (address);
-
- // Add collection admin by substrate address.
- // @param new_admin Substrate administrator address.
- //
- // Selector: addCollectionAdminSubstrate(uint256) 5730062b
- function addCollectionAdminSubstrate(uint256 newAdmin) external;
-
- // Remove collection admin by substrate address.
- // @param admin Substrate administrator address.
- //
- // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
- function removeCollectionAdminSubstrate(uint256 admin) external;
-
- // Add collection admin.
- // @param new_admin Address of the added administrator.
- //
- // Selector: addCollectionAdmin(address) 92e462c7
- function addCollectionAdmin(address newAdmin) external;
-
- // Remove collection admin.
- //
- // @param new_admin Address of the removed administrator.
- //
- // Selector: removeCollectionAdmin(address) fafd7b42
- function removeCollectionAdmin(address admin) external;
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
- //
- // Selector: setCollectionNesting(bool) 112d4586
- function setCollectionNesting(bool enable) external;
-
- // Toggle accessibility of collection nesting.
- //
- // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
- // @param collections Addresses of collections that will be available for nesting.
- //
- // Selector: setCollectionNesting(bool,address[]) 64872396
- function setCollectionNesting(bool enable, address[] memory collections)
- external;
-
- // Set the collection access method.
- // @param mode Access mode
- // 0 for Normal
- // 1 for AllowList
- //
- // Selector: setCollectionAccess(uint8) 41835d4c
- function setCollectionAccess(uint8 mode) external;
-
- // Add the user to the allowed list.
- //
- // @param user Address of a trusted user.
- //
- // Selector: addToCollectionAllowList(address) 67844fe6
- function addToCollectionAllowList(address user) external;
-
- // Remove the user from the allowed list.
- //
- // @param user Address of a removed user.
- //
- // Selector: removeFromCollectionAllowList(address) 85c51acb
- function removeFromCollectionAllowList(address user) external;
-
- // Switch permission for minting.
- //
- // @param mode Enable if "true".
- //
- // Selector: setCollectionMintMode(bool) 00018e84
- function setCollectionMintMode(bool mode) external;
-
- // 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(address) c2282493
- function verifyOwnerOrAdmin(address user) external view returns (bool);
-
- // Check that substrate account is the owner or admin of the collection
- //
- // @param user account to verify
- // @return "true" if account is the owner or admin
- //
- // Selector: verifyOwnerOrAdminSubstrate(uint256) fe818e40
- function verifyOwnerOrAdminSubstrate(uint256 user)
- external
- view
- returns (bool);
-
- // Returns collection type
- //
- // @return `Fungible` or `NFT` or `ReFungible`
- //
- // Selector: uniqueCollectionType() d34b55b8
- function uniqueCollectionType() external returns (string memory);
-
- // Changes collection owner to another account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner account
- //
- // Selector: changeOwner(address) a6f9dae1
- function changeOwner(address newOwner) external;
-
- // Changes collection owner to another substrate account
- //
- // @dev Owner can be changed only by current owner
- // @param newOwner new owner substrate account
- //
- // Selector: changeOwnerSubstrate(uint256) 337e2c60
- function changeOwnerSubstrate(uint256 newOwner) external;
-}
-
// Selector: 41369377
interface TokenProperties is Dummy, ERC165 {
// @notice Set permissions for token property.
@@ -527,6 +337,193 @@
returns (address);
}
+// Selector: f077f83e
+interface Collection is Dummy, ERC165 {
+ // Set collection property.
+ //
+ // @param key Property key.
+ // @param value Propery value.
+ //
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ external;
+
+ // Delete collection property.
+ //
+ // @param key Property key.
+ //
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) external;
+
+ // Get collection property.
+ //
+ // @dev Throws error if key not found.
+ //
+ // @param key Property key.
+ // @return bytes The property corresponding to the key.
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ external
+ view
+ returns (bytes memory);
+
+ // Set the sponsor of the collection.
+ //
+ // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ //
+ // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
+ //
+ // Selector: setCollectionSponsor(address) 7623402e
+ function setCollectionSponsor(address sponsor) external;
+
+ // Collection sponsorship confirmation.
+ //
+ // @dev After setting the sponsor for the collection, it must be confirmed with this function.
+ //
+ // Selector: confirmCollectionSponsorship() 3c50e97a
+ function confirmCollectionSponsorship() external;
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "accountTokenOwnershipLimit",
+ // "sponsoredDataSize",
+ // "sponsoredDataRateLimit",
+ // "tokenLimit",
+ // "sponsorTransferTimeout",
+ // "sponsorApproveTimeout"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,uint32) 6a3841db
+ function setCollectionLimit(string memory limit, uint32 value) external;
+
+ // Set limits for the collection.
+ // @dev Throws error if limit not found.
+ // @param limit Name of the limit. Valid names:
+ // "ownerCanTransfer",
+ // "ownerCanDestroy",
+ // "transfersEnabled"
+ // @param value Value of the limit.
+ //
+ // Selector: setCollectionLimit(string,bool) 993b7fba
+ function setCollectionLimit(string memory limit, bool value) external;
+
+ // Get contract address.
+ //
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() external view returns (address);
+
+ // Add collection admin by substrate address.
+ // @param new_admin Substrate administrator address.
+ //
+ // Selector: addCollectionAdminSubstrate(uint256) 5730062b
+ function addCollectionAdminSubstrate(uint256 newAdmin) external;
+
+ // Remove collection admin by substrate address.
+ // @param admin Substrate administrator address.
+ //
+ // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+ function removeCollectionAdminSubstrate(uint256 admin) external;
+
+ // Add collection admin.
+ // @param new_admin Address of the added administrator.
+ //
+ // Selector: addCollectionAdmin(address) 92e462c7
+ function addCollectionAdmin(address newAdmin) external;
+
+ // Remove collection admin.
+ //
+ // @param new_admin Address of the removed administrator.
+ //
+ // Selector: removeCollectionAdmin(address) fafd7b42
+ function removeCollectionAdmin(address admin) external;
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
+ //
+ // Selector: setCollectionNesting(bool) 112d4586
+ function setCollectionNesting(bool enable) external;
+
+ // Toggle accessibility of collection nesting.
+ //
+ // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
+ // @param collections Addresses of collections that will be available for nesting.
+ //
+ // Selector: setCollectionNesting(bool,address[]) 64872396
+ function setCollectionNesting(bool enable, address[] memory collections)
+ external;
+
+ // Set the collection access method.
+ // @param mode Access mode
+ // 0 for Normal
+ // 1 for AllowList
+ //
+ // Selector: setCollectionAccess(uint8) 41835d4c
+ function setCollectionAccess(uint8 mode) external;
+
+ // Add the user to the allowed list.
+ //
+ // @param user Address of a trusted user.
+ //
+ // Selector: addToCollectionAllowList(address) 67844fe6
+ function addToCollectionAllowList(address user) external;
+
+ // Remove the user from the allowed list.
+ //
+ // @param user Address of a removed user.
+ //
+ // Selector: removeFromCollectionAllowList(address) 85c51acb
+ function removeFromCollectionAllowList(address user) external;
+
+ // Switch permission for minting.
+ //
+ // @param mode Enable if "true".
+ //
+ // Selector: setCollectionMintMode(bool) 00018e84
+ function setCollectionMintMode(bool mode) external;
+
+ // 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(address) c2282493
+ function verifyOwnerOrAdmin(address user) external view returns (bool);
+
+ // Check that substrate 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(uint256) a83328e5
+ function verifyOwnerOrAdmin(uint256 user) external view returns (bool);
+
+ // Returns collection type
+ //
+ // @return `Fungible` or `NFT` or `ReFungible`
+ //
+ // Selector: uniqueCollectionType() d34b55b8
+ function uniqueCollectionType() external returns (string memory);
+
+ // Changes collection owner to another account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner account
+ //
+ // Selector: changeOwner(address) a6f9dae1
+ function changeOwner(address newOwner) external;
+
+ // Changes collection owner to another substrate account
+ //
+ // @dev Owner can be changed only by current owner
+ // @param newOwner new owner substrate account
+ //
+ // Selector: changeOwner(uint256) 924c19f7
+ function changeOwner(uint256 newOwner) external;
+}
+
interface UniqueRefungible is
Dummy,
ERC165,
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth1// 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 { UNIQUE } from '../util/helpers';19import {20 createEthAccount,21 createEthAccountWithBalance, 22 evmCollection, 23 evmCollectionHelpers, 24 getCollectionAddressFromResult, 25 itWeb3,26 recordEthFee,27 subToEth,28} from './util/helpers';2930describe('Add collection admins', () => {31 itWeb3('Add admin by owner', async ({api, web3, privateKeyWrapper}) => {32 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);33 const collectionHelper = evmCollectionHelpers(web3, owner);34 35 const result = await collectionHelper.methods36 .createNonfungibleCollection('A', 'B', 'C')37 .send();38 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);3940 const newAdmin = await createEthAccount(web3);41 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);42 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();43 const adminList = await api.rpc.unique.adminlist(collectionId);44 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())45 .to.be.eq(newAdmin.toLocaleLowerCase());46 });4748 itWeb3('Add substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {49 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);50 const collectionHelper = evmCollectionHelpers(web3, owner);51 52 const result = await collectionHelper.methods53 .createNonfungibleCollection('A', 'B', 'C')54 .send();55 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);5657 const newAdmin = privateKeyWrapper('//Alice');58 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);59 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();6061 const adminList = await api.rpc.unique.adminlist(collectionId);62 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())63 .to.be.eq(newAdmin.address.toLocaleLowerCase());64 });65 66 itWeb3('Verify owner or admin', async ({api, web3, privateKeyWrapper}) => {67 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);68 const collectionHelper = evmCollectionHelpers(web3, owner);69 70 const result = await collectionHelper.methods71 .createNonfungibleCollection('A', 'B', 'C')72 .send();73 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);7475 const newAdmin = createEthAccount(web3);76 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);77 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.false;78 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();79 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.true;80 });8182 itWeb3('(!negative tests!) Add admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {83 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);84 const collectionHelper = evmCollectionHelpers(web3, owner);85 86 const result = await collectionHelper.methods87 .createNonfungibleCollection('A', 'B', 'C')88 .send();89 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);9091 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);92 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);93 await collectionEvm.methods.addCollectionAdmin(admin).send();94 95 const user = await createEthAccount(web3);96 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))97 .to.be.rejectedWith('NoPermission');9899 const adminList = await api.rpc.unique.adminlist(collectionId);100 expect(adminList.length).to.be.eq(1);101 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())102 .to.be.eq(admin.toLocaleLowerCase());103 });104105 itWeb3('(!negative tests!) Add admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {106 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);107 const collectionHelper = evmCollectionHelpers(web3, owner);108 109 const result = await collectionHelper.methods110 .createNonfungibleCollection('A', 'B', 'C')111 .send();112 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);113114 const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);115 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);116 117 const user = await createEthAccount(web3);118 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))119 .to.be.rejectedWith('NoPermission');120121 const adminList = await api.rpc.unique.adminlist(collectionId);122 expect(adminList.length).to.be.eq(0);123 });124125 itWeb3('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {126 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);127 const collectionHelper = evmCollectionHelpers(web3, owner);128 129 const result = await collectionHelper.methods130 .createNonfungibleCollection('A', 'B', 'C')131 .send();132 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);133134 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);135 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);136 await collectionEvm.methods.addCollectionAdmin(admin).send();137138 const notAdmin = privateKey('//Alice');139 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))140 .to.be.rejectedWith('NoPermission');141142 const adminList = await api.rpc.unique.adminlist(collectionId);143 expect(adminList.length).to.be.eq(1);144 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())145 .to.be.eq(admin.toLocaleLowerCase());146 });147 148 itWeb3('(!negative tests!) Add substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {149 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);150 const collectionHelper = evmCollectionHelpers(web3, owner);151 152 const result = await collectionHelper.methods153 .createNonfungibleCollection('A', 'B', 'C')154 .send();155 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);156157 const notAdmin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);158 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);159 const notAdmin1 = privateKey('//Alice');160 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))161 .to.be.rejectedWith('NoPermission');162163 const adminList = await api.rpc.unique.adminlist(collectionId);164 expect(adminList.length).to.be.eq(0);165 });166});167168describe('Remove collection admins', () => {169 itWeb3('Remove admin by owner', async ({api, web3, privateKeyWrapper}) => {170 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);171 const collectionHelper = evmCollectionHelpers(web3, owner);172 173 const result = await collectionHelper.methods174 .createNonfungibleCollection('A', 'B', 'C')175 .send();176 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);177178 const newAdmin = await createEthAccount(web3);179 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);180 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();181 {182 const adminList = await api.rpc.unique.adminlist(collectionId);183 expect(adminList.length).to.be.eq(1);184 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())185 .to.be.eq(newAdmin.toLocaleLowerCase());186 }187188 await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();189 const adminList = await api.rpc.unique.adminlist(collectionId);190 expect(adminList.length).to.be.eq(0);191 });192193 itWeb3('Remove substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {194 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);195 const collectionHelper = evmCollectionHelpers(web3, owner);196 197 const result = await collectionHelper.methods198 .createNonfungibleCollection('A', 'B', 'C')199 .send();200 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);201202 const newAdmin = privateKeyWrapper('//Alice');203 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);204 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();205 {206 const adminList = await api.rpc.unique.adminlist(collectionId);207 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())208 .to.be.eq(newAdmin.address.toLocaleLowerCase());209 }210 211 await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();212 const adminList = await api.rpc.unique.adminlist(collectionId);213 expect(adminList.length).to.be.eq(0);214 });215216 itWeb3('(!negative tests!) Remove admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {217 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);218 const collectionHelper = evmCollectionHelpers(web3, owner);219 220 const result = await collectionHelper.methods221 .createNonfungibleCollection('A', 'B', 'C')222 .send();223 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);224225 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);226227 const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);228 await collectionEvm.methods.addCollectionAdmin(admin0).send();229 const admin1 = await createEthAccount(web3);230 await collectionEvm.methods.addCollectionAdmin(admin1).send();231232 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))233 .to.be.rejectedWith('NoPermission');234 {235 const adminList = await api.rpc.unique.adminlist(collectionId);236 expect(adminList.length).to.be.eq(2);237 expect(adminList.toString().toLocaleLowerCase())238 .to.be.deep.contains(admin0.toLocaleLowerCase())239 .to.be.deep.contains(admin1.toLocaleLowerCase());240 }241 });242243 itWeb3('(!negative tests!) Remove admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {244 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);245 const collectionHelper = evmCollectionHelpers(web3, owner);246 247 const result = await collectionHelper.methods248 .createNonfungibleCollection('A', 'B', 'C')249 .send();250 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);251252 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);253254 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);255 await collectionEvm.methods.addCollectionAdmin(admin).send();256 const notAdmin = await createEthAccount(web3);257258 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))259 .to.be.rejectedWith('NoPermission');260 {261 const adminList = await api.rpc.unique.adminlist(collectionId);262 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())263 .to.be.eq(admin.toLocaleLowerCase());264 expect(adminList.length).to.be.eq(1);265 }266 });267268 itWeb3('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {269 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);270 const collectionHelper = evmCollectionHelpers(web3, owner);271 272 const result = await collectionHelper.methods273 .createNonfungibleCollection('A', 'B', 'C')274 .send();275 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);276277 const adminSub = privateKeyWrapper('//Alice');278 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);279 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();280 const adminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);281 await collectionEvm.methods.addCollectionAdmin(adminEth).send();282283 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))284 .to.be.rejectedWith('NoPermission');285286 const adminList = await api.rpc.unique.adminlist(collectionId);287 expect(adminList.length).to.be.eq(2);288 expect(adminList.toString().toLocaleLowerCase())289 .to.be.deep.contains(adminSub.address.toLocaleLowerCase())290 .to.be.deep.contains(adminEth.toLocaleLowerCase());291 });292293 itWeb3('(!negative tests!) Remove substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {294 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);295 const collectionHelper = evmCollectionHelpers(web3, owner);296 297 const result = await collectionHelper.methods298 .createNonfungibleCollection('A', 'B', 'C')299 .send();300 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);301302 const adminSub = privateKeyWrapper('//Alice');303 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);304 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();305 const notAdminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);306307 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))308 .to.be.rejectedWith('NoPermission');309310 const adminList = await api.rpc.unique.adminlist(collectionId);311 expect(adminList.length).to.be.eq(1);312 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())313 .to.be.eq(adminSub.address.toLocaleLowerCase());314 });315});316317describe('Change owner tests', () => {318 itWeb3('Change owner', async ({api, web3, privateKeyWrapper}) => {319 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);320 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);321 const collectionHelper = evmCollectionHelpers(web3, owner);322 const result = await collectionHelper.methods323 .createNonfungibleCollection('A', 'B', 'C')324 .send();325 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);326 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);327 328 await collectionEvm.methods.changeOwner(newOwner).send();329 330 expect(await collectionEvm.methods.verifyOwnerOrAdmin(owner).call()).to.be.false;331 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newOwner).call()).to.be.true;332 });333334 itWeb3('change owner call fee', async ({web3, api, privateKeyWrapper}) => {335 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);336 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);337 const collectionHelper = evmCollectionHelpers(web3, owner);338 const result = await collectionHelper.methods339 .createNonfungibleCollection('A', 'B', 'C')340 .send();341 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);342 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);343344 const cost = await recordEthFee(api, owner, () => collectionEvm.methods.changeOwner(newOwner).send());345 expect(cost < BigInt(0.2 * Number(UNIQUE)));346 expect(cost > 0);347 });348349 itWeb3('(!negative tests!) call changeOwner by not owner', async ({api, web3, privateKeyWrapper}) => {350 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);351 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);352 const collectionHelper = evmCollectionHelpers(web3, owner);353 const result = await collectionHelper.methods354 .createNonfungibleCollection('A', 'B', 'C')355 .send();356 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);357 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);358 359 await expect(collectionEvm.methods.changeOwner(newOwner).send({from: newOwner})).to.be.rejected;360 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newOwner).call()).to.be.false;361 });362});363364describe('Change substrate owner tests', () => {365 itWeb3('Change owner', async ({api, web3, privateKeyWrapper}) => {366 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);367 const newOwner = privateKeyWrapper('//Alice');368 const collectionHelper = evmCollectionHelpers(web3, owner);369 const result = await collectionHelper.methods370 .createNonfungibleCollection('A', 'B', 'C')371 .send();372 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);373 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);374 375 expect(await collectionEvm.methods.verifyOwnerOrAdmin(owner).call()).to.be.true;376 expect(await collectionEvm.methods.verifyOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;377 await collectionEvm.methods.changeOwnerSubstrate(newOwner.addressRaw).send();378 379 expect(await collectionEvm.methods.verifyOwnerOrAdmin(owner).call()).to.be.false;380 expect(await collectionEvm.methods.verifyOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;381 });382383 itWeb3('change owner call fee', async ({web3, api, privateKeyWrapper}) => {384 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);385 const newOwner = privateKeyWrapper('//Alice');386 const collectionHelper = evmCollectionHelpers(web3, owner);387 const result = await collectionHelper.methods388 .createNonfungibleCollection('A', 'B', 'C')389 .send();390 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);391 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);392393 const cost = await recordEthFee(api, owner, () => collectionEvm.methods.changeOwnerSubstrate(newOwner.addressRaw).send());394 expect(cost < BigInt(0.2 * Number(UNIQUE)));395 expect(cost > 0);396 });397398 itWeb3('(!negative tests!) call changeOwner by not owner', async ({api, web3, privateKeyWrapper}) => {399 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);400 const otherReceiver = await createEthAccountWithBalance(api, web3, privateKeyWrapper);401 const newOwner = privateKeyWrapper('//Alice');402 const collectionHelper = evmCollectionHelpers(web3, owner);403 const result = await collectionHelper.methods404 .createNonfungibleCollection('A', 'B', 'C')405 .send();406 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);407 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);408 409 await expect(collectionEvm.methods.changeOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;410 expect(await collectionEvm.methods.verifyOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;411 });412});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 { UNIQUE } from '../util/helpers';19import {20 createEthAccount,21 createEthAccountWithBalance, 22 evmCollection, 23 evmCollectionHelpers, 24 getCollectionAddressFromResult, 25 itWeb3,26 recordEthFee,27 subToEth,28} from './util/helpers';2930describe('Add collection admins', () => {31 itWeb3('Add admin by owner', async ({api, web3, privateKeyWrapper}) => {32 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);33 const collectionHelper = evmCollectionHelpers(web3, owner);34 35 const result = await collectionHelper.methods36 .createNonfungibleCollection('A', 'B', 'C')37 .send();38 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);3940 const newAdmin = await createEthAccount(web3);41 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);42 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();43 const adminList = await api.rpc.unique.adminlist(collectionId);44 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())45 .to.be.eq(newAdmin.toLocaleLowerCase());46 });4748 itWeb3('Add substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {49 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);50 const collectionHelper = evmCollectionHelpers(web3, owner);51 52 const result = await collectionHelper.methods53 .createNonfungibleCollection('A', 'B', 'C')54 .send();55 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);5657 const newAdmin = privateKeyWrapper('//Alice');58 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);59 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();6061 const adminList = await api.rpc.unique.adminlist(collectionId);62 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())63 .to.be.eq(newAdmin.address.toLocaleLowerCase());64 });65 66 itWeb3('Verify owner or admin', async ({api, web3, privateKeyWrapper}) => {67 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);68 const collectionHelper = evmCollectionHelpers(web3, owner);69 70 const result = await collectionHelper.methods71 .createNonfungibleCollection('A', 'B', 'C')72 .send();73 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);7475 const newAdmin = createEthAccount(web3);76 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);77 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.false;78 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();79 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.true;80 });8182 itWeb3('(!negative tests!) Add admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {83 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);84 const collectionHelper = evmCollectionHelpers(web3, owner);85 86 const result = await collectionHelper.methods87 .createNonfungibleCollection('A', 'B', 'C')88 .send();89 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);9091 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);92 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);93 await collectionEvm.methods.addCollectionAdmin(admin).send();94 95 const user = await createEthAccount(web3);96 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))97 .to.be.rejectedWith('NoPermission');9899 const adminList = await api.rpc.unique.adminlist(collectionId);100 expect(adminList.length).to.be.eq(1);101 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())102 .to.be.eq(admin.toLocaleLowerCase());103 });104105 itWeb3('(!negative tests!) Add admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {106 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);107 const collectionHelper = evmCollectionHelpers(web3, owner);108 109 const result = await collectionHelper.methods110 .createNonfungibleCollection('A', 'B', 'C')111 .send();112 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);113114 const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);115 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);116 117 const user = await createEthAccount(web3);118 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))119 .to.be.rejectedWith('NoPermission');120121 const adminList = await api.rpc.unique.adminlist(collectionId);122 expect(adminList.length).to.be.eq(0);123 });124125 itWeb3('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {126 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);127 const collectionHelper = evmCollectionHelpers(web3, owner);128 129 const result = await collectionHelper.methods130 .createNonfungibleCollection('A', 'B', 'C')131 .send();132 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);133134 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);135 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);136 await collectionEvm.methods.addCollectionAdmin(admin).send();137138 const notAdmin = privateKey('//Alice');139 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))140 .to.be.rejectedWith('NoPermission');141142 const adminList = await api.rpc.unique.adminlist(collectionId);143 expect(adminList.length).to.be.eq(1);144 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())145 .to.be.eq(admin.toLocaleLowerCase());146 });147 148 itWeb3('(!negative tests!) Add substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {149 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);150 const collectionHelper = evmCollectionHelpers(web3, owner);151 152 const result = await collectionHelper.methods153 .createNonfungibleCollection('A', 'B', 'C')154 .send();155 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);156157 const notAdmin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);158 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);159 const notAdmin1 = privateKey('//Alice');160 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))161 .to.be.rejectedWith('NoPermission');162163 const adminList = await api.rpc.unique.adminlist(collectionId);164 expect(adminList.length).to.be.eq(0);165 });166});167168describe('Remove collection admins', () => {169 itWeb3('Remove admin by owner', async ({api, web3, privateKeyWrapper}) => {170 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);171 const collectionHelper = evmCollectionHelpers(web3, owner);172 173 const result = await collectionHelper.methods174 .createNonfungibleCollection('A', 'B', 'C')175 .send();176 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);177178 const newAdmin = await createEthAccount(web3);179 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);180 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();181 {182 const adminList = await api.rpc.unique.adminlist(collectionId);183 expect(adminList.length).to.be.eq(1);184 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())185 .to.be.eq(newAdmin.toLocaleLowerCase());186 }187188 await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();189 const adminList = await api.rpc.unique.adminlist(collectionId);190 expect(adminList.length).to.be.eq(0);191 });192193 itWeb3('Remove substrate admin by owner', async ({api, web3, privateKeyWrapper}) => {194 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);195 const collectionHelper = evmCollectionHelpers(web3, owner);196 197 const result = await collectionHelper.methods198 .createNonfungibleCollection('A', 'B', 'C')199 .send();200 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);201202 const newAdmin = privateKeyWrapper('//Alice');203 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);204 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();205 {206 const adminList = await api.rpc.unique.adminlist(collectionId);207 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())208 .to.be.eq(newAdmin.address.toLocaleLowerCase());209 }210 211 await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();212 const adminList = await api.rpc.unique.adminlist(collectionId);213 expect(adminList.length).to.be.eq(0);214 });215216 itWeb3('(!negative tests!) Remove admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {217 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);218 const collectionHelper = evmCollectionHelpers(web3, owner);219 220 const result = await collectionHelper.methods221 .createNonfungibleCollection('A', 'B', 'C')222 .send();223 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);224225 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);226227 const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);228 await collectionEvm.methods.addCollectionAdmin(admin0).send();229 const admin1 = await createEthAccount(web3);230 await collectionEvm.methods.addCollectionAdmin(admin1).send();231232 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))233 .to.be.rejectedWith('NoPermission');234 {235 const adminList = await api.rpc.unique.adminlist(collectionId);236 expect(adminList.length).to.be.eq(2);237 expect(adminList.toString().toLocaleLowerCase())238 .to.be.deep.contains(admin0.toLocaleLowerCase())239 .to.be.deep.contains(admin1.toLocaleLowerCase());240 }241 });242243 itWeb3('(!negative tests!) Remove admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {244 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);245 const collectionHelper = evmCollectionHelpers(web3, owner);246 247 const result = await collectionHelper.methods248 .createNonfungibleCollection('A', 'B', 'C')249 .send();250 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);251252 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);253254 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);255 await collectionEvm.methods.addCollectionAdmin(admin).send();256 const notAdmin = await createEthAccount(web3);257258 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))259 .to.be.rejectedWith('NoPermission');260 {261 const adminList = await api.rpc.unique.adminlist(collectionId);262 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())263 .to.be.eq(admin.toLocaleLowerCase());264 expect(adminList.length).to.be.eq(1);265 }266 });267268 itWeb3('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {269 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);270 const collectionHelper = evmCollectionHelpers(web3, owner);271 272 const result = await collectionHelper.methods273 .createNonfungibleCollection('A', 'B', 'C')274 .send();275 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);276277 const adminSub = privateKeyWrapper('//Alice');278 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);279 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();280 const adminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);281 await collectionEvm.methods.addCollectionAdmin(adminEth).send();282283 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))284 .to.be.rejectedWith('NoPermission');285286 const adminList = await api.rpc.unique.adminlist(collectionId);287 expect(adminList.length).to.be.eq(2);288 expect(adminList.toString().toLocaleLowerCase())289 .to.be.deep.contains(adminSub.address.toLocaleLowerCase())290 .to.be.deep.contains(adminEth.toLocaleLowerCase());291 });292293 itWeb3('(!negative tests!) Remove substrate admin by USER is not allowed', async ({api, web3, privateKeyWrapper}) => {294 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);295 const collectionHelper = evmCollectionHelpers(web3, owner);296 297 const result = await collectionHelper.methods298 .createNonfungibleCollection('A', 'B', 'C')299 .send();300 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);301302 const adminSub = privateKeyWrapper('//Alice');303 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);304 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();305 const notAdminEth = await createEthAccountWithBalance(api, web3, privateKeyWrapper);306307 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))308 .to.be.rejectedWith('NoPermission');309310 const adminList = await api.rpc.unique.adminlist(collectionId);311 expect(adminList.length).to.be.eq(1);312 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())313 .to.be.eq(adminSub.address.toLocaleLowerCase());314 });315});316317describe('Change owner tests', () => {318 itWeb3('Change owner', async ({api, web3, privateKeyWrapper}) => {319 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);320 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);321 const collectionHelper = evmCollectionHelpers(web3, owner);322 const result = await collectionHelper.methods323 .createNonfungibleCollection('A', 'B', 'C')324 .send();325 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);326 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);327 328 await collectionEvm.methods.changeOwner(newOwner).send();329 330 expect(await collectionEvm.methods.verifyOwnerOrAdmin(owner).call()).to.be.false;331 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newOwner).call()).to.be.true;332 });333334 itWeb3('change owner call fee', async ({web3, api, privateKeyWrapper}) => {335 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);336 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);337 const collectionHelper = evmCollectionHelpers(web3, owner);338 const result = await collectionHelper.methods339 .createNonfungibleCollection('A', 'B', 'C')340 .send();341 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);342 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);343344 const cost = await recordEthFee(api, owner, () => collectionEvm.methods.changeOwner(newOwner).send());345 expect(cost < BigInt(0.2 * Number(UNIQUE)));346 expect(cost > 0);347 });348349 itWeb3('(!negative tests!) call changeOwner by not owner', async ({api, web3, privateKeyWrapper}) => {350 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);351 const newOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);352 const collectionHelper = evmCollectionHelpers(web3, owner);353 const result = await collectionHelper.methods354 .createNonfungibleCollection('A', 'B', 'C')355 .send();356 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);357 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);358 359 await expect(collectionEvm.methods.changeOwner(newOwner).send({from: newOwner})).to.be.rejected;360 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newOwner).call()).to.be.false;361 });362});363364describe('Change substrate owner tests', () => {365 itWeb3('Change owner', async ({api, web3, privateKeyWrapper}) => {366 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);367 const newOwner = privateKeyWrapper('//Alice');368 const collectionHelper = evmCollectionHelpers(web3, owner);369 const result = await collectionHelper.methods370 .createNonfungibleCollection('A', 'B', 'C')371 .send();372 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);373 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);374 375 expect(await collectionEvm.methods.verifyOwnerOrAdmin(owner).call()).to.be.true;376 expect(await collectionEvm.methods['verifyOwnerOrAdmin(uint256)'](newOwner.addressRaw).call()).to.be.false;377 await collectionEvm.methods['changeOwner(uint256)'](newOwner.addressRaw).send();378 379 expect(await collectionEvm.methods.verifyOwnerOrAdmin(owner).call()).to.be.false;380 expect(await collectionEvm.methods['verifyOwnerOrAdmin(uint256)'](newOwner.addressRaw).call()).to.be.true;381 });382383 itWeb3('change owner call fee', async ({web3, api, privateKeyWrapper}) => {384 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);385 const newOwner = privateKeyWrapper('//Alice');386 const collectionHelper = evmCollectionHelpers(web3, owner);387 const result = await collectionHelper.methods388 .createNonfungibleCollection('A', 'B', 'C')389 .send();390 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);391 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);392393 const cost = await recordEthFee(api, owner, () => collectionEvm.methods['changeOwner(uint256)'](newOwner.addressRaw).send());394 expect(cost < BigInt(0.2 * Number(UNIQUE)));395 expect(cost > 0);396 });397398 itWeb3('(!negative tests!) call changeOwner by not owner', async ({api, web3, privateKeyWrapper}) => {399 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);400 const otherReceiver = await createEthAccountWithBalance(api, web3, privateKeyWrapper);401 const newOwner = privateKeyWrapper('//Alice');402 const collectionHelper = evmCollectionHelpers(web3, owner);403 const result = await collectionHelper.methods404 .createNonfungibleCollection('A', 'B', 'C')405 .send();406 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);407 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);408 409 await expect(collectionEvm.methods['changeOwner(uint256)'](newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;410 expect(await collectionEvm.methods['verifyOwnerOrAdmin(uint256)'](newOwner.addressRaw).call()).to.be.false;411 });412});tests/src/eth/fungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -117,7 +117,7 @@
},
{
"inputs": [
- { "internalType": "address", "name": "newOwner", "type": "address" }
+ { "internalType": "uint256", "name": "newOwner", "type": "uint256" }
],
"name": "changeOwner",
"outputs": [],
@@ -126,9 +126,9 @@
},
{
"inputs": [
- { "internalType": "uint256", "name": "newOwner", "type": "uint256" }
+ { "internalType": "address", "name": "newOwner", "type": "address" }
],
- "name": "changeOwnerSubstrate",
+ "name": "changeOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
@@ -329,7 +329,7 @@
},
{
"inputs": [
- { "internalType": "address", "name": "user", "type": "address" }
+ { "internalType": "uint256", "name": "user", "type": "uint256" }
],
"name": "verifyOwnerOrAdmin",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
@@ -338,9 +338,9 @@
},
{
"inputs": [
- { "internalType": "uint256", "name": "user", "type": "uint256" }
+ { "internalType": "address", "name": "user", "type": "address" }
],
- "name": "verifyOwnerOrAdminSubstrate",
+ "name": "verifyOwnerOrAdmin",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -147,7 +147,7 @@
},
{
"inputs": [
- { "internalType": "address", "name": "newOwner", "type": "address" }
+ { "internalType": "uint256", "name": "newOwner", "type": "uint256" }
],
"name": "changeOwner",
"outputs": [],
@@ -156,9 +156,9 @@
},
{
"inputs": [
- { "internalType": "uint256", "name": "newOwner", "type": "uint256" }
+ { "internalType": "address", "name": "newOwner", "type": "address" }
],
- "name": "changeOwnerSubstrate",
+ "name": "changeOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
@@ -554,7 +554,7 @@
},
{
"inputs": [
- { "internalType": "address", "name": "user", "type": "address" }
+ { "internalType": "uint256", "name": "user", "type": "uint256" }
],
"name": "verifyOwnerOrAdmin",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
@@ -563,9 +563,9 @@
},
{
"inputs": [
- { "internalType": "uint256", "name": "user", "type": "uint256" }
+ { "internalType": "address", "name": "user", "type": "address" }
],
- "name": "verifyOwnerOrAdminSubstrate",
+ "name": "verifyOwnerOrAdmin",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -147,7 +147,7 @@
},
{
"inputs": [
- { "internalType": "address", "name": "newOwner", "type": "address" }
+ { "internalType": "uint256", "name": "newOwner", "type": "uint256" }
],
"name": "changeOwner",
"outputs": [],
@@ -156,9 +156,9 @@
},
{
"inputs": [
- { "internalType": "uint256", "name": "newOwner", "type": "uint256" }
+ { "internalType": "address", "name": "newOwner", "type": "address" }
],
- "name": "changeOwnerSubstrate",
+ "name": "changeOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
@@ -563,7 +563,7 @@
},
{
"inputs": [
- { "internalType": "address", "name": "user", "type": "address" }
+ { "internalType": "uint256", "name": "user", "type": "uint256" }
],
"name": "verifyOwnerOrAdmin",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
@@ -572,9 +572,9 @@
},
{
"inputs": [
- { "internalType": "uint256", "name": "user", "type": "uint256" }
+ { "internalType": "address", "name": "user", "type": "address" }
],
- "name": "verifyOwnerOrAdminSubstrate",
+ "name": "verifyOwnerOrAdmin",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"