difftreelog
Merge remote-tracking branch 'origin/feature/fractionalizer-contract' into develop
in: master
50 files changed
pallets/common/src/erc.rsdiffbeforeafterboth25use pallet_evm_coder_substrate::dispatch_to_evm;25use pallet_evm_coder_substrate::dispatch_to_evm;26use sp_std::vec::Vec;26use sp_std::vec::Vec;27use up_data_structs::{27use up_data_structs::{28 Property, SponsoringRateLimit, OwnerRestrictedSet, AccessMode, CollectionPermissions,28 AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,29 SponsoringRateLimit,29};30};30use alloc::format;31use alloc::format;3132409 save(self)410 save(self)410 }411 }412413 /// Check that account is the owner or admin of the collection414 ///415 /// @param user account to verify416 /// @return "true" if account is the owner or admin417 fn verify_owner_or_admin(&self, user: address) -> Result<bool> {418 Ok(check_is_owner_or_admin(user, self)419 .map(|_| true)420 .unwrap_or(false))421 }422423 /// Returns collection type424 ///425 /// @return `Fungible` or `NFT` or `ReFungible`426 fn unique_collection_type(&mut self) -> Result<string> {427 let mode = match self.collection.mode {428 CollectionMode::Fungible(_) => "Fungible",429 CollectionMode::NFT => "NFT",430 CollectionMode::ReFungible => "ReFungible",431 };432 Ok(mode.into())433 }411}434}412435413fn check_is_owner_or_admin<T: Config>(436fn check_is_owner_or_admin<T: Config>(463 property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)486 property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)464 }487 }488489 /// Key "parentNft".490 pub fn parent_nft() -> up_data_structs::PropertyKey {491 property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)492 }465 }493 }466494467 /// Values.495 /// Values.pallets/common/src/lib.rsdiffbeforeafterboth1112 collection: &CollectionHandle<T>,1112 collection: &CollectionHandle<T>,1113 sender: &T::CrossAccountId,1113 sender: &T::CrossAccountId,1114 property_permission: PropertyKeyPermission,1114 property_permission: PropertyKeyPermission,1115 ) -> DispatchResult {1115 ) -> DispatchResult {1116 Self::set_scoped_property_permission(1117 collection,1118 sender,1119 PropertyScope::None,1120 property_permission,1121 )1122 }11231124 /// Set collection property permission with scope.1125 ///1126 /// * `collection` - Collection handler.1127 /// * `sender` - The owner or administrator of the collection.1128 /// * `scope` - Property scope.1129 /// * `property_permission` - Property permission.1130 pub fn set_scoped_property_permission(1131 collection: &CollectionHandle<T>,1132 sender: &T::CrossAccountId,1133 scope: PropertyScope,1134 property_permission: PropertyKeyPermission,1135 ) -> DispatchResult {1116 collection.check_is_owner_or_admin(sender)?;1136 collection.check_is_owner_or_admin(sender)?;111711371118 let all_permissions = CollectionPropertyPermissions::<T>::get(collection.id);1138 let all_permissions = CollectionPropertyPermissions::<T>::get(collection.id);112611461127 CollectionPropertyPermissions::<T>::try_mutate(collection.id, |permissions| {1147 CollectionPropertyPermissions::<T>::try_mutate(collection.id, |permissions| {1128 let property_permission = property_permission.clone();1148 let property_permission = property_permission.clone();1129 permissions.try_set(property_permission.key, property_permission.permission)1149 permissions.try_scoped_set(1150 scope,1151 property_permission.key,1152 property_permission.permission,1153 )1130 })1154 })1131 .map_err(<Error<T>>::from)?;1155 .map_err(<Error<T>>::from)?;1148 collection: &CollectionHandle<T>,1172 collection: &CollectionHandle<T>,1149 sender: &T::CrossAccountId,1173 sender: &T::CrossAccountId,1150 property_permissions: Vec<PropertyKeyPermission>,1174 property_permissions: Vec<PropertyKeyPermission>,1151 ) -> DispatchResult {1175 ) -> DispatchResult {1176 Self::set_scoped_token_property_permissions(1177 collection,1178 sender,1179 PropertyScope::None,1180 property_permissions,1181 )1182 }11831184 /// Set token property permission with scope.1185 ///1186 /// * `collection` - Collection handler.1187 /// * `sender` - The owner or administrator of the collection.1188 /// * `scope` - Property scope.1189 /// * `property_permissions` - Property permissions.1190 #[transactional]1191 pub fn set_scoped_token_property_permissions(1192 collection: &CollectionHandle<T>,1193 sender: &T::CrossAccountId,1194 scope: PropertyScope,1195 property_permissions: Vec<PropertyKeyPermission>,1196 ) -> DispatchResult {1152 for prop_pemission in property_permissions {1197 for prop_pemission in property_permissions {1153 Self::set_property_permission(collection, sender, prop_pemission)?;1198 Self::set_scoped_property_permission(collection, sender, scope, prop_pemission)?;1154 }1199 }115512001156 Ok(())1201 Ok(())1431 .saturating_add(Self::burn_recursively_breadth_raw(max_breadth))1476 .saturating_add(Self::burn_recursively_breadth_raw(max_breadth))1432 }1477 }14781479 /// The price of retrieving token owner1480 fn token_owner() -> Weight;1433}1481}143414821435/// Weight info extension trait for refungible pallet.1483/// Weight info extension trait for refungible pallet.1568 ///1616 ///1569 /// * `sender` - Must be either the owner of the token or its admin.1617 /// * `sender` - Must be either the owner of the token or its admin.1570 /// * `token_id` - The token for which the properties are being set.1618 /// * `token_id` - The token for which the properties are being set.1571 /// * `properties` - Properties to be set.1619 /// * `property_permissions` - Property permissions to be set.1572 /// * `budget` - Budget for setting properties.1620 /// * `budget` - Budget for setting properties.1573 fn set_token_property_permissions(1621 fn set_token_property_permissions(1574 &self,1622 &self,pallets/fungible/src/common.rsdiffbeforeafterboth104 0104 0105 }105 }106107 fn token_owner() -> Weight {108 0109 }106}110}107111108/// Implementation of `CommonCollectionOperations` for `FungibleHandle`. It wraps FungibleHandle Pallete112/// Implementation of `CommonCollectionOperations` for `FungibleHandle`. It wraps FungibleHandle Palletepallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth31 );31 );32}32}3334// Selector: 6cf113cd35contract Collection is Dummy, ERC165 {36 // Set collection property.37 //38 // @param key Property key.39 // @param value Propery value.40 //41 // Selector: setCollectionProperty(string,bytes) 2f073f6642 function setCollectionProperty(string memory key, bytes memory value)43 public44 {45 require(false, stub_error);46 key;47 value;48 dummy = 0;49 }5051 // Delete collection property.52 //53 // @param key Property key.54 //55 // Selector: deleteCollectionProperty(string) 7b7debce56 function deleteCollectionProperty(string memory key) public {57 require(false, stub_error);58 key;59 dummy = 0;60 }6162 // Get collection property.63 //64 // @dev Throws error if key not found.65 //66 // @param key Property key.67 // @return bytes The property corresponding to the key.68 //69 // Selector: collectionProperty(string) cf24fd6d70 function collectionProperty(string memory key)71 public72 view73 returns (bytes memory)74 {75 require(false, stub_error);76 key;77 dummy;78 return hex"";79 }8081 // Set the sponsor of the collection.82 //83 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.84 //85 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.86 //87 // Selector: setCollectionSponsor(address) 7623402e88 function setCollectionSponsor(address sponsor) public {89 require(false, stub_error);90 sponsor;91 dummy = 0;92 }9394 // Collection sponsorship confirmation.95 //96 // @dev After setting the sponsor for the collection, it must be confirmed with this function.97 //98 // Selector: confirmCollectionSponsorship() 3c50e97a99 function confirmCollectionSponsorship() public {100 require(false, stub_error);101 dummy = 0;102 }103104 // Set limits for the collection.105 // @dev Throws error if limit not found.106 // @param limit Name of the limit. Valid names:107 // "accountTokenOwnershipLimit",108 // "sponsoredDataSize",109 // "sponsoredDataRateLimit",110 // "tokenLimit",111 // "sponsorTransferTimeout",112 // "sponsorApproveTimeout"113 // @param value Value of the limit.114 //115 // Selector: setCollectionLimit(string,uint32) 6a3841db116 function setCollectionLimit(string memory limit, uint32 value) public {117 require(false, stub_error);118 limit;119 value;120 dummy = 0;121 }122123 // Set limits for the collection.124 // @dev Throws error if limit not found.125 // @param limit Name of the limit. Valid names:126 // "ownerCanTransfer",127 // "ownerCanDestroy",128 // "transfersEnabled"129 // @param value Value of the limit.130 //131 // Selector: setCollectionLimit(string,bool) 993b7fba132 function setCollectionLimit(string memory limit, bool value) public {133 require(false, stub_error);134 limit;135 value;136 dummy = 0;137 }138139 // Get contract address.140 //141 // Selector: contractAddress() f6b4dfb4142 function contractAddress() public view returns (address) {143 require(false, stub_error);144 dummy;145 return 0x0000000000000000000000000000000000000000;146 }147148 // Add collection admin by substrate address.149 // @param new_admin Substrate administrator address.150 //151 // Selector: addCollectionAdminSubstrate(uint256) 5730062b152 function addCollectionAdminSubstrate(uint256 newAdmin) public {153 require(false, stub_error);154 newAdmin;155 dummy = 0;156 }157158 // Remove collection admin by substrate address.159 // @param admin Substrate administrator address.160 //161 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9162 function removeCollectionAdminSubstrate(uint256 admin) public {163 require(false, stub_error);164 admin;165 dummy = 0;166 }167168 // Add collection admin.169 // @param new_admin Address of the added administrator.170 //171 // Selector: addCollectionAdmin(address) 92e462c7172 function addCollectionAdmin(address newAdmin) public {173 require(false, stub_error);174 newAdmin;175 dummy = 0;176 }177178 // Remove collection admin.179 //180 // @param new_admin Address of the removed administrator.181 //182 // Selector: removeCollectionAdmin(address) fafd7b42183 function removeCollectionAdmin(address admin) public {184 require(false, stub_error);185 admin;186 dummy = 0;187 }188189 // Toggle accessibility of collection nesting.190 //191 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'192 //193 // Selector: setCollectionNesting(bool) 112d4586194 function setCollectionNesting(bool enable) public {195 require(false, stub_error);196 enable;197 dummy = 0;198 }199200 // Toggle accessibility of collection nesting.201 //202 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'203 // @param collections Addresses of collections that will be available for nesting.204 //205 // Selector: setCollectionNesting(bool,address[]) 64872396206 function setCollectionNesting(bool enable, address[] memory collections)207 public208 {209 require(false, stub_error);210 enable;211 collections;212 dummy = 0;213 }214215 // Set the collection access method.216 // @param mode Access mode217 // 0 for Normal218 // 1 for AllowList219 //220 // Selector: setCollectionAccess(uint8) 41835d4c221 function setCollectionAccess(uint8 mode) public {222 require(false, stub_error);223 mode;224 dummy = 0;225 }226227 // Add the user to the allowed list.228 //229 // @param user Address of a trusted user.230 //231 // Selector: addToCollectionAllowList(address) 67844fe6232 function addToCollectionAllowList(address user) public {233 require(false, stub_error);234 user;235 dummy = 0;236 }237238 // Remove the user from the allowed list.239 //240 // @param user Address of a removed user.241 //242 // Selector: removeFromCollectionAllowList(address) 85c51acb243 function removeFromCollectionAllowList(address user) public {244 require(false, stub_error);245 user;246 dummy = 0;247 }248249 // Switch permission for minting.250 //251 // @param mode Enable if "true".252 //253 // Selector: setCollectionMintMode(bool) 00018e84254 function setCollectionMintMode(bool mode) public {255 require(false, stub_error);256 mode;257 dummy = 0;258 }259260 // Check that account is the owner or admin of the collection261 //262 // @param user account to verify263 // @return "true" if account is the owner or admin264 //265 // Selector: verifyOwnerOrAdmin(address) c2282493266 function verifyOwnerOrAdmin(address user) public view returns (bool) {267 require(false, stub_error);268 user;269 dummy;270 return false;271 }272273 // Returns collection type274 //275 // @return `Fungible` or `NFT` or `ReFungible`276 //277 // Selector: uniqueCollectionType() d34b55b8278 function uniqueCollectionType() public returns (string memory) {279 require(false, stub_error);280 dummy = 0;281 return "";282 }283}3328434// Selector: 79cc6790285// Selector: 79cc679035contract ERC20UniqueExtensions is Dummy, ERC165 {286contract ERC20UniqueExtensions is Dummy, ERC165 {43 }294 }44}295}4546// Selector: 7d9262e647contract Collection is Dummy, ERC165 {48 // Set collection property.49 //50 // @param key Property key.51 // @param value Propery value.52 //53 // Selector: setCollectionProperty(string,bytes) 2f073f6654 function setCollectionProperty(string memory key, bytes memory value)55 public56 {57 require(false, stub_error);58 key;59 value;60 dummy = 0;61 }6263 // Delete collection property.64 //65 // @param key Property key.66 //67 // Selector: deleteCollectionProperty(string) 7b7debce68 function deleteCollectionProperty(string memory key) public {69 require(false, stub_error);70 key;71 dummy = 0;72 }7374 // Get collection property.75 //76 // @dev Throws error if key not found.77 //78 // @param key Property key.79 // @return bytes The property corresponding to the key.80 //81 // Selector: collectionProperty(string) cf24fd6d82 function collectionProperty(string memory key)83 public84 view85 returns (bytes memory)86 {87 require(false, stub_error);88 key;89 dummy;90 return hex"";91 }9293 // Set the sponsor of the collection.94 //95 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.96 //97 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.98 //99 // Selector: setCollectionSponsor(address) 7623402e100 function setCollectionSponsor(address sponsor) public {101 require(false, stub_error);102 sponsor;103 dummy = 0;104 }105106 // Collection sponsorship confirmation.107 //108 // @dev After setting the sponsor for the collection, it must be confirmed with this function.109 //110 // Selector: confirmCollectionSponsorship() 3c50e97a111 function confirmCollectionSponsorship() public {112 require(false, stub_error);113 dummy = 0;114 }115116 // Set limits for the collection.117 // @dev Throws error if limit not found.118 // @param limit Name of the limit. Valid names:119 // "accountTokenOwnershipLimit",120 // "sponsoredDataSize",121 // "sponsoredDataRateLimit",122 // "tokenLimit",123 // "sponsorTransferTimeout",124 // "sponsorApproveTimeout"125 // @param value Value of the limit.126 //127 // Selector: setCollectionLimit(string,uint32) 6a3841db128 function setCollectionLimit(string memory limit, uint32 value) public {129 require(false, stub_error);130 limit;131 value;132 dummy = 0;133 }134135 // Set limits for the collection.136 // @dev Throws error if limit not found.137 // @param limit Name of the limit. Valid names:138 // "ownerCanTransfer",139 // "ownerCanDestroy",140 // "transfersEnabled"141 // @param value Value of the limit.142 //143 // Selector: setCollectionLimit(string,bool) 993b7fba144 function setCollectionLimit(string memory limit, bool value) public {145 require(false, stub_error);146 limit;147 value;148 dummy = 0;149 }150151 // Get contract address.152 //153 // Selector: contractAddress() f6b4dfb4154 function contractAddress() public view returns (address) {155 require(false, stub_error);156 dummy;157 return 0x0000000000000000000000000000000000000000;158 }159160 // Add collection admin by substrate address.161 // @param new_admin Substrate administrator address.162 //163 // Selector: addCollectionAdminSubstrate(uint256) 5730062b164 function addCollectionAdminSubstrate(uint256 newAdmin) public {165 require(false, stub_error);166 newAdmin;167 dummy = 0;168 }169170 // Remove collection admin by substrate address.171 // @param admin Substrate administrator address.172 //173 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9174 function removeCollectionAdminSubstrate(uint256 admin) public {175 require(false, stub_error);176 admin;177 dummy = 0;178 }179180 // Add collection admin.181 // @param new_admin Address of the added administrator.182 //183 // Selector: addCollectionAdmin(address) 92e462c7184 function addCollectionAdmin(address newAdmin) public {185 require(false, stub_error);186 newAdmin;187 dummy = 0;188 }189190 // Remove collection admin.191 //192 // @param new_admin Address of the removed administrator.193 //194 // Selector: removeCollectionAdmin(address) fafd7b42195 function removeCollectionAdmin(address admin) public {196 require(false, stub_error);197 admin;198 dummy = 0;199 }200201 // Toggle accessibility of collection nesting.202 //203 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'204 //205 // Selector: setCollectionNesting(bool) 112d4586206 function setCollectionNesting(bool enable) public {207 require(false, stub_error);208 enable;209 dummy = 0;210 }211212 // Toggle accessibility of collection nesting.213 //214 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'215 // @param collections Addresses of collections that will be available for nesting.216 //217 // Selector: setCollectionNesting(bool,address[]) 64872396218 function setCollectionNesting(bool enable, address[] memory collections)219 public220 {221 require(false, stub_error);222 enable;223 collections;224 dummy = 0;225 }226227 // Set the collection access method.228 // @param mode Access mode229 // 0 for Normal230 // 1 for AllowList231 //232 // Selector: setCollectionAccess(uint8) 41835d4c233 function setCollectionAccess(uint8 mode) public {234 require(false, stub_error);235 mode;236 dummy = 0;237 }238239 // Add the user to the allowed list.240 //241 // @param user Address of a trusted user.242 //243 // Selector: addToCollectionAllowList(address) 67844fe6244 function addToCollectionAllowList(address user) public {245 require(false, stub_error);246 user;247 dummy = 0;248 }249250 // Remove the user from the allowed list.251 //252 // @param user Address of a removed user.253 //254 // Selector: removeFromCollectionAllowList(address) 85c51acb255 function removeFromCollectionAllowList(address user) public {256 require(false, stub_error);257 user;258 dummy = 0;259 }260261 // Switch permission for minting.262 //263 // @param mode Enable if "true".264 //265 // Selector: setCollectionMintMode(bool) 00018e84266 function setCollectionMintMode(bool mode) public {267 require(false, stub_error);268 mode;269 dummy = 0;270 }271}272296273// Selector: 942e8b22297// Selector: 942e8b22274contract ERC20 is Dummy, ERC165, ERC20Events {298contract ERC20 is Dummy, ERC165, ERC20Events {pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth17use super::*;17use super::*;18use crate::{Pallet, Config, NonfungibleHandle};18use crate::{Pallet, Config, NonfungibleHandle};191920use sp_std::prelude::*;20use frame_benchmarking::{benchmarks, account};21use pallet_common::benchmarking::{create_collection_raw, property_key, property_value};21use pallet_common::{22 bench_init,23 benchmarking::{create_collection_raw, property_key, property_value},24 CommonCollectionOperations,25};22use frame_benchmarking::{benchmarks, account};26use sp_std::prelude::*;23use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, budget::Unlimited};27use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, budget::Unlimited};24use pallet_common::bench_init;252826const SEED: u32 = 1;29const SEED: u32 = 1;2730209 let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();212 let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();210 }: {<Pallet<T>>::delete_token_properties(&collection, &owner, item, to_delete.into_iter(), &Unlimited)?}213 }: {<Pallet<T>>::delete_token_properties(&collection, &owner, item, to_delete.into_iter(), &Unlimited)?}214215 token_owner {216 bench_init!{217 owner: sub; collection: collection(owner);218 owner: cross_from_sub;219 };220 let item = create_max_item(&collection, &owner, owner.clone())?;221222 }: {collection.token_owner(item)}211}223}212224pallets/nonfungible/src/common.rsdiffbeforeafterboth119 .saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))119 .saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))120 }120 }121122 fn token_owner() -> Weight {123 <SelfWeightOf<T>>::token_owner()124 }121}125}122126123fn map_create_data<T: Config>(127fn map_create_data<T: Config>(pallets/nonfungible/src/lib.rsdiffbeforeafterboth784 <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)784 <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)785 }785 }786787 /// Set property permissions for the token with scope.788 ///789 /// Sender should be the owner or admin of token's collection.790 pub fn set_scoped_token_property_permissions(791 collection: &CollectionHandle<T>,792 sender: &T::CrossAccountId,793 scope: PropertyScope,794 property_permissions: Vec<PropertyKeyPermission>,795 ) -> DispatchResult {796 <PalletCommon<T>>::set_scoped_token_property_permissions(797 collection,798 sender,799 scope,800 property_permissions,801 )802 }786803787 /// Set property permissions for the collection.804 /// Set property permissions for the collection.788 ///805 ///pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth373 }373 }374}374}375376// Selector: 6cf113cd377contract Collection is Dummy, ERC165 {378 // Set collection property.379 //380 // @param key Property key.381 // @param value Propery value.382 //383 // Selector: setCollectionProperty(string,bytes) 2f073f66384 function setCollectionProperty(string memory key, bytes memory value)385 public386 {387 require(false, stub_error);388 key;389 value;390 dummy = 0;391 }392393 // Delete collection property.394 //395 // @param key Property key.396 //397 // Selector: deleteCollectionProperty(string) 7b7debce398 function deleteCollectionProperty(string memory key) public {399 require(false, stub_error);400 key;401 dummy = 0;402 }403404 // Get collection property.405 //406 // @dev Throws error if key not found.407 //408 // @param key Property key.409 // @return bytes The property corresponding to the key.410 //411 // Selector: collectionProperty(string) cf24fd6d412 function collectionProperty(string memory key)413 public414 view415 returns (bytes memory)416 {417 require(false, stub_error);418 key;419 dummy;420 return hex"";421 }422423 // Set the sponsor of the collection.424 //425 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.426 //427 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.428 //429 // Selector: setCollectionSponsor(address) 7623402e430 function setCollectionSponsor(address sponsor) public {431 require(false, stub_error);432 sponsor;433 dummy = 0;434 }435436 // Collection sponsorship confirmation.437 //438 // @dev After setting the sponsor for the collection, it must be confirmed with this function.439 //440 // Selector: confirmCollectionSponsorship() 3c50e97a441 function confirmCollectionSponsorship() public {442 require(false, stub_error);443 dummy = 0;444 }445446 // Set limits for the collection.447 // @dev Throws error if limit not found.448 // @param limit Name of the limit. Valid names:449 // "accountTokenOwnershipLimit",450 // "sponsoredDataSize",451 // "sponsoredDataRateLimit",452 // "tokenLimit",453 // "sponsorTransferTimeout",454 // "sponsorApproveTimeout"455 // @param value Value of the limit.456 //457 // Selector: setCollectionLimit(string,uint32) 6a3841db458 function setCollectionLimit(string memory limit, uint32 value) public {459 require(false, stub_error);460 limit;461 value;462 dummy = 0;463 }464465 // Set limits for the collection.466 // @dev Throws error if limit not found.467 // @param limit Name of the limit. Valid names:468 // "ownerCanTransfer",469 // "ownerCanDestroy",470 // "transfersEnabled"471 // @param value Value of the limit.472 //473 // Selector: setCollectionLimit(string,bool) 993b7fba474 function setCollectionLimit(string memory limit, bool value) public {475 require(false, stub_error);476 limit;477 value;478 dummy = 0;479 }480481 // Get contract address.482 //483 // Selector: contractAddress() f6b4dfb4484 function contractAddress() public view returns (address) {485 require(false, stub_error);486 dummy;487 return 0x0000000000000000000000000000000000000000;488 }489490 // Add collection admin by substrate address.491 // @param new_admin Substrate administrator address.492 //493 // Selector: addCollectionAdminSubstrate(uint256) 5730062b494 function addCollectionAdminSubstrate(uint256 newAdmin) public {495 require(false, stub_error);496 newAdmin;497 dummy = 0;498 }499500 // Remove collection admin by substrate address.501 // @param admin Substrate administrator address.502 //503 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9504 function removeCollectionAdminSubstrate(uint256 admin) public {505 require(false, stub_error);506 admin;507 dummy = 0;508 }509510 // Add collection admin.511 // @param new_admin Address of the added administrator.512 //513 // Selector: addCollectionAdmin(address) 92e462c7514 function addCollectionAdmin(address newAdmin) public {515 require(false, stub_error);516 newAdmin;517 dummy = 0;518 }519520 // Remove collection admin.521 //522 // @param new_admin Address of the removed administrator.523 //524 // Selector: removeCollectionAdmin(address) fafd7b42525 function removeCollectionAdmin(address admin) public {526 require(false, stub_error);527 admin;528 dummy = 0;529 }530531 // Toggle accessibility of collection nesting.532 //533 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'534 //535 // Selector: setCollectionNesting(bool) 112d4586536 function setCollectionNesting(bool enable) public {537 require(false, stub_error);538 enable;539 dummy = 0;540 }541542 // Toggle accessibility of collection nesting.543 //544 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'545 // @param collections Addresses of collections that will be available for nesting.546 //547 // Selector: setCollectionNesting(bool,address[]) 64872396548 function setCollectionNesting(bool enable, address[] memory collections)549 public550 {551 require(false, stub_error);552 enable;553 collections;554 dummy = 0;555 }556557 // Set the collection access method.558 // @param mode Access mode559 // 0 for Normal560 // 1 for AllowList561 //562 // Selector: setCollectionAccess(uint8) 41835d4c563 function setCollectionAccess(uint8 mode) public {564 require(false, stub_error);565 mode;566 dummy = 0;567 }568569 // Add the user to the allowed list.570 //571 // @param user Address of a trusted user.572 //573 // Selector: addToCollectionAllowList(address) 67844fe6574 function addToCollectionAllowList(address user) public {575 require(false, stub_error);576 user;577 dummy = 0;578 }579580 // Remove the user from the allowed list.581 //582 // @param user Address of a removed user.583 //584 // Selector: removeFromCollectionAllowList(address) 85c51acb585 function removeFromCollectionAllowList(address user) public {586 require(false, stub_error);587 user;588 dummy = 0;589 }590591 // Switch permission for minting.592 //593 // @param mode Enable if "true".594 //595 // Selector: setCollectionMintMode(bool) 00018e84596 function setCollectionMintMode(bool mode) public {597 require(false, stub_error);598 mode;599 dummy = 0;600 }601602 // Check that account is the owner or admin of the collection603 //604 // @param user account to verify605 // @return "true" if account is the owner or admin606 //607 // Selector: verifyOwnerOrAdmin(address) c2282493608 function verifyOwnerOrAdmin(address user) public view returns (bool) {609 require(false, stub_error);610 user;611 dummy;612 return false;613 }614615 // Returns collection type616 //617 // @return `Fungible` or `NFT` or `ReFungible`618 //619 // Selector: uniqueCollectionType() d34b55b8620 function uniqueCollectionType() public returns (string memory) {621 require(false, stub_error);622 dummy = 0;623 return "";624 }625}375626376// Selector: 780e9d63627// Selector: 780e9d63377contract ERC721Enumerable is Dummy, ERC165 {628contract ERC721Enumerable is Dummy, ERC165 {415 }666 }416}667}417418// Selector: 7d9262e6419contract Collection is Dummy, ERC165 {420 // Set collection property.421 //422 // @param key Property key.423 // @param value Propery value.424 //425 // Selector: setCollectionProperty(string,bytes) 2f073f66426 function setCollectionProperty(string memory key, bytes memory value)427 public428 {429 require(false, stub_error);430 key;431 value;432 dummy = 0;433 }434435 // Delete collection property.436 //437 // @param key Property key.438 //439 // Selector: deleteCollectionProperty(string) 7b7debce440 function deleteCollectionProperty(string memory key) public {441 require(false, stub_error);442 key;443 dummy = 0;444 }445446 // Get collection property.447 //448 // @dev Throws error if key not found.449 //450 // @param key Property key.451 // @return bytes The property corresponding to the key.452 //453 // Selector: collectionProperty(string) cf24fd6d454 function collectionProperty(string memory key)455 public456 view457 returns (bytes memory)458 {459 require(false, stub_error);460 key;461 dummy;462 return hex"";463 }464465 // Set the sponsor of the collection.466 //467 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.468 //469 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.470 //471 // Selector: setCollectionSponsor(address) 7623402e472 function setCollectionSponsor(address sponsor) public {473 require(false, stub_error);474 sponsor;475 dummy = 0;476 }477478 // Collection sponsorship confirmation.479 //480 // @dev After setting the sponsor for the collection, it must be confirmed with this function.481 //482 // Selector: confirmCollectionSponsorship() 3c50e97a483 function confirmCollectionSponsorship() public {484 require(false, stub_error);485 dummy = 0;486 }487488 // Set limits for the collection.489 // @dev Throws error if limit not found.490 // @param limit Name of the limit. Valid names:491 // "accountTokenOwnershipLimit",492 // "sponsoredDataSize",493 // "sponsoredDataRateLimit",494 // "tokenLimit",495 // "sponsorTransferTimeout",496 // "sponsorApproveTimeout"497 // @param value Value of the limit.498 //499 // Selector: setCollectionLimit(string,uint32) 6a3841db500 function setCollectionLimit(string memory limit, uint32 value) public {501 require(false, stub_error);502 limit;503 value;504 dummy = 0;505 }506507 // Set limits for the collection.508 // @dev Throws error if limit not found.509 // @param limit Name of the limit. Valid names:510 // "ownerCanTransfer",511 // "ownerCanDestroy",512 // "transfersEnabled"513 // @param value Value of the limit.514 //515 // Selector: setCollectionLimit(string,bool) 993b7fba516 function setCollectionLimit(string memory limit, bool value) public {517 require(false, stub_error);518 limit;519 value;520 dummy = 0;521 }522523 // Get contract address.524 //525 // Selector: contractAddress() f6b4dfb4526 function contractAddress() public view returns (address) {527 require(false, stub_error);528 dummy;529 return 0x0000000000000000000000000000000000000000;530 }531532 // Add collection admin by substrate address.533 // @param new_admin Substrate administrator address.534 //535 // Selector: addCollectionAdminSubstrate(uint256) 5730062b536 function addCollectionAdminSubstrate(uint256 newAdmin) public {537 require(false, stub_error);538 newAdmin;539 dummy = 0;540 }541542 // Remove collection admin by substrate address.543 // @param admin Substrate administrator address.544 //545 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9546 function removeCollectionAdminSubstrate(uint256 admin) public {547 require(false, stub_error);548 admin;549 dummy = 0;550 }551552 // Add collection admin.553 // @param new_admin Address of the added administrator.554 //555 // Selector: addCollectionAdmin(address) 92e462c7556 function addCollectionAdmin(address newAdmin) public {557 require(false, stub_error);558 newAdmin;559 dummy = 0;560 }561562 // Remove collection admin.563 //564 // @param new_admin Address of the removed administrator.565 //566 // Selector: removeCollectionAdmin(address) fafd7b42567 function removeCollectionAdmin(address admin) public {568 require(false, stub_error);569 admin;570 dummy = 0;571 }572573 // Toggle accessibility of collection nesting.574 //575 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'576 //577 // Selector: setCollectionNesting(bool) 112d4586578 function setCollectionNesting(bool enable) public {579 require(false, stub_error);580 enable;581 dummy = 0;582 }583584 // Toggle accessibility of collection nesting.585 //586 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'587 // @param collections Addresses of collections that will be available for nesting.588 //589 // Selector: setCollectionNesting(bool,address[]) 64872396590 function setCollectionNesting(bool enable, address[] memory collections)591 public592 {593 require(false, stub_error);594 enable;595 collections;596 dummy = 0;597 }598599 // Set the collection access method.600 // @param mode Access mode601 // 0 for Normal602 // 1 for AllowList603 //604 // Selector: setCollectionAccess(uint8) 41835d4c605 function setCollectionAccess(uint8 mode) public {606 require(false, stub_error);607 mode;608 dummy = 0;609 }610611 // Add the user to the allowed list.612 //613 // @param user Address of a trusted user.614 //615 // Selector: addToCollectionAllowList(address) 67844fe6616 function addToCollectionAllowList(address user) public {617 require(false, stub_error);618 user;619 dummy = 0;620 }621622 // Remove the user from the allowed list.623 //624 // @param user Address of a removed user.625 //626 // Selector: removeFromCollectionAllowList(address) 85c51acb627 function removeFromCollectionAllowList(address user) public {628 require(false, stub_error);629 user;630 dummy = 0;631 }632633 // Switch permission for minting.634 //635 // @param mode Enable if "true".636 //637 // Selector: setCollectionMintMode(bool) 00018e84638 function setCollectionMintMode(bool mode) public {639 require(false, stub_error);640 mode;641 dummy = 0;642 }643}644668645// Selector: d74d154f669// Selector: d74d154f646contract ERC721UniqueExtensions is Dummy, ERC165 {670contract ERC721UniqueExtensions is Dummy, ERC165 {pallets/nonfungible/src/weights.rsdiffbeforeafterboth3//! Autogenerated weights for pallet_nonfungible3//! Autogenerated weights for pallet_nonfungible4//!4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-07-20, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2022-08-01, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10247//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024889// Executed Command:9// Executed Command:46 fn set_token_property_permissions(b: u32, ) -> Weight;46 fn set_token_property_permissions(b: u32, ) -> Weight;47 fn set_token_properties(b: u32, ) -> Weight;47 fn set_token_properties(b: u32, ) -> Weight;48 fn delete_token_properties(b: u32, ) -> Weight;48 fn delete_token_properties(b: u32, ) -> Weight;49 fn token_owner() -> Weight;49}50}505151/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.52/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.56 // Storage: Nonfungible TokenData (r:0 w:1)57 // Storage: Nonfungible TokenData (r:0 w:1)57 // Storage: Nonfungible Owned (r:0 w:1)58 // Storage: Nonfungible Owned (r:0 w:1)58 fn create_item() -> Weight {59 fn create_item() -> Weight {59 (20_328_000 as Weight)60 (20_909_000 as Weight)60 .saturating_add(T::DbWeight::get().reads(2 as Weight))61 .saturating_add(T::DbWeight::get().reads(2 as Weight))61 .saturating_add(T::DbWeight::get().writes(4 as Weight))62 .saturating_add(T::DbWeight::get().writes(4 as Weight))62 }63 }65 // Storage: Nonfungible TokenData (r:0 w:4)66 // Storage: Nonfungible TokenData (r:0 w:4)66 // Storage: Nonfungible Owned (r:0 w:4)67 // Storage: Nonfungible Owned (r:0 w:4)67 fn create_multiple_items(b: u32, ) -> Weight {68 fn create_multiple_items(b: u32, ) -> Weight {68 (10_134_000 as Weight)69 (12_601_000 as Weight)69 // Standard Error: 3_00070 // Standard Error: 1_00070 .saturating_add((4_927_000 as Weight).saturating_mul(b as Weight))71 .saturating_add((4_920_000 as Weight).saturating_mul(b as Weight))71 .saturating_add(T::DbWeight::get().reads(2 as Weight))72 .saturating_add(T::DbWeight::get().reads(2 as Weight))72 .saturating_add(T::DbWeight::get().writes(2 as Weight))73 .saturating_add(T::DbWeight::get().writes(2 as Weight))73 .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))74 .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))77 // Storage: Nonfungible TokenData (r:0 w:4)78 // Storage: Nonfungible TokenData (r:0 w:4)78 // Storage: Nonfungible Owned (r:0 w:4)79 // Storage: Nonfungible Owned (r:0 w:4)79 fn create_multiple_items_ex(b: u32, ) -> Weight {80 fn create_multiple_items_ex(b: u32, ) -> Weight {80 (5_710_000 as Weight)81 (0 as Weight)81 // Standard Error: 4_00082 // Standard Error: 3_00082 .saturating_add((7_578_000 as Weight).saturating_mul(b as Weight))83 .saturating_add((7_734_000 as Weight).saturating_mul(b as Weight))83 .saturating_add(T::DbWeight::get().reads(1 as Weight))84 .saturating_add(T::DbWeight::get().reads(1 as Weight))84 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))85 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))85 .saturating_add(T::DbWeight::get().writes(1 as Weight))86 .saturating_add(T::DbWeight::get().writes(1 as Weight))93 // Storage: Nonfungible Owned (r:0 w:1)94 // Storage: Nonfungible Owned (r:0 w:1)94 // Storage: Nonfungible TokenProperties (r:0 w:1)95 // Storage: Nonfungible TokenProperties (r:0 w:1)95 fn burn_item() -> Weight {96 fn burn_item() -> Weight {96 (28_433_000 as Weight)97 (29_746_000 as Weight)97 .saturating_add(T::DbWeight::get().reads(5 as Weight))98 .saturating_add(T::DbWeight::get().reads(5 as Weight))98 .saturating_add(T::DbWeight::get().writes(5 as Weight))99 .saturating_add(T::DbWeight::get().writes(5 as Weight))99 }100 }105 // Storage: Nonfungible Owned (r:0 w:1)106 // Storage: Nonfungible Owned (r:0 w:1)106 // Storage: Nonfungible TokenProperties (r:0 w:1)107 // Storage: Nonfungible TokenProperties (r:0 w:1)107 fn burn_recursively_self_raw() -> Weight {108 fn burn_recursively_self_raw() -> Weight {108 (34_435_000 as Weight)109 (36_077_000 as Weight)109 .saturating_add(T::DbWeight::get().reads(5 as Weight))110 .saturating_add(T::DbWeight::get().reads(5 as Weight))110 .saturating_add(T::DbWeight::get().writes(5 as Weight))111 .saturating_add(T::DbWeight::get().writes(5 as Weight))111 }112 }119 // Storage: Common CollectionById (r:1 w:0)120 // Storage: Common CollectionById (r:1 w:0)120 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {121 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {121 (0 as Weight)122 (0 as Weight)122 // Standard Error: 1_539_000123 // Standard Error: 1_605_000123 .saturating_add((304_456_000 as Weight).saturating_mul(b as Weight))124 .saturating_add((312_391_000 as Weight).saturating_mul(b as Weight))124 .saturating_add(T::DbWeight::get().reads(7 as Weight))125 .saturating_add(T::DbWeight::get().reads(7 as Weight))125 .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))126 .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))126 .saturating_add(T::DbWeight::get().writes(6 as Weight))127 .saturating_add(T::DbWeight::get().writes(6 as Weight))131 // Storage: Nonfungible Allowance (r:1 w:0)132 // Storage: Nonfungible Allowance (r:1 w:0)132 // Storage: Nonfungible Owned (r:0 w:2)133 // Storage: Nonfungible Owned (r:0 w:2)133 fn transfer() -> Weight {134 fn transfer() -> Weight {134 (24_376_000 as Weight)135 (25_248_000 as Weight)135 .saturating_add(T::DbWeight::get().reads(4 as Weight))136 .saturating_add(T::DbWeight::get().reads(4 as Weight))136 .saturating_add(T::DbWeight::get().writes(5 as Weight))137 .saturating_add(T::DbWeight::get().writes(5 as Weight))137 }138 }138 // Storage: Nonfungible TokenData (r:1 w:0)139 // Storage: Nonfungible TokenData (r:1 w:0)139 // Storage: Nonfungible Allowance (r:1 w:1)140 // Storage: Nonfungible Allowance (r:1 w:1)140 fn approve() -> Weight {141 fn approve() -> Weight {141 (15_890_000 as Weight)142 (16_321_000 as Weight)142 .saturating_add(T::DbWeight::get().reads(2 as Weight))143 .saturating_add(T::DbWeight::get().reads(2 as Weight))143 .saturating_add(T::DbWeight::get().writes(1 as Weight))144 .saturating_add(T::DbWeight::get().writes(1 as Weight))144 }145 }147 // Storage: Nonfungible AccountBalance (r:2 w:2)148 // Storage: Nonfungible AccountBalance (r:2 w:2)148 // Storage: Nonfungible Owned (r:0 w:2)149 // Storage: Nonfungible Owned (r:0 w:2)149 fn transfer_from() -> Weight {150 fn transfer_from() -> Weight {150 (28_634_000 as Weight)151 (29_325_000 as Weight)151 .saturating_add(T::DbWeight::get().reads(4 as Weight))152 .saturating_add(T::DbWeight::get().reads(4 as Weight))152 .saturating_add(T::DbWeight::get().writes(6 as Weight))153 .saturating_add(T::DbWeight::get().writes(6 as Weight))153 }154 }159 // Storage: Nonfungible Owned (r:0 w:1)160 // Storage: Nonfungible Owned (r:0 w:1)160 // Storage: Nonfungible TokenProperties (r:0 w:1)161 // Storage: Nonfungible TokenProperties (r:0 w:1)161 fn burn_from() -> Weight {162 fn burn_from() -> Weight {162 (32_201_000 as Weight)163 (33_323_000 as Weight)163 .saturating_add(T::DbWeight::get().reads(5 as Weight))164 .saturating_add(T::DbWeight::get().reads(5 as Weight))164 .saturating_add(T::DbWeight::get().writes(6 as Weight))165 .saturating_add(T::DbWeight::get().writes(6 as Weight))165 }166 }166 // Storage: Common CollectionPropertyPermissions (r:1 w:1)167 // Storage: Common CollectionPropertyPermissions (r:1 w:1)167 fn set_token_property_permissions(b: u32, ) -> Weight {168 fn set_token_property_permissions(b: u32, ) -> Weight {168 (0 as Weight)169 (0 as Weight)169 // Standard Error: 57_000170 // Standard Error: 62_000170 .saturating_add((15_232_000 as Weight).saturating_mul(b as Weight))171 .saturating_add((16_222_000 as Weight).saturating_mul(b as Weight))171 .saturating_add(T::DbWeight::get().reads(1 as Weight))172 .saturating_add(T::DbWeight::get().reads(1 as Weight))172 .saturating_add(T::DbWeight::get().writes(1 as Weight))173 .saturating_add(T::DbWeight::get().writes(1 as Weight))173 }174 }174 // Storage: Common CollectionPropertyPermissions (r:1 w:0)175 // Storage: Common CollectionPropertyPermissions (r:1 w:0)175 // Storage: Nonfungible TokenProperties (r:1 w:1)176 // Storage: Nonfungible TokenProperties (r:1 w:1)176 fn set_token_properties(b: u32, ) -> Weight {177 fn set_token_properties(b: u32, ) -> Weight {177 (0 as Weight)178 (0 as Weight)178 // Standard Error: 1_648_000179 // Standard Error: 1_750_000179 .saturating_add((288_654_000 as Weight).saturating_mul(b as Weight))180 .saturating_add((304_476_000 as Weight).saturating_mul(b as Weight))180 .saturating_add(T::DbWeight::get().reads(2 as Weight))181 .saturating_add(T::DbWeight::get().reads(2 as Weight))181 .saturating_add(T::DbWeight::get().writes(1 as Weight))182 .saturating_add(T::DbWeight::get().writes(1 as Weight))182 }183 }183 // Storage: Common CollectionPropertyPermissions (r:1 w:0)184 // Storage: Common CollectionPropertyPermissions (r:1 w:0)184 // Storage: Nonfungible TokenProperties (r:1 w:1)185 // Storage: Nonfungible TokenProperties (r:1 w:1)185 fn delete_token_properties(b: u32, ) -> Weight {186 fn delete_token_properties(b: u32, ) -> Weight {186 (0 as Weight)187 (0 as Weight)187 // Standard Error: 1_632_000188 // Standard Error: 1_638_000188 .saturating_add((289_190_000 as Weight).saturating_mul(b as Weight))189 .saturating_add((294_096_000 as Weight).saturating_mul(b as Weight))189 .saturating_add(T::DbWeight::get().reads(2 as Weight))190 .saturating_add(T::DbWeight::get().reads(2 as Weight))190 .saturating_add(T::DbWeight::get().writes(1 as Weight))191 .saturating_add(T::DbWeight::get().writes(1 as Weight))191 }192 }193 // Storage: Nonfungible TokenData (r:1 w:0)194 fn token_owner() -> Weight {195 (2_986_000 as Weight)196 .saturating_add(T::DbWeight::get().reads(1 as Weight))197 }192}198}193199194// For backwards compatibility and tests200// For backwards compatibility and tests198 // Storage: Nonfungible TokenData (r:0 w:1)204 // Storage: Nonfungible TokenData (r:0 w:1)199 // Storage: Nonfungible Owned (r:0 w:1)205 // Storage: Nonfungible Owned (r:0 w:1)200 fn create_item() -> Weight {206 fn create_item() -> Weight {201 (20_328_000 as Weight)207 (20_909_000 as Weight)202 .saturating_add(RocksDbWeight::get().reads(2 as Weight))208 .saturating_add(RocksDbWeight::get().reads(2 as Weight))203 .saturating_add(RocksDbWeight::get().writes(4 as Weight))209 .saturating_add(RocksDbWeight::get().writes(4 as Weight))204 }210 }207 // Storage: Nonfungible TokenData (r:0 w:4)213 // Storage: Nonfungible TokenData (r:0 w:4)208 // Storage: Nonfungible Owned (r:0 w:4)214 // Storage: Nonfungible Owned (r:0 w:4)209 fn create_multiple_items(b: u32, ) -> Weight {215 fn create_multiple_items(b: u32, ) -> Weight {210 (10_134_000 as Weight)216 (12_601_000 as Weight)211 // Standard Error: 3_000217 // Standard Error: 1_000212 .saturating_add((4_927_000 as Weight).saturating_mul(b as Weight))218 .saturating_add((4_920_000 as Weight).saturating_mul(b as Weight))213 .saturating_add(RocksDbWeight::get().reads(2 as Weight))219 .saturating_add(RocksDbWeight::get().reads(2 as Weight))214 .saturating_add(RocksDbWeight::get().writes(2 as Weight))220 .saturating_add(RocksDbWeight::get().writes(2 as Weight))215 .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))221 .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))219 // Storage: Nonfungible TokenData (r:0 w:4)225 // Storage: Nonfungible TokenData (r:0 w:4)220 // Storage: Nonfungible Owned (r:0 w:4)226 // Storage: Nonfungible Owned (r:0 w:4)221 fn create_multiple_items_ex(b: u32, ) -> Weight {227 fn create_multiple_items_ex(b: u32, ) -> Weight {222 (5_710_000 as Weight)228 (0 as Weight)223 // Standard Error: 4_000229 // Standard Error: 3_000224 .saturating_add((7_578_000 as Weight).saturating_mul(b as Weight))230 .saturating_add((7_734_000 as Weight).saturating_mul(b as Weight))225 .saturating_add(RocksDbWeight::get().reads(1 as Weight))231 .saturating_add(RocksDbWeight::get().reads(1 as Weight))226 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))232 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))227 .saturating_add(RocksDbWeight::get().writes(1 as Weight))233 .saturating_add(RocksDbWeight::get().writes(1 as Weight))235 // Storage: Nonfungible Owned (r:0 w:1)241 // Storage: Nonfungible Owned (r:0 w:1)236 // Storage: Nonfungible TokenProperties (r:0 w:1)242 // Storage: Nonfungible TokenProperties (r:0 w:1)237 fn burn_item() -> Weight {243 fn burn_item() -> Weight {238 (28_433_000 as Weight)244 (29_746_000 as Weight)239 .saturating_add(RocksDbWeight::get().reads(5 as Weight))245 .saturating_add(RocksDbWeight::get().reads(5 as Weight))240 .saturating_add(RocksDbWeight::get().writes(5 as Weight))246 .saturating_add(RocksDbWeight::get().writes(5 as Weight))241 }247 }247 // Storage: Nonfungible Owned (r:0 w:1)253 // Storage: Nonfungible Owned (r:0 w:1)248 // Storage: Nonfungible TokenProperties (r:0 w:1)254 // Storage: Nonfungible TokenProperties (r:0 w:1)249 fn burn_recursively_self_raw() -> Weight {255 fn burn_recursively_self_raw() -> Weight {250 (34_435_000 as Weight)256 (36_077_000 as Weight)251 .saturating_add(RocksDbWeight::get().reads(5 as Weight))257 .saturating_add(RocksDbWeight::get().reads(5 as Weight))252 .saturating_add(RocksDbWeight::get().writes(5 as Weight))258 .saturating_add(RocksDbWeight::get().writes(5 as Weight))253 }259 }261 // Storage: Common CollectionById (r:1 w:0)267 // Storage: Common CollectionById (r:1 w:0)262 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {268 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {263 (0 as Weight)269 (0 as Weight)264 // Standard Error: 1_539_000270 // Standard Error: 1_605_000265 .saturating_add((304_456_000 as Weight).saturating_mul(b as Weight))271 .saturating_add((312_391_000 as Weight).saturating_mul(b as Weight))266 .saturating_add(RocksDbWeight::get().reads(7 as Weight))272 .saturating_add(RocksDbWeight::get().reads(7 as Weight))267 .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))273 .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))268 .saturating_add(RocksDbWeight::get().writes(6 as Weight))274 .saturating_add(RocksDbWeight::get().writes(6 as Weight))273 // Storage: Nonfungible Allowance (r:1 w:0)279 // Storage: Nonfungible Allowance (r:1 w:0)274 // Storage: Nonfungible Owned (r:0 w:2)280 // Storage: Nonfungible Owned (r:0 w:2)275 fn transfer() -> Weight {281 fn transfer() -> Weight {276 (24_376_000 as Weight)282 (25_248_000 as Weight)277 .saturating_add(RocksDbWeight::get().reads(4 as Weight))283 .saturating_add(RocksDbWeight::get().reads(4 as Weight))278 .saturating_add(RocksDbWeight::get().writes(5 as Weight))284 .saturating_add(RocksDbWeight::get().writes(5 as Weight))279 }285 }280 // Storage: Nonfungible TokenData (r:1 w:0)286 // Storage: Nonfungible TokenData (r:1 w:0)281 // Storage: Nonfungible Allowance (r:1 w:1)287 // Storage: Nonfungible Allowance (r:1 w:1)282 fn approve() -> Weight {288 fn approve() -> Weight {283 (15_890_000 as Weight)289 (16_321_000 as Weight)284 .saturating_add(RocksDbWeight::get().reads(2 as Weight))290 .saturating_add(RocksDbWeight::get().reads(2 as Weight))285 .saturating_add(RocksDbWeight::get().writes(1 as Weight))291 .saturating_add(RocksDbWeight::get().writes(1 as Weight))286 }292 }289 // Storage: Nonfungible AccountBalance (r:2 w:2)295 // Storage: Nonfungible AccountBalance (r:2 w:2)290 // Storage: Nonfungible Owned (r:0 w:2)296 // Storage: Nonfungible Owned (r:0 w:2)291 fn transfer_from() -> Weight {297 fn transfer_from() -> Weight {292 (28_634_000 as Weight)298 (29_325_000 as Weight)293 .saturating_add(RocksDbWeight::get().reads(4 as Weight))299 .saturating_add(RocksDbWeight::get().reads(4 as Weight))294 .saturating_add(RocksDbWeight::get().writes(6 as Weight))300 .saturating_add(RocksDbWeight::get().writes(6 as Weight))295 }301 }301 // Storage: Nonfungible Owned (r:0 w:1)307 // Storage: Nonfungible Owned (r:0 w:1)302 // Storage: Nonfungible TokenProperties (r:0 w:1)308 // Storage: Nonfungible TokenProperties (r:0 w:1)303 fn burn_from() -> Weight {309 fn burn_from() -> Weight {304 (32_201_000 as Weight)310 (33_323_000 as Weight)305 .saturating_add(RocksDbWeight::get().reads(5 as Weight))311 .saturating_add(RocksDbWeight::get().reads(5 as Weight))306 .saturating_add(RocksDbWeight::get().writes(6 as Weight))312 .saturating_add(RocksDbWeight::get().writes(6 as Weight))307 }313 }308 // Storage: Common CollectionPropertyPermissions (r:1 w:1)314 // Storage: Common CollectionPropertyPermissions (r:1 w:1)309 fn set_token_property_permissions(b: u32, ) -> Weight {315 fn set_token_property_permissions(b: u32, ) -> Weight {310 (0 as Weight)316 (0 as Weight)311 // Standard Error: 57_000317 // Standard Error: 62_000312 .saturating_add((15_232_000 as Weight).saturating_mul(b as Weight))318 .saturating_add((16_222_000 as Weight).saturating_mul(b as Weight))313 .saturating_add(RocksDbWeight::get().reads(1 as Weight))319 .saturating_add(RocksDbWeight::get().reads(1 as Weight))314 .saturating_add(RocksDbWeight::get().writes(1 as Weight))320 .saturating_add(RocksDbWeight::get().writes(1 as Weight))315 }321 }316 // Storage: Common CollectionPropertyPermissions (r:1 w:0)322 // Storage: Common CollectionPropertyPermissions (r:1 w:0)317 // Storage: Nonfungible TokenProperties (r:1 w:1)323 // Storage: Nonfungible TokenProperties (r:1 w:1)318 fn set_token_properties(b: u32, ) -> Weight {324 fn set_token_properties(b: u32, ) -> Weight {319 (0 as Weight)325 (0 as Weight)320 // Standard Error: 1_648_000326 // Standard Error: 1_750_000321 .saturating_add((288_654_000 as Weight).saturating_mul(b as Weight))327 .saturating_add((304_476_000 as Weight).saturating_mul(b as Weight))322 .saturating_add(RocksDbWeight::get().reads(2 as Weight))328 .saturating_add(RocksDbWeight::get().reads(2 as Weight))323 .saturating_add(RocksDbWeight::get().writes(1 as Weight))329 .saturating_add(RocksDbWeight::get().writes(1 as Weight))324 }330 }325 // Storage: Common CollectionPropertyPermissions (r:1 w:0)331 // Storage: Common CollectionPropertyPermissions (r:1 w:0)326 // Storage: Nonfungible TokenProperties (r:1 w:1)332 // Storage: Nonfungible TokenProperties (r:1 w:1)327 fn delete_token_properties(b: u32, ) -> Weight {333 fn delete_token_properties(b: u32, ) -> Weight {328 (0 as Weight)334 (0 as Weight)329 // Standard Error: 1_632_000335 // Standard Error: 1_638_000330 .saturating_add((289_190_000 as Weight).saturating_mul(b as Weight))336 .saturating_add((294_096_000 as Weight).saturating_mul(b as Weight))331 .saturating_add(RocksDbWeight::get().reads(2 as Weight))337 .saturating_add(RocksDbWeight::get().reads(2 as Weight))332 .saturating_add(RocksDbWeight::get().writes(1 as Weight))338 .saturating_add(RocksDbWeight::get().writes(1 as Weight))333 }339 }340 // Storage: Nonfungible TokenData (r:1 w:0)341 fn token_owner() -> Weight {342 (2_986_000 as Weight)343 .saturating_add(RocksDbWeight::get().reads(1 as Weight))344 }334}345}335346pallets/refungible/src/benchmarking.rsdiffbeforeafterboth17use super::*;17use super::*;18use crate::{Pallet, Config, RefungibleHandle};18use crate::{Pallet, Config, RefungibleHandle};191920use sp_std::prelude::*;20use core::convert::TryInto;21use pallet_common::benchmarking::{create_collection_raw, property_key, property_value, create_data};21use core::iter::IntoIterator;22use frame_benchmarking::{benchmarks, account};22use frame_benchmarking::{benchmarks, account};23use up_data_structs::{23use pallet_common::{24 CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, CUSTOM_DATA_LIMIT,24 bench_init,25 budget::Unlimited,25 benchmarking::{create_collection_raw, property_key, property_value, create_data},26};26};27use pallet_common::bench_init;27use sp_core::H160;28use core::convert::TryInto;28use sp_std::prelude::*;29use core::iter::IntoIterator;29use up_data_structs::{30 CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, CUSTOM_DATA_LIMIT,31 budget::Unlimited,32};303331const SEED: u32 = 1;34const SEED: u32 = 1;323533fn create_max_item_data<CrossAccountId: Ord>(36fn create_max_item_data<CrossAccountId: Ord>(34 users: impl IntoIterator<Item = (CrossAccountId, u128)>,37 users: impl IntoIterator<Item = (CrossAccountId, u128)>,35) -> CreateRefungibleExData<CrossAccountId> {38) -> CreateRefungibleExData<CrossAccountId> {36 let const_data = create_data::<CUSTOM_DATA_LIMIT>();37 CreateRefungibleExData {39 CreateRefungibleExData {38 const_data,39 users: users40 users: users40 .into_iter()41 .into_iter()41 .collect::<BTreeMap<_, _>>()42 .collect::<BTreeMap<_, _>>()59) -> Result<RefungibleHandle<T>, DispatchError> {61) -> Result<RefungibleHandle<T>, DispatchError> {60 create_collection_raw(62 create_collection_raw(61 owner,63 owner,62 CollectionMode::NFT,64 CollectionMode::ReFungible,63 <Pallet<T>>::init_collection,65 <Pallet<T>>::init_collection,64 RefungibleHandle::cast,66 RefungibleHandle::cast,65 )67 )278 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;281 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;279 }: {<Pallet<T>>::repartition(&collection, &owner, item, 200)?}282 }: {<Pallet<T>>::repartition(&collection, &owner, item, 200)?}283284 set_parent_nft_unchecked {285 bench_init!{286 owner: sub; collection: collection(owner);287 sender: cross_from_sub(owner); owner: cross_sub;288 };289 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;290291 }: {<Pallet<T>>::set_parent_nft_unchecked(&collection, item, owner, T::CrossAccountId::from_eth(H160::default()))?}292293 token_owner {294 bench_init!{295 owner: sub; collection: collection(owner);296 sender: cross_from_sub(owner); owner: cross_sub;297 };298 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;299 }: {<Pallet<T>>::token_owner(collection.id, item)}280}300}281301pallets/refungible/src/common.rsdiffbeforeafterboth149 0149 0150 }150 }151152 fn token_owner() -> Weight {153 <SelfWeightOf<T>>::token_owner()154 }151}155}152156153fn map_create_data<T: Config>(157fn map_create_data<T: Config>(pallets/refungible/src/erc.rsdiffbeforeafterboth41use sp_core::H160;41use sp_core::H160;42use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};42use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};43use up_data_structs::{43use up_data_structs::{44 CollectionId, CollectionPropertiesVec, Property, PropertyKey, PropertyKeyPermission,44 CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,45 PropertyPermission, TokenId,45 PropertyKeyPermission, PropertyPermission, TokenId,46};46};4747413}413}414414415/// Returns amount of pieces of `token` that `owner` have415/// Returns amount of pieces of `token` that `owner` have416fn balance<T: Config>(416pub fn balance<T: Config>(417 collection: &RefungibleHandle<T>,417 collection: &RefungibleHandle<T>,418 token: TokenId,418 token: TokenId,419 owner: &T::CrossAccountId,419 owner: &T::CrossAccountId,424}424}425425426/// Throws if `owner_balance` is lower than total amount of `token` pieces426/// Throws if `owner_balance` is lower than total amount of `token` pieces427fn ensure_single_owner<T: Config>(427pub fn ensure_single_owner<T: Config>(428 collection: &RefungibleHandle<T>,428 collection: &RefungibleHandle<T>,429 token: TokenId,429 token: TokenId,430 owner_balance: u128,430 owner_balance: u128,789 Ok(true)789 Ok(true)790 }790 }791792 /// Returns EVM address for refungible token793 ///794 /// @param token ID of the token795 fn token_contract_address(&self, token: uint256) -> Result<address> {796 Ok(T::EvmTokenAddressMapping::token_to_address(797 self.id,798 token.try_into().map_err(|_| "token id overflow")?,799 ))800 }791}801}792802793#[solidity_interface(803#[solidity_interface(pallets/refungible/src/erc_token.rsdiffbeforeafterboth212122extern crate alloc;22extern crate alloc;2324#[cfg(not(feature = "std"))]25use alloc::format;2623use core::{27use core::{24 char::{REPLACEMENT_CHARACTER, decode_utf16},28 char::{REPLACEMENT_CHARACTER, decode_utf16},25 convert::TryInto,29 convert::TryInto,26 ops::Deref,30 ops::Deref,27};31};28use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};32use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};29use pallet_common::{33use pallet_common::{30 CommonWeightInfo,34 CommonWeightInfo,31 erc::{CommonEvmHandler, PrecompileResult},35 erc::{CommonEvmHandler, PrecompileResult, static_property::key},36 eth::map_eth_to_id,32};37};33use pallet_evm::{account::CrossAccountId, PrecompileHandle};38use pallet_evm::{account::CrossAccountId, PrecompileHandle};34use pallet_evm_coder_substrate::{call, dispatch_to_evm, WithRecorder};39use pallet_evm_coder_substrate::{call, dispatch_to_evm, WithRecorder};35use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};40use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};41use sp_core::H160;36use sp_std::vec::Vec;42use sp_std::vec::Vec;37use up_data_structs::TokenId;43use up_data_structs::{mapping::TokenAddressMapping, PropertyScope, TokenId};384439use crate::{45use crate::{40 Allowance, Balance, common::CommonWeights, Config, Pallet, RefungibleHandle, SelfWeightOf,46 Allowance, Balance, common::CommonWeights, Config, Pallet, RefungibleHandle, SelfWeightOf,41 weights::WeightInfo, TotalSupply,47 TokenProperties, TotalSupply, weights::WeightInfo,42};48};434944pub struct RefungibleTokenHandle<T: Config>(pub RefungibleHandle<T>, pub TokenId);50pub struct RefungibleTokenHandle<T: Config>(pub RefungibleHandle<T>, pub TokenId);5152#[solidity_interface(name = "ERC1633")]53impl<T: Config> RefungibleTokenHandle<T> {54 fn parent_token(&self) -> Result<address> {55 self.consume_store_reads(2)?;56 let props = <TokenProperties<T>>::get((self.id, self.1));57 let key = key::parent_nft();5859 let key_scoped = PropertyScope::Eth60 .apply(key)61 .expect("property key shouldn't exceed length limit");62 if let Some(value) = props.get(&key_scoped) {63 Ok(H160::from_slice(value.as_slice()))64 } else {65 Ok(*T::CrossTokenAddressMapping::token_to_address(self.id, self.1).as_eth())66 }67 }6869 fn parent_token_id(&self) -> Result<uint256> {70 self.consume_store_reads(2)?;71 let props = <TokenProperties<T>>::get((self.id, self.1));72 let key = key::parent_nft();7374 let key_scoped = PropertyScope::Eth75 .apply(key)76 .expect("property key shouldn't exceed length limit");77 if let Some(value) = props.get(&key_scoped) {78 let nft_token_address = H160::from_slice(value.as_slice());79 let nft_token_account = T::CrossAccountId::from_eth(nft_token_address);80 let (_, token_id) = T::CrossTokenAddressMapping::address_to_token(&nft_token_account)81 .ok_or("parent NFT should contain NFT token address")?;8283 Ok(token_id.into())84 } else {85 Ok(self.1.into())86 }87 }88}8990#[solidity_interface(name = "ERC1633UniqueExtensions")]91impl<T: Config> RefungibleTokenHandle<T> {92 #[solidity(rename_selector = "setParentNFT")]93 #[weight(<CommonWeights<T>>::token_owner() + <SelfWeightOf<T>>::set_parent_nft_unchecked())]94 fn set_parent_nft(95 &mut self,96 caller: caller,97 collection: address,98 nft_id: uint256,99 ) -> Result<bool> {100 self.consume_store_reads(1)?;101 let caller = T::CrossAccountId::from_eth(caller);102 let nft_collection = map_eth_to_id(&collection).ok_or("collection not found")?;103 let nft_token = nft_id.try_into()?;104105 <Pallet<T>>::set_parent_nft(&self.0, self.1, caller, nft_collection, nft_token)106 .map_err(dispatch_to_evm::<T>)?;107108 Ok(true)109 }110}4511146#[derive(ToLog)]112#[derive(ToLog)]47pub enum ERC20Events {113pub enum ERC20Events {120 .weight_calls_budget(<StructureWeight<T>>::find_parent());186 .weight_calls_budget(<StructureWeight<T>>::find_parent());121187122 <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)188 <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)123 .map_err(|_| "transfer error")?;189 .map_err(dispatch_to_evm::<T>)?;124 Ok(true)190 Ok(true)125 }191 }126192241307242#[solidity_interface(name = "UniqueRefungibleToken", is(ERC20, ERC20UniqueExtensions,))]308#[solidity_interface(309 name = "UniqueRefungibleToken",310 is(ERC20, ERC20UniqueExtensions, ERC1633, ERC1633UniqueExtensions)311)]243impl<T: Config> RefungibleTokenHandle<T> where T::AccountId: From<[u8; 32]> {}312impl<T: Config> RefungibleTokenHandle<T> where T::AccountId: From<[u8; 32]> {}244313pallets/refungible/src/lib.rsdiffbeforeafterboth99use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};99use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};100use pallet_evm_coder_substrate::WithRecorder;100use pallet_evm_coder_substrate::WithRecorder;101use pallet_common::{101use pallet_common::{102 CommonCollectionOperations, Error as CommonError, Event as CommonEvent,102 CollectionHandle, CommonCollectionOperations,103 dispatch::CollectionDispatch,104 erc::static_property::{key, property_value_from_bytes},105 Error as CommonError,103 eth::collection_id_to_address, Pallet as PalletCommon,106 eth::collection_id_to_address,107 Event as CommonEvent, Pallet as PalletCommon,104};108};105use pallet_structure::Pallet as PalletStructure;109use pallet_structure::Pallet as PalletStructure;106use scale_info::TypeInfo;110use scale_info::TypeInfo;107use sp_core::H160;111use sp_core::H160;108use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};112use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};109use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};113use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};110use up_data_structs::{114use up_data_structs::{111 AccessMode, budget::Budget, CollectionId, CreateCollectionData, CustomDataLimit,115 AccessMode, budget::Budget, CollectionId, CollectionMode, CollectionPropertiesVec,112 mapping::TokenAddressMapping, MAX_REFUNGIBLE_PIECES, MAX_ITEMS_PER_BATCH, TokenId, Property,116 CreateCollectionData, CustomDataLimit, mapping::TokenAddressMapping, MAX_ITEMS_PER_BATCH,113 PropertyKey, PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue,117 MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission, PropertyPermission,114 TrySetProperty, CollectionPropertiesVec,118 PropertyScope, PropertyValue, TokenId, TrySetProperty,115};119};116use frame_support::BoundedBTreeMap;120use frame_support::BoundedBTreeMap;117use derivative::Derivative;121use derivative::Derivative;1341 <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)1345 <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)1342 }1346 }13471348 pub fn set_scoped_token_property_permissions(1349 collection: &RefungibleHandle<T>,1350 sender: &T::CrossAccountId,1351 scope: PropertyScope,1352 property_permissions: Vec<PropertyKeyPermission>,1353 ) -> DispatchResult {1354 <PalletCommon<T>>::set_scoped_token_property_permissions(1355 collection,1356 sender,1357 scope,1358 property_permissions,1359 )1360 }134313611344 /// Returns 10 token in no particular order.1362 /// Returns 10 token in no particular order.1345 ///1363 ///1363 }1381 }1364 }1382 }13831384 /// Sets the NFT token as a parent for the RFT token1385 ///1386 /// Throws if `sender` is not the owner of the NFT token.1387 /// Throws if `sender` is not the owner of all of the RFT token pieces.1388 pub fn set_parent_nft(1389 collection: &RefungibleHandle<T>,1390 rft_token_id: TokenId,1391 sender: T::CrossAccountId,1392 nft_collection: CollectionId,1393 nft_token: TokenId,1394 ) -> DispatchResult {1395 let handle = <CollectionHandle<T>>::try_get(nft_collection)?;1396 if handle.mode != CollectionMode::NFT {1397 return Err("Only NFT token could be parent to RFT".into());1398 }1399 let dispatch = T::CollectionDispatch::dispatch(handle);1400 let dispatch = dispatch.as_dyn();14011402 let owner = dispatch.token_owner(nft_token).ok_or("owner not found")?;1403 if owner != sender {1404 return Err("Only owned token could be set as parent".into());1405 }14061407 let nft_token_address =1408 T::CrossTokenAddressMapping::token_to_address(nft_collection, nft_token);14091410 Self::set_parent_nft_unchecked(collection, rft_token_id, sender, nft_token_address)1411 }14121413 /// Sets the NFT token as a parent for the RFT token1414 ///1415 /// `sender` should be the owner of the NFT token.1416 /// Throws if `sender` is not the owner of all of the RFT token pieces.1417 pub fn set_parent_nft_unchecked(1418 collection: &RefungibleHandle<T>,1419 rft_token_id: TokenId,1420 sender: T::CrossAccountId,1421 nft_token_address: T::CrossAccountId,1422 ) -> DispatchResult {1423 let owner_balance = <Balance<T>>::get((collection.id, rft_token_id, &sender));1424 let total_supply = <TotalSupply<T>>::get((collection.id, rft_token_id));1425 if total_supply != owner_balance {1426 return Err("token has multiple owners".into());1427 }14281429 let parent_nft_property_key = key::parent_nft();14301431 let parent_nft_property_value =1432 property_value_from_bytes(&nft_token_address.as_eth().to_fixed_bytes())1433 .expect("address should fit in value length limit");14341435 <Pallet<T>>::set_scoped_token_property(1436 collection.id,1437 rft_token_id,1438 PropertyScope::Eth,1439 Property {1440 key: parent_nft_property_key,1441 value: parent_nft_property_value,1442 },1443 )?;14441445 Ok(())1446 }1365}1447}13661448pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth371 }371 }372}372}373374// Selector: 6cf113cd375contract Collection is Dummy, ERC165 {376 // Set collection property.377 //378 // @param key Property key.379 // @param value Propery value.380 //381 // Selector: setCollectionProperty(string,bytes) 2f073f66382 function setCollectionProperty(string memory key, bytes memory value)383 public384 {385 require(false, stub_error);386 key;387 value;388 dummy = 0;389 }390391 // Delete collection property.392 //393 // @param key Property key.394 //395 // Selector: deleteCollectionProperty(string) 7b7debce396 function deleteCollectionProperty(string memory key) public {397 require(false, stub_error);398 key;399 dummy = 0;400 }401402 // Get collection property.403 //404 // @dev Throws error if key not found.405 //406 // @param key Property key.407 // @return bytes The property corresponding to the key.408 //409 // Selector: collectionProperty(string) cf24fd6d410 function collectionProperty(string memory key)411 public412 view413 returns (bytes memory)414 {415 require(false, stub_error);416 key;417 dummy;418 return hex"";419 }420421 // Set the sponsor of the collection.422 //423 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.424 //425 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.426 //427 // Selector: setCollectionSponsor(address) 7623402e428 function setCollectionSponsor(address sponsor) public {429 require(false, stub_error);430 sponsor;431 dummy = 0;432 }433434 // Collection sponsorship confirmation.435 //436 // @dev After setting the sponsor for the collection, it must be confirmed with this function.437 //438 // Selector: confirmCollectionSponsorship() 3c50e97a439 function confirmCollectionSponsorship() public {440 require(false, stub_error);441 dummy = 0;442 }443444 // Set limits for the collection.445 // @dev Throws error if limit not found.446 // @param limit Name of the limit. Valid names:447 // "accountTokenOwnershipLimit",448 // "sponsoredDataSize",449 // "sponsoredDataRateLimit",450 // "tokenLimit",451 // "sponsorTransferTimeout",452 // "sponsorApproveTimeout"453 // @param value Value of the limit.454 //455 // Selector: setCollectionLimit(string,uint32) 6a3841db456 function setCollectionLimit(string memory limit, uint32 value) public {457 require(false, stub_error);458 limit;459 value;460 dummy = 0;461 }462463 // Set limits for the collection.464 // @dev Throws error if limit not found.465 // @param limit Name of the limit. Valid names:466 // "ownerCanTransfer",467 // "ownerCanDestroy",468 // "transfersEnabled"469 // @param value Value of the limit.470 //471 // Selector: setCollectionLimit(string,bool) 993b7fba472 function setCollectionLimit(string memory limit, bool value) public {473 require(false, stub_error);474 limit;475 value;476 dummy = 0;477 }478479 // Get contract address.480 //481 // Selector: contractAddress() f6b4dfb4482 function contractAddress() public view returns (address) {483 require(false, stub_error);484 dummy;485 return 0x0000000000000000000000000000000000000000;486 }487488 // Add collection admin by substrate address.489 // @param new_admin Substrate administrator address.490 //491 // Selector: addCollectionAdminSubstrate(uint256) 5730062b492 function addCollectionAdminSubstrate(uint256 newAdmin) public {493 require(false, stub_error);494 newAdmin;495 dummy = 0;496 }497498 // Remove collection admin by substrate address.499 // @param admin Substrate administrator address.500 //501 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9502 function removeCollectionAdminSubstrate(uint256 admin) public {503 require(false, stub_error);504 admin;505 dummy = 0;506 }507508 // Add collection admin.509 // @param new_admin Address of the added administrator.510 //511 // Selector: addCollectionAdmin(address) 92e462c7512 function addCollectionAdmin(address newAdmin) public {513 require(false, stub_error);514 newAdmin;515 dummy = 0;516 }517518 // Remove collection admin.519 //520 // @param new_admin Address of the removed administrator.521 //522 // Selector: removeCollectionAdmin(address) fafd7b42523 function removeCollectionAdmin(address admin) public {524 require(false, stub_error);525 admin;526 dummy = 0;527 }528529 // Toggle accessibility of collection nesting.530 //531 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'532 //533 // Selector: setCollectionNesting(bool) 112d4586534 function setCollectionNesting(bool enable) public {535 require(false, stub_error);536 enable;537 dummy = 0;538 }539540 // Toggle accessibility of collection nesting.541 //542 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'543 // @param collections Addresses of collections that will be available for nesting.544 //545 // Selector: setCollectionNesting(bool,address[]) 64872396546 function setCollectionNesting(bool enable, address[] memory collections)547 public548 {549 require(false, stub_error);550 enable;551 collections;552 dummy = 0;553 }554555 // Set the collection access method.556 // @param mode Access mode557 // 0 for Normal558 // 1 for AllowList559 //560 // Selector: setCollectionAccess(uint8) 41835d4c561 function setCollectionAccess(uint8 mode) public {562 require(false, stub_error);563 mode;564 dummy = 0;565 }566567 // Add the user to the allowed list.568 //569 // @param user Address of a trusted user.570 //571 // Selector: addToCollectionAllowList(address) 67844fe6572 function addToCollectionAllowList(address user) public {573 require(false, stub_error);574 user;575 dummy = 0;576 }577578 // Remove the user from the allowed list.579 //580 // @param user Address of a removed user.581 //582 // Selector: removeFromCollectionAllowList(address) 85c51acb583 function removeFromCollectionAllowList(address user) public {584 require(false, stub_error);585 user;586 dummy = 0;587 }588589 // Switch permission for minting.590 //591 // @param mode Enable if "true".592 //593 // Selector: setCollectionMintMode(bool) 00018e84594 function setCollectionMintMode(bool mode) public {595 require(false, stub_error);596 mode;597 dummy = 0;598 }599600 // Check that account is the owner or admin of the collection601 //602 // @param user account to verify603 // @return "true" if account is the owner or admin604 //605 // Selector: verifyOwnerOrAdmin(address) c2282493606 function verifyOwnerOrAdmin(address user) public view returns (bool) {607 require(false, stub_error);608 user;609 dummy;610 return false;611 }612613 // Returns collection type614 //615 // @return `Fungible` or `NFT` or `ReFungible`616 //617 // Selector: uniqueCollectionType() d34b55b8618 function uniqueCollectionType() public returns (string memory) {619 require(false, stub_error);620 dummy = 0;621 return "";622 }623}373624374// Selector: 780e9d63625// Selector: 780e9d63375contract ERC721Enumerable is Dummy, ERC165 {626contract ERC721Enumerable is Dummy, ERC165 {413 }664 }414}665}415666416// Selector: 7d9262e6667// Selector: 7c3bef89417contract Collection is Dummy, ERC165 {418 // Set collection property.419 //420 // @param key Property key.421 // @param value Propery value.422 //423 // Selector: setCollectionProperty(string,bytes) 2f073f66424 function setCollectionProperty(string memory key, bytes memory value)425 public426 {427 require(false, stub_error);428 key;429 value;430 dummy = 0;431 }432433 // Delete collection property.434 //435 // @param key Property key.436 //437 // Selector: deleteCollectionProperty(string) 7b7debce438 function deleteCollectionProperty(string memory key) public {439 require(false, stub_error);440 key;441 dummy = 0;442 }443444 // Get collection property.445 //446 // @dev Throws error if key not found.447 //448 // @param key Property key.449 // @return bytes The property corresponding to the key.450 //451 // Selector: collectionProperty(string) cf24fd6d452 function collectionProperty(string memory key)453 public454 view455 returns (bytes memory)456 {457 require(false, stub_error);458 key;459 dummy;460 return hex"";461 }462463 // Set the sponsor of the collection.464 //465 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.466 //467 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.468 //469 // Selector: setCollectionSponsor(address) 7623402e470 function setCollectionSponsor(address sponsor) public {471 require(false, stub_error);472 sponsor;473 dummy = 0;474 }475476 // Collection sponsorship confirmation.477 //478 // @dev After setting the sponsor for the collection, it must be confirmed with this function.479 //480 // Selector: confirmCollectionSponsorship() 3c50e97a481 function confirmCollectionSponsorship() public {482 require(false, stub_error);483 dummy = 0;484 }485486 // Set limits for the collection.487 // @dev Throws error if limit not found.488 // @param limit Name of the limit. Valid names:489 // "accountTokenOwnershipLimit",490 // "sponsoredDataSize",491 // "sponsoredDataRateLimit",492 // "tokenLimit",493 // "sponsorTransferTimeout",494 // "sponsorApproveTimeout"495 // @param value Value of the limit.496 //497 // Selector: setCollectionLimit(string,uint32) 6a3841db498 function setCollectionLimit(string memory limit, uint32 value) public {499 require(false, stub_error);500 limit;501 value;502 dummy = 0;503 }504505 // Set limits for the collection.506 // @dev Throws error if limit not found.507 // @param limit Name of the limit. Valid names:508 // "ownerCanTransfer",509 // "ownerCanDestroy",510 // "transfersEnabled"511 // @param value Value of the limit.512 //513 // Selector: setCollectionLimit(string,bool) 993b7fba514 function setCollectionLimit(string memory limit, bool value) public {515 require(false, stub_error);516 limit;517 value;518 dummy = 0;519 }520521 // Get contract address.522 //523 // Selector: contractAddress() f6b4dfb4524 function contractAddress() public view returns (address) {525 require(false, stub_error);526 dummy;527 return 0x0000000000000000000000000000000000000000;528 }529530 // Add collection admin by substrate address.531 // @param new_admin Substrate administrator address.532 //533 // Selector: addCollectionAdminSubstrate(uint256) 5730062b534 function addCollectionAdminSubstrate(uint256 newAdmin) public {535 require(false, stub_error);536 newAdmin;537 dummy = 0;538 }539540 // Remove collection admin by substrate address.541 // @param admin Substrate administrator address.542 //543 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9544 function removeCollectionAdminSubstrate(uint256 admin) public {545 require(false, stub_error);546 admin;547 dummy = 0;548 }549550 // Add collection admin.551 // @param new_admin Address of the added administrator.552 //553 // Selector: addCollectionAdmin(address) 92e462c7554 function addCollectionAdmin(address newAdmin) public {555 require(false, stub_error);556 newAdmin;557 dummy = 0;558 }559560 // Remove collection admin.561 //562 // @param new_admin Address of the removed administrator.563 //564 // Selector: removeCollectionAdmin(address) fafd7b42565 function removeCollectionAdmin(address admin) public {566 require(false, stub_error);567 admin;568 dummy = 0;569 }570571 // Toggle accessibility of collection nesting.572 //573 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'574 //575 // Selector: setCollectionNesting(bool) 112d4586576 function setCollectionNesting(bool enable) public {577 require(false, stub_error);578 enable;579 dummy = 0;580 }581582 // Toggle accessibility of collection nesting.583 //584 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'585 // @param collections Addresses of collections that will be available for nesting.586 //587 // Selector: setCollectionNesting(bool,address[]) 64872396588 function setCollectionNesting(bool enable, address[] memory collections)589 public590 {591 require(false, stub_error);592 enable;593 collections;594 dummy = 0;595 }596597 // Set the collection access method.598 // @param mode Access mode599 // 0 for Normal600 // 1 for AllowList601 //602 // Selector: setCollectionAccess(uint8) 41835d4c603 function setCollectionAccess(uint8 mode) public {604 require(false, stub_error);605 mode;606 dummy = 0;607 }608609 // Add the user to the allowed list.610 //611 // @param user Address of a trusted user.612 //613 // Selector: addToCollectionAllowList(address) 67844fe6614 function addToCollectionAllowList(address user) public {615 require(false, stub_error);616 user;617 dummy = 0;618 }619620 // Remove the user from the allowed list.621 //622 // @param user Address of a removed user.623 //624 // Selector: removeFromCollectionAllowList(address) 85c51acb625 function removeFromCollectionAllowList(address user) public {626 require(false, stub_error);627 user;628 dummy = 0;629 }630631 // Switch permission for minting.632 //633 // @param mode Enable if "true".634 //635 // Selector: setCollectionMintMode(bool) 00018e84636 function setCollectionMintMode(bool mode) public {637 require(false, stub_error);638 mode;639 dummy = 0;640 }641}642643// Selector: d74d154f644contract ERC721UniqueExtensions is Dummy, ERC165 {668contract ERC721UniqueExtensions is Dummy, ERC165 {645 // @notice Transfer ownership of an RFT669 // @notice Transfer ownership of an RFT646 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`670 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`720 return false;744 return false;721 }745 }746747 // Returns EVM address for refungible token748 //749 // @param token ID of the token750 //751 // Selector: tokenContractAddress(uint256) ab76fac6752 function tokenContractAddress(uint256 token) public view returns (address) {753 require(false, stub_error);754 token;755 dummy;756 return 0x0000000000000000000000000000000000000000;757 }722}758}723759724contract UniqueRefungible is760contract UniqueRefungible ispallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth31 );31 );32}32}3334// Selector: 042f110635contract ERC1633UniqueExtensions is Dummy, ERC165 {36 // Selector: setParentNFT(address,uint256) 042f110637 function setParentNFT(address collection, uint256 nftId)38 public39 returns (bool)40 {41 require(false, stub_error);42 collection;43 nftId;44 dummy = 0;45 return false;46 }47}4849// Selector: 5755c3f250contract ERC1633 is Dummy, ERC165 {51 // Selector: parentToken() 80a5400152 function parentToken() public view returns (address) {53 require(false, stub_error);54 dummy;55 return 0x0000000000000000000000000000000000000000;56 }5758 // Selector: parentTokenId() d7f083f359 function parentTokenId() public view returns (uint256) {60 require(false, stub_error);61 dummy;62 return 0;63 }64}336534// Selector: 942e8b2266// Selector: 942e8b2235contract ERC20 is Dummy, ERC165, ERC20Events {67contract ERC20 is Dummy, ERC165, ERC20Events {214 Dummy,215 ERC165,216 ERC20,217 ERC20UniqueExtensions,218 ERC1633,219 ERC1633UniqueExtensions220{}182221pallets/refungible/src/weights.rsdiffbeforeafterboth3//! Autogenerated weights for pallet_refungible3//! Autogenerated weights for pallet_refungible4//!4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-07-20, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2022-08-01, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10247//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024889// Executed Command:9// Executed Command:53 fn set_token_properties(b: u32, ) -> Weight;53 fn set_token_properties(b: u32, ) -> Weight;54 fn delete_token_properties(b: u32, ) -> Weight;54 fn delete_token_properties(b: u32, ) -> Weight;55 fn repartition_item() -> Weight;55 fn repartition_item() -> Weight;56 fn set_parent_nft_unchecked() -> Weight;57 fn token_owner() -> Weight;56}58}575958/// Weights for pallet_refungible using the Substrate node and recommended hardware.60/// Weights for pallet_refungible using the Substrate node and recommended hardware.65 // Storage: Refungible TokenData (r:0 w:1)67 // Storage: Refungible TokenData (r:0 w:1)66 // Storage: Refungible Owned (r:0 w:1)68 // Storage: Refungible Owned (r:0 w:1)67 fn create_item() -> Weight {69 fn create_item() -> Weight {68 (21_310_000 as Weight)70 (25_197_000 as Weight)69 .saturating_add(T::DbWeight::get().reads(2 as Weight))71 .saturating_add(T::DbWeight::get().reads(2 as Weight))70 .saturating_add(T::DbWeight::get().writes(6 as Weight))72 .saturating_add(T::DbWeight::get().writes(6 as Weight))71 }73 }76 // Storage: Refungible TokenData (r:0 w:4)78 // Storage: Refungible TokenData (r:0 w:4)77 // Storage: Refungible Owned (r:0 w:4)79 // Storage: Refungible Owned (r:0 w:4)78 fn create_multiple_items(b: u32, ) -> Weight {80 fn create_multiple_items(b: u32, ) -> Weight {79 (9_552_000 as Weight)81 (10_852_000 as Weight)80 // Standard Error: 2_00082 // Standard Error: 2_00081 .saturating_add((7_056_000 as Weight).saturating_mul(b as Weight))83 .saturating_add((8_087_000 as Weight).saturating_mul(b as Weight))82 .saturating_add(T::DbWeight::get().reads(2 as Weight))84 .saturating_add(T::DbWeight::get().reads(2 as Weight))83 .saturating_add(T::DbWeight::get().writes(2 as Weight))85 .saturating_add(T::DbWeight::get().writes(2 as Weight))84 .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))86 .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))90 // Storage: Refungible TokenData (r:0 w:4)92 // Storage: Refungible TokenData (r:0 w:4)91 // Storage: Refungible Owned (r:0 w:4)93 // Storage: Refungible Owned (r:0 w:4)92 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {94 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {93 (4_857_000 as Weight)95 (9_978_000 as Weight)94 // Standard Error: 2_00096 // Standard Error: 2_00095 .saturating_add((9_838_000 as Weight).saturating_mul(b as Weight))97 .saturating_add((10_848_000 as Weight).saturating_mul(b as Weight))96 .saturating_add(T::DbWeight::get().reads(1 as Weight))98 .saturating_add(T::DbWeight::get().reads(1 as Weight))97 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))99 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))98 .saturating_add(T::DbWeight::get().writes(1 as Weight))100 .saturating_add(T::DbWeight::get().writes(1 as Weight))105 // Storage: Refungible Balance (r:0 w:4)107 // Storage: Refungible Balance (r:0 w:4)106 // Storage: Refungible Owned (r:0 w:4)108 // Storage: Refungible Owned (r:0 w:4)107 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {109 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {108 (11_335_000 as Weight)110 (15_419_000 as Weight)109 // Standard Error: 2_000111 // Standard Error: 2_000110 .saturating_add((6_784_000 as Weight).saturating_mul(b as Weight))112 .saturating_add((7_813_000 as Weight).saturating_mul(b as Weight))111 .saturating_add(T::DbWeight::get().reads(1 as Weight))113 .saturating_add(T::DbWeight::get().reads(1 as Weight))112 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))114 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))113 .saturating_add(T::DbWeight::get().writes(3 as Weight))115 .saturating_add(T::DbWeight::get().writes(3 as Weight))118 // Storage: Refungible AccountBalance (r:1 w:1)120 // Storage: Refungible AccountBalance (r:1 w:1)119 // Storage: Refungible Owned (r:0 w:1)121 // Storage: Refungible Owned (r:0 w:1)120 fn burn_item_partial() -> Weight {122 fn burn_item_partial() -> Weight {121 (21_239_000 as Weight)123 (25_578_000 as Weight)122 .saturating_add(T::DbWeight::get().reads(3 as Weight))124 .saturating_add(T::DbWeight::get().reads(3 as Weight))123 .saturating_add(T::DbWeight::get().writes(4 as Weight))125 .saturating_add(T::DbWeight::get().writes(4 as Weight))124 }126 }130 // Storage: Refungible Owned (r:0 w:1)132 // Storage: Refungible Owned (r:0 w:1)131 // Storage: Refungible TokenProperties (r:0 w:1)133 // Storage: Refungible TokenProperties (r:0 w:1)132 fn burn_item_fully() -> Weight {134 fn burn_item_fully() -> Weight {133 (29_426_000 as Weight)135 (33_593_000 as Weight)134 .saturating_add(T::DbWeight::get().reads(4 as Weight))136 .saturating_add(T::DbWeight::get().reads(4 as Weight))135 .saturating_add(T::DbWeight::get().writes(7 as Weight))137 .saturating_add(T::DbWeight::get().writes(7 as Weight))136 }138 }137 // Storage: Refungible Balance (r:2 w:2)139 // Storage: Refungible Balance (r:2 w:2)138 fn transfer_normal() -> Weight {140 fn transfer_normal() -> Weight {139 (17_743_000 as Weight)141 (21_049_000 as Weight)140 .saturating_add(T::DbWeight::get().reads(2 as Weight))142 .saturating_add(T::DbWeight::get().reads(2 as Weight))141 .saturating_add(T::DbWeight::get().writes(2 as Weight))143 .saturating_add(T::DbWeight::get().writes(2 as Weight))142 }144 }143 // Storage: Refungible Balance (r:2 w:2)145 // Storage: Refungible Balance (r:2 w:2)144 // Storage: Refungible AccountBalance (r:1 w:1)146 // Storage: Refungible AccountBalance (r:1 w:1)145 // Storage: Refungible Owned (r:0 w:1)147 // Storage: Refungible Owned (r:0 w:1)146 fn transfer_creating() -> Weight {148 fn transfer_creating() -> Weight {147 (20_699_000 as Weight)149 (24_646_000 as Weight)148 .saturating_add(T::DbWeight::get().reads(3 as Weight))150 .saturating_add(T::DbWeight::get().reads(3 as Weight))149 .saturating_add(T::DbWeight::get().writes(4 as Weight))151 .saturating_add(T::DbWeight::get().writes(4 as Weight))150 }152 }151 // Storage: Refungible Balance (r:2 w:2)153 // Storage: Refungible Balance (r:2 w:2)152 // Storage: Refungible AccountBalance (r:1 w:1)154 // Storage: Refungible AccountBalance (r:1 w:1)153 // Storage: Refungible Owned (r:0 w:1)155 // Storage: Refungible Owned (r:0 w:1)154 fn transfer_removing() -> Weight {156 fn transfer_removing() -> Weight {155 (22_833_000 as Weight)157 (26_570_000 as Weight)156 .saturating_add(T::DbWeight::get().reads(3 as Weight))158 .saturating_add(T::DbWeight::get().reads(3 as Weight))157 .saturating_add(T::DbWeight::get().writes(4 as Weight))159 .saturating_add(T::DbWeight::get().writes(4 as Weight))158 }160 }159 // Storage: Refungible Balance (r:2 w:2)161 // Storage: Refungible Balance (r:2 w:2)160 // Storage: Refungible AccountBalance (r:2 w:2)162 // Storage: Refungible AccountBalance (r:2 w:2)161 // Storage: Refungible Owned (r:0 w:2)163 // Storage: Refungible Owned (r:0 w:2)162 fn transfer_creating_removing() -> Weight {164 fn transfer_creating_removing() -> Weight {163 (24_936_000 as Weight)165 (28_906_000 as Weight)164 .saturating_add(T::DbWeight::get().reads(4 as Weight))166 .saturating_add(T::DbWeight::get().reads(4 as Weight))165 .saturating_add(T::DbWeight::get().writes(6 as Weight))167 .saturating_add(T::DbWeight::get().writes(6 as Weight))166 }168 }167 // Storage: Refungible Balance (r:1 w:0)169 // Storage: Refungible Balance (r:1 w:0)168 // Storage: Refungible Allowance (r:0 w:1)170 // Storage: Refungible Allowance (r:0 w:1)169 fn approve() -> Weight {171 fn approve() -> Weight {170 (13_446_000 as Weight)172 (16_451_000 as Weight)171 .saturating_add(T::DbWeight::get().reads(1 as Weight))173 .saturating_add(T::DbWeight::get().reads(1 as Weight))172 .saturating_add(T::DbWeight::get().writes(1 as Weight))174 .saturating_add(T::DbWeight::get().writes(1 as Weight))173 }175 }174 // Storage: Refungible Allowance (r:1 w:1)176 // Storage: Refungible Allowance (r:1 w:1)175 // Storage: Refungible Balance (r:2 w:2)177 // Storage: Refungible Balance (r:2 w:2)176 fn transfer_from_normal() -> Weight {178 fn transfer_from_normal() -> Weight {177 (24_777_000 as Weight)179 (29_545_000 as Weight)178 .saturating_add(T::DbWeight::get().reads(3 as Weight))180 .saturating_add(T::DbWeight::get().reads(3 as Weight))179 .saturating_add(T::DbWeight::get().writes(3 as Weight))181 .saturating_add(T::DbWeight::get().writes(3 as Weight))180 }182 }183 // Storage: Refungible AccountBalance (r:1 w:1)185 // Storage: Refungible AccountBalance (r:1 w:1)184 // Storage: Refungible Owned (r:0 w:1)186 // Storage: Refungible Owned (r:0 w:1)185 fn transfer_from_creating() -> Weight {187 fn transfer_from_creating() -> Weight {186 (28_483_000 as Weight)188 (33_392_000 as Weight)187 .saturating_add(T::DbWeight::get().reads(4 as Weight))189 .saturating_add(T::DbWeight::get().reads(4 as Weight))188 .saturating_add(T::DbWeight::get().writes(5 as Weight))190 .saturating_add(T::DbWeight::get().writes(5 as Weight))189 }191 }192 // Storage: Refungible AccountBalance (r:1 w:1)194 // Storage: Refungible AccountBalance (r:1 w:1)193 // Storage: Refungible Owned (r:0 w:1)195 // Storage: Refungible Owned (r:0 w:1)194 fn transfer_from_removing() -> Weight {196 fn transfer_from_removing() -> Weight {195 (29_896_000 as Weight)197 (35_446_000 as Weight)196 .saturating_add(T::DbWeight::get().reads(4 as Weight))198 .saturating_add(T::DbWeight::get().reads(4 as Weight))197 .saturating_add(T::DbWeight::get().writes(5 as Weight))199 .saturating_add(T::DbWeight::get().writes(5 as Weight))198 }200 }201 // Storage: Refungible AccountBalance (r:2 w:2)203 // Storage: Refungible AccountBalance (r:2 w:2)202 // Storage: Refungible Owned (r:0 w:2)204 // Storage: Refungible Owned (r:0 w:2)203 fn transfer_from_creating_removing() -> Weight {205 fn transfer_from_creating_removing() -> Weight {204 (32_070_000 as Weight)206 (37_762_000 as Weight)205 .saturating_add(T::DbWeight::get().reads(5 as Weight))207 .saturating_add(T::DbWeight::get().reads(5 as Weight))206 .saturating_add(T::DbWeight::get().writes(7 as Weight))208 .saturating_add(T::DbWeight::get().writes(7 as Weight))207 }209 }214 // Storage: Refungible Owned (r:0 w:1)216 // Storage: Refungible Owned (r:0 w:1)215 // Storage: Refungible TokenProperties (r:0 w:1)217 // Storage: Refungible TokenProperties (r:0 w:1)216 fn burn_from() -> Weight {218 fn burn_from() -> Weight {217 (36_789_000 as Weight)219 (42_620_000 as Weight)218 .saturating_add(T::DbWeight::get().reads(5 as Weight))220 .saturating_add(T::DbWeight::get().reads(5 as Weight))219 .saturating_add(T::DbWeight::get().writes(8 as Weight))221 .saturating_add(T::DbWeight::get().writes(8 as Weight))220 }222 }221 // Storage: Common CollectionPropertyPermissions (r:1 w:1)223 // Storage: Common CollectionPropertyPermissions (r:1 w:1)222 fn set_token_property_permissions(b: u32, ) -> Weight {224 fn set_token_property_permissions(b: u32, ) -> Weight {223 (0 as Weight)225 (0 as Weight)224 // Standard Error: 62_000226 // Standard Error: 65_000225 .saturating_add((15_803_000 as Weight).saturating_mul(b as Weight))227 .saturating_add((16_513_000 as Weight).saturating_mul(b as Weight))226 .saturating_add(T::DbWeight::get().reads(1 as Weight))228 .saturating_add(T::DbWeight::get().reads(1 as Weight))227 .saturating_add(T::DbWeight::get().writes(1 as Weight))229 .saturating_add(T::DbWeight::get().writes(1 as Weight))228 }230 }229 // Storage: Common CollectionPropertyPermissions (r:1 w:0)231 // Storage: Common CollectionPropertyPermissions (r:1 w:0)230 // Storage: Refungible TokenProperties (r:1 w:1)232 // Storage: Refungible TokenProperties (r:1 w:1)231 fn set_token_properties(b: u32, ) -> Weight {233 fn set_token_properties(b: u32, ) -> Weight {232 (0 as Weight)234 (0 as Weight)233 // Standard Error: 1_668_000235 // Standard Error: 1_583_000234 .saturating_add((302_308_000 as Weight).saturating_mul(b as Weight))236 .saturating_add((291_392_000 as Weight).saturating_mul(b as Weight))235 .saturating_add(T::DbWeight::get().reads(2 as Weight))237 .saturating_add(T::DbWeight::get().reads(2 as Weight))236 .saturating_add(T::DbWeight::get().writes(1 as Weight))238 .saturating_add(T::DbWeight::get().writes(1 as Weight))237 }239 }238 // Storage: Common CollectionPropertyPermissions (r:1 w:0)240 // Storage: Common CollectionPropertyPermissions (r:1 w:0)239 // Storage: Refungible TokenProperties (r:1 w:1)241 // Storage: Refungible TokenProperties (r:1 w:1)240 fn delete_token_properties(b: u32, ) -> Weight {242 fn delete_token_properties(b: u32, ) -> Weight {241 (0 as Weight)243 (0 as Weight)242 // Standard Error: 1_619_000244 // Standard Error: 1_699_000243 .saturating_add((294_574_000 as Weight).saturating_mul(b as Weight))245 .saturating_add((293_270_000 as Weight).saturating_mul(b as Weight))244 .saturating_add(T::DbWeight::get().reads(2 as Weight))246 .saturating_add(T::DbWeight::get().reads(2 as Weight))245 .saturating_add(T::DbWeight::get().writes(1 as Weight))247 .saturating_add(T::DbWeight::get().writes(1 as Weight))246 }248 }247 // Storage: Refungible TotalSupply (r:1 w:1)249 // Storage: Refungible TotalSupply (r:1 w:1)248 // Storage: Refungible Balance (r:1 w:1)250 // Storage: Refungible Balance (r:1 w:1)249 fn repartition_item() -> Weight {251 fn repartition_item() -> Weight {250 (8_325_000 as Weight)252 (19_206_000 as Weight)251 .saturating_add(T::DbWeight::get().reads(2 as Weight))253 .saturating_add(T::DbWeight::get().reads(2 as Weight))252 .saturating_add(T::DbWeight::get().writes(2 as Weight))254 .saturating_add(T::DbWeight::get().writes(2 as Weight))253 }255 }256 // Storage: Refungible Balance (r:1 w:0)257 // Storage: Refungible TotalSupply (r:1 w:0)258 // Storage: Refungible TokenProperties (r:1 w:1)259 fn set_parent_nft_unchecked() -> Weight {260 (10_189_000 as Weight)261 .saturating_add(T::DbWeight::get().reads(3 as Weight))262 .saturating_add(T::DbWeight::get().writes(1 as Weight))263 }264 // Storage: Refungible Balance (r:2 w:0)265 fn token_owner() -> Weight {266 (8_205_000 as Weight)267 .saturating_add(T::DbWeight::get().reads(2 as Weight))268 }254}269}255270256// For backwards compatibility and tests271// For backwards compatibility and tests262 // Storage: Refungible TokenData (r:0 w:1)277 // Storage: Refungible TokenData (r:0 w:1)263 // Storage: Refungible Owned (r:0 w:1)278 // Storage: Refungible Owned (r:0 w:1)264 fn create_item() -> Weight {279 fn create_item() -> Weight {265 (21_310_000 as Weight)280 (25_197_000 as Weight)266 .saturating_add(RocksDbWeight::get().reads(2 as Weight))281 .saturating_add(RocksDbWeight::get().reads(2 as Weight))267 .saturating_add(RocksDbWeight::get().writes(6 as Weight))282 .saturating_add(RocksDbWeight::get().writes(6 as Weight))268 }283 }273 // Storage: Refungible TokenData (r:0 w:4)288 // Storage: Refungible TokenData (r:0 w:4)274 // Storage: Refungible Owned (r:0 w:4)289 // Storage: Refungible Owned (r:0 w:4)275 fn create_multiple_items(b: u32, ) -> Weight {290 fn create_multiple_items(b: u32, ) -> Weight {276 (9_552_000 as Weight)291 (10_852_000 as Weight)277 // Standard Error: 2_000292 // Standard Error: 2_000278 .saturating_add((7_056_000 as Weight).saturating_mul(b as Weight))293 .saturating_add((8_087_000 as Weight).saturating_mul(b as Weight))279 .saturating_add(RocksDbWeight::get().reads(2 as Weight))294 .saturating_add(RocksDbWeight::get().reads(2 as Weight))280 .saturating_add(RocksDbWeight::get().writes(2 as Weight))295 .saturating_add(RocksDbWeight::get().writes(2 as Weight))281 .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))296 .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))287 // Storage: Refungible TokenData (r:0 w:4)302 // Storage: Refungible TokenData (r:0 w:4)288 // Storage: Refungible Owned (r:0 w:4)303 // Storage: Refungible Owned (r:0 w:4)289 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {304 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {290 (4_857_000 as Weight)305 (9_978_000 as Weight)291 // Standard Error: 2_000306 // Standard Error: 2_000292 .saturating_add((9_838_000 as Weight).saturating_mul(b as Weight))307 .saturating_add((10_848_000 as Weight).saturating_mul(b as Weight))293 .saturating_add(RocksDbWeight::get().reads(1 as Weight))308 .saturating_add(RocksDbWeight::get().reads(1 as Weight))294 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))309 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))295 .saturating_add(RocksDbWeight::get().writes(1 as Weight))310 .saturating_add(RocksDbWeight::get().writes(1 as Weight))302 // Storage: Refungible Balance (r:0 w:4)317 // Storage: Refungible Balance (r:0 w:4)303 // Storage: Refungible Owned (r:0 w:4)318 // Storage: Refungible Owned (r:0 w:4)304 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {319 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {305 (11_335_000 as Weight)320 (15_419_000 as Weight)306 // Standard Error: 2_000321 // Standard Error: 2_000307 .saturating_add((6_784_000 as Weight).saturating_mul(b as Weight))322 .saturating_add((7_813_000 as Weight).saturating_mul(b as Weight))308 .saturating_add(RocksDbWeight::get().reads(1 as Weight))323 .saturating_add(RocksDbWeight::get().reads(1 as Weight))309 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))324 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))310 .saturating_add(RocksDbWeight::get().writes(3 as Weight))325 .saturating_add(RocksDbWeight::get().writes(3 as Weight))315 // Storage: Refungible AccountBalance (r:1 w:1)330 // Storage: Refungible AccountBalance (r:1 w:1)316 // Storage: Refungible Owned (r:0 w:1)331 // Storage: Refungible Owned (r:0 w:1)317 fn burn_item_partial() -> Weight {332 fn burn_item_partial() -> Weight {318 (21_239_000 as Weight)333 (25_578_000 as Weight)319 .saturating_add(RocksDbWeight::get().reads(3 as Weight))334 .saturating_add(RocksDbWeight::get().reads(3 as Weight))320 .saturating_add(RocksDbWeight::get().writes(4 as Weight))335 .saturating_add(RocksDbWeight::get().writes(4 as Weight))321 }336 }327 // Storage: Refungible Owned (r:0 w:1)342 // Storage: Refungible Owned (r:0 w:1)328 // Storage: Refungible TokenProperties (r:0 w:1)343 // Storage: Refungible TokenProperties (r:0 w:1)329 fn burn_item_fully() -> Weight {344 fn burn_item_fully() -> Weight {330 (29_426_000 as Weight)345 (33_593_000 as Weight)331 .saturating_add(RocksDbWeight::get().reads(4 as Weight))346 .saturating_add(RocksDbWeight::get().reads(4 as Weight))332 .saturating_add(RocksDbWeight::get().writes(7 as Weight))347 .saturating_add(RocksDbWeight::get().writes(7 as Weight))333 }348 }334 // Storage: Refungible Balance (r:2 w:2)349 // Storage: Refungible Balance (r:2 w:2)335 fn transfer_normal() -> Weight {350 fn transfer_normal() -> Weight {336 (17_743_000 as Weight)351 (21_049_000 as Weight)337 .saturating_add(RocksDbWeight::get().reads(2 as Weight))352 .saturating_add(RocksDbWeight::get().reads(2 as Weight))338 .saturating_add(RocksDbWeight::get().writes(2 as Weight))353 .saturating_add(RocksDbWeight::get().writes(2 as Weight))339 }354 }340 // Storage: Refungible Balance (r:2 w:2)355 // Storage: Refungible Balance (r:2 w:2)341 // Storage: Refungible AccountBalance (r:1 w:1)356 // Storage: Refungible AccountBalance (r:1 w:1)342 // Storage: Refungible Owned (r:0 w:1)357 // Storage: Refungible Owned (r:0 w:1)343 fn transfer_creating() -> Weight {358 fn transfer_creating() -> Weight {344 (20_699_000 as Weight)359 (24_646_000 as Weight)345 .saturating_add(RocksDbWeight::get().reads(3 as Weight))360 .saturating_add(RocksDbWeight::get().reads(3 as Weight))346 .saturating_add(RocksDbWeight::get().writes(4 as Weight))361 .saturating_add(RocksDbWeight::get().writes(4 as Weight))347 }362 }348 // Storage: Refungible Balance (r:2 w:2)363 // Storage: Refungible Balance (r:2 w:2)349 // Storage: Refungible AccountBalance (r:1 w:1)364 // Storage: Refungible AccountBalance (r:1 w:1)350 // Storage: Refungible Owned (r:0 w:1)365 // Storage: Refungible Owned (r:0 w:1)351 fn transfer_removing() -> Weight {366 fn transfer_removing() -> Weight {352 (22_833_000 as Weight)367 (26_570_000 as Weight)353 .saturating_add(RocksDbWeight::get().reads(3 as Weight))368 .saturating_add(RocksDbWeight::get().reads(3 as Weight))354 .saturating_add(RocksDbWeight::get().writes(4 as Weight))369 .saturating_add(RocksDbWeight::get().writes(4 as Weight))355 }370 }356 // Storage: Refungible Balance (r:2 w:2)371 // Storage: Refungible Balance (r:2 w:2)357 // Storage: Refungible AccountBalance (r:2 w:2)372 // Storage: Refungible AccountBalance (r:2 w:2)358 // Storage: Refungible Owned (r:0 w:2)373 // Storage: Refungible Owned (r:0 w:2)359 fn transfer_creating_removing() -> Weight {374 fn transfer_creating_removing() -> Weight {360 (24_936_000 as Weight)375 (28_906_000 as Weight)361 .saturating_add(RocksDbWeight::get().reads(4 as Weight))376 .saturating_add(RocksDbWeight::get().reads(4 as Weight))362 .saturating_add(RocksDbWeight::get().writes(6 as Weight))377 .saturating_add(RocksDbWeight::get().writes(6 as Weight))363 }378 }364 // Storage: Refungible Balance (r:1 w:0)379 // Storage: Refungible Balance (r:1 w:0)365 // Storage: Refungible Allowance (r:0 w:1)380 // Storage: Refungible Allowance (r:0 w:1)366 fn approve() -> Weight {381 fn approve() -> Weight {367 (13_446_000 as Weight)382 (16_451_000 as Weight)368 .saturating_add(RocksDbWeight::get().reads(1 as Weight))383 .saturating_add(RocksDbWeight::get().reads(1 as Weight))369 .saturating_add(RocksDbWeight::get().writes(1 as Weight))384 .saturating_add(RocksDbWeight::get().writes(1 as Weight))370 }385 }371 // Storage: Refungible Allowance (r:1 w:1)386 // Storage: Refungible Allowance (r:1 w:1)372 // Storage: Refungible Balance (r:2 w:2)387 // Storage: Refungible Balance (r:2 w:2)373 fn transfer_from_normal() -> Weight {388 fn transfer_from_normal() -> Weight {374 (24_777_000 as Weight)389 (29_545_000 as Weight)375 .saturating_add(RocksDbWeight::get().reads(3 as Weight))390 .saturating_add(RocksDbWeight::get().reads(3 as Weight))376 .saturating_add(RocksDbWeight::get().writes(3 as Weight))391 .saturating_add(RocksDbWeight::get().writes(3 as Weight))377 }392 }380 // Storage: Refungible AccountBalance (r:1 w:1)395 // Storage: Refungible AccountBalance (r:1 w:1)381 // Storage: Refungible Owned (r:0 w:1)396 // Storage: Refungible Owned (r:0 w:1)382 fn transfer_from_creating() -> Weight {397 fn transfer_from_creating() -> Weight {383 (28_483_000 as Weight)398 (33_392_000 as Weight)384 .saturating_add(RocksDbWeight::get().reads(4 as Weight))399 .saturating_add(RocksDbWeight::get().reads(4 as Weight))385 .saturating_add(RocksDbWeight::get().writes(5 as Weight))400 .saturating_add(RocksDbWeight::get().writes(5 as Weight))386 }401 }389 // Storage: Refungible AccountBalance (r:1 w:1)404 // Storage: Refungible AccountBalance (r:1 w:1)390 // Storage: Refungible Owned (r:0 w:1)405 // Storage: Refungible Owned (r:0 w:1)391 fn transfer_from_removing() -> Weight {406 fn transfer_from_removing() -> Weight {392 (29_896_000 as Weight)407 (35_446_000 as Weight)393 .saturating_add(RocksDbWeight::get().reads(4 as Weight))408 .saturating_add(RocksDbWeight::get().reads(4 as Weight))394 .saturating_add(RocksDbWeight::get().writes(5 as Weight))409 .saturating_add(RocksDbWeight::get().writes(5 as Weight))395 }410 }398 // Storage: Refungible AccountBalance (r:2 w:2)413 // Storage: Refungible AccountBalance (r:2 w:2)399 // Storage: Refungible Owned (r:0 w:2)414 // Storage: Refungible Owned (r:0 w:2)400 fn transfer_from_creating_removing() -> Weight {415 fn transfer_from_creating_removing() -> Weight {401 (32_070_000 as Weight)416 (37_762_000 as Weight)402 .saturating_add(RocksDbWeight::get().reads(5 as Weight))417 .saturating_add(RocksDbWeight::get().reads(5 as Weight))403 .saturating_add(RocksDbWeight::get().writes(7 as Weight))418 .saturating_add(RocksDbWeight::get().writes(7 as Weight))404 }419 }411 // Storage: Refungible Owned (r:0 w:1)426 // Storage: Refungible Owned (r:0 w:1)412 // Storage: Refungible TokenProperties (r:0 w:1)427 // Storage: Refungible TokenProperties (r:0 w:1)413 fn burn_from() -> Weight {428 fn burn_from() -> Weight {414 (36_789_000 as Weight)429 (42_620_000 as Weight)415 .saturating_add(RocksDbWeight::get().reads(5 as Weight))430 .saturating_add(RocksDbWeight::get().reads(5 as Weight))416 .saturating_add(RocksDbWeight::get().writes(8 as Weight))431 .saturating_add(RocksDbWeight::get().writes(8 as Weight))417 }432 }418 // Storage: Common CollectionPropertyPermissions (r:1 w:1)433 // Storage: Common CollectionPropertyPermissions (r:1 w:1)419 fn set_token_property_permissions(b: u32, ) -> Weight {434 fn set_token_property_permissions(b: u32, ) -> Weight {420 (0 as Weight)435 (0 as Weight)421 // Standard Error: 62_000436 // Standard Error: 65_000422 .saturating_add((15_803_000 as Weight).saturating_mul(b as Weight))437 .saturating_add((16_513_000 as Weight).saturating_mul(b as Weight))423 .saturating_add(RocksDbWeight::get().reads(1 as Weight))438 .saturating_add(RocksDbWeight::get().reads(1 as Weight))424 .saturating_add(RocksDbWeight::get().writes(1 as Weight))439 .saturating_add(RocksDbWeight::get().writes(1 as Weight))425 }440 }426 // Storage: Common CollectionPropertyPermissions (r:1 w:0)441 // Storage: Common CollectionPropertyPermissions (r:1 w:0)427 // Storage: Refungible TokenProperties (r:1 w:1)442 // Storage: Refungible TokenProperties (r:1 w:1)428 fn set_token_properties(b: u32, ) -> Weight {443 fn set_token_properties(b: u32, ) -> Weight {429 (0 as Weight)444 (0 as Weight)430 // Standard Error: 1_668_000445 // Standard Error: 1_583_000431 .saturating_add((302_308_000 as Weight).saturating_mul(b as Weight))446 .saturating_add((291_392_000 as Weight).saturating_mul(b as Weight))432 .saturating_add(RocksDbWeight::get().reads(2 as Weight))447 .saturating_add(RocksDbWeight::get().reads(2 as Weight))433 .saturating_add(RocksDbWeight::get().writes(1 as Weight))448 .saturating_add(RocksDbWeight::get().writes(1 as Weight))434 }449 }435 // Storage: Common CollectionPropertyPermissions (r:1 w:0)450 // Storage: Common CollectionPropertyPermissions (r:1 w:0)436 // Storage: Refungible TokenProperties (r:1 w:1)451 // Storage: Refungible TokenProperties (r:1 w:1)437 fn delete_token_properties(b: u32, ) -> Weight {452 fn delete_token_properties(b: u32, ) -> Weight {438 (0 as Weight)453 (0 as Weight)439 // Standard Error: 1_619_000454 // Standard Error: 1_699_000440 .saturating_add((294_574_000 as Weight).saturating_mul(b as Weight))455 .saturating_add((293_270_000 as Weight).saturating_mul(b as Weight))441 .saturating_add(RocksDbWeight::get().reads(2 as Weight))456 .saturating_add(RocksDbWeight::get().reads(2 as Weight))442 .saturating_add(RocksDbWeight::get().writes(1 as Weight))457 .saturating_add(RocksDbWeight::get().writes(1 as Weight))443 }458 }444 // Storage: Refungible TotalSupply (r:1 w:1)459 // Storage: Refungible TotalSupply (r:1 w:1)445 // Storage: Refungible Balance (r:1 w:1)460 // Storage: Refungible Balance (r:1 w:1)446 fn repartition_item() -> Weight {461 fn repartition_item() -> Weight {447 (8_325_000 as Weight)462 (19_206_000 as Weight)448 .saturating_add(RocksDbWeight::get().reads(2 as Weight))463 .saturating_add(RocksDbWeight::get().reads(2 as Weight))449 .saturating_add(RocksDbWeight::get().writes(2 as Weight))464 .saturating_add(RocksDbWeight::get().writes(2 as Weight))450 }465 }466 // Storage: Refungible Balance (r:1 w:0)467 // Storage: Refungible TotalSupply (r:1 w:0)468 // Storage: Refungible TokenProperties (r:1 w:1)469 fn set_parent_nft_unchecked() -> Weight {470 (10_189_000 as Weight)471 .saturating_add(RocksDbWeight::get().reads(3 as Weight))472 .saturating_add(RocksDbWeight::get().writes(1 as Weight))473 }474 // Storage: Refungible Balance (r:2 w:0)475 fn token_owner() -> Weight {476 (8_205_000 as Weight)477 .saturating_add(RocksDbWeight::get().reads(2 as Weight))478 }451}479}452480pallets/unique/src/eth/mod.rsdiffbeforeafterboth17//! Implementation of CollectionHelpers contract.17//! Implementation of CollectionHelpers contract.181819use core::marker::PhantomData;19use core::marker::PhantomData;20use ethereum as _;20use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};21use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};22use frame_support::traits::Get;21use ethereum as _;23use pallet_common::{24 CollectionById, CollectionHandle,25 dispatch::CollectionDispatch,26 erc::{27 CollectionHelpersEvents,28 static_property::{key, value as property_value},29 },30 Pallet as PalletCommon,31};22use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};32use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};23use pallet_evm::{OnMethodCall, PrecompileResult, account::CrossAccountId, PrecompileHandle};33use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm_coder_substrate::dispatch_to_evm;24use up_data_structs::{35use up_data_structs::{25 CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,36 CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,26 CollectionMode, PropertyValue,37 CollectionMode, PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue,27};38};28use frame_support::traits::Get;3929use pallet_common::{30 CollectionById,31 erc::{32 static_property::{key, value as property_value},33 CollectionHelpersEvents,34 },35 dispatch::CollectionDispatch,36};37use crate::{SelfWeightOf, Config, weights::WeightInfo};40use crate::{Config, SelfWeightOf, weights::WeightInfo};384139use sp_std::vec::Vec;42use sp_std::{vec, vec::Vec};40use alloc::format;43use alloc::format;414442/// See [`CollectionHelpersCall`]45/// See [`CollectionHelpersCall`]151 Ok(data)154 Ok(data)152}155}156157fn parent_nft_property_permissions() -> PropertyKeyPermission {158 PropertyKeyPermission {159 key: key::parent_nft(),160 permission: PropertyPermission {161 mutable: false,162 collection_admin: false,163 token_owner: true,164 },165 }166}167168fn create_refungible_collection_internal<169 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,170>(171 caller: caller,172 name: string,173 description: string,174 token_prefix: string,175 base_uri: string,176 add_properties: bool,177) -> Result<address> {178 let (caller, name, description, token_prefix, base_uri_value) =179 convert_data::<T>(caller, name, description, token_prefix, base_uri)?;180 let data = make_data::<T>(181 name,182 CollectionMode::ReFungible,183 description,184 token_prefix,185 base_uri_value,186 add_properties,187 )?;188189 let collection_id = T::CollectionDispatch::create(caller.clone(), data)190 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;191192 let handle = <CollectionHandle<T>>::try_get(collection_id).map_err(dispatch_to_evm::<T>)?;193 <PalletCommon<T>>::set_scoped_token_property_permissions(194 &handle,195 &caller,196 PropertyScope::Eth,197 vec![parent_nft_property_permissions()],198 )199 .map_err(dispatch_to_evm::<T>)?;200201 let address = pallet_common::eth::collection_id_to_address(collection_id);202 Ok(address)203}153204154/// @title Contract, which allows users to operate with collections205/// @title Contract, which allows users to operate with collections155#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]206#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]216267217 #[weight(<SelfWeightOf<T>>::create_collection())]268 #[weight(<SelfWeightOf<T>>::create_collection())]218 fn create_refungible_collection(269 fn create_refungible_collection(219 &self,270 &mut self,220 caller: caller,271 caller: caller,221 name: string,272 name: string,222 description: string,273 description: string,223 token_prefix: string,274 token_prefix: string,224 ) -> Result<address> {275 ) -> Result<address> {225 let (caller, name, description, token_prefix, _base_uri) =226 convert_data::<T>(caller, name, description, token_prefix, "".into())?;227 let data = make_data::<T>(276 create_refungible_collection_internal::<T>(277 caller,228 name,278 name,229 CollectionMode::ReFungible,230 description,279 description,231 token_prefix,280 token_prefix,232 Default::default(),281 Default::default(),233 false,282 false,234 )?;283 )235 let collection_id = T::CollectionDispatch::create(caller, data)236 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;237238 let address = pallet_common::eth::collection_id_to_address(collection_id);239 Ok(address)240 }284 }241285242 #[weight(<SelfWeightOf<T>>::create_collection())]286 #[weight(<SelfWeightOf<T>>::create_collection())]249 token_prefix: string,293 token_prefix: string,250 base_uri: string,294 base_uri: string,251 ) -> Result<address> {295 ) -> Result<address> {252 let (caller, name, description, token_prefix, base_uri_value) =253 convert_data::<T>(caller, name, description, token_prefix, base_uri)?;296 create_refungible_collection_internal::<T>(254 let data = make_data::<T>(297 caller,255 name,298 name,256 CollectionMode::NFT,299 description,257 description,300 token_prefix,258 token_prefix,301 base_uri,259 base_uri_value,302 true,260 true,303 )261 )?;262 let collection_id = T::CollectionDispatch::create(caller, data)263 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;264265 let address = pallet_common::eth::collection_id_to_address(collection_id);266 Ok(address)267 }304 }268305269 /// Check if a collection exists306 /// Check if a collection existspallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth72 string memory name,72 string memory name,73 string memory description,73 string memory description,74 string memory tokenPrefix74 string memory tokenPrefix75 ) public view returns (address) {75 ) public returns (address) {76 require(false, stub_error);76 require(false, stub_error);77 name;77 name;78 description;78 description;79 tokenPrefix;79 tokenPrefix;80 dummy;80 dummy = 0;81 return 0x0000000000000000000000000000000000000000;81 return 0x0000000000000000000000000000000000000000;82 }82 }8383primitives/data-structs/src/lib.rsdiffbeforeafterboth1050pub enum PropertyScope {1050pub enum PropertyScope {1051 None,1051 None,1052 Rmrk,1052 Rmrk,1053 Eth,1053}1054}105410551055impl PropertyScope {1056impl PropertyScope {1058 let scope_str: &[u8] = match self {1059 let scope_str: &[u8] = match self {1059 Self::None => return Ok(key),1060 Self::None => return Ok(key),1060 Self::Rmrk => b"rmrk",1061 Self::Rmrk => b"rmrk",1062 Self::Eth => b"eth",1061 };1063 };106210641063 [scope_str, b":", key.as_slice()]1065 [scope_str, b":", key.as_slice()]runtime/common/weights.rsdiffbeforeafterboth117 max_weight_of!(burn_recursively_breadth_raw(amount))117 max_weight_of!(burn_recursively_breadth_raw(amount))118 }118 }119120 fn token_owner() -> Weight {121 max_weight_of!(token_owner())122 }119}123}120124121#[cfg(feature = "refungible")]125#[cfg(feature = "refungible")]tests/package.jsondiffbeforeafterboth8 "@polkadot/typegen": "8.7.2-15",8 "@polkadot/typegen": "8.7.2-15",9 "@types/chai": "^4.3.1",9 "@types/chai": "^4.3.1",10 "@types/chai-as-promised": "^7.1.5",10 "@types/chai-as-promised": "^7.1.5",11 "@types/chai-like": "^1.1.1",11 "@types/mocha": "^9.1.1",12 "@types/mocha": "^9.1.1",12 "@types/node": "^17.0.35",13 "@types/node": "^17.0.35",13 "@typescript-eslint/eslint-plugin": "^5.26.0",14 "@typescript-eslint/eslint-plugin": "^5.26.0",96 "@polkadot/util-crypto": "9.4.1",97 "@polkadot/util-crypto": "9.4.1",97 "bignumber.js": "^9.0.2",98 "bignumber.js": "^9.0.2",98 "chai-as-promised": "^7.1.1",99 "chai-as-promised": "^7.1.1",100 "chai-like": "^1.1.1",99 "find-process": "^1.4.7",101 "find-process": "^1.4.7",100 "solc": "0.8.14-fixed",102 "solc": "0.8.14-fixed",101 "web3": "^1.7.3"103 "web3": "^1.7.3"tests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth48 string memory name,48 string memory name,49 string memory description,49 string memory description,50 string memory tokenPrefix50 string memory tokenPrefix51 ) external view returns (address);51 ) external returns (address);525253 // Selector: createERC721MetadataCompatibleRFTCollection(string,string,string,string) a559638853 // Selector: createERC721MetadataCompatibleRFTCollection(string,string,string,string) a559638854 function createERC721MetadataCompatibleRFTCollection(54 function createERC721MetadataCompatibleRFTCollection(tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth22 );22 );23}23}2425// Selector: 6cf113cd26interface Collection is Dummy, ERC165 {27 // Set collection property.28 //29 // @param key Property key.30 // @param value Propery value.31 //32 // Selector: setCollectionProperty(string,bytes) 2f073f6633 function setCollectionProperty(string memory key, bytes memory value)34 external;3536 // Delete collection property.37 //38 // @param key Property key.39 //40 // Selector: deleteCollectionProperty(string) 7b7debce41 function deleteCollectionProperty(string memory key) external;4243 // Get collection property.44 //45 // @dev Throws error if key not found.46 //47 // @param key Property key.48 // @return bytes The property corresponding to the key.49 //50 // Selector: collectionProperty(string) cf24fd6d51 function collectionProperty(string memory key)52 external53 view54 returns (bytes memory);5556 // Set the sponsor of the collection.57 //58 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.59 //60 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.61 //62 // Selector: setCollectionSponsor(address) 7623402e63 function setCollectionSponsor(address sponsor) external;6465 // Collection sponsorship confirmation.66 //67 // @dev After setting the sponsor for the collection, it must be confirmed with this function.68 //69 // Selector: confirmCollectionSponsorship() 3c50e97a70 function confirmCollectionSponsorship() external;7172 // Set limits for the collection.73 // @dev Throws error if limit not found.74 // @param limit Name of the limit. Valid names:75 // "accountTokenOwnershipLimit",76 // "sponsoredDataSize",77 // "sponsoredDataRateLimit",78 // "tokenLimit",79 // "sponsorTransferTimeout",80 // "sponsorApproveTimeout"81 // @param value Value of the limit.82 //83 // Selector: setCollectionLimit(string,uint32) 6a3841db84 function setCollectionLimit(string memory limit, uint32 value) external;8586 // Set limits for the collection.87 // @dev Throws error if limit not found.88 // @param limit Name of the limit. Valid names:89 // "ownerCanTransfer",90 // "ownerCanDestroy",91 // "transfersEnabled"92 // @param value Value of the limit.93 //94 // Selector: setCollectionLimit(string,bool) 993b7fba95 function setCollectionLimit(string memory limit, bool value) external;9697 // Get contract address.98 //99 // Selector: contractAddress() f6b4dfb4100 function contractAddress() external view returns (address);101102 // Add collection admin by substrate address.103 // @param new_admin Substrate administrator address.104 //105 // Selector: addCollectionAdminSubstrate(uint256) 5730062b106 function addCollectionAdminSubstrate(uint256 newAdmin) external;107108 // Remove collection admin by substrate address.109 // @param admin Substrate administrator address.110 //111 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9112 function removeCollectionAdminSubstrate(uint256 admin) external;113114 // Add collection admin.115 // @param new_admin Address of the added administrator.116 //117 // Selector: addCollectionAdmin(address) 92e462c7118 function addCollectionAdmin(address newAdmin) external;119120 // Remove collection admin.121 //122 // @param new_admin Address of the removed administrator.123 //124 // Selector: removeCollectionAdmin(address) fafd7b42125 function removeCollectionAdmin(address admin) external;126127 // Toggle accessibility of collection nesting.128 //129 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'130 //131 // Selector: setCollectionNesting(bool) 112d4586132 function setCollectionNesting(bool enable) external;133134 // Toggle accessibility of collection nesting.135 //136 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'137 // @param collections Addresses of collections that will be available for nesting.138 //139 // Selector: setCollectionNesting(bool,address[]) 64872396140 function setCollectionNesting(bool enable, address[] memory collections)141 external;142143 // Set the collection access method.144 // @param mode Access mode145 // 0 for Normal146 // 1 for AllowList147 //148 // Selector: setCollectionAccess(uint8) 41835d4c149 function setCollectionAccess(uint8 mode) external;150151 // Add the user to the allowed list.152 //153 // @param user Address of a trusted user.154 //155 // Selector: addToCollectionAllowList(address) 67844fe6156 function addToCollectionAllowList(address user) external;157158 // Remove the user from the allowed list.159 //160 // @param user Address of a removed user.161 //162 // Selector: removeFromCollectionAllowList(address) 85c51acb163 function removeFromCollectionAllowList(address user) external;164165 // Switch permission for minting.166 //167 // @param mode Enable if "true".168 //169 // Selector: setCollectionMintMode(bool) 00018e84170 function setCollectionMintMode(bool mode) external;171172 // Check that account is the owner or admin of the collection173 //174 // @param user account to verify175 // @return "true" if account is the owner or admin176 //177 // Selector: verifyOwnerOrAdmin(address) c2282493178 function verifyOwnerOrAdmin(address user) external view returns (bool);179180 // Returns collection type181 //182 // @return `Fungible` or `NFT` or `ReFungible`183 //184 // Selector: uniqueCollectionType() d34b55b8185 function uniqueCollectionType() external returns (string memory);186}2418725// Selector: 79cc6790188// Selector: 79cc679026interface ERC20UniqueExtensions is Dummy, ERC165 {189interface ERC20UniqueExtensions is Dummy, ERC165 {27 // Selector: burnFrom(address,uint256) 79cc6790190 // Selector: burnFrom(address,uint256) 79cc679028 function burnFrom(address from, uint256 amount) external returns (bool);191 function burnFrom(address from, uint256 amount) external returns (bool);29}192}3031// Selector: 7d9262e632interface Collection is Dummy, ERC165 {33 // Set collection property.34 //35 // @param key Property key.36 // @param value Propery value.37 //38 // Selector: setCollectionProperty(string,bytes) 2f073f6639 function setCollectionProperty(string memory key, bytes memory value)40 external;4142 // Delete collection property.43 //44 // @param key Property key.45 //46 // Selector: deleteCollectionProperty(string) 7b7debce47 function deleteCollectionProperty(string memory key) external;4849 // Get collection property.50 //51 // @dev Throws error if key not found.52 //53 // @param key Property key.54 // @return bytes The property corresponding to the key.55 //56 // Selector: collectionProperty(string) cf24fd6d57 function collectionProperty(string memory key)58 external59 view60 returns (bytes memory);6162 // Set the sponsor of the collection.63 //64 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.65 //66 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.67 //68 // Selector: setCollectionSponsor(address) 7623402e69 function setCollectionSponsor(address sponsor) external;7071 // Collection sponsorship confirmation.72 //73 // @dev After setting the sponsor for the collection, it must be confirmed with this function.74 //75 // Selector: confirmCollectionSponsorship() 3c50e97a76 function confirmCollectionSponsorship() external;7778 // Set limits for the collection.79 // @dev Throws error if limit not found.80 // @param limit Name of the limit. Valid names:81 // "accountTokenOwnershipLimit",82 // "sponsoredDataSize",83 // "sponsoredDataRateLimit",84 // "tokenLimit",85 // "sponsorTransferTimeout",86 // "sponsorApproveTimeout"87 // @param value Value of the limit.88 //89 // Selector: setCollectionLimit(string,uint32) 6a3841db90 function setCollectionLimit(string memory limit, uint32 value) external;9192 // Set limits for the collection.93 // @dev Throws error if limit not found.94 // @param limit Name of the limit. Valid names:95 // "ownerCanTransfer",96 // "ownerCanDestroy",97 // "transfersEnabled"98 // @param value Value of the limit.99 //100 // Selector: setCollectionLimit(string,bool) 993b7fba101 function setCollectionLimit(string memory limit, bool value) external;102103 // Get contract address.104 //105 // Selector: contractAddress() f6b4dfb4106 function contractAddress() external view returns (address);107108 // Add collection admin by substrate address.109 // @param new_admin Substrate administrator address.110 //111 // Selector: addCollectionAdminSubstrate(uint256) 5730062b112 function addCollectionAdminSubstrate(uint256 newAdmin) external;113114 // Remove collection admin by substrate address.115 // @param admin Substrate administrator address.116 //117 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9118 function removeCollectionAdminSubstrate(uint256 admin) external;119120 // Add collection admin.121 // @param new_admin Address of the added administrator.122 //123 // Selector: addCollectionAdmin(address) 92e462c7124 function addCollectionAdmin(address newAdmin) external;125126 // Remove collection admin.127 //128 // @param new_admin Address of the removed administrator.129 //130 // Selector: removeCollectionAdmin(address) fafd7b42131 function removeCollectionAdmin(address admin) external;132133 // Toggle accessibility of collection nesting.134 //135 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'136 //137 // Selector: setCollectionNesting(bool) 112d4586138 function setCollectionNesting(bool enable) external;139140 // Toggle accessibility of collection nesting.141 //142 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'143 // @param collections Addresses of collections that will be available for nesting.144 //145 // Selector: setCollectionNesting(bool,address[]) 64872396146 function setCollectionNesting(bool enable, address[] memory collections)147 external;148149 // Set the collection access method.150 // @param mode Access mode151 // 0 for Normal152 // 1 for AllowList153 //154 // Selector: setCollectionAccess(uint8) 41835d4c155 function setCollectionAccess(uint8 mode) external;156157 // Add the user to the allowed list.158 //159 // @param user Address of a trusted user.160 //161 // Selector: addToCollectionAllowList(address) 67844fe6162 function addToCollectionAllowList(address user) external;163164 // Remove the user from the allowed list.165 //166 // @param user Address of a removed user.167 //168 // Selector: removeFromCollectionAllowList(address) 85c51acb169 function removeFromCollectionAllowList(address user) external;170171 // Switch permission for minting.172 //173 // @param mode Enable if "true".174 //175 // Selector: setCollectionMintMode(bool) 00018e84176 function setCollectionMintMode(bool mode) external;177}178193179// Selector: 942e8b22194// Selector: 942e8b22180interface ERC20 is Dummy, ERC165, ERC20Events {195interface ERC20 is Dummy, ERC165, ERC20Events {tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth250 function finishMinting() external returns (bool);250 function finishMinting() external returns (bool);251}251}252253// Selector: 6cf113cd254interface Collection is Dummy, ERC165 {255 // Set collection property.256 //257 // @param key Property key.258 // @param value Propery value.259 //260 // Selector: setCollectionProperty(string,bytes) 2f073f66261 function setCollectionProperty(string memory key, bytes memory value)262 external;263264 // Delete collection property.265 //266 // @param key Property key.267 //268 // Selector: deleteCollectionProperty(string) 7b7debce269 function deleteCollectionProperty(string memory key) external;270271 // Get collection property.272 //273 // @dev Throws error if key not found.274 //275 // @param key Property key.276 // @return bytes The property corresponding to the key.277 //278 // Selector: collectionProperty(string) cf24fd6d279 function collectionProperty(string memory key)280 external281 view282 returns (bytes memory);283284 // Set the sponsor of the collection.285 //286 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.287 //288 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.289 //290 // Selector: setCollectionSponsor(address) 7623402e291 function setCollectionSponsor(address sponsor) external;292293 // Collection sponsorship confirmation.294 //295 // @dev After setting the sponsor for the collection, it must be confirmed with this function.296 //297 // Selector: confirmCollectionSponsorship() 3c50e97a298 function confirmCollectionSponsorship() external;299300 // Set limits for the collection.301 // @dev Throws error if limit not found.302 // @param limit Name of the limit. Valid names:303 // "accountTokenOwnershipLimit",304 // "sponsoredDataSize",305 // "sponsoredDataRateLimit",306 // "tokenLimit",307 // "sponsorTransferTimeout",308 // "sponsorApproveTimeout"309 // @param value Value of the limit.310 //311 // Selector: setCollectionLimit(string,uint32) 6a3841db312 function setCollectionLimit(string memory limit, uint32 value) external;313314 // Set limits for the collection.315 // @dev Throws error if limit not found.316 // @param limit Name of the limit. Valid names:317 // "ownerCanTransfer",318 // "ownerCanDestroy",319 // "transfersEnabled"320 // @param value Value of the limit.321 //322 // Selector: setCollectionLimit(string,bool) 993b7fba323 function setCollectionLimit(string memory limit, bool value) external;324325 // Get contract address.326 //327 // Selector: contractAddress() f6b4dfb4328 function contractAddress() external view returns (address);329330 // Add collection admin by substrate address.331 // @param new_admin Substrate administrator address.332 //333 // Selector: addCollectionAdminSubstrate(uint256) 5730062b334 function addCollectionAdminSubstrate(uint256 newAdmin) external;335336 // Remove collection admin by substrate address.337 // @param admin Substrate administrator address.338 //339 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9340 function removeCollectionAdminSubstrate(uint256 admin) external;341342 // Add collection admin.343 // @param new_admin Address of the added administrator.344 //345 // Selector: addCollectionAdmin(address) 92e462c7346 function addCollectionAdmin(address newAdmin) external;347348 // Remove collection admin.349 //350 // @param new_admin Address of the removed administrator.351 //352 // Selector: removeCollectionAdmin(address) fafd7b42353 function removeCollectionAdmin(address admin) external;354355 // Toggle accessibility of collection nesting.356 //357 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'358 //359 // Selector: setCollectionNesting(bool) 112d4586360 function setCollectionNesting(bool enable) external;361362 // Toggle accessibility of collection nesting.363 //364 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'365 // @param collections Addresses of collections that will be available for nesting.366 //367 // Selector: setCollectionNesting(bool,address[]) 64872396368 function setCollectionNesting(bool enable, address[] memory collections)369 external;370371 // Set the collection access method.372 // @param mode Access mode373 // 0 for Normal374 // 1 for AllowList375 //376 // Selector: setCollectionAccess(uint8) 41835d4c377 function setCollectionAccess(uint8 mode) external;378379 // Add the user to the allowed list.380 //381 // @param user Address of a trusted user.382 //383 // Selector: addToCollectionAllowList(address) 67844fe6384 function addToCollectionAllowList(address user) external;385386 // Remove the user from the allowed list.387 //388 // @param user Address of a removed user.389 //390 // Selector: removeFromCollectionAllowList(address) 85c51acb391 function removeFromCollectionAllowList(address user) external;392393 // Switch permission for minting.394 //395 // @param mode Enable if "true".396 //397 // Selector: setCollectionMintMode(bool) 00018e84398 function setCollectionMintMode(bool mode) external;399400 // Check that account is the owner or admin of the collection401 //402 // @param user account to verify403 // @return "true" if account is the owner or admin404 //405 // Selector: verifyOwnerOrAdmin(address) c2282493406 function verifyOwnerOrAdmin(address user) external view returns (bool);407408 // Returns collection type409 //410 // @return `Fungible` or `NFT` or `ReFungible`411 //412 // Selector: uniqueCollectionType() d34b55b8413 function uniqueCollectionType() external returns (string memory);414}252415253// Selector: 780e9d63416// Selector: 780e9d63254interface ERC721Enumerable is Dummy, ERC165 {417interface ERC721Enumerable is Dummy, ERC165 {276 function totalSupply() external view returns (uint256);439 function totalSupply() external view returns (uint256);277}440}278279// Selector: 7d9262e6280interface Collection is Dummy, ERC165 {281 // Set collection property.282 //283 // @param key Property key.284 // @param value Propery value.285 //286 // Selector: setCollectionProperty(string,bytes) 2f073f66287 function setCollectionProperty(string memory key, bytes memory value)288 external;289290 // Delete collection property.291 //292 // @param key Property key.293 //294 // Selector: deleteCollectionProperty(string) 7b7debce295 function deleteCollectionProperty(string memory key) external;296297 // Get collection property.298 //299 // @dev Throws error if key not found.300 //301 // @param key Property key.302 // @return bytes The property corresponding to the key.303 //304 // Selector: collectionProperty(string) cf24fd6d305 function collectionProperty(string memory key)306 external307 view308 returns (bytes memory);309310 // Set the sponsor of the collection.311 //312 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.313 //314 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.315 //316 // Selector: setCollectionSponsor(address) 7623402e317 function setCollectionSponsor(address sponsor) external;318319 // Collection sponsorship confirmation.320 //321 // @dev After setting the sponsor for the collection, it must be confirmed with this function.322 //323 // Selector: confirmCollectionSponsorship() 3c50e97a324 function confirmCollectionSponsorship() external;325326 // Set limits for the collection.327 // @dev Throws error if limit not found.328 // @param limit Name of the limit. Valid names:329 // "accountTokenOwnershipLimit",330 // "sponsoredDataSize",331 // "sponsoredDataRateLimit",332 // "tokenLimit",333 // "sponsorTransferTimeout",334 // "sponsorApproveTimeout"335 // @param value Value of the limit.336 //337 // Selector: setCollectionLimit(string,uint32) 6a3841db338 function setCollectionLimit(string memory limit, uint32 value) external;339340 // Set limits for the collection.341 // @dev Throws error if limit not found.342 // @param limit Name of the limit. Valid names:343 // "ownerCanTransfer",344 // "ownerCanDestroy",345 // "transfersEnabled"346 // @param value Value of the limit.347 //348 // Selector: setCollectionLimit(string,bool) 993b7fba349 function setCollectionLimit(string memory limit, bool value) external;350351 // Get contract address.352 //353 // Selector: contractAddress() f6b4dfb4354 function contractAddress() external view returns (address);355356 // Add collection admin by substrate address.357 // @param new_admin Substrate administrator address.358 //359 // Selector: addCollectionAdminSubstrate(uint256) 5730062b360 function addCollectionAdminSubstrate(uint256 newAdmin) external;361362 // Remove collection admin by substrate address.363 // @param admin Substrate administrator address.364 //365 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9366 function removeCollectionAdminSubstrate(uint256 admin) external;367368 // Add collection admin.369 // @param new_admin Address of the added administrator.370 //371 // Selector: addCollectionAdmin(address) 92e462c7372 function addCollectionAdmin(address newAdmin) external;373374 // Remove collection admin.375 //376 // @param new_admin Address of the removed administrator.377 //378 // Selector: removeCollectionAdmin(address) fafd7b42379 function removeCollectionAdmin(address admin) external;380381 // Toggle accessibility of collection nesting.382 //383 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'384 //385 // Selector: setCollectionNesting(bool) 112d4586386 function setCollectionNesting(bool enable) external;387388 // Toggle accessibility of collection nesting.389 //390 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'391 // @param collections Addresses of collections that will be available for nesting.392 //393 // Selector: setCollectionNesting(bool,address[]) 64872396394 function setCollectionNesting(bool enable, address[] memory collections)395 external;396397 // Set the collection access method.398 // @param mode Access mode399 // 0 for Normal400 // 1 for AllowList401 //402 // Selector: setCollectionAccess(uint8) 41835d4c403 function setCollectionAccess(uint8 mode) external;404405 // Add the user to the allowed list.406 //407 // @param user Address of a trusted user.408 //409 // Selector: addToCollectionAllowList(address) 67844fe6410 function addToCollectionAllowList(address user) external;411412 // Remove the user from the allowed list.413 //414 // @param user Address of a removed user.415 //416 // Selector: removeFromCollectionAllowList(address) 85c51acb417 function removeFromCollectionAllowList(address user) external;418419 // Switch permission for minting.420 //421 // @param mode Enable if "true".422 //423 // Selector: setCollectionMintMode(bool) 00018e84424 function setCollectionMintMode(bool mode) external;425}426441427// Selector: d74d154f442// Selector: d74d154f428interface ERC721UniqueExtensions is Dummy, ERC165 {443interface ERC721UniqueExtensions is Dummy, ERC165 {tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth248 function finishMinting() external returns (bool);248 function finishMinting() external returns (bool);249}249}250251// Selector: 6cf113cd252interface Collection is Dummy, ERC165 {253 // Set collection property.254 //255 // @param key Property key.256 // @param value Propery value.257 //258 // Selector: setCollectionProperty(string,bytes) 2f073f66259 function setCollectionProperty(string memory key, bytes memory value)260 external;261262 // Delete collection property.263 //264 // @param key Property key.265 //266 // Selector: deleteCollectionProperty(string) 7b7debce267 function deleteCollectionProperty(string memory key) external;268269 // Get collection property.270 //271 // @dev Throws error if key not found.272 //273 // @param key Property key.274 // @return bytes The property corresponding to the key.275 //276 // Selector: collectionProperty(string) cf24fd6d277 function collectionProperty(string memory key)278 external279 view280 returns (bytes memory);281282 // Set the sponsor of the collection.283 //284 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.285 //286 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.287 //288 // Selector: setCollectionSponsor(address) 7623402e289 function setCollectionSponsor(address sponsor) external;290291 // Collection sponsorship confirmation.292 //293 // @dev After setting the sponsor for the collection, it must be confirmed with this function.294 //295 // Selector: confirmCollectionSponsorship() 3c50e97a296 function confirmCollectionSponsorship() external;297298 // Set limits for the collection.299 // @dev Throws error if limit not found.300 // @param limit Name of the limit. Valid names:301 // "accountTokenOwnershipLimit",302 // "sponsoredDataSize",303 // "sponsoredDataRateLimit",304 // "tokenLimit",305 // "sponsorTransferTimeout",306 // "sponsorApproveTimeout"307 // @param value Value of the limit.308 //309 // Selector: setCollectionLimit(string,uint32) 6a3841db310 function setCollectionLimit(string memory limit, uint32 value) external;311312 // Set limits for the collection.313 // @dev Throws error if limit not found.314 // @param limit Name of the limit. Valid names:315 // "ownerCanTransfer",316 // "ownerCanDestroy",317 // "transfersEnabled"318 // @param value Value of the limit.319 //320 // Selector: setCollectionLimit(string,bool) 993b7fba321 function setCollectionLimit(string memory limit, bool value) external;322323 // Get contract address.324 //325 // Selector: contractAddress() f6b4dfb4326 function contractAddress() external view returns (address);327328 // Add collection admin by substrate address.329 // @param new_admin Substrate administrator address.330 //331 // Selector: addCollectionAdminSubstrate(uint256) 5730062b332 function addCollectionAdminSubstrate(uint256 newAdmin) external;333334 // Remove collection admin by substrate address.335 // @param admin Substrate administrator address.336 //337 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9338 function removeCollectionAdminSubstrate(uint256 admin) external;339340 // Add collection admin.341 // @param new_admin Address of the added administrator.342 //343 // Selector: addCollectionAdmin(address) 92e462c7344 function addCollectionAdmin(address newAdmin) external;345346 // Remove collection admin.347 //348 // @param new_admin Address of the removed administrator.349 //350 // Selector: removeCollectionAdmin(address) fafd7b42351 function removeCollectionAdmin(address admin) external;352353 // Toggle accessibility of collection nesting.354 //355 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'356 //357 // Selector: setCollectionNesting(bool) 112d4586358 function setCollectionNesting(bool enable) external;359360 // Toggle accessibility of collection nesting.361 //362 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'363 // @param collections Addresses of collections that will be available for nesting.364 //365 // Selector: setCollectionNesting(bool,address[]) 64872396366 function setCollectionNesting(bool enable, address[] memory collections)367 external;368369 // Set the collection access method.370 // @param mode Access mode371 // 0 for Normal372 // 1 for AllowList373 //374 // Selector: setCollectionAccess(uint8) 41835d4c375 function setCollectionAccess(uint8 mode) external;376377 // Add the user to the allowed list.378 //379 // @param user Address of a trusted user.380 //381 // Selector: addToCollectionAllowList(address) 67844fe6382 function addToCollectionAllowList(address user) external;383384 // Remove the user from the allowed list.385 //386 // @param user Address of a removed user.387 //388 // Selector: removeFromCollectionAllowList(address) 85c51acb389 function removeFromCollectionAllowList(address user) external;390391 // Switch permission for minting.392 //393 // @param mode Enable if "true".394 //395 // Selector: setCollectionMintMode(bool) 00018e84396 function setCollectionMintMode(bool mode) external;397398 // Check that account is the owner or admin of the collection399 //400 // @param user account to verify401 // @return "true" if account is the owner or admin402 //403 // Selector: verifyOwnerOrAdmin(address) c2282493404 function verifyOwnerOrAdmin(address user) external view returns (bool);405406 // Returns collection type407 //408 // @return `Fungible` or `NFT` or `ReFungible`409 //410 // Selector: uniqueCollectionType() d34b55b8411 function uniqueCollectionType() external returns (string memory);412}250413251// Selector: 780e9d63414// Selector: 780e9d63252interface ERC721Enumerable is Dummy, ERC165 {415interface ERC721Enumerable is Dummy, ERC165 {274 function totalSupply() external view returns (uint256);437 function totalSupply() external view returns (uint256);275}438}276439277// Selector: 7d9262e6440// Selector: 7c3bef89278interface Collection is Dummy, ERC165 {279 // Set collection property.280 //281 // @param key Property key.282 // @param value Propery value.283 //284 // Selector: setCollectionProperty(string,bytes) 2f073f66285 function setCollectionProperty(string memory key, bytes memory value)286 external;287288 // Delete collection property.289 //290 // @param key Property key.291 //292 // Selector: deleteCollectionProperty(string) 7b7debce293 function deleteCollectionProperty(string memory key) external;294295 // Get collection property.296 //297 // @dev Throws error if key not found.298 //299 // @param key Property key.300 // @return bytes The property corresponding to the key.301 //302 // Selector: collectionProperty(string) cf24fd6d303 function collectionProperty(string memory key)304 external305 view306 returns (bytes memory);307308 // Set the sponsor of the collection.309 //310 // @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.311 //312 // @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.313 //314 // Selector: setCollectionSponsor(address) 7623402e315 function setCollectionSponsor(address sponsor) external;316317 // Collection sponsorship confirmation.318 //319 // @dev After setting the sponsor for the collection, it must be confirmed with this function.320 //321 // Selector: confirmCollectionSponsorship() 3c50e97a322 function confirmCollectionSponsorship() external;323324 // Set limits for the collection.325 // @dev Throws error if limit not found.326 // @param limit Name of the limit. Valid names:327 // "accountTokenOwnershipLimit",328 // "sponsoredDataSize",329 // "sponsoredDataRateLimit",330 // "tokenLimit",331 // "sponsorTransferTimeout",332 // "sponsorApproveTimeout"333 // @param value Value of the limit.334 //335 // Selector: setCollectionLimit(string,uint32) 6a3841db336 function setCollectionLimit(string memory limit, uint32 value) external;337338 // Set limits for the collection.339 // @dev Throws error if limit not found.340 // @param limit Name of the limit. Valid names:341 // "ownerCanTransfer",342 // "ownerCanDestroy",343 // "transfersEnabled"344 // @param value Value of the limit.345 //346 // Selector: setCollectionLimit(string,bool) 993b7fba347 function setCollectionLimit(string memory limit, bool value) external;348349 // Get contract address.350 //351 // Selector: contractAddress() f6b4dfb4352 function contractAddress() external view returns (address);353354 // Add collection admin by substrate address.355 // @param new_admin Substrate administrator address.356 //357 // Selector: addCollectionAdminSubstrate(uint256) 5730062b358 function addCollectionAdminSubstrate(uint256 newAdmin) external;359360 // Remove collection admin by substrate address.361 // @param admin Substrate administrator address.362 //363 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9364 function removeCollectionAdminSubstrate(uint256 admin) external;365366 // Add collection admin.367 // @param new_admin Address of the added administrator.368 //369 // Selector: addCollectionAdmin(address) 92e462c7370 function addCollectionAdmin(address newAdmin) external;371372 // Remove collection admin.373 //374 // @param new_admin Address of the removed administrator.375 //376 // Selector: removeCollectionAdmin(address) fafd7b42377 function removeCollectionAdmin(address admin) external;378379 // Toggle accessibility of collection nesting.380 //381 // @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'382 //383 // Selector: setCollectionNesting(bool) 112d4586384 function setCollectionNesting(bool enable) external;385386 // Toggle accessibility of collection nesting.387 //388 // @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'389 // @param collections Addresses of collections that will be available for nesting.390 //391 // Selector: setCollectionNesting(bool,address[]) 64872396392 function setCollectionNesting(bool enable, address[] memory collections)393 external;394395 // Set the collection access method.396 // @param mode Access mode397 // 0 for Normal398 // 1 for AllowList399 //400 // Selector: setCollectionAccess(uint8) 41835d4c401 function setCollectionAccess(uint8 mode) external;402403 // Add the user to the allowed list.404 //405 // @param user Address of a trusted user.406 //407 // Selector: addToCollectionAllowList(address) 67844fe6408 function addToCollectionAllowList(address user) external;409410 // Remove the user from the allowed list.411 //412 // @param user Address of a removed user.413 //414 // Selector: removeFromCollectionAllowList(address) 85c51acb415 function removeFromCollectionAllowList(address user) external;416417 // Switch permission for minting.418 //419 // @param mode Enable if "true".420 //421 // Selector: setCollectionMintMode(bool) 00018e84422 function setCollectionMintMode(bool mode) external;423}424425// Selector: d74d154f426interface ERC721UniqueExtensions is Dummy, ERC165 {441interface ERC721UniqueExtensions is Dummy, ERC165 {427 // @notice Transfer ownership of an RFT442 // @notice Transfer ownership of an RFT428 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`443 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`474 external489 external475 returns (bool);490 returns (bool);491492 // Returns EVM address for refungible token493 //494 // @param token ID of the token495 //496 // Selector: tokenContractAddress(uint256) ab76fac6497 function tokenContractAddress(uint256 token)498 external499 view500 returns (address);476}501}477502478interface UniqueRefungible is503interface UniqueRefungible istests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth22 );22 );23}23}2425// Selector: 042f110626interface ERC1633UniqueExtensions is Dummy, ERC165 {27 // Selector: setParentNFT(address,uint256) 042f110628 function setParentNFT(address collection, uint256 nftId)29 external30 returns (bool);31}3233// Selector: 5755c3f234interface ERC1633 is Dummy, ERC165 {35 // Selector: parentToken() 80a5400136 function parentToken() external view returns (address);3738 // Selector: parentTokenId() d7f083f339 function parentTokenId() external view returns (uint256);40}244125// Selector: 942e8b2242// Selector: 942e8b2226interface ERC20 is Dummy, ERC165, ERC20Events {43interface ERC20 is Dummy, ERC165, ERC20Events {115 Dummy,132 Dummy,116 ERC165,133 ERC165,117 ERC20,134 ERC20,118 ERC20UniqueExtensions135 ERC20UniqueExtensions,136 ERC1633,137 ERC1633UniqueExtensions119{}138{}120139tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth60 .to.be.eq(newAdmin.address.toLocaleLowerCase());60 .to.be.eq(newAdmin.address.toLocaleLowerCase());61 });61 });62 63 itWeb3('Verify owner or admin', async ({api, web3, privateKeyWrapper}) => {64 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);65 const collectionHelper = evmCollectionHelpers(web3, owner);66 67 const result = await collectionHelper.methods68 .createNonfungibleCollection('A', 'B', 'C')69 .send();70 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);7172 const newAdmin = createEthAccount(web3);73 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);74 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.false;75 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();76 expect(await collectionEvm.methods.verifyOwnerOrAdmin(newAdmin).call()).to.be.true;77 });627863 itWeb3('(!negative tests!) Add admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {79 itWeb3('(!negative tests!) Add admin by ADMIN is not allowed', async ({api, web3, privateKeyWrapper}) => {64 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);80 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);tests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth61 ],61 ],62 "name": "createRefungibleCollection",62 "name": "createRefungibleCollection",63 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],63 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],64 "stateMutability": "view",64 "stateMutability": "nonpayable",65 "type": "function"65 "type": "function"66 },66 },67 {67 {tests/src/eth/fractionalizer/Fractionalizer.bindiffbeforeafterbothno changes
tests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterbothno changes
tests/src/eth/fractionalizer/FractionalizerAbi.jsondiffbeforeafterbothno changes
tests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterbothno changes
tests/src/eth/fungibleAbi.jsondiffbeforeafterboth301 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],301 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],302 "stateMutability": "nonpayable",302 "stateMutability": "nonpayable",303 "type": "function"303 "type": "function"304 }304 },305 {306 "inputs": [],307 "name": "uniqueCollectionType",308 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],309 "stateMutability": "nonpayable",310 "type": "function"311 },312 {313 "inputs": [314 { "internalType": "address", "name": "user", "type": "address" }315 ],316 "name": "verifyOwnerOrAdmin",317 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],318 "stateMutability": "view",319 "type": "function"320 }305]321]306322tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth526 "outputs": [],526 "outputs": [],527 "stateMutability": "nonpayable",527 "stateMutability": "nonpayable",528 "type": "function"528 "type": "function"529 }529 },530 {531 "inputs": [],532 "name": "uniqueCollectionType",533 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],534 "stateMutability": "nonpayable",535 "type": "function"536 },537 {538 "inputs": [539 { "internalType": "address", "name": "user", "type": "address" }540 ],541 "name": "verifyOwnerOrAdmin",542 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],543 "stateMutability": "view",544 "type": "function"545 }530]546]531547tests/src/eth/reFungible.test.tsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {createCollectionExpectSuccess, UNIQUE, requirePallets, Pallets} from '../util/helpers';17import {createCollectionExpectSuccess, UNIQUE, requirePallets, Pallets} from '../util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, tokenIdToAddress} from './util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, tokenIdToAddress, uniqueRefungibleToken} from './util/helpers';19import reFungibleTokenAbi from './reFungibleTokenAbi.json';20import {expect} from 'chai';19import {expect} from 'chai';212022describe('Refungible: Information getting', () => {21describe('Refungible: Information getting', () => {88 await contract.methods.mint(caller, tokenId).send();87 await contract.methods.mint(caller, tokenId).send();898890 const tokenAddress = tokenIdToAddress(collectionId, tokenId);89 const tokenAddress = tokenIdToAddress(collectionId, tokenId);91 const tokenContract = new web3.eth.Contract(reFungibleTokenAbi as any, tokenAddress, {from: caller, ...GAS_ARGS});90 const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);929193 await tokenContract.methods.repartition(2).send();92 await tokenContract.methods.repartition(2).send();94 await tokenContract.methods.transfer(receiver, 1).send();93 await tokenContract.methods.transfer(receiver, 1).send();112 await contract.methods.mint(caller, tokenId).send();111 await contract.methods.mint(caller, tokenId).send();113112114 const tokenAddress = tokenIdToAddress(collectionId, tokenId);113 const tokenAddress = tokenIdToAddress(collectionId, tokenId);115 const tokenContract = new web3.eth.Contract(reFungibleTokenAbi as any, tokenAddress, {from: caller, ...GAS_ARGS});114 const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);116115117 await tokenContract.methods.repartition(2).send();116 await tokenContract.methods.repartition(2).send();118 await tokenContract.methods.transfer(receiver, 1).send();117 await tokenContract.methods.transfer(receiver, 1).send();258 await contract.methods.mint(caller, tokenId).send();257 await contract.methods.mint(caller, tokenId).send();259258260 const address = tokenIdToAddress(collectionId, tokenId);259 const address = tokenIdToAddress(collectionId, tokenId);261 const tokenContract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: caller, ...GAS_ARGS});260 const tokenContract = uniqueRefungibleToken(web3, address, caller);262 await tokenContract.methods.repartition(15).send();261 await tokenContract.methods.repartition(15).send();263262264 {263 {353 await contract.methods.mint(caller, tokenId).send();352 await contract.methods.mint(caller, tokenId).send();354353355 const tokenAddress = tokenIdToAddress(collectionId, tokenId);354 const tokenAddress = tokenIdToAddress(collectionId, tokenId);356 const tokenContract = new web3.eth.Contract(reFungibleTokenAbi as any, tokenAddress, {from: caller, ...GAS_ARGS});355 const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);357356358 await tokenContract.methods.repartition(2).send();357 await tokenContract.methods.repartition(2).send();359 await tokenContract.methods.transfer(receiver, 1).send();358 await tokenContract.methods.transfer(receiver, 1).send();385 await contract.methods.mint(caller, tokenId).send();384 await contract.methods.mint(caller, tokenId).send();386385387 const tokenAddress = tokenIdToAddress(collectionId, tokenId);386 const tokenAddress = tokenIdToAddress(collectionId, tokenId);388 const tokenContract = new web3.eth.Contract(reFungibleTokenAbi as any, tokenAddress, {from: caller, ...GAS_ARGS});387 const tokenContract = uniqueRefungibleToken(web3, tokenAddress, caller);389388390 await tokenContract.methods.repartition(2).send();389 await tokenContract.methods.repartition(2).send();391 390tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth480 "stateMutability": "view",480 "stateMutability": "view",481 "type": "function"481 "type": "function"482 },482 },483 {484 "inputs": [485 { "internalType": "uint256", "name": "token", "type": "uint256" }486 ],487 "name": "tokenContractAddress",488 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],489 "stateMutability": "view",490 "type": "function"491 },483 {492 {484 "inputs": [493 "inputs": [485 { "internalType": "address", "name": "owner", "type": "address" },494 { "internalType": "address", "name": "owner", "type": "address" },526 "outputs": [],535 "outputs": [],527 "stateMutability": "nonpayable",536 "stateMutability": "nonpayable",528 "type": "function"537 "type": "function"529 }538 },539 {540 "inputs": [],541 "name": "uniqueCollectionType",542 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],543 "stateMutability": "nonpayable",544 "type": "function"545 },546 {547 "inputs": [548 { "internalType": "address", "name": "user", "type": "address" }549 ],550 "name": "verifyOwnerOrAdmin",551 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],552 "stateMutability": "view",553 "type": "function"554 }530]555]531556tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers';17import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth} from './util/helpers';18import {collectionIdFromAddress, collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createNonfungibleCollection, createRefungibleCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from './util/helpers';19import reFungibleTokenAbi from './reFungibleTokenAbi.json';201921import chai from 'chai';20import chai from 'chai';22import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';38 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: caller})).itemId;37 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: caller})).itemId;393840 const address = tokenIdToAddress(collectionId, tokenId);39 const address = tokenIdToAddress(collectionId, tokenId);41 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: caller, ...GAS_ARGS});40 const contract = uniqueRefungibleToken(web3, address, caller);42 const totalSupply = await contract.methods.totalSupply().call();41 const totalSupply = await contract.methods.totalSupply().call();434244 expect(totalSupply).to.equal('200');43 expect(totalSupply).to.equal('200');54 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: caller})).itemId;53 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: caller})).itemId;555456 const address = tokenIdToAddress(collectionId, tokenId);55 const address = tokenIdToAddress(collectionId, tokenId);57 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: caller, ...GAS_ARGS});56 const contract = uniqueRefungibleToken(web3, address, caller);58 const balance = await contract.methods.balanceOf(caller).call();57 const balance = await contract.methods.balanceOf(caller).call();595860 expect(balance).to.equal('200');59 expect(balance).to.equal('200');70 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: caller})).itemId;69 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: caller})).itemId;717072 const address = tokenIdToAddress(collectionId, tokenId);71 const address = tokenIdToAddress(collectionId, tokenId);73 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: caller, ...GAS_ARGS});72 const contract = uniqueRefungibleToken(web3, address, caller);74 const decimals = await contract.methods.decimals().call();73 const decimals = await contract.methods.decimals().call();757476 expect(decimals).to.equal('0');75 expect(decimals).to.equal('0');90 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);89 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);91 const receiver = createEthAccount(web3);90 const receiver = createEthAccount(web3);92 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});91 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});93 9294 const nextTokenId = await contract.methods.nextTokenId().call();93 const nextTokenId = await contract.methods.nextTokenId().call();95 expect(nextTokenId).to.be.equal('1');94 expect(nextTokenId).to.be.equal('1');96 result = await contract.methods.mint(95 result = await contract.methods.mint(123 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);122 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);124 const receiver = createEthAccount(web3);123 const receiver = createEthAccount(web3);125 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});124 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});126 125127 const nextTokenId = await contract.methods.nextTokenId().call();126 const nextTokenId = await contract.methods.nextTokenId().call();128 expect(nextTokenId).to.be.equal('1');127 expect(nextTokenId).to.be.equal('1');129 result = await contract.methods.mint(128 result = await contract.methods.mint(130 receiver,129 receiver,131 nextTokenId,130 nextTokenId,132 ).send();131 ).send();133 132134 // Set URL133 // Set URL135 await contract.methods.setProperty(nextTokenId, 'url', Buffer.from('Token URI')).send();134 await contract.methods.setProperty(nextTokenId, 'url', Buffer.from('Token URI')).send();136 135137 const events = normalizeEvents(result.events);136 const events = normalizeEvents(result.events);138 const address = collectionIdToAddress(collectionId);137 const address = collectionIdToAddress(collectionId);139138159 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);158 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);160 const receiver = createEthAccount(web3);159 const receiver = createEthAccount(web3);161 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});160 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});162 161163 const nextTokenId = await contract.methods.nextTokenId().call();162 const nextTokenId = await contract.methods.nextTokenId().call();164 expect(nextTokenId).to.be.equal('1');163 expect(nextTokenId).to.be.equal('1');165 result = await contract.methods.mint(164 result = await contract.methods.mint(166 receiver,165 receiver,167 nextTokenId,166 nextTokenId,168 ).send();167 ).send();169 168170 const events = normalizeEvents(result.events);169 const events = normalizeEvents(result.events);171 const address = collectionIdToAddress(collectionId);170 const address = collectionIdToAddress(collectionId);172171192 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);191 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);193 const receiver = createEthAccount(web3);192 const receiver = createEthAccount(web3);194 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});193 const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});195 194196 const nextTokenId = await contract.methods.nextTokenId().call();195 const nextTokenId = await contract.methods.nextTokenId().call();197 expect(nextTokenId).to.be.equal('1');196 expect(nextTokenId).to.be.equal('1');198 result = await contract.methods.mint(197 result = await contract.methods.mint(199 receiver,198 receiver,200 nextTokenId,199 nextTokenId,201 ).send();200 ).send();202 201203 // Set suffix202 // Set suffix204 const suffix = '/some/suffix';203 const suffix = '/some/suffix';205 await contract.methods.setProperty(nextTokenId, 'suffix', Buffer.from(suffix)).send();204 await contract.methods.setProperty(nextTokenId, 'suffix', Buffer.from(suffix)).send();241240242 const spender = createEthAccount(web3);241 const spender = createEthAccount(web3);243242244 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});243 const contract = uniqueRefungibleToken(web3, address, owner);245244246 {245 {247 const result = await contract.methods.approve(spender, 100).send({from: owner});246 const result = await contract.methods.approve(spender, 100).send({from: owner});282 const receiver = createEthAccount(web3);281 const receiver = createEthAccount(web3);283282284 const address = tokenIdToAddress(collectionId, tokenId);283 const address = tokenIdToAddress(collectionId, tokenId);285 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});284 const contract = uniqueRefungibleToken(web3, address, owner);286285287 await contract.methods.approve(spender, 100).send();286 await contract.methods.approve(spender, 100).send();288287336 await transferBalanceToEth(api, alice, receiver);335 await transferBalanceToEth(api, alice, receiver);337336338 const address = tokenIdToAddress(collectionId, tokenId);337 const address = tokenIdToAddress(collectionId, tokenId);339 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});338 const contract = uniqueRefungibleToken(web3, address, owner);340339341 {340 {342 const result = await contract.methods.transfer(receiver, 50).send({from: owner});341 const result = await contract.methods.transfer(receiver, 50).send({from: owner});379 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n, {Ethereum: owner})).itemId;378 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n, {Ethereum: owner})).itemId;380379381 const address = tokenIdToAddress(collectionId, tokenId);380 const address = tokenIdToAddress(collectionId, tokenId);382 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});381 const contract = uniqueRefungibleToken(web3, address, owner);383382384 await contract.methods.repartition(200).send({from: owner});383 await contract.methods.repartition(200).send({from: owner});385 expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(200);384 expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(200);386 await contract.methods.transfer(receiver, 110).send({from: owner});385 await contract.methods.transfer(receiver, 110).send({from: owner});387 expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(90);386 expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(90);388 expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(110);387 expect(+await contract.methods.balanceOf(receiver).call()).to.be.equal(110);389 388390 await expect(contract.methods.repartition(80).send({from: owner})).to.eventually.be.rejected;389 await expect(contract.methods.repartition(80).send({from: owner})).to.eventually.be.rejected;391390392 await contract.methods.transfer(receiver, 90).send({from: owner});391 await contract.methods.transfer(receiver, 90).send({from: owner});409 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n, {Ethereum: owner})).itemId;408 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n, {Ethereum: owner})).itemId;410409411 const address = tokenIdToAddress(collectionId, tokenId);410 const address = tokenIdToAddress(collectionId, tokenId);412 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});411 const contract = uniqueRefungibleToken(web3, address, owner);413412414 const result = await contract.methods.repartition(200).send();413 const result = await contract.methods.repartition(200).send();415 const events = normalizeEvents(result.events);414 const events = normalizeEvents(result.events);438 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n, {Ethereum: owner})).itemId;437 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n, {Ethereum: owner})).itemId;439438440 const address = tokenIdToAddress(collectionId, tokenId);439 const address = tokenIdToAddress(collectionId, tokenId);441 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});440 const contract = uniqueRefungibleToken(web3, address, owner);442441443 const result = await contract.methods.repartition(50).send();442 const result = await contract.methods.repartition(50).send();444 const events = normalizeEvents(result.events);443 const events = normalizeEvents(result.events);468467469 const address = tokenIdToAddress(collectionId, tokenId);468 const address = tokenIdToAddress(collectionId, tokenId);470469471 const tokenContract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: caller, ...GAS_ARGS});470 const tokenContract = uniqueRefungibleToken(web3, address, caller);472 await tokenContract.methods.repartition(2).send();471 await tokenContract.methods.repartition(2).send();473 await tokenContract.methods.transfer(receiver, 1).send();472 await tokenContract.methods.transfer(receiver, 1).send();474473475 const events = await recordEvents(contract, async () => 474 const events = await recordEvents(contract, async () =>476 await tokenContract.methods.burnFrom(caller, 1).send());475 await tokenContract.methods.burnFrom(caller, 1).send());477 expect(events).to.deep.equal([476 expect(events).to.deep.equal([478 {477 {504 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: owner})).itemId;503 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: owner})).itemId;505504506 const address = tokenIdToAddress(collectionId, tokenId);505 const address = tokenIdToAddress(collectionId, tokenId);507 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});506 const contract = uniqueRefungibleToken(web3, address, owner);508507509 const cost = await recordEthFee(api, owner, () => contract.methods.approve(spender, 100).send({from: owner}));508 const cost = await recordEthFee(api, owner, () => contract.methods.approve(spender, 100).send({from: owner}));510 expect(cost < BigInt(0.2 * Number(UNIQUE)));509 expect(cost < BigInt(0.2 * Number(UNIQUE)));521 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: owner})).itemId;520 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: owner})).itemId;522521523 const address = tokenIdToAddress(collectionId, tokenId);522 const address = tokenIdToAddress(collectionId, tokenId);524 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});523 const contract = uniqueRefungibleToken(web3, address, owner);525524526 await contract.methods.approve(spender, 100).send({from: owner});525 await contract.methods.approve(spender, 100).send({from: owner});527526540 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: owner})).itemId;539 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n, {Ethereum: owner})).itemId;541540542 const address = tokenIdToAddress(collectionId, tokenId);541 const address = tokenIdToAddress(collectionId, tokenId);543 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address, {from: owner, ...GAS_ARGS});542 const contract = uniqueRefungibleToken(web3, address, owner);544543545 const cost = await recordEthFee(api, owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));544 const cost = await recordEthFee(api, owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));546 expect(cost < BigInt(0.2 * Number(UNIQUE)));545 expect(cost < BigInt(0.2 * Number(UNIQUE)));562 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n)).itemId;561 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n)).itemId;563562564 const address = tokenIdToAddress(collectionId, tokenId);563 const address = tokenIdToAddress(collectionId, tokenId);565 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address);564 const contract = uniqueRefungibleToken(web3, address);566565567 const events = await recordEvents(contract, async () => {566 const events = await recordEvents(contract, async () => {568 expect(await approve(api, collectionId, tokenId, alice, {Ethereum: receiver}, 100n)).to.be.true;567 expect(await approve(api, collectionId, tokenId, alice, {Ethereum: receiver}, 100n)).to.be.true;593 expect(await approve(api, collectionId, tokenId, alice, bob.address, 100n)).to.be.true;592 expect(await approve(api, collectionId, tokenId, alice, bob.address, 100n)).to.be.true;594593595 const address = tokenIdToAddress(collectionId, tokenId);594 const address = tokenIdToAddress(collectionId, tokenId);596 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address);595 const contract = uniqueRefungibleToken(web3, address);597596598 const events = await recordEvents(contract, async () => {597 const events = await recordEvents(contract, async () => {599 expect(await transferFrom(api, collectionId, tokenId, bob, alice, {Ethereum: receiver}, 51n)).to.be.true;598 expect(await transferFrom(api, collectionId, tokenId, bob, alice, {Ethereum: receiver}, 51n)).to.be.true;631 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n)).itemId;630 const tokenId = (await createRefungibleToken(api, alice, collectionId, 200n)).itemId;632631633 const address = tokenIdToAddress(collectionId, tokenId);632 const address = tokenIdToAddress(collectionId, tokenId);634 const contract = new web3.eth.Contract(reFungibleTokenAbi as any, address);633 const contract = uniqueRefungibleToken(web3, address);635634636 const events = await recordEvents(contract, async () => {635 const events = await recordEvents(contract, async () => {637 expect(await transfer(api, collectionId, tokenId, alice, {Ethereum: receiver}, 51n)).to.be.true;636 expect(await transfer(api, collectionId, tokenId, alice, {Ethereum: receiver}, 51n)).to.be.true;648 },647 },649 },648 },650 ]);649 ]);650 });651});652653describe('ERC 1633 implementation', () => {654 itWeb3('Parent NFT token address and id', async ({api, web3, privateKeyWrapper}) => {655 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);656657 const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);658 const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);659 const nftTokenId = await nftContract.methods.nextTokenId().call();660 await nftContract.methods.mint(owner, nftTokenId).send();661 const nftCollectionId = collectionIdFromAddress(nftCollectionAddress);662663 const {collectionIdAddress, collectionId} = await createRefungibleCollection(api, web3, owner);664 const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);665 const refungibleTokenId = await refungibleContract.methods.nextTokenId().call();666 await refungibleContract.methods.mint(owner, refungibleTokenId).send();667668 const rftTokenAddress = tokenIdToAddress(collectionId, refungibleTokenId);669 const refungibleTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);670 await refungibleTokenContract.methods.setParentNFT(nftCollectionAddress, nftTokenId).send();671672 const tokenAddress = await refungibleTokenContract.methods.parentToken().call();673 const tokenId = await refungibleTokenContract.methods.parentTokenId().call();674 const nftTokenAddress = tokenIdToAddress(nftCollectionId, nftTokenId);675 expect(tokenAddress).to.be.equal(nftTokenAddress);676 expect(tokenId).to.be.equal(nftTokenId);677 });678679 itWeb3('Default parent token address and id', async ({api, web3, privateKeyWrapper}) => {680 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);681682 const {collectionIdAddress, collectionId} = await createRefungibleCollection(api, web3, owner);683 const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);684 const refungibleTokenId = await refungibleContract.methods.nextTokenId().call();685 await refungibleContract.methods.mint(owner, refungibleTokenId).send();686687 const rftTokenAddress = tokenIdToAddress(collectionId, refungibleTokenId);688 const refungibleTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);689690 const tokenAddress = await refungibleTokenContract.methods.parentToken().call();691 const tokenId = await refungibleTokenContract.methods.parentTokenId().call();692 expect(tokenAddress).to.be.equal(rftTokenAddress);693 expect(tokenId).to.be.equal(refungibleTokenId);651 });694 });652});695});653696tests/src/eth/reFungibleTokenAbi.jsondiffbeforeafterboth102 "stateMutability": "view",102 "stateMutability": "view",103 "type": "function"103 "type": "function"104 },104 },105 {106 "inputs": [],107 "name": "parentToken",108 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],109 "stateMutability": "view",110 "type": "function"111 },112 {113 "inputs": [],114 "name": "parentTokenId",115 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],116 "stateMutability": "view",117 "type": "function"118 },105 {119 {106 "inputs": [120 "inputs": [107 { "internalType": "uint256", "name": "amount", "type": "uint256" }121 { "internalType": "uint256", "name": "amount", "type": "uint256" }111 "stateMutability": "nonpayable",125 "stateMutability": "nonpayable",112 "type": "function"126 "type": "function"113 },127 },128 {129 "inputs": [130 { "internalType": "address", "name": "collection", "type": "address" },131 { "internalType": "uint256", "name": "nftId", "type": "uint256" }132 ],133 "name": "setParentNFT",134 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],135 "stateMutability": "nonpayable",136 "type": "function"137 },114 {138 {115 "inputs": [139 "inputs": [116 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }140 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }tests/src/eth/util/helpers.tsdiffbeforeafterboth32import fungibleAbi from '../fungibleAbi.json';32import fungibleAbi from '../fungibleAbi.json';33import nonFungibleAbi from '../nonFungibleAbi.json';33import nonFungibleAbi from '../nonFungibleAbi.json';34import refungibleAbi from '../reFungibleAbi.json';34import refungibleAbi from '../reFungibleAbi.json';35import refungibleTokenAbi from '../reFungibleTokenAbi.json';35import contractHelpersAbi from './contractHelpersAbi.json';36import contractHelpersAbi from './contractHelpersAbi.json';363737export const GAS_ARGS = {gas: 2500000};38export const GAS_ARGS = {gas: 2500000};102 return Web3.utils.toChecksumAddress('0x' + buf.toString('hex'));103 return Web3.utils.toChecksumAddress('0x' + buf.toString('hex'));103}104}105106export function tokenIdFromAddress(address: string) {107 if (!address.startsWith('0x'))108 throw 'address not starts with "0x"';109 if (address.length > 42)110 throw 'address length is more than 20 bytes';111 return {112 collectionId: Number('0x' + address.substring(address.length - 16, address.length - 8)),113 tokenId: Number('0x' + address.substring(address.length - 8)),114 };115}116104export function tokenIdToCross(collection: number, token: number): CrossAccountId {117export function tokenIdToCross(collection: number, token: number): CrossAccountId {105 return {118 return {128 expect(result.success).to.be.true;141 expect(result.success).to.be.true;129}142}143144export async function createRefungibleCollection(api: ApiPromise, web3: Web3, owner: string) {145 const collectionHelper = evmCollectionHelpers(web3, owner);146 const result = await collectionHelper.methods147 .createRefungibleCollection('A', 'B', 'C')148 .send();149 return await getCollectionAddressFromResult(api, result);150}151152153export async function createNonfungibleCollection(api: ApiPromise, web3: Web3, owner: string) {154 const collectionHelper = evmCollectionHelpers(web3, owner);155 const result = await collectionHelper.methods156 .createNonfungibleCollection('A', 'B', 'C')157 .send();158 return await getCollectionAddressFromResult(api, result);159}160161export function uniqueNFT(web3: Web3, address: string, owner: string) {162 return new web3.eth.Contract(nonFungibleAbi as any, address, {163 from: owner,164 ...GAS_ARGS,165 });166}167168export function uniqueRefungible(web3: Web3, collectionAddress: string, owner: string) {169 return new web3.eth.Contract(refungibleAbi as any, collectionAddress, {170 from: owner,171 ...GAS_ARGS,172 });173}174175export function uniqueRefungibleToken(web3: Web3, tokenAddress: string, owner: string | undefined = undefined) {176 return new web3.eth.Contract(refungibleTokenAbi as any, tokenAddress, {177 from: owner,178 ...GAS_ARGS,179 });180}130181131export async function itWeb3(name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {182export async function itWeb3(name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {132 let i: any = it;183 let i: any = it;199 return Web3.utils.toChecksumAddress(subToEthLowercase(eth));250 return Web3.utils.toChecksumAddress(subToEthLowercase(eth));200}251}252253export interface CompiledContract {254 abi: any,255 object: string,256}201257202export function compileContract(name: string, src: string) {258export function compileContract(name: string, src: string) : CompiledContract {203 const out = JSON.parse(solc.compile(JSON.stringify({259 const out = JSON.parse(solc.compile(JSON.stringify({204 language: 'Solidity',260 language: 'Solidity',205 sources: {261 sources: {tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth266 * 266 * 267 * Currently used to store RMRK data.267 * Currently used to store RMRK data.268 **/268 **/269 tokenAuxProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: UpDataStructsPropertyScope | 'None' | 'Rmrk' | number | Uint8Array, arg4: Bytes | string | Uint8Array) => Observable<Option<Bytes>>, [u32, u32, UpDataStructsPropertyScope, Bytes]> & QueryableStorageEntry<ApiType, [u32, u32, UpDataStructsPropertyScope, Bytes]>;269 tokenAuxProperties: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: UpDataStructsPropertyScope | 'None' | 'Rmrk' | 'Eth' | number | Uint8Array, arg4: Bytes | string | Uint8Array) => Observable<Option<Bytes>>, [u32, u32, UpDataStructsPropertyScope, Bytes]> & QueryableStorageEntry<ApiType, [u32, u32, UpDataStructsPropertyScope, Bytes]>;270 /**270 /**271 * Used to enumerate token's children.271 * Used to enumerate token's children.272 **/272 **/tests/src/interfaces/default/types.tsdiffbeforeafterboth2521export interface UpDataStructsPropertyScope extends Enum {2521export interface UpDataStructsPropertyScope extends Enum {2522 readonly isNone: boolean;2522 readonly isNone: boolean;2523 readonly isRmrk: boolean;2523 readonly isRmrk: boolean;2524 readonly isEth: boolean;2524 readonly type: 'None' | 'Rmrk';2525 readonly type: 'None' | 'Rmrk' | 'Eth';2525}2526}252625272527/** @name UpDataStructsRpcCollection */2528/** @name UpDataStructsRpcCollection */tests/src/interfaces/lookup.tsdiffbeforeafterboth2978 * Lookup397: up_data_structs::PropertyScope2978 * Lookup397: up_data_structs::PropertyScope2979 **/2979 **/2980 UpDataStructsPropertyScope: {2980 UpDataStructsPropertyScope: {2981 _enum: ['None', 'Rmrk']2981 _enum: ['None', 'Rmrk', 'Eth']2982 },2982 },2983 /**2983 /**2984 * Lookup399: pallet_nonfungible::pallet::Error<T>2984 * Lookup399: pallet_nonfungible::pallet::Error<T>tests/src/interfaces/types-lookup.tsdiffbeforeafterboth3126 export interface UpDataStructsPropertyScope extends Enum {3126 export interface UpDataStructsPropertyScope extends Enum {3127 readonly isNone: boolean;3127 readonly isNone: boolean;3128 readonly isRmrk: boolean;3128 readonly isRmrk: boolean;3129 readonly isEth: boolean;3129 readonly type: 'None' | 'Rmrk';3130 readonly type: 'None' | 'Rmrk' | 'Eth';3130 }3131 }313131323132 /** @name PalletNonfungibleError (399) */3133 /** @name PalletNonfungibleError (399) */tests/yarn.lockdiffbeforeafterboth963 dependencies:963 dependencies:964 "@types/chai" "*"964 "@types/chai" "*"965965966"@types/chai-like@^1.1.1":967 version "1.1.1"968 resolved "https://registry.yarnpkg.com/@types/chai-like/-/chai-like-1.1.1.tgz#c454039b0a2f92664fb5b7b7a2a66c3358783ae7"969 integrity sha512-s46EZsupBuVhLn66DbRee5B0SELLmL4nFXVrBiV29BxLGm9Sh7Bful623j3AfiQRu2zAP4cnlZ3ETWB3eWc4bA==970 dependencies:971 "@types/chai" "*"972973"@types/chai-things@^0.0.35":974 version "0.0.35"975 resolved "https://registry.yarnpkg.com/@types/chai-things/-/chai-things-0.0.35.tgz#4b5d9ec032067faa62b3bf7bb40dc0bec941945f"976 integrity sha512-BC8FwMf9FHj87XT4dgTwbdb8dNRilGqYWGmwLPdJ54YNk6K2PlcFTt68NGHjgPDnms8zIYcOtmPePd0mPNTo/Q==977 dependencies:978 "@types/chai" "*"979966"@types/chai@*", "@types/chai@^4.3.1":980"@types/chai@*", "@types/chai@^4.3.1":967 version "4.3.1"981 version "4.3.1"968 resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.1.tgz#e2c6e73e0bdeb2521d00756d099218e9f5d90a04"982 resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.1.tgz#e2c6e73e0bdeb2521d00756d099218e9f5d90a04"1544 integrity sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==1558 integrity sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==1545 dependencies:1559 dependencies:1546 check-error "^1.0.2"1560 check-error "^1.0.2"15611562chai-like@^1.1.1:1563 version "1.1.1"1564 resolved "https://registry.yarnpkg.com/chai-like/-/chai-like-1.1.1.tgz#8c558a414c34514e814d497c772547ceb7958f64"1565 integrity sha512-VKa9z/SnhXhkT1zIjtPACFWSoWsqVoaz1Vg+ecrKo5DCKVlgL30F/pEyEvXPBOVwCgLZcWUleCM/C1okaKdTTA==15661567chai-things@^0.2.0:1568 version "0.2.0"1569 resolved "https://registry.yarnpkg.com/chai-things/-/chai-things-0.2.0.tgz#c55128378f9bb399e994f00052151984ed6ebe70"1570 integrity sha512-6ns0SU21xdRCoEXVKH3HGbwnsgfVMXQ+sU5V8PI9rfxaITos8lss1vUxbF1FAcJKjfqmmmLVlr/z3sLes00w+A==154715711548chai@^4.3.6:1572chai@^4.3.6:1549 version "4.3.6"1573 version "4.3.6"