git.delta.rocks / unique-network / refs/commits / 17cf7864d109

difftreelog

Merge pull request #723 from UniqueNetwork/feature/deprecate-non-cross-methods

Yaroslav Bolyukin2022-11-22parents: #149c99d #2c2e9d0.patch.diff
in: master

51 files changed

modifiedMakefilediffbeforeafterboth
7 @echo " bench-unique"7 @echo " bench-unique"
88
9FUNGIBLE_EVM_STUBS=./pallets/fungible/src/stubs9FUNGIBLE_EVM_STUBS=./pallets/fungible/src/stubs
10FUNGIBLE_EVM_ABI=./tests/src/eth/fungibleAbi.json10FUNGIBLE_EVM_ABI=./tests/src/eth/abi/fungible.json
11
12REFUNGIBLE_EVM_STUBS=./pallets/refungible/src/stubs
13REFUNGIBLE_EVM_ABI=./tests/src/eth/refungibleAbi.json
1411
15NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs12NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs
16NONFUNGIBLE_EVM_ABI=./tests/src/eth/nonFungibleAbi.json13NONFUNGIBLE_EVM_ABI=./tests/src/eth/abi/nonFungible.json
1714
18REFUNGIBLE_EVM_STUBS=./pallets/refungible/src/stubs15REFUNGIBLE_EVM_STUBS=./pallets/refungible/src/stubs
19REFUNGIBLE_EVM_ABI=./tests/src/eth/reFungibleAbi.json16REFUNGIBLE_EVM_ABI=./tests/src/eth/abi/reFungible.json
20REFUNGIBLE_TOKEN_EVM_ABI=./tests/src/eth/reFungibleTokenAbi.json17REFUNGIBLE_TOKEN_EVM_ABI=./tests/src/eth/abi/reFungibleToken.json
2118
22CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/19CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/
23CONTRACT_HELPERS_ABI=./tests/src/eth/util/contractHelpersAbi.json20CONTRACT_HELPERS_ABI=./tests/src/eth/abi/contractHelpers.json
2421
25COLLECTION_HELPER_STUBS=./pallets/unique/src/eth/stubs/22COLLECTION_HELPER_STUBS=./pallets/unique/src/eth/stubs/
26COLLECTION_HELPER_ABI=./tests/src/eth/collectionHelpersAbi.json23COLLECTION_HELPER_ABI=./tests/src/eth/abi/collectionHelpers.json
2724
28TESTS_API=./tests/src/eth/api/25TESTS_API=./tests/src/eth/api/
2926
modifiedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth
153 }153 }
154}154}
155
156impl sealed::CanBePlacedInVec for Property {}
157
158impl AbiType for Property {
159 const SIGNATURE: SignatureUnit = make_signature!(new fixed("(string,bytes)"));
160
161 fn is_dynamic() -> bool {
162 string::is_dynamic() || bytes::is_dynamic()
163 }
164
165 fn size() -> usize {
166 <string as AbiType>::size() + <bytes as AbiType>::size()
167 }
168}
169
170impl AbiRead for Property {
171 fn abi_read(reader: &mut AbiReader) -> Result<Property> {
172 let size = if !Property::is_dynamic() {
173 Some(<Property as AbiType>::size())
174 } else {
175 None
176 };
177 let mut subresult = reader.subresult(size)?;
178 let key = <string>::abi_read(&mut subresult)?;
179 let value = <bytes>::abi_read(&mut subresult)?;
180
181 Ok(Property { key, value })
182 }
183}
184
185impl AbiWrite for Property {
186 fn abi_write(&self, writer: &mut AbiWriter) {
187 self.key.abi_write(writer);
188 self.value.abi_write(writer);
189 }
190}
155191
156macro_rules! impl_abi_writeable {192macro_rules! impl_abi_writeable {
157 ($ty:ty, $method:ident) => {193 ($ty:ty, $method:ident) => {
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
254 T::CrossAccountId::from_sub(account_id)254 T::CrossAccountId::from_sub(account_id)
255 }255 }
256
257 #[derive(Debug, Default)]
258 pub struct Property {
259 pub key: string,
260 pub value: bytes,
261 }
256}262}
257263
258/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro264/// Parseable EVM call, this trait should be implemented with [`solidity_interface`] macro
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
157impl sealed::CanBePlacedInVec for string {}157impl sealed::CanBePlacedInVec for string {}
158impl sealed::CanBePlacedInVec for address {}158impl sealed::CanBePlacedInVec for address {}
159impl sealed::CanBePlacedInVec for EthCrossAccount {}159impl sealed::CanBePlacedInVec for EthCrossAccount {}
160impl sealed::CanBePlacedInVec for Property {}
160161
161impl<T: SolidityTypeName + sealed::CanBePlacedInVec> SolidityTypeName for Vec<T> {162impl<T: SolidityTypeName + sealed::CanBePlacedInVec> SolidityTypeName for Vec<T> {
162 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {163 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
227 }229 }
228}230}
231
232impl StructCollect for Property {
233 fn name() -> String {
234 "Property".into()
235 }
236
237 fn declaration() -> String {
238 let mut str = String::new();
239 writeln!(str, "/// @dev Property struct").unwrap();
240 writeln!(str, "struct {} {{", Self::name()).unwrap();
241 writeln!(str, "\tstring key;").unwrap();
242 writeln!(str, "\tbytes value;").unwrap();
243 writeln!(str, "}}").unwrap();
244 str
245 }
246}
247
248impl SolidityTypeName for Property {
249 fn solidity_name(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
250 write!(writer, "{}", tc.collect_struct::<Self>())
251 }
252
253 fn is_simple() -> bool {
254 false
255 }
256
257 fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
258 write!(writer, "{}(", tc.collect_struct::<Self>())?;
259 address::solidity_default(writer, tc)?;
260 write!(writer, ",")?;
261 uint256::solidity_default(writer, tc)?;
262 write!(writer, ")")
263 }
264}
265
266impl SolidityTupleType for Property {
267 fn names(tc: &TypeCollector) -> Vec<string> {
268 let mut collected = Vec::with_capacity(Self::len());
269 {
270 let mut out = string::new();
271 string::solidity_name(&mut out, tc).expect("no fmt error");
272 collected.push(out);
273 }
274 {
275 let mut out = string::new();
276 bytes::solidity_name(&mut out, tc).expect("no fmt error");
277 collected.push(out);
278 }
279 collected
280 }
281
282 fn len() -> usize {
283 2
284 }
285}
229286
230pub trait SolidityTupleType {287pub trait SolidityTupleType {
231 fn names(tc: &TypeCollector) -> Vec<String>;288 fn names(tc: &TypeCollector) -> Vec<String>;
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
20 abi::AbiType,20 abi::AbiType,
21 solidity_interface, solidity, ToLog,21 solidity_interface, solidity, ToLog,
22 types::*,22 types::*,
23 types::Property as PropertyStruct,
23 execution::{Result, Error},24 execution::{Result, Error},
24 weight,25 weight,
25};26};
78 ///79 ///
79 /// @param key Property key.80 /// @param key Property key.
80 /// @param value Propery value.81 /// @param value Propery value.
82 #[solidity(hide)]
81 #[weight(<SelfWeightOf<T>>::set_collection_properties(1))]83 #[weight(<SelfWeightOf<T>>::set_collection_properties(1))]
82 fn set_collection_property(84 fn set_collection_property(
83 &mut self,85 &mut self,
102 fn set_collection_properties(104 fn set_collection_properties(
103 &mut self,105 &mut self,
104 caller: caller,106 caller: caller,
105 properties: Vec<(string, bytes)>,107 properties: Vec<PropertyStruct>,
106 ) -> Result<void> {108 ) -> Result<void> {
107 let caller = T::CrossAccountId::from_eth(caller);109 let caller = T::CrossAccountId::from_eth(caller);
108110
109 let properties = properties111 let properties = properties
110 .into_iter()112 .into_iter()
111 .map(|(key, value)| {113 .map(|PropertyStruct { key, value }| {
112 let key = <Vec<u8>>::from(key)114 let key = <Vec<u8>>::from(key)
113 .try_into()115 .try_into()
114 .map_err(|_| "key too large")?;116 .map_err(|_| "key too large")?;
126 /// Delete collection property.128 /// Delete collection property.
127 ///129 ///
128 /// @param key Property key.130 /// @param key Property key.
131 #[solidity(hide)]
129 #[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]132 #[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]
130 fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {133 fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {
131 let caller = T::CrossAccountId::from_eth(caller);134 let caller = T::CrossAccountId::from_eth(caller);
208 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.211 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
209 ///212 ///
210 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.213 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
214 #[solidity(hide)]
211 fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {215 fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {
212 self.consume_store_reads_and_writes(1, 1)?;216 self.consume_store_reads_and_writes(1, 1)?;
213217
411415
412 /// Add collection admin.416 /// Add collection admin.
413 /// @param newAdmin Address of the added administrator.417 /// @param newAdmin Address of the added administrator.
418 #[solidity(hide)]
414 fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<void> {419 fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<void> {
415 self.consume_store_writes(2)?;420 self.consume_store_writes(2)?;
416421
423 /// Remove collection admin.428 /// Remove collection admin.
424 ///429 ///
425 /// @param admin Address of the removed administrator.430 /// @param admin Address of the removed administrator.
431 #[solidity(hide)]
426 fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<void> {432 fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<void> {
427 self.consume_store_writes(2)?;433 self.consume_store_writes(2)?;
428434
547 /// Add the user to the allowed list.553 /// Add the user to the allowed list.
548 ///554 ///
549 /// @param user Address of a trusted user.555 /// @param user Address of a trusted user.
556 #[solidity(hide)]
550 fn add_to_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {557 fn add_to_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {
551 self.consume_store_writes(1)?;558 self.consume_store_writes(1)?;
552559
575 /// Remove the user from the allowed list.582 /// Remove the user from the allowed list.
576 ///583 ///
577 /// @param user Address of a removed user.584 /// @param user Address of a removed user.
585 #[solidity(hide)]
578 fn remove_from_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {586 fn remove_from_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {
579 self.consume_store_writes(1)?;587 self.consume_store_writes(1)?;
580588
625 ///633 ///
626 /// @param user account to verify634 /// @param user account to verify
627 /// @return "true" if account is the owner or admin635 /// @return "true" if account is the owner or admin
628 #[solidity(rename_selector = "isOwnerOrAdmin")]636 #[solidity(hide, rename_selector = "isOwnerOrAdmin")]
629 fn is_owner_or_admin_eth(&self, user: address) -> Result<bool> {637 fn is_owner_or_admin_eth(&self, user: address) -> Result<bool> {
630 let user = T::CrossAccountId::from_eth(user);638 let user = T::CrossAccountId::from_eth(user);
631 Ok(self.is_owner_or_admin(&user))639 Ok(self.is_owner_or_admin(&user))
666 ///674 ///
667 /// @dev Owner can be changed only by current owner675 /// @dev Owner can be changed only by current owner
668 /// @param newOwner new owner account676 /// @param newOwner new owner account
669 #[solidity(rename_selector = "changeCollectionOwner")]677 #[solidity(hide, rename_selector = "changeCollectionOwner")]
670 fn set_owner(&mut self, caller: caller, new_owner: address) -> Result<void> {678 fn set_owner(&mut self, caller: caller, new_owner: address) -> Result<void> {
671 self.consume_store_writes(1)?;679 self.consume_store_writes(1)?;
672680
691 ///699 ///
692 /// @dev Owner can be changed only by current owner700 /// @dev Owner can be changed only by current owner
693 /// @param newOwner new owner cross account701 /// @param newOwner new owner cross account
694 fn set_owner_cross(&mut self, caller: caller, new_owner: EthCrossAccount) -> Result<void> {702 fn change_collection_owner_cross(
703 &mut self,
704 caller: caller,
705 new_owner: EthCrossAccount,
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
21use core::convert::TryInto;21use core::convert::TryInto;
22use evm_coder::{22use evm_coder::{
23 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight,23 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,
24 weight,
24};25};
25use up_data_structs::CollectionMode;26use up_data_structs::CollectionMode;
178 /// deducting from the sender's allowance for said account.179 /// deducting from the sender's allowance for said account.
179 /// @param from The account whose tokens will be burnt.180 /// @param from The account whose tokens will be burnt.
180 /// @param amount The amount that will be burnt.181 /// @param amount The amount that will be burnt.
182 #[solidity(hide)]
181 #[weight(<SelfWeightOf<T>>::burn_from())]183 #[weight(<SelfWeightOf<T>>::burn_from())]
182 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {184 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {
183 let caller = T::CrossAccountId::from_eth(caller);185 let caller = T::CrossAccountId::from_eth(caller);
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
18}18}
1919
20/// @title A contract that allows you to work with collections.20/// @title A contract that allows you to work with collections.
21/// @dev the ERC-165 identifier for this interface is 0xb3152af321/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
22contract Collection is Dummy, ERC165 {22contract Collection is Dummy, ERC165 {
23 /// Set collection property.23 // /// Set collection property.
24 ///24 // ///
25 /// @param key Property key.25 // /// @param key Property key.
26 /// @param value Propery value.26 // /// @param value Propery value.
27 /// @dev EVM selector for this function is: 0x2f073f66,27 // /// @dev EVM selector for this function is: 0x2f073f66,
28 /// or in textual repr: setCollectionProperty(string,bytes)28 // /// or in textual repr: setCollectionProperty(string,bytes)
29 function setCollectionProperty(string memory key, bytes memory value) public {29 // function setCollectionProperty(string memory key, bytes memory value) public {
30 require(false, stub_error);30 // require(false, stub_error);
31 key;31 // key;
32 value;32 // value;
33 dummy = 0;33 // dummy = 0;
34 }34 // }
3535
36 /// Set collection properties.36 /// Set collection properties.
37 ///37 ///
38 /// @param properties Vector of properties key/value pair.38 /// @param properties Vector of properties key/value pair.
39 /// @dev EVM selector for this function is: 0x50b26b2a,39 /// @dev EVM selector for this function is: 0x50b26b2a,
40 /// or in textual repr: setCollectionProperties((string,bytes)[])40 /// or in textual repr: setCollectionProperties((string,bytes)[])
41 function setCollectionProperties(Tuple15[] memory properties) public {41 function setCollectionProperties(Property[] memory properties) public {
42 require(false, stub_error);42 require(false, stub_error);
43 properties;43 properties;
44 dummy = 0;44 dummy = 0;
45 }45 }
4646
47 /// Delete collection property.47 // /// Delete collection property.
48 ///48 // ///
49 /// @param key Property key.49 // /// @param key Property key.
50 /// @dev EVM selector for this function is: 0x7b7debce,50 // /// @dev EVM selector for this function is: 0x7b7debce,
51 /// or in textual repr: deleteCollectionProperty(string)51 // /// or in textual repr: deleteCollectionProperty(string)
52 function deleteCollectionProperty(string memory key) public {52 // function deleteCollectionProperty(string memory key) public {
53 require(false, stub_error);53 // require(false, stub_error);
54 key;54 // key;
55 dummy = 0;55 // dummy = 0;
56 }56 // }
5757
58 /// Delete collection properties.58 /// Delete collection properties.
59 ///59 ///
87 /// @return Vector of properties key/value pairs.87 /// @return Vector of properties key/value pairs.
88 /// @dev EVM selector for this function is: 0x285fb8e6,88 /// @dev EVM selector for this function is: 0x285fb8e6,
89 /// or in textual repr: collectionProperties(string[])89 /// or in textual repr: collectionProperties(string[])
90 function collectionProperties(string[] memory keys) public view returns (Tuple15[] memory) {90 function collectionProperties(string[] memory keys) public view returns (Tuple16[] memory) {
91 require(false, stub_error);91 require(false, stub_error);
92 keys;92 keys;
93 dummy;93 dummy;
94 return new Tuple15[](0);94 return new Tuple16[](0);
95 }95 }
9696
97 /// Set the sponsor of the collection.97 // /// Set the sponsor of the collection.
98 ///98 // ///
99 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.99 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
100 ///100 // ///
101 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.101 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
102 /// @dev EVM selector for this function is: 0x7623402e,102 // /// @dev EVM selector for this function is: 0x7623402e,
103 /// or in textual repr: setCollectionSponsor(address)103 // /// or in textual repr: setCollectionSponsor(address)
104 function setCollectionSponsor(address sponsor) public {104 // function setCollectionSponsor(address sponsor) public {
105 require(false, stub_error);105 // require(false, stub_error);
106 sponsor;106 // sponsor;
107 dummy = 0;107 // dummy = 0;
108 }108 // }
109109
110 /// Set the sponsor of the collection.110 /// Set the sponsor of the collection.
111 ///111 ///
222 dummy = 0;222 dummy = 0;
223 }223 }
224224
225 /// Add collection admin.225 // /// Add collection admin.
226 /// @param newAdmin Address of the added administrator.226 // /// @param newAdmin Address of the added administrator.
227 /// @dev EVM selector for this function is: 0x92e462c7,227 // /// @dev EVM selector for this function is: 0x92e462c7,
228 /// or in textual repr: addCollectionAdmin(address)228 // /// or in textual repr: addCollectionAdmin(address)
229 function addCollectionAdmin(address newAdmin) public {229 // function addCollectionAdmin(address newAdmin) public {
230 require(false, stub_error);230 // require(false, stub_error);
231 newAdmin;231 // newAdmin;
232 dummy = 0;232 // dummy = 0;
233 }233 // }
234234
235 /// Remove collection admin.235 // /// Remove collection admin.
236 ///236 // ///
237 /// @param admin Address of the removed administrator.237 // /// @param admin Address of the removed administrator.
238 /// @dev EVM selector for this function is: 0xfafd7b42,238 // /// @dev EVM selector for this function is: 0xfafd7b42,
239 /// or in textual repr: removeCollectionAdmin(address)239 // /// or in textual repr: removeCollectionAdmin(address)
240 function removeCollectionAdmin(address admin) public {240 // function removeCollectionAdmin(address admin) public {
241 require(false, stub_error);241 // require(false, stub_error);
242 admin;242 // admin;
243 dummy = 0;243 // dummy = 0;
244 }244 // }
245245
246 /// Toggle accessibility of collection nesting.246 /// Toggle accessibility of collection nesting.
247 ///247 ///
291 return false;291 return false;
292 }292 }
293293
294 /// Add the user to the allowed list.294 // /// Add the user to the allowed list.
295 ///295 // ///
296 /// @param user Address of a trusted user.296 // /// @param user Address of a trusted user.
297 /// @dev EVM selector for this function is: 0x67844fe6,297 // /// @dev EVM selector for this function is: 0x67844fe6,
298 /// or in textual repr: addToCollectionAllowList(address)298 // /// or in textual repr: addToCollectionAllowList(address)
299 function addToCollectionAllowList(address user) public {299 // function addToCollectionAllowList(address user) public {
300 require(false, stub_error);300 // require(false, stub_error);
301 user;301 // user;
302 dummy = 0;302 // dummy = 0;
303 }303 // }
304304
305 /// Add user to allowed list.305 /// Add user to allowed list.
306 ///306 ///
313 dummy = 0;313 dummy = 0;
314 }314 }
315315
316 /// Remove the user from the allowed list.316 // /// Remove the user from the allowed list.
317 ///317 // ///
318 /// @param user Address of a removed user.318 // /// @param user Address of a removed user.
319 /// @dev EVM selector for this function is: 0x85c51acb,319 // /// @dev EVM selector for this function is: 0x85c51acb,
320 /// or in textual repr: removeFromCollectionAllowList(address)320 // /// or in textual repr: removeFromCollectionAllowList(address)
321 function removeFromCollectionAllowList(address user) public {321 // function removeFromCollectionAllowList(address user) public {
322 require(false, stub_error);322 // require(false, stub_error);
323 user;323 // user;
324 dummy = 0;324 // dummy = 0;
325 }325 // }
326326
327 /// Remove user from allowed list.327 /// Remove user from allowed list.
328 ///328 ///
346 dummy = 0;346 dummy = 0;
347 }347 }
348348
349 /// Check that account is the owner or admin of the collection349 // /// Check that account is the owner or admin of the collection
350 ///350 // ///
351 /// @param user account to verify351 // /// @param user account to verify
352 /// @return "true" if account is the owner or admin352 // /// @return "true" if account is the owner or admin
353 /// @dev EVM selector for this function is: 0x9811b0c7,353 // /// @dev EVM selector for this function is: 0x9811b0c7,
354 /// or in textual repr: isOwnerOrAdmin(address)354 // /// or in textual repr: isOwnerOrAdmin(address)
355 function isOwnerOrAdmin(address user) public view returns (bool) {355 // function isOwnerOrAdmin(address user) public view returns (bool) {
356 require(false, stub_error);356 // require(false, stub_error);
357 user;357 // user;
358 dummy;358 // dummy;
359 return false;359 // return false;
360 }360 // }
361361
362 /// Check that account is the owner or admin of the collection362 /// Check that account is the owner or admin of the collection
363 ///363 ///
395 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);395 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
396 }396 }
397397
398 /// Changes collection owner to another account398 // /// Changes collection owner to another account
399 ///399 // ///
400 /// @dev Owner can be changed only by current owner400 // /// @dev Owner can be changed only by current owner
401 /// @param newOwner new owner account401 // /// @param newOwner new owner account
402 /// @dev EVM selector for this function is: 0x4f53e226,402 // /// @dev EVM selector for this function is: 0x4f53e226,
403 /// or in textual repr: changeCollectionOwner(address)403 // /// or in textual repr: changeCollectionOwner(address)
404 function changeCollectionOwner(address newOwner) public {404 // function changeCollectionOwner(address newOwner) public {
405 require(false, stub_error);405 // require(false, stub_error);
406 newOwner;406 // newOwner;
407 dummy = 0;407 // dummy = 0;
408 }408 // }
409409
410 /// Get collection administrators410 /// Get collection administrators
411 ///411 ///
423 ///423 ///
424 /// @dev Owner can be changed only by current owner424 /// @dev Owner can be changed only by current owner
425 /// @param newOwner new owner cross account425 /// @param newOwner new owner cross account
426 /// @dev EVM selector for this function is: 0xe5c9913f,426 /// @dev EVM selector for this function is: 0x6496c497,
427 /// or in textual repr: setOwnerCross((address,uint256))427 /// or in textual repr: changeCollectionOwnerCross((address,uint256))
428 function setOwnerCross(EthCrossAccount memory newOwner) public {428 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) public {
429 require(false, stub_error);429 require(false, stub_error);
430 newOwner;430 newOwner;
431 dummy = 0;431 dummy = 0;
439}439}
440440
441/// @dev anonymous struct441/// @dev anonymous struct
442struct Tuple15 {442struct Tuple16 {
443 string field_0;443 string field_0;
444 bytes field_1;444 bytes field_1;
445}445}
446
447/// @dev Property struct
448struct Property {
449 string key;
450 bytes value;
451}
446452
447/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9453/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9
448contract ERC20UniqueExtensions is Dummy, ERC165 {454contract ERC20UniqueExtensions is Dummy, ERC165 {
456 return false;462 return false;
457 }463 }
458464
459 /// Burn tokens from account465 // /// Burn tokens from account
460 /// @dev Function that burns an `amount` of the tokens of a given account,466 // /// @dev Function that burns an `amount` of the tokens of a given account,
461 /// deducting from the sender's allowance for said account.467 // /// deducting from the sender's allowance for said account.
462 /// @param from The account whose tokens will be burnt.468 // /// @param from The account whose tokens will be burnt.
463 /// @param amount The amount that will be burnt.469 // /// @param amount The amount that will be burnt.
464 /// @dev EVM selector for this function is: 0x79cc6790,470 // /// @dev EVM selector for this function is: 0x79cc6790,
465 /// or in textual repr: burnFrom(address,uint256)471 // /// or in textual repr: burnFrom(address,uint256)
466 function burnFrom(address from, uint256 amount) public returns (bool) {472 // function burnFrom(address from, uint256 amount) public returns (bool) {
467 require(false, stub_error);473 // require(false, stub_error);
468 from;474 // from;
469 amount;475 // amount;
470 dummy = 0;476 // dummy = 0;
471 return false;477 // return false;
472 }478 // }
473479
474 /// Burn tokens from account480 /// Burn tokens from account
475 /// @dev Function that burns an `amount` of the tokens of a given account,481 /// @dev Function that burns an `amount` of the tokens of a given account,
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
26};26};
27use evm_coder::{27use evm_coder::{
28 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,28 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,
29 weight,29 types::Property as PropertyStruct, weight,
30};30};
31use frame_support::BoundedVec;31use frame_support::BoundedVec;
32use up_data_structs::{32use up_data_structs::{
88 /// @param tokenId ID of the token.88 /// @param tokenId ID of the token.
89 /// @param key Property key.89 /// @param key Property key.
90 /// @param value Property value.90 /// @param value Property value.
91 #[solidity(hide)]
91 fn set_property(92 fn set_property(
92 &mut self,93 &mut self,
93 caller: caller,94 caller: caller,
125 &mut self,126 &mut self,
126 caller: caller,127 caller: caller,
127 token_id: uint256,128 token_id: uint256,
128 properties: Vec<(string, bytes)>,129 properties: Vec<PropertyStruct>,
129 ) -> Result<()> {130 ) -> Result<()> {
130 let caller = T::CrossAccountId::from_eth(caller);131 let caller = T::CrossAccountId::from_eth(caller);
131 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;132 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
136137
137 let properties = properties138 let properties = properties
138 .into_iter()139 .into_iter()
139 .map(|(key, value)| {140 .map(|PropertyStruct { key, value }| {
140 let key = <Vec<u8>>::from(key)141 let key = <Vec<u8>>::from(key)
141 .try_into()142 .try_into()
142 .map_err(|_| "key too large")?;143 .map_err(|_| "key too large")?;
794 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.795 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
795 /// @param from The current owner of the NFT796 /// @param from The current owner of the NFT
796 /// @param tokenId The NFT to transfer797 /// @param tokenId The NFT to transfer
798 #[solidity(hide)]
797 #[weight(<SelfWeightOf<T>>::burn_from())]799 #[weight(<SelfWeightOf<T>>::burn_from())]
798 fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {800 fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {
799 let caller = T::CrossAccountId::from_eth(caller);801 let caller = T::CrossAccountId::from_eth(caller);
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
42 dummy = 0;42 dummy = 0;
43 }43 }
4444
45 /// @notice Set token property value.45 // /// @notice Set token property value.
46 /// @dev Throws error if `msg.sender` has no permission to edit the property.46 // /// @dev Throws error if `msg.sender` has no permission to edit the property.
47 /// @param tokenId ID of the token.47 // /// @param tokenId ID of the token.
48 /// @param key Property key.48 // /// @param key Property key.
49 /// @param value Property value.49 // /// @param value Property value.
50 /// @dev EVM selector for this function is: 0x1752d67b,50 // /// @dev EVM selector for this function is: 0x1752d67b,
51 /// or in textual repr: setProperty(uint256,string,bytes)51 // /// or in textual repr: setProperty(uint256,string,bytes)
52 function setProperty(52 // function setProperty(uint256 tokenId, string memory key, bytes memory value) public {
53 uint256 tokenId,53 // require(false, stub_error);
54 string memory key,54 // tokenId;
55 bytes memory value55 // key;
56 ) public {56 // value;
57 require(false, stub_error);57 // dummy = 0;
58 tokenId;58 // }
59 key;
60 value;
61 dummy = 0;
62 }
6359
64 /// @notice Set token properties value.60 /// @notice Set token properties value.
65 /// @dev Throws error if `msg.sender` has no permission to edit the property.61 /// @dev Throws error if `msg.sender` has no permission to edit the property.
66 /// @param tokenId ID of the token.62 /// @param tokenId ID of the token.
67 /// @param properties settable properties63 /// @param properties settable properties
68 /// @dev EVM selector for this function is: 0x14ed3a6e,64 /// @dev EVM selector for this function is: 0x14ed3a6e,
69 /// or in textual repr: setProperties(uint256,(string,bytes)[])65 /// or in textual repr: setProperties(uint256,(string,bytes)[])
70 function setProperties(uint256 tokenId, Tuple22[] memory properties) public {66 function setProperties(uint256 tokenId, Property[] memory properties) public {
71 require(false, stub_error);67 require(false, stub_error);
72 tokenId;68 tokenId;
73 properties;69 properties;
116 }112 }
117}113}
114
115/// @dev Property struct
116struct Property {
117 string key;
118 bytes value;
119}
118120
119/// @title A contract that allows you to work with collections.121/// @title A contract that allows you to work with collections.
120/// @dev the ERC-165 identifier for this interface is 0xb3152af3122/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
121contract Collection is Dummy, ERC165 {123contract Collection is Dummy, ERC165 {
122 /// Set collection property.124 // /// Set collection property.
123 ///125 // ///
124 /// @param key Property key.126 // /// @param key Property key.
125 /// @param value Propery value.127 // /// @param value Propery value.
126 /// @dev EVM selector for this function is: 0x2f073f66,128 // /// @dev EVM selector for this function is: 0x2f073f66,
127 /// or in textual repr: setCollectionProperty(string,bytes)129 // /// or in textual repr: setCollectionProperty(string,bytes)
128 function setCollectionProperty(string memory key, bytes memory value) public {130 // function setCollectionProperty(string memory key, bytes memory value) public {
129 require(false, stub_error);131 // require(false, stub_error);
130 key;132 // key;
131 value;133 // value;
132 dummy = 0;134 // dummy = 0;
133 }135 // }
134136
135 /// Set collection properties.137 /// Set collection properties.
136 ///138 ///
137 /// @param properties Vector of properties key/value pair.139 /// @param properties Vector of properties key/value pair.
138 /// @dev EVM selector for this function is: 0x50b26b2a,140 /// @dev EVM selector for this function is: 0x50b26b2a,
139 /// or in textual repr: setCollectionProperties((string,bytes)[])141 /// or in textual repr: setCollectionProperties((string,bytes)[])
140 function setCollectionProperties(Tuple22[] memory properties) public {142 function setCollectionProperties(Property[] memory properties) public {
141 require(false, stub_error);143 require(false, stub_error);
142 properties;144 properties;
143 dummy = 0;145 dummy = 0;
144 }146 }
145147
146 /// Delete collection property.148 // /// Delete collection property.
147 ///149 // ///
148 /// @param key Property key.150 // /// @param key Property key.
149 /// @dev EVM selector for this function is: 0x7b7debce,151 // /// @dev EVM selector for this function is: 0x7b7debce,
150 /// or in textual repr: deleteCollectionProperty(string)152 // /// or in textual repr: deleteCollectionProperty(string)
151 function deleteCollectionProperty(string memory key) public {153 // function deleteCollectionProperty(string memory key) public {
152 require(false, stub_error);154 // require(false, stub_error);
153 key;155 // key;
154 dummy = 0;156 // dummy = 0;
155 }157 // }
156158
157 /// Delete collection properties.159 /// Delete collection properties.
158 ///160 ///
186 /// @return Vector of properties key/value pairs.188 /// @return Vector of properties key/value pairs.
187 /// @dev EVM selector for this function is: 0x285fb8e6,189 /// @dev EVM selector for this function is: 0x285fb8e6,
188 /// or in textual repr: collectionProperties(string[])190 /// or in textual repr: collectionProperties(string[])
189 function collectionProperties(string[] memory keys) public view returns (Tuple22[] memory) {191 function collectionProperties(string[] memory keys) public view returns (Tuple23[] memory) {
190 require(false, stub_error);192 require(false, stub_error);
191 keys;193 keys;
192 dummy;194 dummy;
193 return new Tuple22[](0);195 return new Tuple23[](0);
194 }196 }
195197
196 /// Set the sponsor of the collection.198 // /// Set the sponsor of the collection.
197 ///199 // ///
198 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.200 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
199 ///201 // ///
200 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.202 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
201 /// @dev EVM selector for this function is: 0x7623402e,203 // /// @dev EVM selector for this function is: 0x7623402e,
202 /// or in textual repr: setCollectionSponsor(address)204 // /// or in textual repr: setCollectionSponsor(address)
203 function setCollectionSponsor(address sponsor) public {205 // function setCollectionSponsor(address sponsor) public {
204 require(false, stub_error);206 // require(false, stub_error);
205 sponsor;207 // sponsor;
206 dummy = 0;208 // dummy = 0;
207 }209 // }
208210
209 /// Set the sponsor of the collection.211 /// Set the sponsor of the collection.
210 ///212 ///
251 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.253 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
252 /// @dev EVM selector for this function is: 0x6ec0a9f1,254 /// @dev EVM selector for this function is: 0x6ec0a9f1,
253 /// or in textual repr: collectionSponsor()255 /// or in textual repr: collectionSponsor()
254 function collectionSponsor() public view returns (Tuple25 memory) {256 function collectionSponsor() public view returns (Tuple26 memory) {
255 require(false, stub_error);257 require(false, stub_error);
256 dummy;258 dummy;
257 return Tuple25(0x0000000000000000000000000000000000000000, 0);259 return Tuple26(0x0000000000000000000000000000000000000000, 0);
258 }260 }
259261
260 /// Set limits for the collection.262 /// Set limits for the collection.
321 dummy = 0;323 dummy = 0;
322 }324 }
323325
324 /// Add collection admin.326 // /// Add collection admin.
325 /// @param newAdmin Address of the added administrator.327 // /// @param newAdmin Address of the added administrator.
326 /// @dev EVM selector for this function is: 0x92e462c7,328 // /// @dev EVM selector for this function is: 0x92e462c7,
327 /// or in textual repr: addCollectionAdmin(address)329 // /// or in textual repr: addCollectionAdmin(address)
328 function addCollectionAdmin(address newAdmin) public {330 // function addCollectionAdmin(address newAdmin) public {
329 require(false, stub_error);331 // require(false, stub_error);
330 newAdmin;332 // newAdmin;
331 dummy = 0;333 // dummy = 0;
332 }334 // }
333335
334 /// Remove collection admin.336 // /// Remove collection admin.
335 ///337 // ///
336 /// @param admin Address of the removed administrator.338 // /// @param admin Address of the removed administrator.
337 /// @dev EVM selector for this function is: 0xfafd7b42,339 // /// @dev EVM selector for this function is: 0xfafd7b42,
338 /// or in textual repr: removeCollectionAdmin(address)340 // /// or in textual repr: removeCollectionAdmin(address)
339 function removeCollectionAdmin(address admin) public {341 // function removeCollectionAdmin(address admin) public {
340 require(false, stub_error);342 // require(false, stub_error);
341 admin;343 // admin;
342 dummy = 0;344 // dummy = 0;
343 }345 // }
344346
345 /// Toggle accessibility of collection nesting.347 /// Toggle accessibility of collection nesting.
346 ///348 ///
390 return false;392 return false;
391 }393 }
392394
393 /// Add the user to the allowed list.395 // /// Add the user to the allowed list.
394 ///396 // ///
395 /// @param user Address of a trusted user.397 // /// @param user Address of a trusted user.
396 /// @dev EVM selector for this function is: 0x67844fe6,398 // /// @dev EVM selector for this function is: 0x67844fe6,
397 /// or in textual repr: addToCollectionAllowList(address)399 // /// or in textual repr: addToCollectionAllowList(address)
398 function addToCollectionAllowList(address user) public {400 // function addToCollectionAllowList(address user) public {
399 require(false, stub_error);401 // require(false, stub_error);
400 user;402 // user;
401 dummy = 0;403 // dummy = 0;
402 }404 // }
403405
404 /// Add user to allowed list.406 /// Add user to allowed list.
405 ///407 ///
412 dummy = 0;414 dummy = 0;
413 }415 }
414416
415 /// Remove the user from the allowed list.417 // /// Remove the user from the allowed list.
416 ///418 // ///
417 /// @param user Address of a removed user.419 // /// @param user Address of a removed user.
418 /// @dev EVM selector for this function is: 0x85c51acb,420 // /// @dev EVM selector for this function is: 0x85c51acb,
419 /// or in textual repr: removeFromCollectionAllowList(address)421 // /// or in textual repr: removeFromCollectionAllowList(address)
420 function removeFromCollectionAllowList(address user) public {422 // function removeFromCollectionAllowList(address user) public {
421 require(false, stub_error);423 // require(false, stub_error);
422 user;424 // user;
423 dummy = 0;425 // dummy = 0;
424 }426 // }
425427
426 /// Remove user from allowed list.428 /// Remove user from allowed list.
427 ///429 ///
445 dummy = 0;447 dummy = 0;
446 }448 }
447449
448 /// Check that account is the owner or admin of the collection450 // /// Check that account is the owner or admin of the collection
449 ///451 // ///
450 /// @param user account to verify452 // /// @param user account to verify
451 /// @return "true" if account is the owner or admin453 // /// @return "true" if account is the owner or admin
452 /// @dev EVM selector for this function is: 0x9811b0c7,454 // /// @dev EVM selector for this function is: 0x9811b0c7,
453 /// or in textual repr: isOwnerOrAdmin(address)455 // /// or in textual repr: isOwnerOrAdmin(address)
454 function isOwnerOrAdmin(address user) public view returns (bool) {456 // function isOwnerOrAdmin(address user) public view returns (bool) {
455 require(false, stub_error);457 // require(false, stub_error);
456 user;458 // user;
457 dummy;459 // dummy;
458 return false;460 // return false;
459 }461 // }
460462
461 /// Check that account is the owner or admin of the collection463 /// Check that account is the owner or admin of the collection
462 ///464 ///
494 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);496 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
495 }497 }
496498
497 /// Changes collection owner to another account499 // /// Changes collection owner to another account
498 ///500 // ///
499 /// @dev Owner can be changed only by current owner501 // /// @dev Owner can be changed only by current owner
500 /// @param newOwner new owner account502 // /// @param newOwner new owner account
501 /// @dev EVM selector for this function is: 0x4f53e226,503 // /// @dev EVM selector for this function is: 0x4f53e226,
502 /// or in textual repr: changeCollectionOwner(address)504 // /// or in textual repr: changeCollectionOwner(address)
503 function changeCollectionOwner(address newOwner) public {505 // function changeCollectionOwner(address newOwner) public {
504 require(false, stub_error);506 // require(false, stub_error);
505 newOwner;507 // newOwner;
506 dummy = 0;508 // dummy = 0;
507 }509 // }
508510
509 /// Get collection administrators511 /// Get collection administrators
510 ///512 ///
522 ///524 ///
523 /// @dev Owner can be changed only by current owner525 /// @dev Owner can be changed only by current owner
524 /// @param newOwner new owner cross account526 /// @param newOwner new owner cross account
525 /// @dev EVM selector for this function is: 0xe5c9913f,527 /// @dev EVM selector for this function is: 0x6496c497,
526 /// or in textual repr: setOwnerCross((address,uint256))528 /// or in textual repr: changeCollectionOwnerCross((address,uint256))
527 function setOwnerCross(EthCrossAccount memory newOwner) public {529 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) public {
528 require(false, stub_error);530 require(false, stub_error);
529 newOwner;531 newOwner;
530 dummy = 0;532 dummy = 0;
538}540}
539541
540/// @dev anonymous struct542/// @dev anonymous struct
541struct Tuple25 {543struct Tuple26 {
542 address field_0;544 address field_0;
543 uint256 field_1;545 uint256 field_1;
544}546}
545547
546/// @dev anonymous struct548/// @dev anonymous struct
547struct Tuple22 {549struct Tuple23 {
548 string field_0;550 string field_0;
549 bytes field_1;551 bytes field_1;
550}552}
776 dummy = 0;778 dummy = 0;
777 }779 }
778780
779 /// @notice Burns a specific ERC721 token.781 // /// @notice Burns a specific ERC721 token.
780 /// @dev Throws unless `msg.sender` is the current owner or an authorized782 // /// @dev Throws unless `msg.sender` is the current owner or an authorized
781 /// operator for this NFT. Throws if `from` is not the current owner. Throws783 // /// operator for this NFT. Throws if `from` is not the current owner. Throws
782 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.784 // /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
783 /// @param from The current owner of the NFT785 // /// @param from The current owner of the NFT
784 /// @param tokenId The NFT to transfer786 // /// @param tokenId The NFT to transfer
785 /// @dev EVM selector for this function is: 0x79cc6790,787 // /// @dev EVM selector for this function is: 0x79cc6790,
786 /// or in textual repr: burnFrom(address,uint256)788 // /// or in textual repr: burnFrom(address,uint256)
787 function burnFrom(address from, uint256 tokenId) public {789 // function burnFrom(address from, uint256 tokenId) public {
788 require(false, stub_error);790 // require(false, stub_error);
789 from;791 // from;
790 tokenId;792 // tokenId;
791 dummy = 0;793 // dummy = 0;
792 }794 // }
793795
794 /// @notice Burns a specific ERC721 token.796 /// @notice Burns a specific ERC721 token.
795 /// @dev Throws unless `msg.sender` is the current owner or an authorized797 /// @dev Throws unless `msg.sender` is the current owner or an authorized
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
27};27};
28use evm_coder::{28use evm_coder::{
29 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,29 abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,
30 weight,30 types::Property as PropertyStruct, weight,
31};31};
32use frame_support::{BoundedBTreeMap, BoundedVec};32use frame_support::{BoundedBTreeMap, BoundedVec};
33use pallet_common::{33use pallet_common::{
91 /// @param tokenId ID of the token.91 /// @param tokenId ID of the token.
92 /// @param key Property key.92 /// @param key Property key.
93 /// @param value Property value.93 /// @param value Property value.
94 #[solidity(hide)]
94 fn set_property(95 fn set_property(
95 &mut self,96 &mut self,
96 caller: caller,97 caller: caller,
127 &mut self,128 &mut self,
128 caller: caller,129 caller: caller,
129 token_id: uint256,130 token_id: uint256,
130 properties: Vec<(string, bytes)>,131 properties: Vec<PropertyStruct>,
131 ) -> Result<()> {132 ) -> Result<()> {
132 let caller = T::CrossAccountId::from_eth(caller);133 let caller = T::CrossAccountId::from_eth(caller);
133 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;134 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
138139
139 let properties = properties140 let properties = properties
140 .into_iter()141 .into_iter()
141 .map(|(key, value)| {142 .map(|PropertyStruct { key, value }| {
142 let key = <Vec<u8>>::from(key)143 let key = <Vec<u8>>::from(key)
143 .try_into()144 .try_into()
144 .map_err(|_| "key too large")?;145 .map_err(|_| "key too large")?;
814 /// Throws if RFT pieces have multiple owners.815 /// Throws if RFT pieces have multiple owners.
815 /// @param from The current owner of the RFT816 /// @param from The current owner of the RFT
816 /// @param tokenId The RFT to transfer817 /// @param tokenId The RFT to transfer
818 #[solidity(hide)]
817 #[weight(<SelfWeightOf<T>>::burn_from())]819 #[weight(<SelfWeightOf<T>>::burn_from())]
818 fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {820 fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {
819 let caller = T::CrossAccountId::from_eth(caller);821 let caller = T::CrossAccountId::from_eth(caller);
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
42 dummy = 0;42 dummy = 0;
43 }43 }
4444
45 /// @notice Set token property value.45 // /// @notice Set token property value.
46 /// @dev Throws error if `msg.sender` has no permission to edit the property.46 // /// @dev Throws error if `msg.sender` has no permission to edit the property.
47 /// @param tokenId ID of the token.47 // /// @param tokenId ID of the token.
48 /// @param key Property key.48 // /// @param key Property key.
49 /// @param value Property value.49 // /// @param value Property value.
50 /// @dev EVM selector for this function is: 0x1752d67b,50 // /// @dev EVM selector for this function is: 0x1752d67b,
51 /// or in textual repr: setProperty(uint256,string,bytes)51 // /// or in textual repr: setProperty(uint256,string,bytes)
52 function setProperty(52 // function setProperty(uint256 tokenId, string memory key, bytes memory value) public {
53 uint256 tokenId,53 // require(false, stub_error);
54 string memory key,54 // tokenId;
55 bytes memory value55 // key;
56 ) public {56 // value;
57 require(false, stub_error);57 // dummy = 0;
58 tokenId;58 // }
59 key;
60 value;
61 dummy = 0;
62 }
6359
64 /// @notice Set token properties value.60 /// @notice Set token properties value.
65 /// @dev Throws error if `msg.sender` has no permission to edit the property.61 /// @dev Throws error if `msg.sender` has no permission to edit the property.
66 /// @param tokenId ID of the token.62 /// @param tokenId ID of the token.
67 /// @param properties settable properties63 /// @param properties settable properties
68 /// @dev EVM selector for this function is: 0x14ed3a6e,64 /// @dev EVM selector for this function is: 0x14ed3a6e,
69 /// or in textual repr: setProperties(uint256,(string,bytes)[])65 /// or in textual repr: setProperties(uint256,(string,bytes)[])
70 function setProperties(uint256 tokenId, Tuple21[] memory properties) public {66 function setProperties(uint256 tokenId, Property[] memory properties) public {
71 require(false, stub_error);67 require(false, stub_error);
72 tokenId;68 tokenId;
73 properties;69 properties;
116 }112 }
117}113}
114
115/// @dev Property struct
116struct Property {
117 string key;
118 bytes value;
119}
118120
119/// @title A contract that allows you to work with collections.121/// @title A contract that allows you to work with collections.
120/// @dev the ERC-165 identifier for this interface is 0xb3152af3122/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
121contract Collection is Dummy, ERC165 {123contract Collection is Dummy, ERC165 {
122 /// Set collection property.124 // /// Set collection property.
123 ///125 // ///
124 /// @param key Property key.126 // /// @param key Property key.
125 /// @param value Propery value.127 // /// @param value Propery value.
126 /// @dev EVM selector for this function is: 0x2f073f66,128 // /// @dev EVM selector for this function is: 0x2f073f66,
127 /// or in textual repr: setCollectionProperty(string,bytes)129 // /// or in textual repr: setCollectionProperty(string,bytes)
128 function setCollectionProperty(string memory key, bytes memory value) public {130 // function setCollectionProperty(string memory key, bytes memory value) public {
129 require(false, stub_error);131 // require(false, stub_error);
130 key;132 // key;
131 value;133 // value;
132 dummy = 0;134 // dummy = 0;
133 }135 // }
134136
135 /// Set collection properties.137 /// Set collection properties.
136 ///138 ///
137 /// @param properties Vector of properties key/value pair.139 /// @param properties Vector of properties key/value pair.
138 /// @dev EVM selector for this function is: 0x50b26b2a,140 /// @dev EVM selector for this function is: 0x50b26b2a,
139 /// or in textual repr: setCollectionProperties((string,bytes)[])141 /// or in textual repr: setCollectionProperties((string,bytes)[])
140 function setCollectionProperties(Tuple21[] memory properties) public {142 function setCollectionProperties(Property[] memory properties) public {
141 require(false, stub_error);143 require(false, stub_error);
142 properties;144 properties;
143 dummy = 0;145 dummy = 0;
144 }146 }
145147
146 /// Delete collection property.148 // /// Delete collection property.
147 ///149 // ///
148 /// @param key Property key.150 // /// @param key Property key.
149 /// @dev EVM selector for this function is: 0x7b7debce,151 // /// @dev EVM selector for this function is: 0x7b7debce,
150 /// or in textual repr: deleteCollectionProperty(string)152 // /// or in textual repr: deleteCollectionProperty(string)
151 function deleteCollectionProperty(string memory key) public {153 // function deleteCollectionProperty(string memory key) public {
152 require(false, stub_error);154 // require(false, stub_error);
153 key;155 // key;
154 dummy = 0;156 // dummy = 0;
155 }157 // }
156158
157 /// Delete collection properties.159 /// Delete collection properties.
158 ///160 ///
186 /// @return Vector of properties key/value pairs.188 /// @return Vector of properties key/value pairs.
187 /// @dev EVM selector for this function is: 0x285fb8e6,189 /// @dev EVM selector for this function is: 0x285fb8e6,
188 /// or in textual repr: collectionProperties(string[])190 /// or in textual repr: collectionProperties(string[])
189 function collectionProperties(string[] memory keys) public view returns (Tuple21[] memory) {191 function collectionProperties(string[] memory keys) public view returns (Tuple22[] memory) {
190 require(false, stub_error);192 require(false, stub_error);
191 keys;193 keys;
192 dummy;194 dummy;
193 return new Tuple21[](0);195 return new Tuple22[](0);
194 }196 }
195197
196 /// Set the sponsor of the collection.198 // /// Set the sponsor of the collection.
197 ///199 // ///
198 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.200 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
199 ///201 // ///
200 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.202 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
201 /// @dev EVM selector for this function is: 0x7623402e,203 // /// @dev EVM selector for this function is: 0x7623402e,
202 /// or in textual repr: setCollectionSponsor(address)204 // /// or in textual repr: setCollectionSponsor(address)
203 function setCollectionSponsor(address sponsor) public {205 // function setCollectionSponsor(address sponsor) public {
204 require(false, stub_error);206 // require(false, stub_error);
205 sponsor;207 // sponsor;
206 dummy = 0;208 // dummy = 0;
207 }209 // }
208210
209 /// Set the sponsor of the collection.211 /// Set the sponsor of the collection.
210 ///212 ///
251 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.253 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
252 /// @dev EVM selector for this function is: 0x6ec0a9f1,254 /// @dev EVM selector for this function is: 0x6ec0a9f1,
253 /// or in textual repr: collectionSponsor()255 /// or in textual repr: collectionSponsor()
254 function collectionSponsor() public view returns (Tuple24 memory) {256 function collectionSponsor() public view returns (Tuple25 memory) {
255 require(false, stub_error);257 require(false, stub_error);
256 dummy;258 dummy;
257 return Tuple24(0x0000000000000000000000000000000000000000, 0);259 return Tuple25(0x0000000000000000000000000000000000000000, 0);
258 }260 }
259261
260 /// Set limits for the collection.262 /// Set limits for the collection.
321 dummy = 0;323 dummy = 0;
322 }324 }
323325
324 /// Add collection admin.326 // /// Add collection admin.
325 /// @param newAdmin Address of the added administrator.327 // /// @param newAdmin Address of the added administrator.
326 /// @dev EVM selector for this function is: 0x92e462c7,328 // /// @dev EVM selector for this function is: 0x92e462c7,
327 /// or in textual repr: addCollectionAdmin(address)329 // /// or in textual repr: addCollectionAdmin(address)
328 function addCollectionAdmin(address newAdmin) public {330 // function addCollectionAdmin(address newAdmin) public {
329 require(false, stub_error);331 // require(false, stub_error);
330 newAdmin;332 // newAdmin;
331 dummy = 0;333 // dummy = 0;
332 }334 // }
333335
334 /// Remove collection admin.336 // /// Remove collection admin.
335 ///337 // ///
336 /// @param admin Address of the removed administrator.338 // /// @param admin Address of the removed administrator.
337 /// @dev EVM selector for this function is: 0xfafd7b42,339 // /// @dev EVM selector for this function is: 0xfafd7b42,
338 /// or in textual repr: removeCollectionAdmin(address)340 // /// or in textual repr: removeCollectionAdmin(address)
339 function removeCollectionAdmin(address admin) public {341 // function removeCollectionAdmin(address admin) public {
340 require(false, stub_error);342 // require(false, stub_error);
341 admin;343 // admin;
342 dummy = 0;344 // dummy = 0;
343 }345 // }
344346
345 /// Toggle accessibility of collection nesting.347 /// Toggle accessibility of collection nesting.
346 ///348 ///
390 return false;392 return false;
391 }393 }
392394
393 /// Add the user to the allowed list.395 // /// Add the user to the allowed list.
394 ///396 // ///
395 /// @param user Address of a trusted user.397 // /// @param user Address of a trusted user.
396 /// @dev EVM selector for this function is: 0x67844fe6,398 // /// @dev EVM selector for this function is: 0x67844fe6,
397 /// or in textual repr: addToCollectionAllowList(address)399 // /// or in textual repr: addToCollectionAllowList(address)
398 function addToCollectionAllowList(address user) public {400 // function addToCollectionAllowList(address user) public {
399 require(false, stub_error);401 // require(false, stub_error);
400 user;402 // user;
401 dummy = 0;403 // dummy = 0;
402 }404 // }
403405
404 /// Add user to allowed list.406 /// Add user to allowed list.
405 ///407 ///
412 dummy = 0;414 dummy = 0;
413 }415 }
414416
415 /// Remove the user from the allowed list.417 // /// Remove the user from the allowed list.
416 ///418 // ///
417 /// @param user Address of a removed user.419 // /// @param user Address of a removed user.
418 /// @dev EVM selector for this function is: 0x85c51acb,420 // /// @dev EVM selector for this function is: 0x85c51acb,
419 /// or in textual repr: removeFromCollectionAllowList(address)421 // /// or in textual repr: removeFromCollectionAllowList(address)
420 function removeFromCollectionAllowList(address user) public {422 // function removeFromCollectionAllowList(address user) public {
421 require(false, stub_error);423 // require(false, stub_error);
422 user;424 // user;
423 dummy = 0;425 // dummy = 0;
424 }426 // }
425427
426 /// Remove user from allowed list.428 /// Remove user from allowed list.
427 ///429 ///
445 dummy = 0;447 dummy = 0;
446 }448 }
447449
448 /// Check that account is the owner or admin of the collection450 // /// Check that account is the owner or admin of the collection
449 ///451 // ///
450 /// @param user account to verify452 // /// @param user account to verify
451 /// @return "true" if account is the owner or admin453 // /// @return "true" if account is the owner or admin
452 /// @dev EVM selector for this function is: 0x9811b0c7,454 // /// @dev EVM selector for this function is: 0x9811b0c7,
453 /// or in textual repr: isOwnerOrAdmin(address)455 // /// or in textual repr: isOwnerOrAdmin(address)
454 function isOwnerOrAdmin(address user) public view returns (bool) {456 // function isOwnerOrAdmin(address user) public view returns (bool) {
455 require(false, stub_error);457 // require(false, stub_error);
456 user;458 // user;
457 dummy;459 // dummy;
458 return false;460 // return false;
459 }461 // }
460462
461 /// Check that account is the owner or admin of the collection463 /// Check that account is the owner or admin of the collection
462 ///464 ///
494 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);496 return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
495 }497 }
496498
497 /// Changes collection owner to another account499 // /// Changes collection owner to another account
498 ///500 // ///
499 /// @dev Owner can be changed only by current owner501 // /// @dev Owner can be changed only by current owner
500 /// @param newOwner new owner account502 // /// @param newOwner new owner account
501 /// @dev EVM selector for this function is: 0x4f53e226,503 // /// @dev EVM selector for this function is: 0x4f53e226,
502 /// or in textual repr: changeCollectionOwner(address)504 // /// or in textual repr: changeCollectionOwner(address)
503 function changeCollectionOwner(address newOwner) public {505 // function changeCollectionOwner(address newOwner) public {
504 require(false, stub_error);506 // require(false, stub_error);
505 newOwner;507 // newOwner;
506 dummy = 0;508 // dummy = 0;
507 }509 // }
508510
509 /// Get collection administrators511 /// Get collection administrators
510 ///512 ///
522 ///524 ///
523 /// @dev Owner can be changed only by current owner525 /// @dev Owner can be changed only by current owner
524 /// @param newOwner new owner cross account526 /// @param newOwner new owner cross account
525 /// @dev EVM selector for this function is: 0xe5c9913f,527 /// @dev EVM selector for this function is: 0x6496c497,
526 /// or in textual repr: setOwnerCross((address,uint256))528 /// or in textual repr: changeCollectionOwnerCross((address,uint256))
527 function setOwnerCross(EthCrossAccount memory newOwner) public {529 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) public {
528 require(false, stub_error);530 require(false, stub_error);
529 newOwner;531 newOwner;
530 dummy = 0;532 dummy = 0;
538}540}
539541
540/// @dev anonymous struct542/// @dev anonymous struct
541struct Tuple24 {543struct Tuple25 {
542 address field_0;544 address field_0;
543 uint256 field_1;545 uint256 field_1;
544}546}
545547
546/// @dev anonymous struct548/// @dev anonymous struct
547struct Tuple21 {549struct Tuple22 {
548 string field_0;550 string field_0;
549 bytes field_1;551 bytes field_1;
550}552}
761 dummy = 0;763 dummy = 0;
762 }764 }
763765
764 /// @notice Burns a specific ERC721 token.766 // /// @notice Burns a specific ERC721 token.
765 /// @dev Throws unless `msg.sender` is the current owner or an authorized767 // /// @dev Throws unless `msg.sender` is the current owner or an authorized
766 /// operator for this RFT. Throws if `from` is not the current owner. Throws768 // /// operator for this RFT. Throws if `from` is not the current owner. Throws
767 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.769 // /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
768 /// Throws if RFT pieces have multiple owners.770 // /// Throws if RFT pieces have multiple owners.
769 /// @param from The current owner of the RFT771 // /// @param from The current owner of the RFT
770 /// @param tokenId The RFT to transfer772 // /// @param tokenId The RFT to transfer
771 /// @dev EVM selector for this function is: 0x79cc6790,773 // /// @dev EVM selector for this function is: 0x79cc6790,
772 /// or in textual repr: burnFrom(address,uint256)774 // /// or in textual repr: burnFrom(address,uint256)
773 function burnFrom(address from, uint256 tokenId) public {775 // function burnFrom(address from, uint256 tokenId) public {
774 require(false, stub_error);776 // require(false, stub_error);
775 from;777 // from;
776 tokenId;778 // tokenId;
777 dummy = 0;779 // dummy = 0;
778 }780 // }
779781
780 /// @notice Burns a specific ERC721 token.782 /// @notice Burns a specific ERC721 token.
781 /// @dev Throws unless `msg.sender` is the current owner or an authorized783 /// @dev Throws unless `msg.sender` is the current owner or an authorized
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

