difftreelog
feat Add some collection methods to eth.
in: master
17 files changed
pallets/common/src/erc.rsdiffbeforeafterboth33use crate::{33use crate::{34 Pallet, CollectionHandle, Config, CollectionProperties,34 Pallet, CollectionHandle, Config, CollectionProperties,35 eth::{convert_cross_account_to_uint256, convert_uint256_to_cross_account},35 eth::{36 convert_cross_account_to_uint256, convert_uint256_to_cross_account,37 convert_cross_account_to_tuple,38 },36};39};3740146 save(self)149 save(self)147 }150 }148151149 // /// Whether there is a pending sponsor.152 /// Whether there is a pending sponsor.150 fn has_collection_pending_sponsor(&self) -> Result<bool> {153 fn has_collection_pending_sponsor(&self) -> Result<bool> {151 Ok(matches!(154 Ok(matches!(152 self.collection.sponsorship,155 self.collection.sponsorship,275 }278 }276279277 /// Get contract address.280 /// Get contract address.278 fn contract_address(&self, _caller: caller) -> Result<address> {281 fn contract_address(&self) -> Result<address> {279 Ok(crate::eth::collection_id_to_address(self.id))282 Ok(crate::eth::collection_id_to_address(self.id))280 }283 }281284420 save(self)423 save(self)421 }424 }425426 /// Checks that user allowed to operate with collection.427 ///428 /// @param user User address to check.429 fn allowed(&self, user: address) -> Result<bool> {430 Ok(Pallet::<T>::allowed(431 self.id,432 T::CrossAccountId::from_eth(user),433 ))434 }422435423 /// Add the user to the allowed list.436 /// Add the user to the allowed list.424 ///437 ///430 Ok(())443 Ok(())431 }444 }445446 /// Add substrate user to allowed list.447 ///448 /// @param user User substrate address.449 fn add_to_collection_allow_list_substrate(450 &mut self,451 caller: caller,452 user: uint256,453 ) -> Result<void> {454 let caller = T::CrossAccountId::from_eth(caller);455 let user = convert_uint256_to_cross_account::<T>(user);456 Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;457 Ok(())458 }432459433 /// Remove the user from the allowed list.460 /// Remove the user from the allowed list.434 ///461 ///440 Ok(())467 Ok(())441 }468 }469470 /// Remove substrate user from allowed list.471 ///472 /// @param user User substrate address.473 fn remove_from_collection_allow_list_substrate(474 &mut self,475 caller: caller,476 user: uint256,477 ) -> Result<void> {478 let caller = T::CrossAccountId::from_eth(caller);479 let user = convert_uint256_to_cross_account::<T>(user);480 Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;481 Ok(())482 }442483443 /// Switch permission for minting.484 /// Switch permission for minting.444 ///485 ///481 /// Returns collection type522 /// Returns collection type482 ///523 ///483 /// @return `Fungible` or `NFT` or `ReFungible`524 /// @return `Fungible` or `NFT` or `ReFungible`484 fn unique_collection_type(&mut self) -> Result<string> {525 fn unique_collection_type(&self) -> Result<string> {485 let mode = match self.collection.mode {526 let mode = match self.collection.mode {486 CollectionMode::Fungible(_) => "Fungible",527 CollectionMode::Fungible(_) => "Fungible",487 CollectionMode::NFT => "NFT",528 CollectionMode::NFT => "NFT",490 Ok(mode.into())531 Ok(mode.into())491 }532 }533534 /// Get collection owner.535 ///536 /// @return Tuble with sponsor address and his substrate mirror.537 /// If address is canonical then substrate mirror is zero and vice versa.538 fn collection_owner(&self) -> Result<(address, uint256)> {539 Ok(convert_cross_account_to_tuple::<T>(540 &T::CrossAccountId::from_sub(self.owner.clone()),541 ))542 }492543493 /// Changes collection owner to another account544 /// Changes collection owner to another account494 ///545 ///512 .map_err(dispatch_to_evm::<T>)563 .map_err(dispatch_to_evm::<T>)513 }564 }565566 // TODO: need implement AbiWriter for &Vec<T>567 // fn collection_admins(&self) -> Result<Vec<(address, uint256)>> {568 // let result = pallet_common::IsAdmin::<T>::iter_prefix((self.id,))569 // .map(|(admin, _)| pallet_common::eth::convert_cross_account_to_tuple::<T>(&admin))570 // .collect();571 // Ok(result)572 // }514}573}515574516fn check_is_owner_or_admin<T: Config>(575fn check_is_owner_or_admin<T: Config>(pallets/common/src/eth.rsdiffbeforeafterboth161617//! The module contains a number of functions for converting and checking ethereum identifiers.17//! The module contains a number of functions for converting and checking ethereum identifiers.181819use evm_coder::types::uint256;19use evm_coder::types::{uint256, address};20pub use pallet_evm::account::{Config, CrossAccountId};20pub use pallet_evm::account::{Config, CrossAccountId};21use sp_core::H160;21use sp_core::H160;22use up_data_structs::CollectionId;22use up_data_structs::CollectionId;70 T::CrossAccountId::from_sub(account_id)70 T::CrossAccountId::from_sub(account_id)71}71}727273/// Convert `CrossAccountId` to `(address, uint256)`.74pub fn convert_cross_account_to_tuple<T: Config>(cross_account_id: &T::CrossAccountId) -> (address, uint256)75where76 T::AccountId: AsRef<[u8; 32]>77{78 if cross_account_id.is_canonical_substrate() {79 let sub = convert_cross_account_to_uint256::<T>(cross_account_id);80 (Default::default(), sub)81 } else {82 let eth = *cross_account_id.as_eth();83 (eth, Default::default())84 }85}pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth171 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {171 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {172 let sponsor =172 let sponsor =173 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;173 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;174 let result: (address, uint256) = if sponsor.is_canonical_substrate() {175 let sponsor = pallet_common::eth::convert_cross_account_to_uint256::<T>(&sponsor);174 Ok(pallet_common::eth::convert_cross_account_to_tuple::<T>(&sponsor))176 (Default::default(), sponsor)177 } else {178 let sponsor = *sponsor.as_eth();179 (sponsor, Default::default())180 };181 Ok(result)182 }175 }183176184 /// Check tat contract has confirmed sponsor.177 /// Check tat contract has confirmed sponsor.pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth22}22}232324/// @title A contract that allows you to work with collections.24/// @title A contract that allows you to work with collections.25/// @dev the ERC-165 identifier for this interface is 0xe54be64025/// @dev the ERC-165 identifier for this interface is 0x9f70d4e026contract Collection is Dummy, ERC165 {26contract Collection is Dummy, ERC165 {27 /// Set collection property.27 /// Set collection property.28 ///28 ///255 dummy = 0;255 dummy = 0;256 }256 }257258 /// Checks that user allowed to operate with collection.259 ///260 /// @param user User address to check.261 /// @dev EVM selector for this function is: 0xd63a8e11,262 /// or in textual repr: allowed(address)263 function allowed(address user) public view returns (bool) {264 require(false, stub_error);265 user;266 dummy;267 return false;268 }257269258 /// Add the user to the allowed list.270 /// Add the user to the allowed list.259 ///271 ///266 dummy = 0;278 dummy = 0;267 }279 }280281 /// Add substrate user to allowed list.282 ///283 /// @param user User substrate address.284 /// @dev EVM selector for this function is: 0xd06ad267,285 /// or in textual repr: addToCollectionAllowListSubstrate(uint256)286 function addToCollectionAllowListSubstrate(uint256 user) public {287 require(false, stub_error);288 user;289 dummy = 0;290 }268291269 /// Remove the user from the allowed list.292 /// Remove the user from the allowed list.270 ///293 ///277 dummy = 0;300 dummy = 0;278 }301 }302303 /// Remove substrate user from allowed list.304 ///305 /// @param user User substrate address.306 /// @dev EVM selector for this function is: 0xa31913ed,307 /// or in textual repr: removeFromCollectionAllowListSubstrate(uint256)308 function removeFromCollectionAllowListSubstrate(uint256 user) public {309 require(false, stub_error);310 user;311 dummy = 0;312 }279313280 /// Switch permission for minting.314 /// Switch permission for minting.281 ///315 ///325 return "";359 return "";326 }360 }361362 /// Get collection owner.363 ///364 /// @return Tuble with sponsor address and his substrate mirror.365 /// If address is canonical then substrate mirror is zero and vice versa.366 /// @dev EVM selector for this function is: 0xdf727d3b,367 /// or in textual repr: collectionOwner()368 function collectionOwner() public view returns (Tuple6 memory) {369 require(false, stub_error);370 dummy;371 return Tuple6(0x0000000000000000000000000000000000000000, 0);372 }327373328 /// Changes collection owner to another account374 /// Changes collection owner to another account329 ///375 ///pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth99}99}100100101/// @title A contract that allows you to work with collections.101/// @title A contract that allows you to work with collections.102/// @dev the ERC-165 identifier for this interface is 0xe54be640102/// @dev the ERC-165 identifier for this interface is 0x9f70d4e0103contract Collection is Dummy, ERC165 {103contract Collection is Dummy, ERC165 {104 /// Set collection property.104 /// Set collection property.105 ///105 ///332 dummy = 0;332 dummy = 0;333 }333 }334335 /// Checks that user allowed to operate with collection.336 ///337 /// @param user User address to check.338 /// @dev EVM selector for this function is: 0xd63a8e11,339 /// or in textual repr: allowed(address)340 function allowed(address user) public view returns (bool) {341 require(false, stub_error);342 user;343 dummy;344 return false;345 }334346335 /// Add the user to the allowed list.347 /// Add the user to the allowed list.336 ///348 ///343 dummy = 0;355 dummy = 0;344 }356 }357358 /// Add substrate user to allowed list.359 ///360 /// @param user User substrate address.361 /// @dev EVM selector for this function is: 0xd06ad267,362 /// or in textual repr: addToCollectionAllowListSubstrate(uint256)363 function addToCollectionAllowListSubstrate(uint256 user) public {364 require(false, stub_error);365 user;366 dummy = 0;367 }345368346 /// Remove the user from the allowed list.369 /// Remove the user from the allowed list.347 ///370 ///354 dummy = 0;377 dummy = 0;355 }378 }379380 /// Remove substrate user from allowed list.381 ///382 /// @param user User substrate address.383 /// @dev EVM selector for this function is: 0xa31913ed,384 /// or in textual repr: removeFromCollectionAllowListSubstrate(uint256)385 function removeFromCollectionAllowListSubstrate(uint256 user) public {386 require(false, stub_error);387 user;388 dummy = 0;389 }356390357 /// Switch permission for minting.391 /// Switch permission for minting.358 ///392 ///402 return "";436 return "";403 }437 }438439 /// Get collection owner.440 ///441 /// @return Tuble with sponsor address and his substrate mirror.442 /// If address is canonical then substrate mirror is zero and vice versa.443 /// @dev EVM selector for this function is: 0xdf727d3b,444 /// or in textual repr: collectionOwner()445 function collectionOwner() public view returns (Tuple17 memory) {446 require(false, stub_error);447 dummy;448 return Tuple17(0x0000000000000000000000000000000000000000, 0);449 }404450405 /// Changes collection owner to another account451 /// Changes collection owner to another account406 ///452 ///pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth99}99}100100101/// @title A contract that allows you to work with collections.101/// @title A contract that allows you to work with collections.102/// @dev the ERC-165 identifier for this interface is 0xe54be640102/// @dev the ERC-165 identifier for this interface is 0x9f70d4e0103contract Collection is Dummy, ERC165 {103contract Collection is Dummy, ERC165 {104 /// Set collection property.104 /// Set collection property.105 ///105 ///332 dummy = 0;332 dummy = 0;333 }333 }334335 /// Checks that user allowed to operate with collection.336 ///337 /// @param user User address to check.338 /// @dev EVM selector for this function is: 0xd63a8e11,339 /// or in textual repr: allowed(address)340 function allowed(address user) public view returns (bool) {341 require(false, stub_error);342 user;343 dummy;344 return false;345 }334346335 /// Add the user to the allowed list.347 /// Add the user to the allowed list.336 ///348 ///343 dummy = 0;355 dummy = 0;344 }356 }357358 /// Add substrate user to allowed list.359 ///360 /// @param user User substrate address.361 /// @dev EVM selector for this function is: 0xd06ad267,362 /// or in textual repr: addToCollectionAllowListSubstrate(uint256)363 function addToCollectionAllowListSubstrate(uint256 user) public {364 require(false, stub_error);365 user;366 dummy = 0;367 }345368346 /// Remove the user from the allowed list.369 /// Remove the user from the allowed list.347 ///370 ///354 dummy = 0;377 dummy = 0;355 }378 }379380 /// Remove substrate user from allowed list.381 ///382 /// @param user User substrate address.383 /// @dev EVM selector for this function is: 0xa31913ed,384 /// or in textual repr: removeFromCollectionAllowListSubstrate(uint256)385 function removeFromCollectionAllowListSubstrate(uint256 user) public {386 require(false, stub_error);387 user;388 dummy = 0;389 }356390357 /// Switch permission for minting.391 /// Switch permission for minting.358 ///392 ///402 return "";436 return "";403 }437 }438439 /// Get collection owner.440 ///441 /// @return Tuble with sponsor address and his substrate mirror.442 /// If address is canonical then substrate mirror is zero and vice versa.443 /// @dev EVM selector for this function is: 0xdf727d3b,444 /// or in textual repr: collectionOwner()445 function collectionOwner() public view returns (Tuple17 memory) {446 require(false, stub_error);447 dummy;448 return Tuple17(0x0000000000000000000000000000000000000000, 0);449 }404450405 /// Changes collection owner to another account451 /// Changes collection owner to another account406 ///452 ///tests/src/eth/allowlist.test.tsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {expect} from 'chai';17import {expect} from 'chai';18import {isAllowlisted} from '../util/helpers';18import {contractHelpers, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers';19import {20 contractHelpers,21 createEthAccount,22 createEthAccountWithBalance,23 deployFlipper,24 evmCollection,25 evmCollectionHelpers,26 getCollectionAddressFromResult,27 itWeb3,28} from './util/helpers';192920describe('EVM allowlist', () => {30describe('EVM contract allowlist', () => {21 itWeb3('Contract allowlist can be toggled', async ({api, web3, privateKeyWrapper}) => {31 itWeb3('Contract allowlist can be toggled', async ({api, web3, privateKeyWrapper}) => {22 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);32 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);23 const flipper = await deployFlipper(web3, owner);33 const flipper = await deployFlipper(web3, owner);59 });69 });60});70});7172describe('EVM collection allowlist', () => {73 itWeb3('Collection allowlist can be added and removed by [eth] address', async ({api, web3, privateKeyWrapper}) => {74 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);75 const user = createEthAccount(web3);76 77 const collectionHelpers = evmCollectionHelpers(web3, owner);78 const result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();79 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);80 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);81 82 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;83 await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});84 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;85 86 await collectionEvm.methods.removeFromCollectionAllowList(user).send({from: owner});87 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;88 });8990 itWeb3('Collection allowlist can be added and removed by [sub] address', async ({api, web3, privateKeyWrapper}) => {91 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);92 const user = privateKeyWrapper('//Alice');93 94 const collectionHelpers = evmCollectionHelpers(web3, owner);95 const result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();96 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);97 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);98 99 expect(await isAllowlisted(api, collectionId, user)).to.be.false;100 await collectionEvm.methods.addToCollectionAllowListSubstrate(user.addressRaw).send({from: owner});101 expect(await isAllowlisted(api, collectionId, user)).to.be.true;102103 await collectionEvm.methods.removeFromCollectionAllowListSubstrate(user.addressRaw).send({from: owner});104 expect(await isAllowlisted(api, collectionId, user)).to.be.false;105 });106107 itWeb3('Collection allowlist can not be add and remove [eth] address by not owner', async ({api, web3, privateKeyWrapper}) => {108 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);109 const notOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);110 const user = createEthAccount(web3);111 112 const collectionHelpers = evmCollectionHelpers(web3, owner);113 const result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();114 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);115 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);116 117 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;118 await expect(collectionEvm.methods.addToCollectionAllowList(user).call({from: notOwner})).to.be.rejectedWith('NoPermission');119 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;120 await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});121 122 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;123 await expect(collectionEvm.methods.removeFromCollectionAllowList(user).call({from: notOwner})).to.be.rejectedWith('NoPermission');124 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;125 });126127 itWeb3('Collection allowlist can not be add and remove [sub] address by not owner', async ({api, web3, privateKeyWrapper}) => {128 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);129 const notOwner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);130 const user = privateKeyWrapper('//Alice');131 132 const collectionHelpers = evmCollectionHelpers(web3, owner);133 const result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();134 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);135 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);136 137 expect(await isAllowlisted(api, collectionId, user)).to.be.false;138 await expect(collectionEvm.methods.addToCollectionAllowListSubstrate(user.addressRaw).call({from: notOwner})).to.be.rejectedWith('NoPermission');139 expect(await isAllowlisted(api, collectionId, user)).to.be.false;140 await collectionEvm.methods.addToCollectionAllowListSubstrate(user.addressRaw).send({from: owner});141 142 expect(await isAllowlisted(api, collectionId, user)).to.be.true;143 await expect(collectionEvm.methods.removeFromCollectionAllowListSubstrate(user.addressRaw).call({from: notOwner})).to.be.rejectedWith('NoPermission');144 expect(await isAllowlisted(api, collectionId, user)).to.be.true;145 });146});61147tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth13}13}141415/// @title A contract that allows you to work with collections.15/// @title A contract that allows you to work with collections.16/// @dev the ERC-165 identifier for this interface is 0xe54be64016/// @dev the ERC-165 identifier for this interface is 0x9f70d4e017interface Collection is Dummy, ERC165 {17interface Collection is Dummy, ERC165 {18 /// Set collection property.18 /// Set collection property.19 ///19 ///164 /// or in textual repr: setCollectionAccess(uint8)164 /// or in textual repr: setCollectionAccess(uint8)165 function setCollectionAccess(uint8 mode) external;165 function setCollectionAccess(uint8 mode) external;166167 /// Checks that user allowed to operate with collection.168 ///169 /// @param user User address to check.170 /// @dev EVM selector for this function is: 0xd63a8e11,171 /// or in textual repr: allowed(address)172 function allowed(address user) external view returns (bool);166173167 /// Add the user to the allowed list.174 /// Add the user to the allowed list.168 ///175 ///171 /// or in textual repr: addToCollectionAllowList(address)178 /// or in textual repr: addToCollectionAllowList(address)172 function addToCollectionAllowList(address user) external;179 function addToCollectionAllowList(address user) external;180181 /// Add substrate user to allowed list.182 ///183 /// @param user User substrate address.184 /// @dev EVM selector for this function is: 0xd06ad267,185 /// or in textual repr: addToCollectionAllowListSubstrate(uint256)186 function addToCollectionAllowListSubstrate(uint256 user) external;173187174 /// Remove the user from the allowed list.188 /// Remove the user from the allowed list.175 ///189 ///178 /// or in textual repr: removeFromCollectionAllowList(address)192 /// or in textual repr: removeFromCollectionAllowList(address)179 function removeFromCollectionAllowList(address user) external;193 function removeFromCollectionAllowList(address user) external;194195 /// Remove substrate user from allowed list.196 ///197 /// @param user User substrate address.198 /// @dev EVM selector for this function is: 0xa31913ed,199 /// or in textual repr: removeFromCollectionAllowListSubstrate(uint256)200 function removeFromCollectionAllowListSubstrate(uint256 user) external;180201181 /// Switch permission for minting.202 /// Switch permission for minting.182 ///203 ///208 /// or in textual repr: uniqueCollectionType()229 /// or in textual repr: uniqueCollectionType()209 function uniqueCollectionType() external returns (string memory);230 function uniqueCollectionType() external returns (string memory);231232 /// Get collection owner.233 ///234 /// @return Tuble with sponsor address and his substrate mirror.235 /// If address is canonical then substrate mirror is zero and vice versa.236 /// @dev EVM selector for this function is: 0xdf727d3b,237 /// or in textual repr: collectionOwner()238 function collectionOwner() external view returns (Tuple6 memory);210239211 /// Changes collection owner to another account240 /// Changes collection owner to another account212 ///241 ///tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth65}65}666667/// @title A contract that allows you to work with collections.67/// @title A contract that allows you to work with collections.68/// @dev the ERC-165 identifier for this interface is 0xe54be64068/// @dev the ERC-165 identifier for this interface is 0x9f70d4e069interface Collection is Dummy, ERC165 {69interface Collection is Dummy, ERC165 {70 /// Set collection property.70 /// Set collection property.71 ///71 ///216 /// or in textual repr: setCollectionAccess(uint8)216 /// or in textual repr: setCollectionAccess(uint8)217 function setCollectionAccess(uint8 mode) external;217 function setCollectionAccess(uint8 mode) external;218219 /// Checks that user allowed to operate with collection.220 ///221 /// @param user User address to check.222 /// @dev EVM selector for this function is: 0xd63a8e11,223 /// or in textual repr: allowed(address)224 function allowed(address user) external view returns (bool);218225219 /// Add the user to the allowed list.226 /// Add the user to the allowed list.220 ///227 ///223 /// or in textual repr: addToCollectionAllowList(address)230 /// or in textual repr: addToCollectionAllowList(address)224 function addToCollectionAllowList(address user) external;231 function addToCollectionAllowList(address user) external;232233 /// Add substrate user to allowed list.234 ///235 /// @param user User substrate address.236 /// @dev EVM selector for this function is: 0xd06ad267,237 /// or in textual repr: addToCollectionAllowListSubstrate(uint256)238 function addToCollectionAllowListSubstrate(uint256 user) external;225239226 /// Remove the user from the allowed list.240 /// Remove the user from the allowed list.227 ///241 ///230 /// or in textual repr: removeFromCollectionAllowList(address)244 /// or in textual repr: removeFromCollectionAllowList(address)231 function removeFromCollectionAllowList(address user) external;245 function removeFromCollectionAllowList(address user) external;246247 /// Remove substrate user from allowed list.248 ///249 /// @param user User substrate address.250 /// @dev EVM selector for this function is: 0xa31913ed,251 /// or in textual repr: removeFromCollectionAllowListSubstrate(uint256)252 function removeFromCollectionAllowListSubstrate(uint256 user) external;232253233 /// Switch permission for minting.254 /// Switch permission for minting.234 ///255 ///260 /// or in textual repr: uniqueCollectionType()281 /// or in textual repr: uniqueCollectionType()261 function uniqueCollectionType() external returns (string memory);282 function uniqueCollectionType() external returns (string memory);283284 /// Get collection owner.285 ///286 /// @return Tuble with sponsor address and his substrate mirror.287 /// If address is canonical then substrate mirror is zero and vice versa.288 /// @dev EVM selector for this function is: 0xdf727d3b,289 /// or in textual repr: collectionOwner()290 function collectionOwner() external view returns (Tuple17 memory);262291263 /// Changes collection owner to another account292 /// Changes collection owner to another account264 ///293 ///tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth65}65}666667/// @title A contract that allows you to work with collections.67/// @title A contract that allows you to work with collections.68/// @dev the ERC-165 identifier for this interface is 0xe54be64068/// @dev the ERC-165 identifier for this interface is 0x9f70d4e069interface Collection is Dummy, ERC165 {69interface Collection is Dummy, ERC165 {70 /// Set collection property.70 /// Set collection property.71 ///71 ///216 /// or in textual repr: setCollectionAccess(uint8)216 /// or in textual repr: setCollectionAccess(uint8)217 function setCollectionAccess(uint8 mode) external;217 function setCollectionAccess(uint8 mode) external;218219 /// Checks that user allowed to operate with collection.220 ///221 /// @param user User address to check.222 /// @dev EVM selector for this function is: 0xd63a8e11,223 /// or in textual repr: allowed(address)224 function allowed(address user) external view returns (bool);218225219 /// Add the user to the allowed list.226 /// Add the user to the allowed list.220 ///227 ///223 /// or in textual repr: addToCollectionAllowList(address)230 /// or in textual repr: addToCollectionAllowList(address)224 function addToCollectionAllowList(address user) external;231 function addToCollectionAllowList(address user) external;232233 /// Add substrate user to allowed list.234 ///235 /// @param user User substrate address.236 /// @dev EVM selector for this function is: 0xd06ad267,237 /// or in textual repr: addToCollectionAllowListSubstrate(uint256)238 function addToCollectionAllowListSubstrate(uint256 user) external;225239226 /// Remove the user from the allowed list.240 /// Remove the user from the allowed list.227 ///241 ///230 /// or in textual repr: removeFromCollectionAllowList(address)244 /// or in textual repr: removeFromCollectionAllowList(address)231 function removeFromCollectionAllowList(address user) external;245 function removeFromCollectionAllowList(address user) external;246247 /// Remove substrate user from allowed list.248 ///249 /// @param user User substrate address.250 /// @dev EVM selector for this function is: 0xa31913ed,251 /// or in textual repr: removeFromCollectionAllowListSubstrate(uint256)252 function removeFromCollectionAllowListSubstrate(uint256 user) external;232253233 /// Switch permission for minting.254 /// Switch permission for minting.234 ///255 ///260 /// or in textual repr: uniqueCollectionType()281 /// or in textual repr: uniqueCollectionType()261 function uniqueCollectionType() external returns (string memory);282 function uniqueCollectionType() external returns (string memory);283284 /// Get collection owner.285 ///286 /// @return Tuble with sponsor address and his substrate mirror.287 /// If address is canonical then substrate mirror is zero and vice versa.288 /// @dev EVM selector for this function is: 0xdf727d3b,289 /// or in textual repr: collectionOwner()290 function collectionOwner() external view returns (Tuple17 memory);262291263 /// Changes collection owner to another account292 /// Changes collection owner to another account264 ///293 ///tests/src/eth/fungibleAbi.jsondiffbeforeafterboth76 "stateMutability": "nonpayable",76 "stateMutability": "nonpayable",77 "type": "function"77 "type": "function"78 },78 },79 {80 "inputs": [81 { "internalType": "uint256", "name": "user", "type": "uint256" }82 ],83 "name": "addToCollectionAllowListSubstrate",84 "outputs": [],85 "stateMutability": "nonpayable",86 "type": "function"87 },79 {88 {80 "inputs": [89 "inputs": [81 { "internalType": "address", "name": "owner", "type": "address" },90 { "internalType": "address", "name": "owner", "type": "address" },86 "stateMutability": "view",95 "stateMutability": "view",87 "type": "function"96 "type": "function"88 },97 },98 {99 "inputs": [100 { "internalType": "address", "name": "user", "type": "address" }101 ],102 "name": "allowed",103 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],104 "stateMutability": "view",105 "type": "function"106 },89 {107 {90 "inputs": [108 "inputs": [91 { "internalType": "address", "name": "spender", "type": "address" },109 { "internalType": "address", "name": "spender", "type": "address" },115 "stateMutability": "nonpayable",133 "stateMutability": "nonpayable",116 "type": "function"134 "type": "function"117 },135 },136 {137 "inputs": [],138 "name": "collectionOwner",139 "outputs": [140 {141 "components": [142 { "internalType": "address", "name": "field_0", "type": "address" },143 { "internalType": "uint256", "name": "field_1", "type": "uint256" }144 ],145 "internalType": "struct Tuple6",146 "name": "",147 "type": "tuple"148 }149 ],150 "stateMutability": "view",151 "type": "function"152 },118 {153 {119 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],154 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],120 "name": "collectionProperty",155 "name": "collectionProperty",260 "stateMutability": "nonpayable",295 "stateMutability": "nonpayable",261 "type": "function"296 "type": "function"262 },297 },298 {299 "inputs": [300 { "internalType": "uint256", "name": "user", "type": "uint256" }301 ],302 "name": "removeFromCollectionAllowListSubstrate",303 "outputs": [],304 "stateMutability": "nonpayable",305 "type": "function"306 },263 {307 {264 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],308 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],265 "name": "setCollectionAccess",309 "name": "setCollectionAccess",tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth107 "stateMutability": "nonpayable",107 "stateMutability": "nonpayable",108 "type": "function"108 "type": "function"109 },109 },110 {111 "inputs": [112 { "internalType": "uint256", "name": "user", "type": "uint256" }113 ],114 "name": "addToCollectionAllowListSubstrate",115 "outputs": [],116 "stateMutability": "nonpayable",117 "type": "function"118 },119 {120 "inputs": [121 { "internalType": "address", "name": "user", "type": "address" }122 ],123 "name": "allowed",124 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],125 "stateMutability": "view",126 "type": "function"127 },110 {128 {111 "inputs": [129 "inputs": [112 { "internalType": "address", "name": "approved", "type": "address" },130 { "internalType": "address", "name": "approved", "type": "address" },145 "stateMutability": "nonpayable",163 "stateMutability": "nonpayable",146 "type": "function"164 "type": "function"147 },165 },166 {167 "inputs": [],168 "name": "collectionOwner",169 "outputs": [170 {171 "components": [172 { "internalType": "address", "name": "field_0", "type": "address" },173 { "internalType": "uint256", "name": "field_1", "type": "uint256" }174 ],175 "internalType": "struct Tuple17",176 "name": "",177 "type": "tuple"178 }179 ],180 "stateMutability": "view",181 "type": "function"182 },148 {183 {149 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],184 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],150 "name": "collectionProperty",185 "name": "collectionProperty",374 "stateMutability": "nonpayable",409 "stateMutability": "nonpayable",375 "type": "function"410 "type": "function"376 },411 },412 {413 "inputs": [414 { "internalType": "uint256", "name": "user", "type": "uint256" }415 ],416 "name": "removeFromCollectionAllowListSubstrate",417 "outputs": [],418 "stateMutability": "nonpayable",419 "type": "function"420 },377 {421 {378 "inputs": [422 "inputs": [379 { "internalType": "address", "name": "from", "type": "address" },423 { "internalType": "address", "name": "from", "type": "address" },tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth107 "stateMutability": "nonpayable",107 "stateMutability": "nonpayable",108 "type": "function"108 "type": "function"109 },109 },110 {111 "inputs": [112 { "internalType": "uint256", "name": "user", "type": "uint256" }113 ],114 "name": "addToCollectionAllowListSubstrate",115 "outputs": [],116 "stateMutability": "nonpayable",117 "type": "function"118 },119 {120 "inputs": [121 { "internalType": "address", "name": "user", "type": "address" }122 ],123 "name": "allowed",124 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],125 "stateMutability": "view",126 "type": "function"127 },110 {128 {111 "inputs": [129 "inputs": [112 { "internalType": "address", "name": "approved", "type": "address" },130 { "internalType": "address", "name": "approved", "type": "address" },145 "stateMutability": "nonpayable",163 "stateMutability": "nonpayable",146 "type": "function"164 "type": "function"147 },165 },166 {167 "inputs": [],168 "name": "collectionOwner",169 "outputs": [170 {171 "components": [172 { "internalType": "address", "name": "field_0", "type": "address" },173 { "internalType": "uint256", "name": "field_1", "type": "uint256" }174 ],175 "internalType": "struct Tuple17",176 "name": "",177 "type": "tuple"178 }179 ],180 "stateMutability": "view",181 "type": "function"182 },148 {183 {149 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],184 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],150 "name": "collectionProperty",185 "name": "collectionProperty",374 "stateMutability": "nonpayable",409 "stateMutability": "nonpayable",375 "type": "function"410 "type": "function"376 },411 },412 {413 "inputs": [414 { "internalType": "uint256", "name": "user", "type": "uint256" }415 ],416 "name": "removeFromCollectionAllowListSubstrate",417 "outputs": [],418 "stateMutability": "nonpayable",419 "type": "function"420 },377 {421 {378 "inputs": [422 "inputs": [379 { "internalType": "address", "name": "from", "type": "address" },423 { "internalType": "address", "name": "from", "type": "address" },tests/src/util/helpers.tsdiffbeforeafterboth1651 });1651 });1652}1652}165316531654export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {1654export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId | IKeyringPair) {1655 return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();1655 return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();1656}1656}16571657