addedtests/src/eth/abi/collectionHelpers.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/contractHelpers.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/fungible.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/fungibleDeprecated.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/nonFungibleDeprecated.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/reFungibleDeprecated.jsondiffbeforeafterboth

no changes

addedtests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/allowlist.test.tsdiffbeforeafterboth
74 });74 });
75 });75 });
7676
77 // Soft-deprecated
77 itEth('Collection allowlist can be added and removed by [eth] address', async ({helper}) => {78 itEth('Collection allowlist can be added and removed by [eth] address', async ({helper}) => {
78 const owner = await helper.eth.createAccountWithBalance(donor);79 const owner = await helper.eth.createAccountWithBalance(donor);
79 const user = helper.eth.createAccount();80 const user = helper.eth.createAccount();
8081
81 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');82 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
82 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);83 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
8384
84 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;85 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
85 await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});86 await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});
105 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;106 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
106 });107 });
107108
109 // Soft-deprecated
108 itEth('Collection allowlist can not be add and remove [eth] address by not owner', async ({helper}) => {110 itEth('Collection allowlist can not be add and remove [eth] address by not owner', async ({helper}) => {
109 const owner = await helper.eth.createAccountWithBalance(donor);111 const owner = await helper.eth.createAccountWithBalance(donor);
110 const notOwner = await helper.eth.createAccountWithBalance(donor);112 const notOwner = await helper.eth.createAccountWithBalance(donor);
111 const user = helper.eth.createAccount();113 const user = helper.eth.createAccount();
112114
113 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');115 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
114 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);116 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
115117
116 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;118 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
117 await expect(collectionEvm.methods.addToCollectionAllowList(user).call({from: notOwner})).to.be.rejectedWith('NoPermission');119 await expect(collectionEvm.methods.addToCollectionAllowList(user).call({from: notOwner})).to.be.rejectedWith('NoPermission');
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
13}13}
1414
15/// @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 0xb3152af316/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
17interface Collection is Dummy, ERC165 {17interface Collection is Dummy, ERC165 {
18 /// Set collection property.18 // /// Set collection property.
19 ///19 // ///
20 /// @param key Property key.20 // /// @param key Property key.
21 /// @param value Propery value.21 // /// @param value Propery value.
22 /// @dev EVM selector for this function is: 0x2f073f66,22 // /// @dev EVM selector for this function is: 0x2f073f66,
23 /// or in textual repr: setCollectionProperty(string,bytes)23 // /// or in textual repr: setCollectionProperty(string,bytes)
24 function setCollectionProperty(string memory key, bytes memory value) external;24 // function setCollectionProperty(string memory key, bytes memory value) external;
2525
26 /// Set collection properties.26 /// Set collection properties.
27 ///27 ///
28 /// @param properties Vector of properties key/value pair.28 /// @param properties Vector of properties key/value pair.
29 /// @dev EVM selector for this function is: 0x50b26b2a,29 /// @dev EVM selector for this function is: 0x50b26b2a,
30 /// or in textual repr: setCollectionProperties((string,bytes)[])30 /// or in textual repr: setCollectionProperties((string,bytes)[])
31 function setCollectionProperties(Tuple15[] memory properties) external;31 function setCollectionProperties(Property[] memory properties) external;
3232
33 /// Delete collection property.33 // /// Delete collection property.
34 ///34 // ///
35 /// @param key Property key.35 // /// @param key Property key.
36 /// @dev EVM selector for this function is: 0x7b7debce,36 // /// @dev EVM selector for this function is: 0x7b7debce,
37 /// or in textual repr: deleteCollectionProperty(string)37 // /// or in textual repr: deleteCollectionProperty(string)
38 function deleteCollectionProperty(string memory key) external;38 // function deleteCollectionProperty(string memory key) external;
3939
40 /// Delete collection properties.40 /// Delete collection properties.
41 ///41 ///
60 /// @return Vector of properties key/value pairs.60 /// @return Vector of properties key/value pairs.
61 /// @dev EVM selector for this function is: 0x285fb8e6,61 /// @dev EVM selector for this function is: 0x285fb8e6,
62 /// or in textual repr: collectionProperties(string[])62 /// or in textual repr: collectionProperties(string[])
63 function collectionProperties(string[] memory keys) external view returns (Tuple15[] memory);63 function collectionProperties(string[] memory keys) external view returns (Tuple16[] memory);
6464
65 /// Set the sponsor of the collection.65 // /// Set the sponsor of the collection.
66 ///66 // ///
67 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.67 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
68 ///68 // ///
69 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.69 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
70 /// @dev EVM selector for this function is: 0x7623402e,70 // /// @dev EVM selector for this function is: 0x7623402e,
71 /// or in textual repr: setCollectionSponsor(address)71 // /// or in textual repr: setCollectionSponsor(address)
72 function setCollectionSponsor(address sponsor) external;72 // function setCollectionSponsor(address sponsor) external;
7373
74 /// Set the sponsor of the collection.74 /// Set the sponsor of the collection.
75 ///75 ///
146 /// or in textual repr: removeCollectionAdminCross((address,uint256))146 /// or in textual repr: removeCollectionAdminCross((address,uint256))
147 function removeCollectionAdminCross(EthCrossAccount memory admin) external;147 function removeCollectionAdminCross(EthCrossAccount memory admin) external;
148148
149 /// Add collection admin.149 // /// Add collection admin.
150 /// @param newAdmin Address of the added administrator.150 // /// @param newAdmin Address of the added administrator.
151 /// @dev EVM selector for this function is: 0x92e462c7,151 // /// @dev EVM selector for this function is: 0x92e462c7,
152 /// or in textual repr: addCollectionAdmin(address)152 // /// or in textual repr: addCollectionAdmin(address)
153 function addCollectionAdmin(address newAdmin) external;153 // function addCollectionAdmin(address newAdmin) external;
154154
155 /// Remove collection admin.155 // /// Remove collection admin.
156 ///156 // ///
157 /// @param admin Address of the removed administrator.157 // /// @param admin Address of the removed administrator.
158 /// @dev EVM selector for this function is: 0xfafd7b42,158 // /// @dev EVM selector for this function is: 0xfafd7b42,
159 /// or in textual repr: removeCollectionAdmin(address)159 // /// or in textual repr: removeCollectionAdmin(address)
160 function removeCollectionAdmin(address admin) external;160 // function removeCollectionAdmin(address admin) external;
161161
162 /// Toggle accessibility of collection nesting.162 /// Toggle accessibility of collection nesting.
163 ///163 ///
189 /// or in textual repr: allowed(address)189 /// or in textual repr: allowed(address)
190 function allowed(address user) external view returns (bool);190 function allowed(address user) external view returns (bool);
191191
192 /// Add the user to the allowed list.192 // /// Add the user to the allowed list.
193 ///193 // ///
194 /// @param user Address of a trusted user.194 // /// @param user Address of a trusted user.
195 /// @dev EVM selector for this function is: 0x67844fe6,195 // /// @dev EVM selector for this function is: 0x67844fe6,
196 /// or in textual repr: addToCollectionAllowList(address)196 // /// or in textual repr: addToCollectionAllowList(address)
197 function addToCollectionAllowList(address user) external;197 // function addToCollectionAllowList(address user) external;
198198
199 /// Add user to allowed list.199 /// Add user to allowed list.
200 ///200 ///
203 /// or in textual repr: addToCollectionAllowListCross((address,uint256))203 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
204 function addToCollectionAllowListCross(EthCrossAccount memory user) external;204 function addToCollectionAllowListCross(EthCrossAccount memory user) external;
205205
206 /// Remove the user from the allowed list.206 // /// Remove the user from the allowed list.
207 ///207 // ///
208 /// @param user Address of a removed user.208 // /// @param user Address of a removed user.
209 /// @dev EVM selector for this function is: 0x85c51acb,209 // /// @dev EVM selector for this function is: 0x85c51acb,
210 /// or in textual repr: removeFromCollectionAllowList(address)210 // /// or in textual repr: removeFromCollectionAllowList(address)
211 function removeFromCollectionAllowList(address user) external;211 // function removeFromCollectionAllowList(address user) external;
212212
213 /// Remove user from allowed list.213 /// Remove user from allowed list.
214 ///214 ///
224 /// or in textual repr: setCollectionMintMode(bool)224 /// or in textual repr: setCollectionMintMode(bool)
225 function setCollectionMintMode(bool mode) external;225 function setCollectionMintMode(bool mode) external;
226226
227 /// Check that account is the owner or admin of the collection227 // /// Check that account is the owner or admin of the collection
228 ///228 // ///
229 /// @param user account to verify229 // /// @param user account to verify
230 /// @return "true" if account is the owner or admin230 // /// @return "true" if account is the owner or admin
231 /// @dev EVM selector for this function is: 0x9811b0c7,231 // /// @dev EVM selector for this function is: 0x9811b0c7,
232 /// or in textual repr: isOwnerOrAdmin(address)232 // /// or in textual repr: isOwnerOrAdmin(address)
233 function isOwnerOrAdmin(address user) external view returns (bool);233 // function isOwnerOrAdmin(address user) external view returns (bool);
234234
235 /// Check that account is the owner or admin of the collection235 /// Check that account is the owner or admin of the collection
236 ///236 ///
255 /// or in textual repr: collectionOwner()255 /// or in textual repr: collectionOwner()
256 function collectionOwner() external view returns (EthCrossAccount memory);256 function collectionOwner() external view returns (EthCrossAccount memory);
257257
258 /// Changes collection owner to another account258 // /// Changes collection owner to another account
259 ///259 // ///
260 /// @dev Owner can be changed only by current owner260 // /// @dev Owner can be changed only by current owner
261 /// @param newOwner new owner account261 // /// @param newOwner new owner account
262 /// @dev EVM selector for this function is: 0x4f53e226,262 // /// @dev EVM selector for this function is: 0x4f53e226,
263 /// or in textual repr: changeCollectionOwner(address)263 // /// or in textual repr: changeCollectionOwner(address)
264 function changeCollectionOwner(address newOwner) external;264 // function changeCollectionOwner(address newOwner) external;
265265
266 /// Get collection administrators266 /// Get collection administrators
267 ///267 ///
275 ///275 ///
276 /// @dev Owner can be changed only by current owner276 /// @dev Owner can be changed only by current owner
277 /// @param newOwner new owner cross account277 /// @param newOwner new owner cross account
278 /// @dev EVM selector for this function is: 0xe5c9913f,278 /// @dev EVM selector for this function is: 0x6496c497,
279 /// or in textual repr: setOwnerCross((address,uint256))279 /// or in textual repr: changeCollectionOwnerCross((address,uint256))
280 function setOwnerCross(EthCrossAccount memory newOwner) external;280 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) external;
281}281}
282282
283/// @dev Cross account struct283/// @dev Cross account struct
287}287}
288288
289/// @dev anonymous struct289/// @dev anonymous struct
290struct Tuple15 {290struct Tuple16 {
291 string field_0;291 string field_0;
292 bytes field_1;292 bytes field_1;
293}293}
294
295/// @dev Property struct
296struct Property {
297 string key;
298 bytes value;
299}
294300
295/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9301/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9
296interface ERC20UniqueExtensions is Dummy, ERC165 {302interface ERC20UniqueExtensions is Dummy, ERC165 {
297 /// @dev EVM selector for this function is: 0x0ecd0ab0,303 /// @dev EVM selector for this function is: 0x0ecd0ab0,
298 /// or in textual repr: approveCross((address,uint256),uint256)304 /// or in textual repr: approveCross((address,uint256),uint256)
299 function approveCross(EthCrossAccount memory spender, uint256 amount) external returns (bool);305 function approveCross(EthCrossAccount memory spender, uint256 amount) external returns (bool);
300306
301 /// Burn tokens from account307 // /// Burn tokens from account
302 /// @dev Function that burns an `amount` of the tokens of a given account,308 // /// @dev Function that burns an `amount` of the tokens of a given account,
303 /// deducting from the sender's allowance for said account.309 // /// deducting from the sender's allowance for said account.
304 /// @param from The account whose tokens will be burnt.310 // /// @param from The account whose tokens will be burnt.
305 /// @param amount The amount that will be burnt.311 // /// @param amount The amount that will be burnt.
306 /// @dev EVM selector for this function is: 0x79cc6790,312 // /// @dev EVM selector for this function is: 0x79cc6790,
307 /// or in textual repr: burnFrom(address,uint256)313 // /// or in textual repr: burnFrom(address,uint256)
308 function burnFrom(address from, uint256 amount) external returns (bool);314 // function burnFrom(address from, uint256 amount) external returns (bool);
309315
310 /// Burn tokens from account316 /// Burn tokens from account
311 /// @dev Function that burns an `amount` of the tokens of a given account,317 /// @dev Function that burns an `amount` of the tokens of a given account,
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
30 bool tokenOwner30 bool tokenOwner
31 ) external;31 ) external;
3232
33 /// @notice Set token property value.33 // /// @notice Set token property value.
34 /// @dev Throws error if `msg.sender` has no permission to edit the property.34 // /// @dev Throws error if `msg.sender` has no permission to edit the property.
35 /// @param tokenId ID of the token.35 // /// @param tokenId ID of the token.
36 /// @param key Property key.36 // /// @param key Property key.
37 /// @param value Property value.37 // /// @param value Property value.
38 /// @dev EVM selector for this function is: 0x1752d67b,38 // /// @dev EVM selector for this function is: 0x1752d67b,
39 /// or in textual repr: setProperty(uint256,string,bytes)39 // /// or in textual repr: setProperty(uint256,string,bytes)
40 function setProperty(40 // function setProperty(uint256 tokenId, string memory key, bytes memory value) external;
41 uint256 tokenId,
42 string memory key,
43 bytes memory value
44 ) external;
4541
46 /// @notice Set token properties value.42 /// @notice Set token properties value.
47 /// @dev Throws error if `msg.sender` has no permission to edit the property.43 /// @dev Throws error if `msg.sender` has no permission to edit the property.
48 /// @param tokenId ID of the token.44 /// @param tokenId ID of the token.
49 /// @param properties settable properties45 /// @param properties settable properties
50 /// @dev EVM selector for this function is: 0x14ed3a6e,46 /// @dev EVM selector for this function is: 0x14ed3a6e,
51 /// or in textual repr: setProperties(uint256,(string,bytes)[])47 /// or in textual repr: setProperties(uint256,(string,bytes)[])
52 function setProperties(uint256 tokenId, Tuple22[] memory properties) external;48 function setProperties(uint256 tokenId, Property[] memory properties) external;
5349
54 // /// @notice Delete token property value.50 // /// @notice Delete token property value.
55 // /// @dev Throws error if `msg.sender` has no permission to edit the property.51 // /// @dev Throws error if `msg.sender` has no permission to edit the property.
77 function property(uint256 tokenId, string memory key) external view returns (bytes memory);73 function property(uint256 tokenId, string memory key) external view returns (bytes memory);
78}74}
75
76/// @dev Property struct
77struct Property {
78 string key;
79 bytes value;
80}
7981
80/// @title A contract that allows you to work with collections.82/// @title A contract that allows you to work with collections.
81/// @dev the ERC-165 identifier for this interface is 0xb3152af383/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
82interface Collection is Dummy, ERC165 {84interface Collection is Dummy, ERC165 {
83 /// Set collection property.85 // /// Set collection property.
84 ///86 // ///
85 /// @param key Property key.87 // /// @param key Property key.
86 /// @param value Propery value.88 // /// @param value Propery value.
87 /// @dev EVM selector for this function is: 0x2f073f66,89 // /// @dev EVM selector for this function is: 0x2f073f66,
88 /// or in textual repr: setCollectionProperty(string,bytes)90 // /// or in textual repr: setCollectionProperty(string,bytes)
89 function setCollectionProperty(string memory key, bytes memory value) external;91 // function setCollectionProperty(string memory key, bytes memory value) external;
9092
91 /// Set collection properties.93 /// Set collection properties.
92 ///94 ///
93 /// @param properties Vector of properties key/value pair.95 /// @param properties Vector of properties key/value pair.
94 /// @dev EVM selector for this function is: 0x50b26b2a,96 /// @dev EVM selector for this function is: 0x50b26b2a,
95 /// or in textual repr: setCollectionProperties((string,bytes)[])97 /// or in textual repr: setCollectionProperties((string,bytes)[])
96 function setCollectionProperties(Tuple22[] memory properties) external;98 function setCollectionProperties(Property[] memory properties) external;
9799
98 /// Delete collection property.100 // /// Delete collection property.
99 ///101 // ///
100 /// @param key Property key.102 // /// @param key Property key.
101 /// @dev EVM selector for this function is: 0x7b7debce,103 // /// @dev EVM selector for this function is: 0x7b7debce,
102 /// or in textual repr: deleteCollectionProperty(string)104 // /// or in textual repr: deleteCollectionProperty(string)
103 function deleteCollectionProperty(string memory key) external;105 // function deleteCollectionProperty(string memory key) external;
104106
105 /// Delete collection properties.107 /// Delete collection properties.
106 ///108 ///
125 /// @return Vector of properties key/value pairs.127 /// @return Vector of properties key/value pairs.
126 /// @dev EVM selector for this function is: 0x285fb8e6,128 /// @dev EVM selector for this function is: 0x285fb8e6,
127 /// or in textual repr: collectionProperties(string[])129 /// or in textual repr: collectionProperties(string[])
128 function collectionProperties(string[] memory keys) external view returns (Tuple22[] memory);130 function collectionProperties(string[] memory keys) external view returns (Tuple23[] memory);
129131
130 /// Set the sponsor of the collection.132 // /// Set the sponsor of the collection.
131 ///133 // ///
132 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.134 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
133 ///135 // ///
134 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.136 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
135 /// @dev EVM selector for this function is: 0x7623402e,137 // /// @dev EVM selector for this function is: 0x7623402e,
136 /// or in textual repr: setCollectionSponsor(address)138 // /// or in textual repr: setCollectionSponsor(address)
137 function setCollectionSponsor(address sponsor) external;139 // function setCollectionSponsor(address sponsor) external;
138140
139 /// Set the sponsor of the collection.141 /// Set the sponsor of the collection.
140 ///142 ///
167 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.169 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
168 /// @dev EVM selector for this function is: 0x6ec0a9f1,170 /// @dev EVM selector for this function is: 0x6ec0a9f1,
169 /// or in textual repr: collectionSponsor()171 /// or in textual repr: collectionSponsor()
170 function collectionSponsor() external view returns (Tuple25 memory);172 function collectionSponsor() external view returns (Tuple26 memory);
171173
172 /// Set limits for the collection.174 /// Set limits for the collection.
173 /// @dev Throws error if limit not found.175 /// @dev Throws error if limit not found.
211 /// or in textual repr: removeCollectionAdminCross((address,uint256))213 /// or in textual repr: removeCollectionAdminCross((address,uint256))
212 function removeCollectionAdminCross(EthCrossAccount memory admin) external;214 function removeCollectionAdminCross(EthCrossAccount memory admin) external;
213215
214 /// Add collection admin.216 // /// Add collection admin.
215 /// @param newAdmin Address of the added administrator.217 // /// @param newAdmin Address of the added administrator.
216 /// @dev EVM selector for this function is: 0x92e462c7,218 // /// @dev EVM selector for this function is: 0x92e462c7,
217 /// or in textual repr: addCollectionAdmin(address)219 // /// or in textual repr: addCollectionAdmin(address)
218 function addCollectionAdmin(address newAdmin) external;220 // function addCollectionAdmin(address newAdmin) external;
219221
220 /// Remove collection admin.222 // /// Remove collection admin.
221 ///223 // ///
222 /// @param admin Address of the removed administrator.224 // /// @param admin Address of the removed administrator.
223 /// @dev EVM selector for this function is: 0xfafd7b42,225 // /// @dev EVM selector for this function is: 0xfafd7b42,
224 /// or in textual repr: removeCollectionAdmin(address)226 // /// or in textual repr: removeCollectionAdmin(address)
225 function removeCollectionAdmin(address admin) external;227 // function removeCollectionAdmin(address admin) external;
226228
227 /// Toggle accessibility of collection nesting.229 /// Toggle accessibility of collection nesting.
228 ///230 ///
254 /// or in textual repr: allowed(address)256 /// or in textual repr: allowed(address)
255 function allowed(address user) external view returns (bool);257 function allowed(address user) external view returns (bool);
256258
257 /// Add the user to the allowed list.259 // /// Add the user to the allowed list.
258 ///260 // ///
259 /// @param user Address of a trusted user.261 // /// @param user Address of a trusted user.
260 /// @dev EVM selector for this function is: 0x67844fe6,262 // /// @dev EVM selector for this function is: 0x67844fe6,
261 /// or in textual repr: addToCollectionAllowList(address)263 // /// or in textual repr: addToCollectionAllowList(address)
262 function addToCollectionAllowList(address user) external;264 // function addToCollectionAllowList(address user) external;
263265
264 /// Add user to allowed list.266 /// Add user to allowed list.
265 ///267 ///
268 /// or in textual repr: addToCollectionAllowListCross((address,uint256))270 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
269 function addToCollectionAllowListCross(EthCrossAccount memory user) external;271 function addToCollectionAllowListCross(EthCrossAccount memory user) external;
270272
271 /// Remove the user from the allowed list.273 // /// Remove the user from the allowed list.
272 ///274 // ///
273 /// @param user Address of a removed user.275 // /// @param user Address of a removed user.
274 /// @dev EVM selector for this function is: 0x85c51acb,276 // /// @dev EVM selector for this function is: 0x85c51acb,
275 /// or in textual repr: removeFromCollectionAllowList(address)277 // /// or in textual repr: removeFromCollectionAllowList(address)
276 function removeFromCollectionAllowList(address user) external;278 // function removeFromCollectionAllowList(address user) external;
277279
278 /// Remove user from allowed list.280 /// Remove user from allowed list.
279 ///281 ///
289 /// or in textual repr: setCollectionMintMode(bool)291 /// or in textual repr: setCollectionMintMode(bool)
290 function setCollectionMintMode(bool mode) external;292 function setCollectionMintMode(bool mode) external;
291293
292 /// Check that account is the owner or admin of the collection294 // /// Check that account is the owner or admin of the collection
293 ///295 // ///
294 /// @param user account to verify296 // /// @param user account to verify
295 /// @return "true" if account is the owner or admin297 // /// @return "true" if account is the owner or admin
296 /// @dev EVM selector for this function is: 0x9811b0c7,298 // /// @dev EVM selector for this function is: 0x9811b0c7,
297 /// or in textual repr: isOwnerOrAdmin(address)299 // /// or in textual repr: isOwnerOrAdmin(address)
298 function isOwnerOrAdmin(address user) external view returns (bool);300 // function isOwnerOrAdmin(address user) external view returns (bool);
299301
300 /// Check that account is the owner or admin of the collection302 /// Check that account is the owner or admin of the collection
301 ///303 ///
320 /// or in textual repr: collectionOwner()322 /// or in textual repr: collectionOwner()
321 function collectionOwner() external view returns (EthCrossAccount memory);323 function collectionOwner() external view returns (EthCrossAccount memory);
322324
323 /// Changes collection owner to another account325 // /// Changes collection owner to another account
324 ///326 // ///
325 /// @dev Owner can be changed only by current owner327 // /// @dev Owner can be changed only by current owner
326 /// @param newOwner new owner account328 // /// @param newOwner new owner account
327 /// @dev EVM selector for this function is: 0x4f53e226,329 // /// @dev EVM selector for this function is: 0x4f53e226,
328 /// or in textual repr: changeCollectionOwner(address)330 // /// or in textual repr: changeCollectionOwner(address)
329 function changeCollectionOwner(address newOwner) external;331 // function changeCollectionOwner(address newOwner) external;
330332
331 /// Get collection administrators333 /// Get collection administrators
332 ///334 ///
340 ///342 ///
341 /// @dev Owner can be changed only by current owner343 /// @dev Owner can be changed only by current owner
342 /// @param newOwner new owner cross account344 /// @param newOwner new owner cross account
343 /// @dev EVM selector for this function is: 0xe5c9913f,345 /// @dev EVM selector for this function is: 0x6496c497,
344 /// or in textual repr: setOwnerCross((address,uint256))346 /// or in textual repr: changeCollectionOwnerCross((address,uint256))
345 function setOwnerCross(EthCrossAccount memory newOwner) external;347 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) external;
346}348}
347349
348/// @dev Cross account struct350/// @dev Cross account struct
352}354}
353355
354/// @dev anonymous struct356/// @dev anonymous struct
355struct Tuple25 {357struct Tuple26 {
356 address field_0;358 address field_0;
357 uint256 field_1;359 uint256 field_1;
358}360}
359361
360/// @dev anonymous struct362/// @dev anonymous struct
361struct Tuple22 {363struct Tuple23 {
362 string field_0;364 string field_0;
363 bytes field_1;365 bytes field_1;
364}366}
512 uint256 tokenId514 uint256 tokenId
513 ) external;515 ) external;
514516
515 /// @notice Burns a specific ERC721 token.517 // /// @notice Burns a specific ERC721 token.
516 /// @dev Throws unless `msg.sender` is the current owner or an authorized518 // /// @dev Throws unless `msg.sender` is the current owner or an authorized
517 /// operator for this NFT. Throws if `from` is not the current owner. Throws519 // /// operator for this NFT. Throws if `from` is not the current owner. Throws
518 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.520 // /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
519 /// @param from The current owner of the NFT521 // /// @param from The current owner of the NFT
520 /// @param tokenId The NFT to transfer522 // /// @param tokenId The NFT to transfer
521 /// @dev EVM selector for this function is: 0x79cc6790,523 // /// @dev EVM selector for this function is: 0x79cc6790,
522 /// or in textual repr: burnFrom(address,uint256)524 // /// or in textual repr: burnFrom(address,uint256)
523 function burnFrom(address from, uint256 tokenId) external;525 // function burnFrom(address from, uint256 tokenId) external;
524526
525 /// @notice Burns a specific ERC721 token.527 /// @notice Burns a specific ERC721 token.
526 /// @dev Throws unless `msg.sender` is the current owner or an authorized528 /// @dev Throws unless `msg.sender` is the current owner or an authorized
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
30 bool tokenOwner30 bool tokenOwner
31 ) external;31 ) external;
3232
33 /// @notice Set token property value.33 // /// @notice Set token property value.
34 /// @dev Throws error if `msg.sender` has no permission to edit the property.34 // /// @dev Throws error if `msg.sender` has no permission to edit the property.
35 /// @param tokenId ID of the token.35 // /// @param tokenId ID of the token.
36 /// @param key Property key.36 // /// @param key Property key.
37 /// @param value Property value.37 // /// @param value Property value.
38 /// @dev EVM selector for this function is: 0x1752d67b,38 // /// @dev EVM selector for this function is: 0x1752d67b,
39 /// or in textual repr: setProperty(uint256,string,bytes)39 // /// or in textual repr: setProperty(uint256,string,bytes)
40 function setProperty(40 // function setProperty(uint256 tokenId, string memory key, bytes memory value) external;
41 uint256 tokenId,
42 string memory key,
43 bytes memory value
44 ) external;
4541
46 /// @notice Set token properties value.42 /// @notice Set token properties value.
47 /// @dev Throws error if `msg.sender` has no permission to edit the property.43 /// @dev Throws error if `msg.sender` has no permission to edit the property.
48 /// @param tokenId ID of the token.44 /// @param tokenId ID of the token.
49 /// @param properties settable properties45 /// @param properties settable properties
50 /// @dev EVM selector for this function is: 0x14ed3a6e,46 /// @dev EVM selector for this function is: 0x14ed3a6e,
51 /// or in textual repr: setProperties(uint256,(string,bytes)[])47 /// or in textual repr: setProperties(uint256,(string,bytes)[])
52 function setProperties(uint256 tokenId, Tuple21[] memory properties) external;48 function setProperties(uint256 tokenId, Property[] memory properties) external;
5349
54 // /// @notice Delete token property value.50 // /// @notice Delete token property value.
55 // /// @dev Throws error if `msg.sender` has no permission to edit the property.51 // /// @dev Throws error if `msg.sender` has no permission to edit the property.
77 function property(uint256 tokenId, string memory key) external view returns (bytes memory);73 function property(uint256 tokenId, string memory key) external view returns (bytes memory);
78}74}
75
76/// @dev Property struct
77struct Property {
78 string key;
79 bytes value;
80}
7981
80/// @title A contract that allows you to work with collections.82/// @title A contract that allows you to work with collections.
81/// @dev the ERC-165 identifier for this interface is 0xb3152af383/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
82interface Collection is Dummy, ERC165 {84interface Collection is Dummy, ERC165 {
83 /// Set collection property.85 // /// Set collection property.
84 ///86 // ///
85 /// @param key Property key.87 // /// @param key Property key.
86 /// @param value Propery value.88 // /// @param value Propery value.
87 /// @dev EVM selector for this function is: 0x2f073f66,89 // /// @dev EVM selector for this function is: 0x2f073f66,
88 /// or in textual repr: setCollectionProperty(string,bytes)90 // /// or in textual repr: setCollectionProperty(string,bytes)
89 function setCollectionProperty(string memory key, bytes memory value) external;91 // function setCollectionProperty(string memory key, bytes memory value) external;
9092
91 /// Set collection properties.93 /// Set collection properties.
92 ///94 ///
93 /// @param properties Vector of properties key/value pair.95 /// @param properties Vector of properties key/value pair.
94 /// @dev EVM selector for this function is: 0x50b26b2a,96 /// @dev EVM selector for this function is: 0x50b26b2a,
95 /// or in textual repr: setCollectionProperties((string,bytes)[])97 /// or in textual repr: setCollectionProperties((string,bytes)[])
96 function setCollectionProperties(Tuple21[] memory properties) external;98 function setCollectionProperties(Property[] memory properties) external;
9799
98 /// Delete collection property.100 // /// Delete collection property.
99 ///101 // ///
100 /// @param key Property key.102 // /// @param key Property key.
101 /// @dev EVM selector for this function is: 0x7b7debce,103 // /// @dev EVM selector for this function is: 0x7b7debce,
102 /// or in textual repr: deleteCollectionProperty(string)104 // /// or in textual repr: deleteCollectionProperty(string)
103 function deleteCollectionProperty(string memory key) external;105 // function deleteCollectionProperty(string memory key) external;
104106
105 /// Delete collection properties.107 /// Delete collection properties.
106 ///108 ///
125 /// @return Vector of properties key/value pairs.127 /// @return Vector of properties key/value pairs.
126 /// @dev EVM selector for this function is: 0x285fb8e6,128 /// @dev EVM selector for this function is: 0x285fb8e6,
127 /// or in textual repr: collectionProperties(string[])129 /// or in textual repr: collectionProperties(string[])
128 function collectionProperties(string[] memory keys) external view returns (Tuple21[] memory);130 function collectionProperties(string[] memory keys) external view returns (Tuple22[] memory);
129131
130 /// Set the sponsor of the collection.132 // /// Set the sponsor of the collection.
131 ///133 // ///
132 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.134 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
133 ///135 // ///
134 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.136 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
135 /// @dev EVM selector for this function is: 0x7623402e,137 // /// @dev EVM selector for this function is: 0x7623402e,
136 /// or in textual repr: setCollectionSponsor(address)138 // /// or in textual repr: setCollectionSponsor(address)
137 function setCollectionSponsor(address sponsor) external;139 // function setCollectionSponsor(address sponsor) external;
138140
139 /// Set the sponsor of the collection.141 /// Set the sponsor of the collection.
140 ///142 ///
167 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.169 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
168 /// @dev EVM selector for this function is: 0x6ec0a9f1,170 /// @dev EVM selector for this function is: 0x6ec0a9f1,
169 /// or in textual repr: collectionSponsor()171 /// or in textual repr: collectionSponsor()
170 function collectionSponsor() external view returns (Tuple24 memory);172 function collectionSponsor() external view returns (Tuple25 memory);
171173
172 /// Set limits for the collection.174 /// Set limits for the collection.
173 /// @dev Throws error if limit not found.175 /// @dev Throws error if limit not found.
211 /// or in textual repr: removeCollectionAdminCross((address,uint256))213 /// or in textual repr: removeCollectionAdminCross((address,uint256))
212 function removeCollectionAdminCross(EthCrossAccount memory admin) external;214 function removeCollectionAdminCross(EthCrossAccount memory admin) external;
213215
214 /// Add collection admin.216 // /// Add collection admin.
215 /// @param newAdmin Address of the added administrator.217 // /// @param newAdmin Address of the added administrator.
216 /// @dev EVM selector for this function is: 0x92e462c7,218 // /// @dev EVM selector for this function is: 0x92e462c7,
217 /// or in textual repr: addCollectionAdmin(address)219 // /// or in textual repr: addCollectionAdmin(address)
218 function addCollectionAdmin(address newAdmin) external;220 // function addCollectionAdmin(address newAdmin) external;
219221
220 /// Remove collection admin.222 // /// Remove collection admin.
221 ///223 // ///
222 /// @param admin Address of the removed administrator.224 // /// @param admin Address of the removed administrator.
223 /// @dev EVM selector for this function is: 0xfafd7b42,225 // /// @dev EVM selector for this function is: 0xfafd7b42,
224 /// or in textual repr: removeCollectionAdmin(address)226 // /// or in textual repr: removeCollectionAdmin(address)
225 function removeCollectionAdmin(address admin) external;227 // function removeCollectionAdmin(address admin) external;
226228
227 /// Toggle accessibility of collection nesting.229 /// Toggle accessibility of collection nesting.
228 ///230 ///
254 /// or in textual repr: allowed(address)256 /// or in textual repr: allowed(address)
255 function allowed(address user) external view returns (bool);257 function allowed(address user) external view returns (bool);
256258
257 /// Add the user to the allowed list.259 // /// Add the user to the allowed list.
258 ///260 // ///
259 /// @param user Address of a trusted user.261 // /// @param user Address of a trusted user.
260 /// @dev EVM selector for this function is: 0x67844fe6,262 // /// @dev EVM selector for this function is: 0x67844fe6,
261 /// or in textual repr: addToCollectionAllowList(address)263 // /// or in textual repr: addToCollectionAllowList(address)
262 function addToCollectionAllowList(address user) external;264 // function addToCollectionAllowList(address user) external;
263265
264 /// Add user to allowed list.266 /// Add user to allowed list.
265 ///267 ///
268 /// or in textual repr: addToCollectionAllowListCross((address,uint256))270 /// or in textual repr: addToCollectionAllowListCross((address,uint256))
269 function addToCollectionAllowListCross(EthCrossAccount memory user) external;271 function addToCollectionAllowListCross(EthCrossAccount memory user) external;
270272
271 /// Remove the user from the allowed list.273 // /// Remove the user from the allowed list.
272 ///274 // ///
273 /// @param user Address of a removed user.275 // /// @param user Address of a removed user.
274 /// @dev EVM selector for this function is: 0x85c51acb,276 // /// @dev EVM selector for this function is: 0x85c51acb,
275 /// or in textual repr: removeFromCollectionAllowList(address)277 // /// or in textual repr: removeFromCollectionAllowList(address)
276 function removeFromCollectionAllowList(address user) external;278 // function removeFromCollectionAllowList(address user) external;
277279
278 /// Remove user from allowed list.280 /// Remove user from allowed list.
279 ///281 ///
289 /// or in textual repr: setCollectionMintMode(bool)291 /// or in textual repr: setCollectionMintMode(bool)
290 function setCollectionMintMode(bool mode) external;292 function setCollectionMintMode(bool mode) external;
291293
292 /// Check that account is the owner or admin of the collection294 // /// Check that account is the owner or admin of the collection
293 ///295 // ///
294 /// @param user account to verify296 // /// @param user account to verify
295 /// @return "true" if account is the owner or admin297 // /// @return "true" if account is the owner or admin
296 /// @dev EVM selector for this function is: 0x9811b0c7,298 // /// @dev EVM selector for this function is: 0x9811b0c7,
297 /// or in textual repr: isOwnerOrAdmin(address)299 // /// or in textual repr: isOwnerOrAdmin(address)
298 function isOwnerOrAdmin(address user) external view returns (bool);300 // function isOwnerOrAdmin(address user) external view returns (bool);
299301
300 /// Check that account is the owner or admin of the collection302 /// Check that account is the owner or admin of the collection
301 ///303 ///
320 /// or in textual repr: collectionOwner()322 /// or in textual repr: collectionOwner()
321 function collectionOwner() external view returns (EthCrossAccount memory);323 function collectionOwner() external view returns (EthCrossAccount memory);
322324
323 /// Changes collection owner to another account325 // /// Changes collection owner to another account
324 ///326 // ///
325 /// @dev Owner can be changed only by current owner327 // /// @dev Owner can be changed only by current owner
326 /// @param newOwner new owner account328 // /// @param newOwner new owner account
327 /// @dev EVM selector for this function is: 0x4f53e226,329 // /// @dev EVM selector for this function is: 0x4f53e226,
328 /// or in textual repr: changeCollectionOwner(address)330 // /// or in textual repr: changeCollectionOwner(address)
329 function changeCollectionOwner(address newOwner) external;331 // function changeCollectionOwner(address newOwner) external;
330332
331 /// Get collection administrators333 /// Get collection administrators
332 ///334 ///
340 ///342 ///
341 /// @dev Owner can be changed only by current owner343 /// @dev Owner can be changed only by current owner
342 /// @param newOwner new owner cross account344 /// @param newOwner new owner cross account
343 /// @dev EVM selector for this function is: 0xe5c9913f,345 /// @dev EVM selector for this function is: 0x6496c497,
344 /// or in textual repr: setOwnerCross((address,uint256))346 /// or in textual repr: changeCollectionOwnerCross((address,uint256))
345 function setOwnerCross(EthCrossAccount memory newOwner) external;347 function changeCollectionOwnerCross(EthCrossAccount memory newOwner) external;
346}348}
347349
348/// @dev Cross account struct350/// @dev Cross account struct
352}354}
353355
354/// @dev anonymous struct356/// @dev anonymous struct
355struct Tuple24 {357struct Tuple25 {
356 address field_0;358 address field_0;
357 uint256 field_1;359 uint256 field_1;
358}360}
359361
360/// @dev anonymous struct362/// @dev anonymous struct
361struct Tuple21 {363struct Tuple22 {
362 string field_0;364 string field_0;
363 bytes field_1;365 bytes field_1;
364}366}
502 uint256 tokenId504 uint256 tokenId
503 ) external;505 ) external;
504506
505 /// @notice Burns a specific ERC721 token.507 // /// @notice Burns a specific ERC721 token.
506 /// @dev Throws unless `msg.sender` is the current owner or an authorized508 // /// @dev Throws unless `msg.sender` is the current owner or an authorized
507 /// operator for this RFT. Throws if `from` is not the current owner. Throws509 // /// operator for this RFT. Throws if `from` is not the current owner. Throws
508 /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.510 // /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
509 /// Throws if RFT pieces have multiple owners.511 // /// Throws if RFT pieces have multiple owners.
510 /// @param from The current owner of the RFT512 // /// @param from The current owner of the RFT
511 /// @param tokenId The RFT to transfer513 // /// @param tokenId The RFT to transfer
512 /// @dev EVM selector for this function is: 0x79cc6790,514 // /// @dev EVM selector for this function is: 0x79cc6790,
513 /// or in textual repr: burnFrom(address,uint256)515 // /// or in textual repr: burnFrom(address,uint256)
514 function burnFrom(address from, uint256 tokenId) external;516 // function burnFrom(address from, uint256 tokenId) external;
515517
516 /// @notice Burns a specific ERC721 token.518 /// @notice Burns a specific ERC721 token.
517 /// @dev Throws unless `msg.sender` is the current owner or an authorized519 /// @dev Throws unless `msg.sender` is the current owner or an authorized
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
39 });39 });
40 });40 });
4141
42 // Soft-deprecated
42 itEth('Add admin by owner', async ({helper}) => {43 itEth('Add admin by owner', async ({helper}) => {
43 const owner = await helper.eth.createAccountWithBalance(donor);44 const owner = await helper.eth.createAccountWithBalance(donor);
44 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');45 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
45 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);46 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
4647
47 const newAdmin = helper.eth.createAccount();48 const newAdmin = helper.eth.createAccount();
4849
70 const owner = await helper.eth.createAccountWithBalance(donor);71 const owner = await helper.eth.createAccountWithBalance(donor);
71 72
72 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');73 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
73 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);74 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
7475
75 const admin1 = helper.eth.createAccount();76 const admin1 = helper.eth.createAccount();
76 const admin2 = await privateKey('admin');77 const admin2 = await privateKey('admin');
77 const admin2Cross = helper.ethCrossAccount.fromKeyringPair(admin2);78 const admin2Cross = helper.ethCrossAccount.fromKeyringPair(admin2);
79
80 // Soft-deprecated
78 await collectionEvm.methods.addCollectionAdmin(admin1).send();81 await collectionEvm.methods.addCollectionAdmin(admin1).send();
79 await collectionEvm.methods.addCollectionAdminCross(admin2Cross).send();82 await collectionEvm.methods.addCollectionAdminCross(admin2Cross).send();
8083
86 expect(adminListRpc).to.be.like(adminListEth);89 expect(adminListRpc).to.be.like(adminListEth);
87 });90 });
8891
92 // Soft-deprecated
89 itEth('Verify owner or admin', async ({helper}) => {93 itEth('Verify owner or admin', async ({helper}) => {
90 const owner = await helper.eth.createAccountWithBalance(donor);94 const owner = await helper.eth.createAccountWithBalance(donor);
91 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');95 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
9296
93 const newAdmin = helper.eth.createAccount();97 const newAdmin = helper.eth.createAccount();
94 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);98 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
95 99
96 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;100 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;
97 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();101 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();
98 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;102 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;
99 });103 });
100 104
105 itEth('Verify owner or admin cross', async ({helper, privateKey}) => {
106 const owner = await helper.eth.createAccountWithBalance(donor);
107 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
108
109 const newAdmin = await privateKey('admin');
110 const newAdminCross = helper.ethCrossAccount.fromKeyringPair(newAdmin);
111 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
112
113 expect(await collectionEvm.methods.isOwnerOrAdminCross(newAdminCross).call()).to.be.false;
114 await collectionEvm.methods.addCollectionAdminCross(newAdminCross).send();
115 expect(await collectionEvm.methods.isOwnerOrAdminCross(newAdminCross).call()).to.be.true;
116 });
117
118 // Soft-deprecated
101 itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {119 itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {
102 const owner = await helper.eth.createAccountWithBalance(donor);120 const owner = await helper.eth.createAccountWithBalance(donor);
103 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');121 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
104122
105 const admin = await helper.eth.createAccountWithBalance(donor);123 const admin = await helper.eth.createAccountWithBalance(donor);
106 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);124 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
107 await collectionEvm.methods.addCollectionAdmin(admin).send();125 await collectionEvm.methods.addCollectionAdmin(admin).send();
108126
109 const user = helper.eth.createAccount();127 const user = helper.eth.createAccount();
116 .to.be.eq(admin.toLocaleLowerCase());134 .to.be.eq(admin.toLocaleLowerCase());
117 });135 });
118136
137 // Soft-deprecated
119 itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {138 itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {
120 const owner = await helper.eth.createAccountWithBalance(donor);139 const owner = await helper.eth.createAccountWithBalance(donor);
121 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');140 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
122141
123 const notAdmin = await helper.eth.createAccountWithBalance(donor);142 const notAdmin = await helper.eth.createAccountWithBalance(donor);
124 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);143 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
125144
126 const user = helper.eth.createAccount();145 const user = helper.eth.createAccount();
127 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))146 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))
135 const owner = await helper.eth.createAccountWithBalance(donor);154 const owner = await helper.eth.createAccountWithBalance(donor);
136 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');155 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
137156
138 const admin = await helper.eth.createAccountWithBalance(donor);157 const [admin] = await helper.arrange.createAccounts([10n], donor);
158 const adminCross = helper.ethCrossAccount.fromKeyringPair(admin);
139 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);159 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
140 await collectionEvm.methods.addCollectionAdmin(admin).send();160 await collectionEvm.methods.addCollectionAdminCross(adminCross).send();
141161
142 const [notAdmin] = await helper.arrange.createAccounts([10n], donor);162 const [notAdmin] = await helper.arrange.createAccounts([10n], donor);
143 const notAdminCross = helper.ethCrossAccount.fromKeyringPair(notAdmin);163 const notAdminCross = helper.ethCrossAccount.fromKeyringPair(notAdmin);
144 await expect(collectionEvm.methods.addCollectionAdminCross(notAdminCross).call({from: admin}))164 await expect(collectionEvm.methods.addCollectionAdminCross(notAdminCross).call({from: adminCross.eth}))
145 .to.be.rejectedWith('NoPermission');165 .to.be.rejectedWith('NoPermission');
146166
147 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);167 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
148 expect(adminList.length).to.be.eq(1);168 expect(adminList.length).to.be.eq(1);
169
170 const admin0Cross = helper.ethCrossAccount.fromKeyringPair(adminList[0]);
149 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())171 expect(admin0Cross.eth.toLocaleLowerCase())
150 .to.be.eq(admin.toLocaleLowerCase());172 .to.be.eq(adminCross.eth.toLocaleLowerCase());
151 });173 });
152174
153 itEth('(!negative tests!) Add [cross] admin by USER is not allowed', async ({helper}) => {175 itEth('(!negative tests!) Add [cross] admin by USER is not allowed', async ({helper}) => {
175 });197 });
176 });198 });
177199
200 // Soft-deprecated
178 itEth('Remove admin by owner', async ({helper}) => {201 itEth('Remove admin by owner', async ({helper}) => {
179 const owner = await helper.eth.createAccountWithBalance(donor);202 const owner = await helper.eth.createAccountWithBalance(donor);
180 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');203 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
181204
182 const newAdmin = helper.eth.createAccount();205 const newAdmin = helper.eth.createAccount();
183 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);206 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
184 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();207 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();
185208
186 {209 {
214 expect(adminList.length).to.be.eq(0);237 expect(adminList.length).to.be.eq(0);
215 });238 });
216239
240 // Soft-deprecated
217 itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {241 itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {
218 const owner = await helper.eth.createAccountWithBalance(donor);242 const owner = await helper.eth.createAccountWithBalance(donor);
219 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');243 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
220244
221 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);245 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
222246
223 const admin0 = await helper.eth.createAccountWithBalance(donor);247 const admin0 = await helper.eth.createAccountWithBalance(donor);
224 await collectionEvm.methods.addCollectionAdmin(admin0).send();248 await collectionEvm.methods.addCollectionAdmin(admin0).send();
236 }260 }
237 });261 });
238262
263 // Soft-deprecated
239 itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {264 itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {
240 const owner = await helper.eth.createAccountWithBalance(donor);265 const owner = await helper.eth.createAccountWithBalance(donor);
241 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');266 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
242267
243 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);268 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
244269
245 const admin = await helper.eth.createAccountWithBalance(donor);270 const admin = await helper.eth.createAccountWithBalance(donor);
246 await collectionEvm.methods.addCollectionAdmin(admin).send();271 await collectionEvm.methods.addCollectionAdmin(admin).send();
260 const owner = await helper.eth.createAccountWithBalance(donor);285 const owner = await helper.eth.createAccountWithBalance(donor);
261 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');286 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
262287
263 const [adminSub] = await helper.arrange.createAccounts([10n], donor);288 const [admin1] = await helper.arrange.createAccounts([10n], donor);
264 const adminSubCross = helper.ethCrossAccount.fromKeyringPair(adminSub);289 const admin1Cross = helper.ethCrossAccount.fromKeyringPair(admin1);
265 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);290 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
266 await collectionEvm.methods.addCollectionAdminCross(adminSubCross).send();291 await collectionEvm.methods.addCollectionAdminCross(admin1Cross).send();
292
267 const adminEth = await helper.eth.createAccountWithBalance(donor);293 const [admin2] = await helper.arrange.createAccounts([10n], donor);
294 const admin2Cross = helper.ethCrossAccount.fromKeyringPair(admin2);
268 await collectionEvm.methods.addCollectionAdmin(adminEth).send();295 await collectionEvm.methods.addCollectionAdminCross(admin2Cross).send();
269296
270 await expect(collectionEvm.methods.removeCollectionAdminCross(adminSubCross).call({from: adminEth}))297 await expect(collectionEvm.methods.removeCollectionAdminCross(admin1Cross).call({from: admin2Cross.eth}))
271 .to.be.rejectedWith('NoPermission');298 .to.be.rejectedWith('NoPermission');
272299
273 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);300 const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
274 expect(adminList.length).to.be.eq(2);301 expect(adminList.length).to.be.eq(2);
275 expect(adminList.toString().toLocaleLowerCase())302 expect(adminList.toString().toLocaleLowerCase())
276 .to.be.deep.contains(adminSub.address.toLocaleLowerCase())303 .to.be.deep.contains(admin1.address.toLocaleLowerCase())
277 .to.be.deep.contains(adminEth.toLocaleLowerCase());304 .to.be.deep.contains(admin2.address.toLocaleLowerCase());
278 });305 });
279306
280 itEth('(!negative tests!) Remove [cross] admin by USER is not allowed', async ({helper}) => {307 itEth('(!negative tests!) Remove [cross] admin by USER is not allowed', async ({helper}) => {
297 });324 });
298});325});
299326
327// Soft-deprecated
300describe('Change owner tests', () => {328describe('Change owner tests', () => {
301 let donor: IKeyringPair;329 let donor: IKeyringPair;
302330
310 const owner = await helper.eth.createAccountWithBalance(donor);338 const owner = await helper.eth.createAccountWithBalance(donor);
311 const newOwner = await helper.eth.createAccountWithBalance(donor);339 const newOwner = await helper.eth.createAccountWithBalance(donor);
312 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');340 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
313 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);341 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
314342
315 await collectionEvm.methods.changeCollectionOwner(newOwner).send();343 await collectionEvm.methods.changeCollectionOwner(newOwner).send();
316344
322 const owner = await helper.eth.createAccountWithBalance(donor);350 const owner = await helper.eth.createAccountWithBalance(donor);
323 const newOwner = await helper.eth.createAccountWithBalance(donor);351 const newOwner = await helper.eth.createAccountWithBalance(donor);
324 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');352 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
325 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);353 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
326 const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.changeCollectionOwner(newOwner).send());354 const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.changeCollectionOwner(newOwner).send());
327 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));355 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
328 expect(cost > 0);356 expect(cost > 0);
332 const owner = await helper.eth.createAccountWithBalance(donor);360 const owner = await helper.eth.createAccountWithBalance(donor);
333 const newOwner = await helper.eth.createAccountWithBalance(donor);361 const newOwner = await helper.eth.createAccountWithBalance(donor);
334 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');362 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
335 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);363 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
336364
337 await expect(collectionEvm.methods.changeCollectionOwner(newOwner).send({from: newOwner})).to.be.rejected;365 await expect(collectionEvm.methods.changeCollectionOwner(newOwner).send({from: newOwner})).to.be.rejected;
338 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;366 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;
355 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');383 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
356 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);384 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
357385
358 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;
359 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;386 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;
360387
361 await collectionEvm.methods.setOwnerCross(newOwnerCross).send();388 await collectionEvm.methods.changeCollectionOwnerCross(newOwnerCross).send();
362389
363 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;
364 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.true;390 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.true;
365 });391 });
366392
383 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');409 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
384 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);410 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
385411
386 await expect(collectionEvm.methods.setOwnerCross(newOwnerCross).send({from: otherReceiver})).to.be.rejected;412 await expect(collectionEvm.methods.changeCollectionOwnerCross(newOwnerCross).send({from: otherReceiver})).to.be.rejected;
387 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;413 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;
388 });414 });
389});415});
deletedtests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
27 before(async function() {27 before(async function() {
28 await usingEthPlaygrounds(async (_helper, privateKey) => {28 await usingEthPlaygrounds(async (_helper, privateKey) => {
29 donor = await privateKey({filename: __filename});29 donor = await privateKey({filename: __filename});
30 [alice] = await _helper.arrange.createAccounts([10n], donor);30 [alice] = await _helper.arrange.createAccounts([20n], donor);
31 });31 });
32 });32 });
3333
39 const address = helper.ethAddress.fromCollectionId(collection.collectionId);39 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
40 const contract = helper.ethNativeContract.collection(address, 'nft', caller);40 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
4141
42 await contract.methods.setCollectionProperty('testKey', Buffer.from('testValue')).send({from: caller});42 await contract.methods.setCollectionProperties([{key: 'testKey', value: Buffer.from('testValue')}]).send({from: caller});
4343
44 const raw = (await collection.getData())?.raw;44 const raw = (await collection.getData())?.raw;
4545
55 const address = helper.ethAddress.fromCollectionId(collection.collectionId);55 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
56 const contract = helper.ethNativeContract.collection(address, 'nft', caller);56 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
5757
58 await contract.methods.deleteCollectionProperty('testKey').send({from: caller});58 await contract.methods.deleteCollectionProperties(['testKey']).send({from: caller});
5959
60 const raw = (await collection.getData())?.raw;60 const raw = (await collection.getData())?.raw;
6161
73 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));73 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));
74 });74 });
75
76 // Soft-deprecated
77 itEth('Collection property can be set', async({helper}) => {
78 const caller = await helper.eth.createAccountWithBalance(donor);
79 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});
80 await collection.addAdmin(alice, {Ethereum: caller});
81
82 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
83 const contract = helper.ethNativeContract.collection(address, 'nft', caller, true);
84
85 await contract.methods.setCollectionProperty('testKey', Buffer.from('testValue')).send();
86
87 const raw = (await collection.getData())?.raw;
88
89 expect(raw.properties[0].value).to.equal('testValue');
90 });
91
92 // Soft-deprecated
93 itEth('Collection property can be deleted', async({helper}) => {
94 const caller = await helper.eth.createAccountWithBalance(donor);
95 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});
96
97 await collection.addAdmin(alice, {Ethereum: caller});
98
99 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
100 const contract = helper.ethNativeContract.collection(address, 'nft', caller, true);
101
102 await contract.methods.deleteCollectionProperty('testKey').send({from: caller});
103
104 const raw = (await collection.getData())?.raw;
105
106 expect(raw.properties.length).to.equal(0);
107 });
75});108});
76109
77describe('Supports ERC721Metadata', () => {110describe('Supports ERC721Metadata', () => {
95 const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection';128 const creatorMethod = mode === 'rft' ? 'createRFTCollection' : 'createNFTCollection';
96129
97 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');130 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');
131 const bruhCross = helper.ethCrossAccount.fromAddress(bruh);
98132
99 const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);133 const contract = helper.ethNativeContract.collectionById(collectionId, mode, caller);
100 await contract.methods.addCollectionAdmin(bruh).send(); // to check that admin will work too134 await contract.methods.addCollectionAdminCross(bruhCross).send(); // to check that admin will work too
101135
102 const collection1 = helper.nft.getCollectionObject(collectionId);136 const collection1 = helper.nft.getCollectionObject(collectionId);
103 const data1 = await collection1.getData();137 const data1 = await collection1.getData();
133167
134 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);168 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);
135169
136 await contract.methods.setProperty(tokenId1, 'URISuffix', Buffer.from(SUFFIX)).send();170 await contract.methods.setProperties(tokenId1, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();
137 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);171 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);
138172
139 await contract.methods.setProperty(tokenId1, 'URI', Buffer.from(URI)).send();173 await contract.methods.setProperties(tokenId1, [{key: 'URI', value: Buffer.from(URI)}]).send();
140 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);174 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);
141175
142 await contract.methods.deleteProperties(tokenId1, ['URI']).send();176 await contract.methods.deleteProperties(tokenId1, ['URI']).send();
150 await contract.methods.deleteProperties(tokenId2, ['URI']).send();184 await contract.methods.deleteProperties(tokenId2, ['URI']).send();
151 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);185 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);
152186
153 await contract.methods.setProperty(tokenId2, 'URISuffix', Buffer.from(SUFFIX)).send();187 await contract.methods.setProperties(tokenId2, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();
154 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);188 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);
155 };189 };
156190
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
81 // expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);81 // expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);
82 // });82 // });
8383
84 itEth('Remove sponsor', async ({helper}) => {84 // Soft-deprecated
85 itEth('[eth] Remove sponsor', async ({helper}) => {
85 const owner = await helper.eth.createAccountWithBalance(donor);86 const owner = await helper.eth.createAccountWithBalance(donor);
86 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);87 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
8788
88 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});89 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});
89 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);90 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
90 const sponsor = await helper.eth.createAccountWithBalance(donor);91 const sponsor = await helper.eth.createAccountWithBalance(donor);
91 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);92 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, true);
9293
93 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;94 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
94 result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});95 result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
103 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');104 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
104 });105 });
105106
106 itEth('Sponsoring collection from evm address via access list', async ({helper}) => {107 itEth('[cross] Remove sponsor', async ({helper}) => {
107 const owner = await helper.eth.createAccountWithBalance(donor);108 const owner = await helper.eth.createAccountWithBalance(donor);
109 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
108110
111 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});
112 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
113 const sponsor = await helper.eth.createAccountWithBalance(donor);
114 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
115 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
116
117 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
118 result = await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send({from: owner});
119 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
120
121 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
122 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
123
124 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
125
126 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
127 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
128 });
129
130 // Soft-deprecated
131 itEth('[eth] Sponsoring collection from evm address via access list', async ({helper}) => {
132 const owner = await helper.eth.createAccountWithBalance(donor);
133
109 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');134 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');
110135
111 const collection = helper.nft.getCollectionObject(collectionId);136 const collection = helper.nft.getCollectionObject(collectionId);
112 const sponsor = await helper.eth.createAccountWithBalance(donor);137 const sponsor = await helper.eth.createAccountWithBalance(donor);
113 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);138 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
114139
115 await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});140 await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
116 let collectionData = (await collection.getData())!;141 let collectionData = (await collection.getData())!;
165 }190 }
166 });191 });
167192
193 itEth('[cross] Sponsoring collection from evm address via access list', async ({helper}) => {
194 const owner = await helper.eth.createAccountWithBalance(donor);
195
196 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');
197
198 const collection = helper.nft.getCollectionObject(collectionId);
199 const sponsor = await helper.eth.createAccountWithBalance(donor);
200 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
201 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
202
203 await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send({from: owner});
204 let collectionData = (await collection.getData())!;
205 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
206 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
207
208 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
209 collectionData = (await collection.getData())!;
210 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
211
212 const user = helper.eth.createAccount();
213 const userCross = helper.ethCrossAccount.fromAddress(user);
214 const nextTokenId = await collectionEvm.methods.nextTokenId().call();
215 expect(nextTokenId).to.be.equal('1');
216
217 const oldPermissions = (await collection.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
218 expect(oldPermissions.mintMode).to.be.false;
219 expect(oldPermissions.access).to.be.equal('Normal');
220
221 await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});
222 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
223 await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});
224
225 const newPermissions = (await collection.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
226 expect(newPermissions.mintMode).to.be.true;
227 expect(newPermissions.access).to.be.equal('AllowList');
228
229 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
230 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
231
232 {
233 const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});
234 const events = helper.eth.normalizeEvents(result.events);
235
236 expect(events).to.be.deep.equal([
237 {
238 address: collectionAddress,
239 event: 'Transfer',
240 args: {
241 from: '0x0000000000000000000000000000000000000000',
242 to: user,
243 tokenId: '1',
244 },
245 },
246 ]);
247
248 const ownerBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(owner));
249 const sponsorBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(sponsor));
250
251 expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
252 expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);
253 expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;
254 }
255 });
256
168 // TODO: Temprorary off. Need refactor257 // TODO: Temprorary off. Need refactor
169 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {258 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {
221 // }310 // }
222 // });311 // });
223312
224 itEth('Check that transaction via EVM spend money from sponsor address', async ({helper}) => {313 // Soft-deprecated
314 itEth('[eth] Check that transaction via EVM spend money from sponsor address', async ({helper}) => {
225 const owner = await helper.eth.createAccountWithBalance(donor);315 const owner = await helper.eth.createAccountWithBalance(donor);
226316
227 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');317 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');
228 const collection = helper.nft.getCollectionObject(collectionId);318 const collection = helper.nft.getCollectionObject(collectionId);
229 const sponsor = await helper.eth.createAccountWithBalance(donor);319 const sponsor = await helper.eth.createAccountWithBalance(donor);
230 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);320 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
231321
232 await collectionEvm.methods.setCollectionSponsor(sponsor).send();322 await collectionEvm.methods.setCollectionSponsor(sponsor).send();
233 let collectionData = (await collection.getData())!;323 let collectionData = (await collection.getData())!;
234 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));324 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
235 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');325 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
236326
327 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);
328 await sponsorCollection.methods.confirmCollectionSponsorship().send();
329 collectionData = (await collection.getData())!;
330 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
331
332 const user = helper.eth.createAccount();
333 await collectionEvm.methods.addCollectionAdmin(user).send();
334
335 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
336 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
337
338 const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user, true);
339
340 const result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI').send();
341 const tokenId = result.events.Transfer.returnValues.tokenId;
342
343 const events = helper.eth.normalizeEvents(result.events);
344 const address = helper.ethAddress.fromCollectionId(collectionId);
345
346 expect(events).to.be.deep.equal([
347 {
348 address,
349 event: 'Transfer',
350 args: {
351 from: '0x0000000000000000000000000000000000000000',
352 to: user,
353 tokenId: '1',
354 },
355 },
356 ]);
357 expect(await userCollectionEvm.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
358
359 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
360 expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);
361 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
362 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
363 });
364
365 itEth('[cross] Check that transaction via EVM spend money from sponsor address', async ({helper}) => {
366 const owner = await helper.eth.createAccountWithBalance(donor);
367
368 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');
369 const collection = helper.nft.getCollectionObject(collectionId);
370 const sponsor = await helper.eth.createAccountWithBalance(donor);
371 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
372 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
373
374 await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send();
375 let collectionData = (await collection.getData())!;
376 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
377 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
378
237 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);379 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);
238 await sponsorCollection.methods.confirmCollectionSponsorship().send();380 await sponsorCollection.methods.confirmCollectionSponsorship().send();
239 collectionData = (await collection.getData())!;381 collectionData = (await collection.getData())!;
240 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));382 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
241383
242 const user = helper.eth.createAccount();384 const user = helper.eth.createAccount();
243 await collectionEvm.methods.addCollectionAdmin(user).send();385 const userCross = helper.ethCrossAccount.fromAddress(user);
386 await collectionEvm.methods.addCollectionAdminCross(userCross).send();
244387
245 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));388 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
246 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));389 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
31 });31 });
32 });32 });
33 33
34 // Soft-deprecated
34 itEth('Set sponsorship', async ({helper}) => {35 itEth('[eth] Set sponsorship', async ({helper}) => {
35 const owner = await helper.eth.createAccountWithBalance(donor);36 const owner = await helper.eth.createAccountWithBalance(donor);
36 const sponsor = await helper.eth.createAccountWithBalance(donor);37 const sponsor = await helper.eth.createAccountWithBalance(donor);
37 const ss58Format = helper.chain.getChainProperties().ss58Format;38 const ss58Format = helper.chain.getChainProperties().ss58Format;
38 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, 'absolutely anything', 'ENVY');39 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, 'absolutely anything', 'ENVY');
3940
40 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);41 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);
41 await collection.methods.setCollectionSponsor(sponsor).send();42 await collection.methods.setCollectionSponsor(sponsor).send();
4243
43 let data = (await helper.rft.getData(collectionId))!;44 let data = (await helper.rft.getData(collectionId))!;
44 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));45 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
4546
46 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');47 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
4748
48 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);49 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);
49 await sponsorCollection.methods.confirmCollectionSponsorship().send();50 await sponsorCollection.methods.confirmCollectionSponsorship().send();
5051
51 data = (await helper.rft.getData(collectionId))!;52 data = (await helper.rft.getData(collectionId))!;
52 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));53 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
53 });54 });
55
56 itEth('[cross] Set sponsorship', async ({helper}) => {
57 const owner = await helper.eth.createAccountWithBalance(donor);
58 const sponsor = await helper.eth.createAccountWithBalance(donor);
59 const ss58Format = helper.chain.getChainProperties().ss58Format;
60 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, 'absolutely anything', 'ENVY');
61
62 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
63 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
64 await collection.methods.setCollectionSponsorCross(sponsorCross).send();
65
66 let data = (await helper.rft.getData(collectionId))!;
67 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
68
69 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
70
71 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);
72 await sponsorCollection.methods.confirmCollectionSponsorship().send();
73
74 data = (await helper.rft.getData(collectionId))!;
75 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
76 });
5477
55 itEth('Set limits', async ({helper}) => {78 itEth('Set limits', async ({helper}) => {
56 const owner = await helper.eth.createAccountWithBalance(donor);79 const owner = await helper.eth.createAccountWithBalance(donor);
183 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');206 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
184 });207 });
185208
209 // Soft-deprecated
186 itEth('(!negative test!) Check owner', async ({helper}) => {210 itEth('(!negative test!) [eth] Check owner', async ({helper}) => {
187 const owner = await helper.eth.createAccountWithBalance(donor);211 const owner = await helper.eth.createAccountWithBalance(donor);
188 const peasant = helper.eth.createAccount();212 const peasant = helper.eth.createAccount();
189 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');213 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');
190 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant);214 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant, true);
191 const EXPECTED_ERROR = 'NoPermission';215 const EXPECTED_ERROR = 'NoPermission';
192 {216 {
193 const sponsor = await helper.eth.createAccountWithBalance(donor);217 const sponsor = await helper.eth.createAccountWithBalance(donor);
194 await expect(peasantCollection.methods218 await expect(peasantCollection.methods
195 .setCollectionSponsor(sponsor)219 .setCollectionSponsor(sponsor)
196 .call()).to.be.rejectedWith(EXPECTED_ERROR);220 .call()).to.be.rejectedWith(EXPECTED_ERROR);
197 221
198 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor);222 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor, true);
199 await expect(sponsorCollection.methods223 await expect(sponsorCollection.methods
200 .confirmCollectionSponsorship()224 .confirmCollectionSponsorship()
201 .call()).to.be.rejectedWith('caller is not set as sponsor');225 .call()).to.be.rejectedWith('caller is not set as sponsor');
207 }231 }
208 });232 });
233
234 itEth('(!negative test!) [cross] Check owner', async ({helper}) => {
235 const owner = await helper.eth.createAccountWithBalance(donor);
236 const peasant = helper.eth.createAccount();
237 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');
238 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant);
239 const EXPECTED_ERROR = 'NoPermission';
240 {
241 const sponsor = await helper.eth.createAccountWithBalance(donor);
242 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
243 await expect(peasantCollection.methods
244 .setCollectionSponsorCross(sponsorCross)
245 .call()).to.be.rejectedWith(EXPECTED_ERROR);
246
247 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor);
248 await expect(sponsorCollection.methods
249 .confirmCollectionSponsorship()
250 .call()).to.be.rejectedWith('caller is not set as sponsor');
251 }
252 {
253 await expect(peasantCollection.methods
254 .setCollectionLimit('account_token_ownership_limit', '1000')
255 .call()).to.be.rejectedWith(EXPECTED_ERROR);
256 }
257 });
209258
210 itEth('(!negative test!) Set limits', async ({helper}) => {259 itEth('(!negative test!) Set limits', async ({helper}) => {
211 const owner = await helper.eth.createAccountWithBalance(donor);260 const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
70 ]);70 ]);
71 });71 });
7272
73 // Soft-deprecated
73 itEth('Set sponsorship', async ({helper}) => {74 itEth('[eth] Set sponsorship', async ({helper}) => {
74 const owner = await helper.eth.createAccountWithBalance(donor);75 const owner = await helper.eth.createAccountWithBalance(donor);
75 const sponsor = await helper.eth.createAccountWithBalance(donor);76 const sponsor = await helper.eth.createAccountWithBalance(donor);
76 const ss58Format = helper.chain.getChainProperties().ss58Format;77 const ss58Format = helper.chain.getChainProperties().ss58Format;
77 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');78 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');
7879
79 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);80 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
80 await collection.methods.setCollectionSponsor(sponsor).send();81 await collection.methods.setCollectionSponsor(sponsor).send();
8182
82 let data = (await helper.nft.getData(collectionId))!;83 let data = (await helper.nft.getData(collectionId))!;
83 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));84 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
8485
85 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');86 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
8687
87 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);88 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);
88 await sponsorCollection.methods.confirmCollectionSponsorship().send();89 await sponsorCollection.methods.confirmCollectionSponsorship().send();
8990
90 data = (await helper.nft.getData(collectionId))!;91 data = (await helper.nft.getData(collectionId))!;
91 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));92 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
92 });93 });
94
95 itEth('[cross] Set sponsorship', async ({helper}) => {
96 const owner = await helper.eth.createAccountWithBalance(donor);
97 const sponsor = await helper.eth.createAccountWithBalance(donor);
98 const ss58Format = helper.chain.getChainProperties().ss58Format;
99 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');
100
101 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
102 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
103 await collection.methods.setCollectionSponsorCross(sponsorCross).send();
104
105 let data = (await helper.nft.getData(collectionId))!;
106 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
107
108 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
109
110 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);
111 await sponsorCollection.methods.confirmCollectionSponsorship().send();
112
113 data = (await helper.nft.getData(collectionId))!;
114 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
115 });
93116
94 itEth('Set limits', async ({helper}) => {117 itEth('Set limits', async ({helper}) => {
95 const owner = await helper.eth.createAccountWithBalance(donor);118 const owner = await helper.eth.createAccountWithBalance(donor);
196 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');219 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
197 });220 });
198221
222 // Soft-deprecated
199 itEth('(!negative test!) Check owner', async ({helper}) => {223 itEth('(!negative test!) [eth] Check owner', async ({helper}) => {
200 const owner = await helper.eth.createAccountWithBalance(donor);224 const owner = await helper.eth.createAccountWithBalance(donor);
201 const malfeasant = helper.eth.createAccount();225 const malfeasant = helper.eth.createAccount();
202 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');226 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');
203 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);227 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);
204 const EXPECTED_ERROR = 'NoPermission';228 const EXPECTED_ERROR = 'NoPermission';
205 {229 {
206 const sponsor = await helper.eth.createAccountWithBalance(donor);230 const sponsor = await helper.eth.createAccountWithBalance(donor);
207 await expect(malfeasantCollection.methods231 await expect(malfeasantCollection.methods
208 .setCollectionSponsor(sponsor)232 .setCollectionSponsor(sponsor)
209 .call()).to.be.rejectedWith(EXPECTED_ERROR);233 .call()).to.be.rejectedWith(EXPECTED_ERROR);
210234
211 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);235 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);
212 await expect(sponsorCollection.methods236 await expect(sponsorCollection.methods
213 .confirmCollectionSponsorship()237 .confirmCollectionSponsorship()
214 .call()).to.be.rejectedWith('caller is not set as sponsor');238 .call()).to.be.rejectedWith('caller is not set as sponsor');
220 }244 }
221 });245 });
246
247 itEth('(!negative test!) [cross] Check owner', async ({helper}) => {
248 const owner = await helper.eth.createAccountWithBalance(donor);
249 const malfeasant = helper.eth.createAccount();
250 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');
251 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);
252 const EXPECTED_ERROR = 'NoPermission';
253 {
254 const sponsor = await helper.eth.createAccountWithBalance(donor);
255 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
256 await expect(malfeasantCollection.methods
257 .setCollectionSponsorCross(sponsorCross)
258 .call()).to.be.rejectedWith(EXPECTED_ERROR);
259
260 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);
261 await expect(sponsorCollection.methods
262 .confirmCollectionSponsorship()
263 .call()).to.be.rejectedWith('caller is not set as sponsor');
264 }
265 {
266 await expect(malfeasantCollection.methods
267 .setCollectionLimit('account_token_ownership_limit', '1000')
268 .call()).to.be.rejectedWith(EXPECTED_ERROR);
269 }
270 });
222271
223 itEth('(!negative test!) Set limits', async ({helper}) => {272 itEth('(!negative test!) Set limits', async ({helper}) => {
224 const owner = await helper.eth.createAccountWithBalance(donor);273 const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
105 .call()).to.be.true;105 .call()).to.be.true;
106 });106 });
107 107
108 // Soft-deprecated
108 itEth('Set sponsorship', async ({helper}) => {109 itEth('[eth] Set sponsorship', async ({helper}) => {
109 const owner = await helper.eth.createAccountWithBalance(donor);110 const owner = await helper.eth.createAccountWithBalance(donor);
110 const sponsor = await helper.eth.createAccountWithBalance(donor);111 const sponsor = await helper.eth.createAccountWithBalance(donor);
111 const ss58Format = helper.chain.getChainProperties().ss58Format;112 const ss58Format = helper.chain.getChainProperties().ss58Format;
112 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');113 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');
113114
114 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);115 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);
115 await collection.methods.setCollectionSponsor(sponsor).send();116 await collection.methods.setCollectionSponsor(sponsor).send();
116117
117 let data = (await helper.rft.getData(collectionId))!;118 let data = (await helper.rft.getData(collectionId))!;
118 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));119 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
119120
120 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');121 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
121122
122 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);123 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);
123 await sponsorCollection.methods.confirmCollectionSponsorship().send();124 await sponsorCollection.methods.confirmCollectionSponsorship().send();
124125
125 data = (await helper.rft.getData(collectionId))!;126 data = (await helper.rft.getData(collectionId))!;
126 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));127 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
127 });128 });
129
130 itEth('[cross] Set sponsorship', async ({helper}) => {
131 const owner = await helper.eth.createAccountWithBalance(donor);
132 const sponsor = await helper.eth.createAccountWithBalance(donor);
133 const ss58Format = helper.chain.getChainProperties().ss58Format;
134 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');
135
136 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
137 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
138 await collection.methods.setCollectionSponsorCross(sponsorCross).send();
139
140 let data = (await helper.rft.getData(collectionId))!;
141 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
142
143 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
144
145 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);
146 await sponsorCollection.methods.confirmCollectionSponsorship().send();
147
148 data = (await helper.rft.getData(collectionId))!;
149 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
150 });
128151
129 itEth('Set limits', async ({helper}) => {152 itEth('Set limits', async ({helper}) => {
130 const owner = await helper.eth.createAccountWithBalance(donor);153 const owner = await helper.eth.createAccountWithBalance(donor);
231 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');254 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
232 });255 });
233256
257 // Soft-deprecated
234 itEth('(!negative test!) Check owner', async ({helper}) => {258 itEth('(!negative test!) [eth] Check owner', async ({helper}) => {
235 const owner = await helper.eth.createAccountWithBalance(donor);259 const owner = await helper.eth.createAccountWithBalance(donor);
236 const peasant = helper.eth.createAccount();260 const peasant = helper.eth.createAccount();
237 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');261 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');
238 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);262 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant, true);
239 const EXPECTED_ERROR = 'NoPermission';263 const EXPECTED_ERROR = 'NoPermission';
240 {264 {
241 const sponsor = await helper.eth.createAccountWithBalance(donor);265 const sponsor = await helper.eth.createAccountWithBalance(donor);
242 await expect(peasantCollection.methods266 await expect(peasantCollection.methods
243 .setCollectionSponsor(sponsor)267 .setCollectionSponsor(sponsor)
244 .call()).to.be.rejectedWith(EXPECTED_ERROR);268 .call()).to.be.rejectedWith(EXPECTED_ERROR);
245 269
246 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);270 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);
247 await expect(sponsorCollection.methods271 await expect(sponsorCollection.methods
248 .confirmCollectionSponsorship()272 .confirmCollectionSponsorship()
249 .call()).to.be.rejectedWith('caller is not set as sponsor');273 .call()).to.be.rejectedWith('caller is not set as sponsor');
255 }279 }
256 });280 });
281
282 itEth('(!negative test!) [cross] Check owner', async ({helper}) => {
283 const owner = await helper.eth.createAccountWithBalance(donor);
284 const peasant = helper.eth.createAccount();
285 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');
286 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);
287 const EXPECTED_ERROR = 'NoPermission';
288 {
289 const sponsor = await helper.eth.createAccountWithBalance(donor);
290 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
291 await expect(peasantCollection.methods
292 .setCollectionSponsorCross(sponsorCross)
293 .call()).to.be.rejectedWith(EXPECTED_ERROR);
294
295 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);
296 await expect(sponsorCollection.methods
297 .confirmCollectionSponsorship()
298 .call()).to.be.rejectedWith('caller is not set as sponsor');
299 }
300 {
301 await expect(peasantCollection.methods
302 .setCollectionLimit('account_token_ownership_limit', '1000')
303 .call()).to.be.rejectedWith(EXPECTED_ERROR);
304 }
305 });
257306
258 itEth('(!negative test!) Set limits', async ({helper}) => {307 itEth('(!negative test!) Set limits', async ({helper}) => {
259 const owner = await helper.eth.createAccountWithBalance(donor);308 const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth
3import {CollectionHelpers} from "../api/CollectionHelpers.sol";3import {CollectionHelpers} from "../api/CollectionHelpers.sol";
4import {ContractHelpers} from "../api/ContractHelpers.sol";4import {ContractHelpers} from "../api/ContractHelpers.sol";
5import {UniqueRefungibleToken} from "../api/UniqueRefungibleToken.sol";5import {UniqueRefungibleToken} from "../api/UniqueRefungibleToken.sol";
6import {UniqueRefungible} from "../api/UniqueRefungible.sol";6import {UniqueRefungible, EthCrossAccount} from "../api/UniqueRefungible.sol";
7import {UniqueNFT} from "../api/UniqueNFT.sol";7import {UniqueNFT} from "../api/UniqueNFT.sol";
88
9/// @dev Fractionalization contract. It stores mappings between NFT and RFT tokens,9/// @dev Fractionalization contract. It stores mappings between NFT and RFT tokens,
63 "Wrong collection type. Collection is not refungible."63 "Wrong collection type. Collection is not refungible."
64 );64 );
65 require(65 require(
66 refungibleContract.isOwnerOrAdmin(address(this)),66 refungibleContract.isOwnerOrAdminCross(EthCrossAccount({eth: address(this), sub: uint256(0)})),
67 "Fractionalizer contract should be an admin of the collection"67 "Fractionalizer contract should be an admin of the collection"
68 );68 );
69 rftCollection = _collection;69 rftCollection = _collection;
modifiedtests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth
95 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');95 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');
96 const rftContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);96 const rftContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
9797
98 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);
98 await rftContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});99 await rftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});
99 const result = await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});100 const result = await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});
100 expect(result.events).to.be.like({101 expect(result.events).to.be.like({
101 RFTCollectionSet: {102 RFTCollectionSet: {
235 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);236 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);
236237
237 const fractionalizer = await deployContract(helper, owner);238 const fractionalizer = await deployContract(helper, owner);
239 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);
238 await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});240 await refungibleContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});
239 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});241 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});
240242
241 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())243 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())
248 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);250 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);
249251
250 const fractionalizer = await deployContract(helper, owner);252 const fractionalizer = await deployContract(helper, owner);
253 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);
251 await nftContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});254 await nftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});
252255
253 await expect(fractionalizer.methods.setRFTCollection(nftCollection.collectionAddress).call())256 await expect(fractionalizer.methods.setRFTCollection(nftCollection.collectionAddress).call())
254 .to.be.rejectedWith(/Wrong collection type. Collection is not refungible.$/g);257 .to.be.rejectedWith(/Wrong collection type. Collection is not refungible.$/g);
370373
371 const fractionalizer = await deployContract(helper, owner);374 const fractionalizer = await deployContract(helper, owner);
372375
376 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);
373 await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send({from: owner});377 await refungibleContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});
374 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});378 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});
375379
376 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});380 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
102 }102 }
103 });103 });
104104
105 // Soft-deprecated
105 itEth('Can perform burn()', async ({helper}) => {106 itEth('Can perform burn()', async ({helper}) => {
106 const owner = await helper.eth.createAccountWithBalance(donor);107 const owner = await helper.eth.createAccountWithBalance(donor);
107 const receiver = await helper.eth.createAccountWithBalance(donor);108 const receiver = await helper.eth.createAccountWithBalance(donor);
108 const collection = await helper.ft.mintCollection(alice);109 const collection = await helper.ft.mintCollection(alice);
109 await collection.addAdmin(alice, {Ethereum: owner});110 await collection.addAdmin(alice, {Ethereum: owner});
110111
111 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);112 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
112 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);113 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
113 await contract.methods.mint(receiver, 100).send();114 await contract.methods.mint(receiver, 100).send();
114115
115 const result = await contract.methods.burnFrom(receiver, 49).send({from: receiver});116 const result = await contract.methods.burnFrom(receiver, 49).send({from: receiver});
deletedtests/src/eth/fungibleAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
102102
103 if (propertyKey && propertyValue) {103 if (propertyKey && propertyValue) {
104 // Set URL or suffix104 // Set URL or suffix
105 await contract.methods.setProperty(tokenId, propertyKey, Buffer.from(propertyValue)).send();105 await contract.methods.setProperties(tokenId, [{key: propertyKey, value: Buffer.from(propertyValue)}]).send();
106 }106 }
107107
108 const event = result.events.Transfer;108 const event = result.events.Transfer;
deletedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
99 });99 });
100 });100 });
101101
102 // Soft-deprecated
102 itEth('Can perform mint()', async ({helper}) => {103 itEth('[eth] Can perform mint()', async ({helper}) => {
103 const owner = await helper.eth.createAccountWithBalance(donor);104 const owner = await helper.eth.createAccountWithBalance(donor);
104 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');105 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');
105 const caller = await helper.eth.createAccountWithBalance(donor);106 const caller = await helper.eth.createAccountWithBalance(donor);
106 const receiver = helper.eth.createAccount();107 const receiver = helper.eth.createAccount();
107108
108 const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);109 const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
109 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);110 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller, true);
110 const contract = await proxyWrap(helper, collectionEvm, donor);111 const contract = await proxyWrap(helper, collectionEvm, donor);
111 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();112 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();
112113
135 }136 }
136 });137 });
138
139 itEth('[cross] Can perform mint()', async ({helper}) => {
140 const owner = await helper.eth.createAccountWithBalance(donor);
141 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'A', 'A', 'A', '');
142 const caller = await helper.eth.createAccountWithBalance(donor);
143 const receiver = helper.eth.createAccount();
144
145 const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
146 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);
147 const contract = await proxyWrap(helper, collectionEvm, donor);
148 const contractAddressCross = helper.ethCrossAccount.fromAddress(contract.options.address);
149 await collectionEvmOwned.methods.addCollectionAdminCross(contractAddressCross).send();
150
151 {
152 const nextTokenId = await contract.methods.nextTokenId().call();
153 const result = await contract.methods.mintWithTokenURI(receiver, nextTokenId, 'Test URI').send({from: caller});
154 const tokenId = result.events.Transfer.returnValues.tokenId;
155 expect(tokenId).to.be.equal('1');
156
157 const events = helper.eth.normalizeEvents(result.events);
158 events[0].address = events[0].address.toLocaleLowerCase();
159
160 expect(events).to.be.deep.equal([
161 {
162 address: collectionAddress.toLocaleLowerCase(),
163 event: 'Transfer',
164 args: {
165 from: '0x0000000000000000000000000000000000000000',
166 to: receiver,
167 tokenId,
168 },
169 },
170 ]);
171
172 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
173 }
174 });
137175
138 //TODO: CORE-302 add eth methods176 //TODO: CORE-302 add eth methods
139 itEth.skip('Can perform mintBulk()', async ({helper}) => {177 itEth.skip('Can perform mintBulk()', async ({helper}) => {
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
231 }231 }
232 });232 });
233233
234 // Soft-deprecated
234 itEth('Can perform burnFrom()', async ({helper}) => {235 itEth('Can perform burnFrom()', async ({helper}) => {
235 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});236 const collection = await helper.rft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
236237
240 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});241 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});
241242
242 const address = helper.ethAddress.fromCollectionId(collection.collectionId);243 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
243 const contract = helper.ethNativeContract.collection(address, 'rft');244 const contract = helper.ethNativeContract.collection(address, 'rft', spender, true);
244245
245 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);246 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);
246 const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);247 const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);
247 await tokenContract.methods.repartition(15).send();248 await tokenContract.methods.repartition(15).send();
248 await tokenContract.methods.approve(spender, 15).send();249 await tokenContract.methods.approve(spender, 15).send();
249250
250 {251 {
251 const result = await contract.methods.burnFrom(owner, token.tokenId).send({from: spender});252 const result = await contract.methods.burnFrom(owner, token.tokenId).send();
252 const event = result.events.Transfer;253 const event = result.events.Transfer;
253 expect(event).to.be.like({254 expect(event).to.be.like({
254 address: helper.ethAddress.fromCollectionId(collection.collectionId),255 address: helper.ethAddress.fromCollectionId(collection.collectionId),
deletedtests/src/eth/reFungibleAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
95 if (propertyKey && propertyValue) {95 if (propertyKey && propertyValue) {
96 // Set URL or suffix96 // Set URL or suffix
97
97 await contract.methods.setProperty(tokenId, propertyKey, Buffer.from(propertyValue)).send();98 await contract.methods.setProperties(tokenId, [{key: propertyKey, value: Buffer.from(propertyValue)}]).send();
98 }99 }
99100
100 return {contract, nextTokenId: tokenId};101 return {contract, nextTokenId: tokenId};
deletedtests/src/eth/reFungibleTokenAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
48 }48 }
49 });49 });
5050
51 itEth('Can be set', async({helper}) => {
52 const caller = await helper.eth.createAccountWithBalance(donor);
53 const collection = await helper.nft.mintCollection(alice, {
54 tokenPropertyPermissions: [{
55 key: 'testKey',
56 permission: {
57 collectionAdmin: true,
58 },
59 }],
60 });
61 const token = await collection.mintToken(alice);
62
63 await collection.addAdmin(alice, {Ethereum: caller});
64
65 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
66 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
67
68 await contract.methods.setProperties(token.tokenId, [{key: 'testKey', value: Buffer.from('testValue')}]).send({from: caller});
69
70 const [{value}] = await token.getProperties(['testKey']);
71 expect(value).to.equal('testValue');
72 });
73
74 // Soft-deprecated
51 itEth('Can be set', async({helper}) => {75 itEth('Property can be set', async({helper}) => {
52 const caller = await helper.eth.createAccountWithBalance(donor);76 const caller = await helper.eth.createAccountWithBalance(donor);
53 const collection = await helper.nft.mintCollection(alice, {77 const collection = await helper.nft.mintCollection(alice, {
54 tokenPropertyPermissions: [{78 tokenPropertyPermissions: [{
63 await collection.addAdmin(alice, {Ethereum: caller});87 await collection.addAdmin(alice, {Ethereum: caller});
6488
65 const address = helper.ethAddress.fromCollectionId(collection.collectionId);89 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
66 const contract = helper.ethNativeContract.collection(address, 'nft', caller);90 const contract = helper.ethNativeContract.collection(address, 'nft', caller, true);
6791
68 await contract.methods.setProperty(token.tokenId, 'testKey', Buffer.from('testValue')).send({from: caller});92 await contract.methods.setProperty(token.tokenId, 'testKey', Buffer.from('testValue')).send({from: caller});
6993
74 itEth('Can be multiple set for NFT ', async({helper}) => {98 itEth('Can be multiple set for NFT ', async({helper}) => {
75 const caller = await helper.eth.createAccountWithBalance(donor);99 const caller = await helper.eth.createAccountWithBalance(donor);
76 100
77 const properties = Array(5).fill(0).map((_, i) => { return {field_0: `key_${i}`, field_1: Buffer.from(`value_${i}`)}; });101 const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
78 const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.field_0, permission: {tokenOwner: true,102 const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,
79 collectionAdmin: true,103 collectionAdmin: true,
80 mutable: true}}; });104 mutable: true}}; });
81 105
86 110
87 const token = await collection.mintToken(alice);111 const token = await collection.mintToken(alice);
88 112
89 const valuesBefore = await token.getProperties(properties.map(p => p.field_0));113 const valuesBefore = await token.getProperties(properties.map(p => p.key));
90 expect(valuesBefore).to.be.deep.equal([]);114 expect(valuesBefore).to.be.deep.equal([]);
91 115
92 await collection.addAdmin(alice, {Ethereum: caller});116 await collection.addAdmin(alice, {Ethereum: caller});
96120
97 await contract.methods.setProperties(token.tokenId, properties).send({from: caller});121 await contract.methods.setProperties(token.tokenId, properties).send({from: caller});
98122
99 const values = await token.getProperties(properties.map(p => p.field_0));123 const values = await token.getProperties(properties.map(p => p.key));
100 expect(values).to.be.deep.equal(properties.map(p => { return {key: p.field_0, value: p.field_1.toString()}; }));124 expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));
101 });125 });
102 126
103 itEth.ifWithPallets('Can be multiple set for RFT ', [Pallets.ReFungible], async({helper}) => {127 itEth.ifWithPallets('Can be multiple set for RFT ', [Pallets.ReFungible], async({helper}) => {
104 const caller = await helper.eth.createAccountWithBalance(donor);128 const caller = await helper.eth.createAccountWithBalance(donor);
105 129
106 const properties = Array(5).fill(0).map((_, i) => { return {field_0: `key_${i}`, field_1: Buffer.from(`value_${i}`)}; });130 const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
107 const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.field_0, permission: {tokenOwner: true,131 const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,
108 collectionAdmin: true,132 collectionAdmin: true,
109 mutable: true}}; });133 mutable: true}}; });
110 134
115 139
116 const token = await collection.mintToken(alice);140 const token = await collection.mintToken(alice);
117 141
118 const valuesBefore = await token.getProperties(properties.map(p => p.field_0));142 const valuesBefore = await token.getProperties(properties.map(p => p.key));
119 expect(valuesBefore).to.be.deep.equal([]);143 expect(valuesBefore).to.be.deep.equal([]);
120 144
121 await collection.addAdmin(alice, {Ethereum: caller});145 await collection.addAdmin(alice, {Ethereum: caller});
125149
126 await contract.methods.setProperties(token.tokenId, properties).send({from: caller});150 await contract.methods.setProperties(token.tokenId, properties).send({from: caller});
127151
128 const values = await token.getProperties(properties.map(p => p.field_0));152 const values = await token.getProperties(properties.map(p => p.key));
129 expect(values).to.be.deep.equal(properties.map(p => { return {key: p.field_0, value: p.field_1.toString()}; }));153 expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));
130 });154 });
131155
132 itEth('Can be deleted', async({helper}) => {156 itEth('Can be deleted', async({helper}) => {
deletedtests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth

no changes

modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
21import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent, EthProperty} from './types';21import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent, EthProperty} from './types';
2222
23// Native contracts ABI23// Native contracts ABI
24import collectionHelpersAbi from '../../collectionHelpersAbi.json';24import collectionHelpersAbi from '../../abi/collectionHelpers.json';
25import fungibleAbi from '../../fungibleAbi.json';25import fungibleAbi from '../../abi/fungible.json';
26import fungibleDeprecatedAbi from '../../abi/fungibleDeprecated.json';
26import nonFungibleAbi from '../../nonFungibleAbi.json';27import nonFungibleAbi from '../../abi/nonFungible.json';
28import nonFungibleDeprecatedAbi from '../../abi/nonFungibleDeprecated.json';
27import refungibleAbi from '../../reFungibleAbi.json';29import refungibleAbi from '../../abi/reFungible.json';
30import refungibleDeprecatedAbi from '../../abi/reFungibleDeprecated.json';
28import refungibleTokenAbi from '../../reFungibleTokenAbi.json';31import refungibleTokenAbi from '../../abi/reFungibleToken.json';
29import contractHelpersAbi from './../contractHelpersAbi.json';32import contractHelpersAbi from '../../abi/contractHelpers.json';
30import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';33import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';
31import {TCollectionMode} from '../../../util/playgrounds/types';34import {TCollectionMode} from '../../../util/playgrounds/types';
3235
108 return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});111 return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});
109 }112 }
110113
111 collection(address: string, mode: TCollectionMode, caller?: string): Contract {114 collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false): Contract {
112 const abi = {115 let abi = {
113 'nft': nonFungibleAbi,116 'nft': nonFungibleAbi,
114 'rft': refungibleAbi,117 'rft': refungibleAbi,
115 'ft': fungibleAbi,118 'ft': fungibleAbi,
116 }[mode];119 }[mode];
120 if (mergeDeprecated) {
121 const deprecated = {
122 'nft': nonFungibleDeprecatedAbi,
123 'rft': refungibleDeprecatedAbi,
124 'ft': fungibleDeprecatedAbi,
125 }[mode];
126 abi = [...abi,...deprecated];
127 }
117 const web3 = this.helper.getWeb3();128 const web3 = this.helper.getWeb3();
118 return new web3.eth.Contract(abi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});129 return new web3.eth.Contract(abi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});
119 }130 }