difftreelog
feat add mint_bulk_cross
in: master
15 files changed
pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -631,3 +631,12 @@
}
}
}
+
+/// Token minting parameters
+#[derive(AbiCoder, Default, Debug)]
+pub struct MintTokenData {
+ /// Minted token owner
+ pub owner: CrossAddress,
+ /// Minted token properties
+ pub properties: Vec<Property>,
+}
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -981,13 +981,41 @@
Ok(true)
}
+ /// @notice Function to mint a token.
+ /// @param data Array of pairs of token owner and token's properties for minted token
+ #[weight(<SelfWeightOf<T>>::create_multiple_items(data.len() as u32) + <SelfWeightOf<T>>::set_token_properties(data.len() as u32))]
+ fn mint_bulk_cross(&mut self, caller: Caller, data: Vec<eth::MintTokenData>) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ let mut create_nft_data = Vec::with_capacity(data.len());
+ for eth::MintTokenData { owner, properties } in data {
+ let owner = owner.into_sub_cross_account::<T>()?;
+ create_nft_data.push(CreateItemData::<T> {
+ properties: properties
+ .into_iter()
+ .map(|property| property.try_into())
+ .collect::<Result<Vec<_>>>()?
+ .try_into()
+ .map_err(|_| "too many properties")?,
+ owner,
+ });
+ }
+
+ <Pallet<T>>::create_multiple_items(self, &caller, create_nft_data, &budget)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(true)
+ }
+
/// @notice Function to mint multiple tokens with the given tokenUris.
/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
/// numbers and first number should be obtained with `nextTokenId` method
/// @param to The new owner
/// @param tokens array of pairs of token ID and token URI for minted tokens
#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]
- #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]
+ #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]
fn mint_bulk_with_token_uri(
&mut self,
caller: Caller,
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7contract Dummy {8 uint8 dummy;9 string stub_error = "this contract is implemented in native";10}1112contract ERC165 is Dummy {13 function supportsInterface(bytes4 interfaceID) external view returns (bool) {14 require(false, stub_error);15 interfaceID;16 return true;17 }18}1920/// @dev inlined interface21contract ERC721TokenEvent {22 event TokenChanged(uint256 indexed tokenId);23}2425/// @title A contract that allows to set and delete token properties and change token property permissions.26/// @dev the ERC-165 identifier for this interface is 0xde0695c227contract TokenProperties is Dummy, ERC165, ERC721TokenEvent {28 // /// @notice Set permissions for token property.29 // /// @dev Throws error if `msg.sender` is not admin or owner of the collection.30 // /// @param key Property key.31 // /// @param isMutable Permission to mutate property.32 // /// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.33 // /// @param tokenOwner Permission to mutate property by token owner if property is mutable.34 // /// @dev EVM selector for this function is: 0x222d97fa,35 // /// or in textual repr: setTokenPropertyPermission(string,bool,bool,bool)36 // function setTokenPropertyPermission(string memory key, bool isMutable, bool collectionAdmin, bool tokenOwner) public {37 // require(false, stub_error);38 // key;39 // isMutable;40 // collectionAdmin;41 // tokenOwner;42 // dummy = 0;43 // }4445 /// @notice Set permissions for token property.46 /// @dev Throws error if `msg.sender` is not admin or owner of the collection.47 /// @param permissions Permissions for keys.48 /// @dev EVM selector for this function is: 0xbd92983a,49 /// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])50 function setTokenPropertyPermissions(TokenPropertyPermission[] memory permissions) public {51 require(false, stub_error);52 permissions;53 dummy = 0;54 }5556 /// @notice Get permissions for token properties.57 /// @dev EVM selector for this function is: 0xf23d7790,58 /// or in textual repr: tokenPropertyPermissions()59 function tokenPropertyPermissions() public view returns (TokenPropertyPermission[] memory) {60 require(false, stub_error);61 dummy;62 return new TokenPropertyPermission[](0);63 }6465 // /// @notice Set token property value.66 // /// @dev Throws error if `msg.sender` has no permission to edit the property.67 // /// @param tokenId ID of the token.68 // /// @param key Property key.69 // /// @param value Property value.70 // /// @dev EVM selector for this function is: 0x1752d67b,71 // /// or in textual repr: setProperty(uint256,string,bytes)72 // function setProperty(uint256 tokenId, string memory key, bytes memory value) public {73 // require(false, stub_error);74 // tokenId;75 // key;76 // value;77 // dummy = 0;78 // }7980 /// @notice Set token properties value.81 /// @dev Throws error if `msg.sender` has no permission to edit the property.82 /// @param tokenId ID of the token.83 /// @param properties settable properties84 /// @dev EVM selector for this function is: 0x14ed3a6e,85 /// or in textual repr: setProperties(uint256,(string,bytes)[])86 function setProperties(uint256 tokenId, Property[] memory properties) public {87 require(false, stub_error);88 tokenId;89 properties;90 dummy = 0;91 }9293 // /// @notice Delete token property value.94 // /// @dev Throws error if `msg.sender` has no permission to edit the property.95 // /// @param tokenId ID of the token.96 // /// @param key Property key.97 // /// @dev EVM selector for this function is: 0x066111d1,98 // /// or in textual repr: deleteProperty(uint256,string)99 // function deleteProperty(uint256 tokenId, string memory key) public {100 // require(false, stub_error);101 // tokenId;102 // key;103 // dummy = 0;104 // }105106 /// @notice Delete token properties value.107 /// @dev Throws error if `msg.sender` has no permission to edit the property.108 /// @param tokenId ID of the token.109 /// @param keys Properties key.110 /// @dev EVM selector for this function is: 0xc472d371,111 /// or in textual repr: deleteProperties(uint256,string[])112 function deleteProperties(uint256 tokenId, string[] memory keys) public {113 require(false, stub_error);114 tokenId;115 keys;116 dummy = 0;117 }118119 /// @notice Get token property value.120 /// @dev Throws error if key not found121 /// @param tokenId ID of the token.122 /// @param key Property key.123 /// @return Property value bytes124 /// @dev EVM selector for this function is: 0x7228c327,125 /// or in textual repr: property(uint256,string)126 function property(uint256 tokenId, string memory key) public view returns (bytes memory) {127 require(false, stub_error);128 tokenId;129 key;130 dummy;131 return hex"";132 }133}134135/// Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).136struct Property {137 string key;138 bytes value;139}140141/// Ethereum representation of Token Property Permissions.142struct TokenPropertyPermission {143 /// Token property key.144 string key;145 /// Token property permissions.146 PropertyPermission[] permissions;147}148149/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.150struct PropertyPermission {151 /// TokenPermission field.152 TokenPermissionField code;153 /// TokenPermission value.154 bool value;155}156157/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.158enum TokenPermissionField {159 /// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]160 Mutable,161 /// Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]162 TokenOwner,163 /// Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]164 CollectionAdmin165}166167/// @title A contract that allows you to work with collections.168/// @dev the ERC-165 identifier for this interface is 0xb34d97e9169contract Collection is Dummy, ERC165 {170 // /// Set collection property.171 // ///172 // /// @param key Property key.173 // /// @param value Propery value.174 // /// @dev EVM selector for this function is: 0x2f073f66,175 // /// or in textual repr: setCollectionProperty(string,bytes)176 // function setCollectionProperty(string memory key, bytes memory value) public {177 // require(false, stub_error);178 // key;179 // value;180 // dummy = 0;181 // }182183 /// Set collection properties.184 ///185 /// @param properties Vector of properties key/value pair.186 /// @dev EVM selector for this function is: 0x50b26b2a,187 /// or in textual repr: setCollectionProperties((string,bytes)[])188 function setCollectionProperties(Property[] memory properties) public {189 require(false, stub_error);190 properties;191 dummy = 0;192 }193194 // /// Delete collection property.195 // ///196 // /// @param key Property key.197 // /// @dev EVM selector for this function is: 0x7b7debce,198 // /// or in textual repr: deleteCollectionProperty(string)199 // function deleteCollectionProperty(string memory key) public {200 // require(false, stub_error);201 // key;202 // dummy = 0;203 // }204205 /// Delete collection properties.206 ///207 /// @param keys Properties keys.208 /// @dev EVM selector for this function is: 0xee206ee3,209 /// or in textual repr: deleteCollectionProperties(string[])210 function deleteCollectionProperties(string[] memory keys) public {211 require(false, stub_error);212 keys;213 dummy = 0;214 }215216 /// Get collection property.217 ///218 /// @dev Throws error if key not found.219 ///220 /// @param key Property key.221 /// @return bytes The property corresponding to the key.222 /// @dev EVM selector for this function is: 0xcf24fd6d,223 /// or in textual repr: collectionProperty(string)224 function collectionProperty(string memory key) public view returns (bytes memory) {225 require(false, stub_error);226 key;227 dummy;228 return hex"";229 }230231 /// Get collection properties.232 ///233 /// @param keys Properties keys. Empty keys for all propertyes.234 /// @return Vector of properties key/value pairs.235 /// @dev EVM selector for this function is: 0x285fb8e6,236 /// or in textual repr: collectionProperties(string[])237 function collectionProperties(string[] memory keys) public view returns (Property[] memory) {238 require(false, stub_error);239 keys;240 dummy;241 return new Property[](0);242 }243244 // /// Set the sponsor of the collection.245 // ///246 // /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.247 // ///248 // /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.249 // /// @dev EVM selector for this function is: 0x7623402e,250 // /// or in textual repr: setCollectionSponsor(address)251 // function setCollectionSponsor(address sponsor) public {252 // require(false, stub_error);253 // sponsor;254 // dummy = 0;255 // }256257 /// Set the sponsor of the collection.258 ///259 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.260 ///261 /// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.262 /// @dev EVM selector for this function is: 0x84a1d5a8,263 /// or in textual repr: setCollectionSponsorCross((address,uint256))264 function setCollectionSponsorCross(CrossAddress memory sponsor) public {265 require(false, stub_error);266 sponsor;267 dummy = 0;268 }269270 /// Whether there is a pending sponsor.271 /// @dev EVM selector for this function is: 0x058ac185,272 /// or in textual repr: hasCollectionPendingSponsor()273 function hasCollectionPendingSponsor() public view returns (bool) {274 require(false, stub_error);275 dummy;276 return false;277 }278279 /// Collection sponsorship confirmation.280 ///281 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.282 /// @dev EVM selector for this function is: 0x3c50e97a,283 /// or in textual repr: confirmCollectionSponsorship()284 function confirmCollectionSponsorship() public {285 require(false, stub_error);286 dummy = 0;287 }288289 /// Remove collection sponsor.290 /// @dev EVM selector for this function is: 0x6e0326a3,291 /// or in textual repr: removeCollectionSponsor()292 function removeCollectionSponsor() public {293 require(false, stub_error);294 dummy = 0;295 }296297 /// Get current sponsor.298 ///299 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.300 /// @dev EVM selector for this function is: 0x6ec0a9f1,301 /// or in textual repr: collectionSponsor()302 function collectionSponsor() public view returns (CrossAddress memory) {303 require(false, stub_error);304 dummy;305 return CrossAddress(0x0000000000000000000000000000000000000000, 0);306 }307308 /// Get current collection limits.309 ///310 /// @return Array of collection limits311 /// @dev EVM selector for this function is: 0xf63bc572,312 /// or in textual repr: collectionLimits()313 function collectionLimits() public view returns (CollectionLimit[] memory) {314 require(false, stub_error);315 dummy;316 return new CollectionLimit[](0);317 }318319 /// Set limits for the collection.320 /// @dev Throws error if limit not found.321 /// @param limit Some limit.322 /// @dev EVM selector for this function is: 0x2316ee74,323 /// or in textual repr: setCollectionLimit((uint8,(bool,uint256)))324 function setCollectionLimit(CollectionLimit memory limit) public {325 require(false, stub_error);326 limit;327 dummy = 0;328 }329330 /// Get contract address.331 /// @dev EVM selector for this function is: 0xf6b4dfb4,332 /// or in textual repr: contractAddress()333 function contractAddress() public view returns (address) {334 require(false, stub_error);335 dummy;336 return 0x0000000000000000000000000000000000000000;337 }338339 /// Add collection admin.340 /// @param newAdmin Cross account administrator address.341 /// @dev EVM selector for this function is: 0x859aa7d6,342 /// or in textual repr: addCollectionAdminCross((address,uint256))343 function addCollectionAdminCross(CrossAddress memory newAdmin) public {344 require(false, stub_error);345 newAdmin;346 dummy = 0;347 }348349 /// Remove collection admin.350 /// @param admin Cross account administrator address.351 /// @dev EVM selector for this function is: 0x6c0cd173,352 /// or in textual repr: removeCollectionAdminCross((address,uint256))353 function removeCollectionAdminCross(CrossAddress memory admin) public {354 require(false, stub_error);355 admin;356 dummy = 0;357 }358359 // /// Add collection admin.360 // /// @param newAdmin Address of the added administrator.361 // /// @dev EVM selector for this function is: 0x92e462c7,362 // /// or in textual repr: addCollectionAdmin(address)363 // function addCollectionAdmin(address newAdmin) public {364 // require(false, stub_error);365 // newAdmin;366 // dummy = 0;367 // }368369 // /// Remove collection admin.370 // ///371 // /// @param admin Address of the removed administrator.372 // /// @dev EVM selector for this function is: 0xfafd7b42,373 // /// or in textual repr: removeCollectionAdmin(address)374 // function removeCollectionAdmin(address admin) public {375 // require(false, stub_error);376 // admin;377 // dummy = 0;378 // }379380 /// @dev EVM selector for this function is: 0x0b9f3890,381 /// or in textual repr: setCollectionNesting((bool,bool,address[]))382 function setCollectionNesting(CollectionNestingAndPermission memory collectionNestingAndPermissions) public {383 require(false, stub_error);384 collectionNestingAndPermissions;385 dummy = 0;386 }387388 // /// Toggle accessibility of collection nesting.389 // ///390 // /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'391 // /// @dev EVM selector for this function is: 0x112d4586,392 // /// or in textual repr: setCollectionNesting(bool)393 // function setCollectionNesting(bool enable) public {394 // require(false, stub_error);395 // enable;396 // dummy = 0;397 // }398399 // /// Toggle accessibility of collection nesting.400 // ///401 // /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'402 // /// @param collections Addresses of collections that will be available for nesting.403 // /// @dev EVM selector for this function is: 0x64872396,404 // /// or in textual repr: setCollectionNesting(bool,address[])405 // function setCollectionNesting(bool enable, address[] memory collections) public {406 // require(false, stub_error);407 // enable;408 // collections;409 // dummy = 0;410 // }411412 /// @dev EVM selector for this function is: 0x92c660a8,413 /// or in textual repr: collectionNesting()414 function collectionNesting() public view returns (CollectionNestingAndPermission memory) {415 require(false, stub_error);416 dummy;417 return CollectionNestingAndPermission(false, false, new address[](0));418 }419420 // /// Returns nesting for a collection421 // /// @dev EVM selector for this function is: 0x22d25bfe,422 // /// or in textual repr: collectionNestingRestrictedCollectionIds()423 // function collectionNestingRestrictedCollectionIds() public view returns (CollectionNesting memory) {424 // require(false, stub_error);425 // dummy;426 // return CollectionNesting(false,new uint256[](0));427 // }428429 // /// Returns permissions for a collection430 // /// @dev EVM selector for this function is: 0x5b2eaf4b,431 // /// or in textual repr: collectionNestingPermissions()432 // function collectionNestingPermissions() public view returns (CollectionNestingPermission[] memory) {433 // require(false, stub_error);434 // dummy;435 // return new CollectionNestingPermission[](0);436 // }437438 /// Set the collection access method.439 /// @param mode Access mode440 /// @dev EVM selector for this function is: 0x41835d4c,441 /// or in textual repr: setCollectionAccess(uint8)442 function setCollectionAccess(AccessMode mode) public {443 require(false, stub_error);444 mode;445 dummy = 0;446 }447448 /// Checks that user allowed to operate with collection.449 ///450 /// @param user User address to check.451 /// @dev EVM selector for this function is: 0x91b6df49,452 /// or in textual repr: allowlistedCross((address,uint256))453 function allowlistedCross(CrossAddress memory user) public view returns (bool) {454 require(false, stub_error);455 user;456 dummy;457 return false;458 }459460 // /// Add the user to the allowed list.461 // ///462 // /// @param user Address of a trusted user.463 // /// @dev EVM selector for this function is: 0x67844fe6,464 // /// or in textual repr: addToCollectionAllowList(address)465 // function addToCollectionAllowList(address user) public {466 // require(false, stub_error);467 // user;468 // dummy = 0;469 // }470471 /// Add user to allowed list.472 ///473 /// @param user User cross account address.474 /// @dev EVM selector for this function is: 0xa0184a3a,475 /// or in textual repr: addToCollectionAllowListCross((address,uint256))476 function addToCollectionAllowListCross(CrossAddress memory user) public {477 require(false, stub_error);478 user;479 dummy = 0;480 }481482 // /// Remove the user from the allowed list.483 // ///484 // /// @param user Address of a removed user.485 // /// @dev EVM selector for this function is: 0x85c51acb,486 // /// or in textual repr: removeFromCollectionAllowList(address)487 // function removeFromCollectionAllowList(address user) public {488 // require(false, stub_error);489 // user;490 // dummy = 0;491 // }492493 /// Remove user from allowed list.494 ///495 /// @param user User cross account address.496 /// @dev EVM selector for this function is: 0x09ba452a,497 /// or in textual repr: removeFromCollectionAllowListCross((address,uint256))498 function removeFromCollectionAllowListCross(CrossAddress memory user) public {499 require(false, stub_error);500 user;501 dummy = 0;502 }503504 /// Switch permission for minting.505 ///506 /// @param mode Enable if "true".507 /// @dev EVM selector for this function is: 0x00018e84,508 /// or in textual repr: setCollectionMintMode(bool)509 function setCollectionMintMode(bool mode) public {510 require(false, stub_error);511 mode;512 dummy = 0;513 }514515 // /// Check that account is the owner or admin of the collection516 // ///517 // /// @param user account to verify518 // /// @return "true" if account is the owner or admin519 // /// @dev EVM selector for this function is: 0x9811b0c7,520 // /// or in textual repr: isOwnerOrAdmin(address)521 // function isOwnerOrAdmin(address user) public view returns (bool) {522 // require(false, stub_error);523 // user;524 // dummy;525 // return false;526 // }527528 /// Check that account is the owner or admin of the collection529 ///530 /// @param user User cross account to verify531 /// @return "true" if account is the owner or admin532 /// @dev EVM selector for this function is: 0x3e75a905,533 /// or in textual repr: isOwnerOrAdminCross((address,uint256))534 function isOwnerOrAdminCross(CrossAddress memory user) public view returns (bool) {535 require(false, stub_error);536 user;537 dummy;538 return false;539 }540541 /// Returns collection type542 ///543 /// @return `Fungible` or `NFT` or `ReFungible`544 /// @dev EVM selector for this function is: 0xd34b55b8,545 /// or in textual repr: uniqueCollectionType()546 function uniqueCollectionType() public view returns (string memory) {547 require(false, stub_error);548 dummy;549 return "";550 }551552 /// Get collection owner.553 ///554 /// @return Tuble with sponsor address and his substrate mirror.555 /// If address is canonical then substrate mirror is zero and vice versa.556 /// @dev EVM selector for this function is: 0xdf727d3b,557 /// or in textual repr: collectionOwner()558 function collectionOwner() public view returns (CrossAddress memory) {559 require(false, stub_error);560 dummy;561 return CrossAddress(0x0000000000000000000000000000000000000000, 0);562 }563564 // /// Changes collection owner to another account565 // ///566 // /// @dev Owner can be changed only by current owner567 // /// @param newOwner new owner account568 // /// @dev EVM selector for this function is: 0x4f53e226,569 // /// or in textual repr: changeCollectionOwner(address)570 // function changeCollectionOwner(address newOwner) public {571 // require(false, stub_error);572 // newOwner;573 // dummy = 0;574 // }575576 /// Get collection administrators577 ///578 /// @return Vector of tuples with admins address and his substrate mirror.579 /// If address is canonical then substrate mirror is zero and vice versa.580 /// @dev EVM selector for this function is: 0x5813216b,581 /// or in textual repr: collectionAdmins()582 function collectionAdmins() public view returns (CrossAddress[] memory) {583 require(false, stub_error);584 dummy;585 return new CrossAddress[](0);586 }587588 /// Changes collection owner to another account589 ///590 /// @dev Owner can be changed only by current owner591 /// @param newOwner new owner cross account592 /// @dev EVM selector for this function is: 0x6496c497,593 /// or in textual repr: changeCollectionOwnerCross((address,uint256))594 function changeCollectionOwnerCross(CrossAddress memory newOwner) public {595 require(false, stub_error);596 newOwner;597 dummy = 0;598 }599}600601/// Cross account struct602struct CrossAddress {603 address eth;604 uint256 sub;605}606607/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).608enum AccessMode {609 /// Access grant for owner and admins. Used as default.610 Normal,611 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.612 AllowList613}614615/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.616struct CollectionNestingPermission {617 CollectionPermissionField field;618 bool value;619}620621/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.622enum CollectionPermissionField {623 /// Owner of token can nest tokens under it.624 TokenOwner,625 /// Admin of token collection can nest tokens under token.626 CollectionAdmin627}628629/// Nested collections.630struct CollectionNesting {631 bool token_owner;632 uint256[] ids;633}634635/// Nested collections and permissions636struct CollectionNestingAndPermission {637 /// Owner of token can nest tokens under it.638 bool token_owner;639 /// Admin of token collection can nest tokens under token.640 bool collection_admin;641 /// If set - only tokens from specified collections can be nested.642 address[] restricted;643}644645/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.646struct CollectionLimit {647 CollectionLimitField field;648 OptionUint256 value;649}650651/// Optional value652struct OptionUint256 {653 /// Shows the status of accessibility of value654 bool status;655 /// Actual value if `status` is true656 uint256 value;657}658659/// [`CollectionLimits`](up_data_structs::CollectionLimits) fields representation for EVM.660enum CollectionLimitField {661 /// How many tokens can a user have on one account.662 AccountTokenOwnership,663 /// How many bytes of data are available for sponsorship.664 SponsoredDataSize,665 /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]666 SponsoredDataRateLimit,667 /// How many tokens can be mined into this collection.668 TokenLimit,669 /// Timeouts for transfer sponsoring.670 SponsorTransferTimeout,671 /// Timeout for sponsoring an approval in passed blocks.672 SponsorApproveTimeout,673 /// Whether the collection owner of the collection can send tokens (which belong to other users).674 OwnerCanTransfer,675 /// Can the collection owner burn other people's tokens.676 OwnerCanDestroy,677 /// Is it possible to send tokens from this collection between users.678 TransferEnabled679}680681/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension682/// @dev See https://eips.ethereum.org/EIPS/eip-721683/// @dev the ERC-165 identifier for this interface is 0x5b5e139f684contract ERC721Metadata is Dummy, ERC165 {685 // /// @notice A descriptive name for a collection of NFTs in this contract686 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`687 // /// @dev EVM selector for this function is: 0x06fdde03,688 // /// or in textual repr: name()689 // function name() public view returns (string memory) {690 // require(false, stub_error);691 // dummy;692 // return "";693 // }694695 // /// @notice An abbreviated name for NFTs in this contract696 // /// @dev real implementation of this function lies in `ERC721UniqueExtensions`697 // /// @dev EVM selector for this function is: 0x95d89b41,698 // /// or in textual repr: symbol()699 // function symbol() public view returns (string memory) {700 // require(false, stub_error);701 // dummy;702 // return "";703 // }704705 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.706 ///707 /// @dev If the token has a `url` property and it is not empty, it is returned.708 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.709 /// If the collection property `baseURI` is empty or absent, return "" (empty string)710 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix711 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).712 ///713 /// @return token's const_metadata714 /// @dev EVM selector for this function is: 0xc87b56dd,715 /// or in textual repr: tokenURI(uint256)716 function tokenURI(uint256 tokenId) public view returns (string memory) {717 require(false, stub_error);718 tokenId;719 dummy;720 return "";721 }722}723724/// @title ERC721 Token that can be irreversibly burned (destroyed).725/// @dev the ERC-165 identifier for this interface is 0x42966c68726contract ERC721Burnable is Dummy, ERC165 {727 /// @notice Burns a specific ERC721 token.728 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized729 /// operator of the current owner.730 /// @param tokenId The NFT to approve731 /// @dev EVM selector for this function is: 0x42966c68,732 /// or in textual repr: burn(uint256)733 function burn(uint256 tokenId) public {734 require(false, stub_error);735 tokenId;736 dummy = 0;737 }738}739740/// @title ERC721 minting logic.741/// @dev the ERC-165 identifier for this interface is 0x3fd94ea6742contract ERC721UniqueMintable is Dummy, ERC165 {743 /// @notice Function to mint a token.744 /// @param to The new owner745 /// @return uint256 The id of the newly minted token746 /// @dev EVM selector for this function is: 0x6a627842,747 /// or in textual repr: mint(address)748 function mint(address to) public returns (uint256) {749 require(false, stub_error);750 to;751 dummy = 0;752 return 0;753 }754755 // /// @notice Function to mint a token.756 // /// @dev `tokenId` should be obtained with `nextTokenId` method,757 // /// unlike standard, you can't specify it manually758 // /// @param to The new owner759 // /// @param tokenId ID of the minted NFT760 // /// @dev EVM selector for this function is: 0x40c10f19,761 // /// or in textual repr: mint(address,uint256)762 // function mint(address to, uint256 tokenId) public returns (bool) {763 // require(false, stub_error);764 // to;765 // tokenId;766 // dummy = 0;767 // return false;768 // }769770 /// @notice Function to mint token with the given tokenUri.771 /// @param to The new owner772 /// @param tokenUri Token URI that would be stored in the NFT properties773 /// @return uint256 The id of the newly minted token774 /// @dev EVM selector for this function is: 0x45c17782,775 /// or in textual repr: mintWithTokenURI(address,string)776 function mintWithTokenURI(address to, string memory tokenUri) public returns (uint256) {777 require(false, stub_error);778 to;779 tokenUri;780 dummy = 0;781 return 0;782 }783 // /// @notice Function to mint token with the given tokenUri.784 // /// @dev `tokenId` should be obtained with `nextTokenId` method,785 // /// unlike standard, you can't specify it manually786 // /// @param to The new owner787 // /// @param tokenId ID of the minted NFT788 // /// @param tokenUri Token URI that would be stored in the NFT properties789 // /// @dev EVM selector for this function is: 0x50bb4e7f,790 // /// or in textual repr: mintWithTokenURI(address,uint256,string)791 // function mintWithTokenURI(address to, uint256 tokenId, string memory tokenUri) public returns (bool) {792 // require(false, stub_error);793 // to;794 // tokenId;795 // tokenUri;796 // dummy = 0;797 // return false;798 // }799800}801802/// @title Unique extensions for ERC721.803/// @dev the ERC-165 identifier for this interface is 0x9b397d16804contract ERC721UniqueExtensions is Dummy, ERC165 {805 /// @notice A descriptive name for a collection of NFTs in this contract806 /// @dev EVM selector for this function is: 0x06fdde03,807 /// or in textual repr: name()808 function name() public view returns (string memory) {809 require(false, stub_error);810 dummy;811 return "";812 }813814 /// @notice An abbreviated name for NFTs in this contract815 /// @dev EVM selector for this function is: 0x95d89b41,816 /// or in textual repr: symbol()817 function symbol() public view returns (string memory) {818 require(false, stub_error);819 dummy;820 return "";821 }822823 /// @notice A description for the collection.824 /// @dev EVM selector for this function is: 0x7284e416,825 /// or in textual repr: description()826 function description() public view returns (string memory) {827 require(false, stub_error);828 dummy;829 return "";830 }831832 // /// Returns the owner (in cross format) of the token.833 // ///834 // /// @param tokenId Id for the token.835 // /// @dev EVM selector for this function is: 0x2b29dace,836 // /// or in textual repr: crossOwnerOf(uint256)837 // function crossOwnerOf(uint256 tokenId) public view returns (CrossAddress memory) {838 // require(false, stub_error);839 // tokenId;840 // dummy;841 // return CrossAddress(0x0000000000000000000000000000000000000000,0);842 // }843844 /// Returns the owner (in cross format) of the token.845 ///846 /// @param tokenId Id for the token.847 /// @dev EVM selector for this function is: 0xcaa3a4d0,848 /// or in textual repr: ownerOfCross(uint256)849 function ownerOfCross(uint256 tokenId) public view returns (CrossAddress memory) {850 require(false, stub_error);851 tokenId;852 dummy;853 return CrossAddress(0x0000000000000000000000000000000000000000, 0);854 }855856 /// @notice Count all NFTs assigned to an owner857 /// @param owner An cross address for whom to query the balance858 /// @return The number of NFTs owned by `owner`, possibly zero859 /// @dev EVM selector for this function is: 0xec069398,860 /// or in textual repr: balanceOfCross((address,uint256))861 function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {862 require(false, stub_error);863 owner;864 dummy;865 return 0;866 }867868 /// Returns the token properties.869 ///870 /// @param tokenId Id for the token.871 /// @param keys Properties keys. Empty keys for all propertyes.872 /// @return Vector of properties key/value pairs.873 /// @dev EVM selector for this function is: 0xe07ede7e,874 /// or in textual repr: properties(uint256,string[])875 function properties(uint256 tokenId, string[] memory keys) public view returns (Property[] memory) {876 require(false, stub_error);877 tokenId;878 keys;879 dummy;880 return new Property[](0);881 }882883 /// @notice Set or reaffirm the approved address for an NFT884 /// @dev The zero address indicates there is no approved address.885 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized886 /// operator of the current owner.887 /// @param approved The new substrate address approved NFT controller888 /// @param tokenId The NFT to approve889 /// @dev EVM selector for this function is: 0x0ecd0ab0,890 /// or in textual repr: approveCross((address,uint256),uint256)891 function approveCross(CrossAddress memory approved, uint256 tokenId) public {892 require(false, stub_error);893 approved;894 tokenId;895 dummy = 0;896 }897898 /// @notice Transfer ownership of an NFT899 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`900 /// is the zero address. Throws if `tokenId` is not a valid NFT.901 /// @param to The new owner902 /// @param tokenId The NFT to transfer903 /// @dev EVM selector for this function is: 0xa9059cbb,904 /// or in textual repr: transfer(address,uint256)905 function transfer(address to, uint256 tokenId) public {906 require(false, stub_error);907 to;908 tokenId;909 dummy = 0;910 }911912 /// @notice Transfer ownership of an NFT913 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`914 /// is the zero address. Throws if `tokenId` is not a valid NFT.915 /// @param to The new owner916 /// @param tokenId The NFT to transfer917 /// @dev EVM selector for this function is: 0x2ada85ff,918 /// or in textual repr: transferCross((address,uint256),uint256)919 function transferCross(CrossAddress memory to, uint256 tokenId) public {920 require(false, stub_error);921 to;922 tokenId;923 dummy = 0;924 }925926 /// @notice Transfer ownership of an NFT from cross account address to cross account address927 /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`928 /// is the zero address. Throws if `tokenId` is not a valid NFT.929 /// @param from Cross acccount address of current owner930 /// @param to Cross acccount address of new owner931 /// @param tokenId The NFT to transfer932 /// @dev EVM selector for this function is: 0xd5cf430b,933 /// or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)934 function transferFromCross(935 CrossAddress memory from,936 CrossAddress memory to,937 uint256 tokenId938 ) public {939 require(false, stub_error);940 from;941 to;942 tokenId;943 dummy = 0;944 }945946 // /// @notice Burns a specific ERC721 token.947 // /// @dev Throws unless `msg.sender` is the current owner or an authorized948 // /// operator for this NFT. Throws if `from` is not the current owner. Throws949 // /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.950 // /// @param from The current owner of the NFT951 // /// @param tokenId The NFT to transfer952 // /// @dev EVM selector for this function is: 0x79cc6790,953 // /// or in textual repr: burnFrom(address,uint256)954 // function burnFrom(address from, uint256 tokenId) public {955 // require(false, stub_error);956 // from;957 // tokenId;958 // dummy = 0;959 // }960961 /// @notice Burns a specific ERC721 token.962 /// @dev Throws unless `msg.sender` is the current owner or an authorized963 /// operator for this NFT. Throws if `from` is not the current owner. Throws964 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.965 /// @param from The current owner of the NFT966 /// @param tokenId The NFT to transfer967 /// @dev EVM selector for this function is: 0xbb2f5a58,968 /// or in textual repr: burnFromCross((address,uint256),uint256)969 function burnFromCross(CrossAddress memory from, uint256 tokenId) public {970 require(false, stub_error);971 from;972 tokenId;973 dummy = 0;974 }975976 /// @notice Returns next free NFT ID.977 /// @dev EVM selector for this function is: 0x75794a3c,978 /// or in textual repr: nextTokenId()979 function nextTokenId() public view returns (uint256) {980 require(false, stub_error);981 dummy;982 return 0;983 }984985 // /// @notice Function to mint multiple tokens.986 // /// @dev `tokenIds` should be an array of consecutive numbers and first number987 // /// should be obtained with `nextTokenId` method988 // /// @param to The new owner989 // /// @param tokenIds IDs of the minted NFTs990 // /// @dev EVM selector for this function is: 0x44a9945e,991 // /// or in textual repr: mintBulk(address,uint256[])992 // function mintBulk(address to, uint256[] memory tokenIds) public returns (bool) {993 // require(false, stub_error);994 // to;995 // tokenIds;996 // dummy = 0;997 // return false;998 // }9991000 /// @notice Function to mint a token.1001 /// @param data Array of pairs of token owner and token's properties for minted token1002 /// @dev EVM selector for this function is: 0xab427b0c,1003 /// or in textual repr: mintBulkCross(((address,uint256),(string,bytes)[])[])1004 function mintBulkCross(MintTokenData[] memory data) public returns (bool) {1005 require(false, stub_error);1006 data;1007 dummy = 0;1008 return false;1009 }10101011 // /// @notice Function to mint multiple tokens with the given tokenUris.1012 // /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive1013 // /// numbers and first number should be obtained with `nextTokenId` method1014 // /// @param to The new owner1015 // /// @param tokens array of pairs of token ID and token URI for minted tokens1016 // /// @dev EVM selector for this function is: 0x36543006,1017 // /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])1018 // function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) public returns (bool) {1019 // require(false, stub_error);1020 // to;1021 // tokens;1022 // dummy = 0;1023 // return false;1024 // }10251026 /// @notice Function to mint a token.1027 /// @param to The new owner crossAccountId1028 /// @param properties Properties of minted token1029 /// @return uint256 The id of the newly minted token1030 /// @dev EVM selector for this function is: 0xb904db03,1031 /// or in textual repr: mintCross((address,uint256),(string,bytes)[])1032 function mintCross(CrossAddress memory to, Property[] memory properties) public returns (uint256) {1033 require(false, stub_error);1034 to;1035 properties;1036 dummy = 0;1037 return 0;1038 }10391040 /// @notice Returns collection helper contract address1041 /// @dev EVM selector for this function is: 0x1896cce6,1042 /// or in textual repr: collectionHelperAddress()1043 function collectionHelperAddress() public view returns (address) {1044 require(false, stub_error);1045 dummy;1046 return 0x0000000000000000000000000000000000000000;1047 }1048}10491050/// Data for creation token with uri.1051struct TokenUri {1052 /// Id of new token.1053 uint256 id;1054 /// Uri of new token.1055 string uri;1056}10571058struct MintTokenData {1059 CrossAddress owner;1060 Property[] properties;1061}10621063/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension1064/// @dev See https://eips.ethereum.org/EIPS/eip-7211065/// @dev the ERC-165 identifier for this interface is 0x780e9d631066contract ERC721Enumerable is Dummy, ERC165 {1067 /// @notice Enumerate valid NFTs1068 /// @param index A counter less than `totalSupply()`1069 /// @return The token identifier for the `index`th NFT,1070 /// (sort order not specified)1071 /// @dev EVM selector for this function is: 0x4f6ccce7,1072 /// or in textual repr: tokenByIndex(uint256)1073 function tokenByIndex(uint256 index) public view returns (uint256) {1074 require(false, stub_error);1075 index;1076 dummy;1077 return 0;1078 }10791080 /// @dev Not implemented1081 /// @dev EVM selector for this function is: 0x2f745c59,1082 /// or in textual repr: tokenOfOwnerByIndex(address,uint256)1083 function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {1084 require(false, stub_error);1085 owner;1086 index;1087 dummy;1088 return 0;1089 }10901091 /// @notice Count NFTs tracked by this contract1092 /// @return A count of valid NFTs tracked by this contract, where each one of1093 /// them has an assigned and queryable owner not equal to the zero address1094 /// @dev EVM selector for this function is: 0x18160ddd,1095 /// or in textual repr: totalSupply()1096 function totalSupply() public view returns (uint256) {1097 require(false, stub_error);1098 dummy;1099 return 0;1100 }1101}11021103/// @dev inlined interface1104contract ERC721Events {1105 event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);1106 event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);1107 event ApprovalForAll(address indexed owner, address indexed operator, bool approved);1108}11091110/// @title ERC-721 Non-Fungible Token Standard1111/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md1112/// @dev the ERC-165 identifier for this interface is 0x80ac58cd1113contract ERC721 is Dummy, ERC165, ERC721Events {1114 /// @notice Count all NFTs assigned to an owner1115 /// @dev NFTs assigned to the zero address are considered invalid, and this1116 /// function throws for queries about the zero address.1117 /// @param owner An address for whom to query the balance1118 /// @return The number of NFTs owned by `owner`, possibly zero1119 /// @dev EVM selector for this function is: 0x70a08231,1120 /// or in textual repr: balanceOf(address)1121 function balanceOf(address owner) public view returns (uint256) {1122 require(false, stub_error);1123 owner;1124 dummy;1125 return 0;1126 }11271128 /// @notice Find the owner of an NFT1129 /// @dev NFTs assigned to zero address are considered invalid, and queries1130 /// about them do throw.1131 /// @param tokenId The identifier for an NFT1132 /// @return The address of the owner of the NFT1133 /// @dev EVM selector for this function is: 0x6352211e,1134 /// or in textual repr: ownerOf(uint256)1135 function ownerOf(uint256 tokenId) public view returns (address) {1136 require(false, stub_error);1137 tokenId;1138 dummy;1139 return 0x0000000000000000000000000000000000000000;1140 }11411142 /// @dev Not implemented1143 /// @dev EVM selector for this function is: 0xb88d4fde,1144 /// or in textual repr: safeTransferFrom(address,address,uint256,bytes)1145 function safeTransferFrom(1146 address from,1147 address to,1148 uint256 tokenId,1149 bytes memory data1150 ) public {1151 require(false, stub_error);1152 from;1153 to;1154 tokenId;1155 data;1156 dummy = 0;1157 }11581159 /// @dev Not implemented1160 /// @dev EVM selector for this function is: 0x42842e0e,1161 /// or in textual repr: safeTransferFrom(address,address,uint256)1162 function safeTransferFrom(1163 address from,1164 address to,1165 uint256 tokenId1166 ) public {1167 require(false, stub_error);1168 from;1169 to;1170 tokenId;1171 dummy = 0;1172 }11731174 /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE1175 /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE1176 /// THEY MAY BE PERMANENTLY LOST1177 /// @dev Throws unless `msg.sender` is the current owner or an authorized1178 /// operator for this NFT. Throws if `from` is not the current owner. Throws1179 /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.1180 /// @param from The current owner of the NFT1181 /// @param to The new owner1182 /// @param tokenId The NFT to transfer1183 /// @dev EVM selector for this function is: 0x23b872dd,1184 /// or in textual repr: transferFrom(address,address,uint256)1185 function transferFrom(1186 address from,1187 address to,1188 uint256 tokenId1189 ) public {1190 require(false, stub_error);1191 from;1192 to;1193 tokenId;1194 dummy = 0;1195 }11961197 /// @notice Set or reaffirm the approved address for an NFT1198 /// @dev The zero address indicates there is no approved address.1199 /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized1200 /// operator of the current owner.1201 /// @param approved The new approved NFT controller1202 /// @param tokenId The NFT to approve1203 /// @dev EVM selector for this function is: 0x095ea7b3,1204 /// or in textual repr: approve(address,uint256)1205 function approve(address approved, uint256 tokenId) public {1206 require(false, stub_error);1207 approved;1208 tokenId;1209 dummy = 0;1210 }12111212 /// @notice Sets or unsets the approval of a given operator.1213 /// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.1214 /// @param operator Operator1215 /// @param approved Should operator status be granted or revoked?1216 /// @dev EVM selector for this function is: 0xa22cb465,1217 /// or in textual repr: setApprovalForAll(address,bool)1218 function setApprovalForAll(address operator, bool approved) public {1219 require(false, stub_error);1220 operator;1221 approved;1222 dummy = 0;1223 }12241225 /// @notice Get the approved address for a single NFT1226 /// @dev Throws if `tokenId` is not a valid NFT1227 /// @param tokenId The NFT to find the approved address for1228 /// @return The approved address for this NFT, or the zero address if there is none1229 /// @dev EVM selector for this function is: 0x081812fc,1230 /// or in textual repr: getApproved(uint256)1231 function getApproved(uint256 tokenId) public view returns (address) {1232 require(false, stub_error);1233 tokenId;1234 dummy;1235 return 0x0000000000000000000000000000000000000000;1236 }12371238 /// @notice Tells whether the given `owner` approves the `operator`.1239 /// @dev EVM selector for this function is: 0xe985e9c5,1240 /// or in textual repr: isApprovedForAll(address,address)1241 function isApprovedForAll(address owner, address operator) public view returns (bool) {1242 require(false, stub_error);1243 owner;1244 operator;1245 dummy;1246 return false;1247 }1248}12491250contract UniqueNFT is1251 Dummy,1252 ERC165,1253 ERC721,1254 ERC721Enumerable,1255 ERC721UniqueExtensions,1256 ERC721UniqueMintable,1257 ERC721Burnable,1258 ERC721Metadata,1259 Collection,1260 TokenProperties1261{}pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -1021,6 +1021,43 @@
Ok(true)
}
+ /// @notice Function to mint a token.
+ /// @param tokenProperties Properties of minted token
+ #[weight(<SelfWeightOf<T>>::create_multiple_items(token_properties.len() as u32) + <SelfWeightOf<T>>::set_token_properties(token_properties.len() as u32))]
+ fn mint_bulk_cross(
+ &mut self,
+ caller: Caller,
+ token_properties: Vec<eth::MintTokenData>,
+ ) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ let mut create_rft_data = Vec::with_capacity(token_properties.len());
+ for eth::MintTokenData { owner, properties } in token_properties {
+ let owner = owner.into_sub_cross_account::<T>()?;
+ let users: BoundedBTreeMap<_, _, _> = [(owner, 1)]
+ .into_iter()
+ .collect::<BTreeMap<_, _>>()
+ .try_into()
+ .map_err(|_| "too many users")?;
+ create_rft_data.push(CreateItemData::<T> {
+ properties: properties
+ .into_iter()
+ .map(|property| property.try_into())
+ .collect::<Result<Vec<_>>>()?
+ .try_into()
+ .map_err(|_| "too many properties")?,
+ users,
+ });
+ }
+
+ <Pallet<T>>::create_multiple_items(self, &caller, create_rft_data, &budget)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(true)
+ }
+
/// @notice Function to mint multiple tokens with the given tokenUris.
/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
/// numbers and first number should be obtained with `nextTokenId` method
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -800,7 +800,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x95c0f66c
+/// @dev the ERC-165 identifier for this interface is 0x3e828d60
contract ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -986,6 +986,17 @@
// return false;
// }
+ /// @notice Function to mint a token.
+ /// @param tokenProperties Properties of minted token
+ /// @dev EVM selector for this function is: 0xab427b0c,
+ /// or in textual repr: mintBulkCross(((address,uint256),(string,bytes)[])[])
+ function mintBulkCross(MintTokenData[] memory tokenProperties) public returns (bool) {
+ require(false, stub_error);
+ tokenProperties;
+ dummy = 0;
+ return false;
+ }
+
// /// @notice Function to mint multiple tokens with the given tokenUris.
// /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
// /// numbers and first number should be obtained with `nextTokenId` method
@@ -1045,6 +1056,11 @@
string uri;
}
+struct MintTokenData {
+ CrossAddress owner;
+ Property[] properties;
+}
+
/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// @dev the ERC-165 identifier for this interface is 0x780e9d63
pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth--- a/pallets/unique/src/eth/stubs/CollectionHelpers.sol
+++ b/pallets/unique/src/eth/stubs/CollectionHelpers.sol
@@ -25,12 +25,12 @@
}
/// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x4135fff1
+/// @dev the ERC-165 identifier for this interface is 0x94e5af0d
contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
/// Create a collection
/// @return address Address of the newly created collection
- /// @dev EVM selector for this function is: 0xa765ee5b,
- /// or in textual repr: createCollection(((address,uint256),string,string,string,uint8,uint8,(string,bytes)[],(string,(uint8,bool)[])[],(address,uint256)[],(bool,bool,address[]),(uint8,uint256)[],uint8))
+ /// @dev EVM selector for this function is: 0x72b5bea7,
+ /// or in textual repr: createCollection((string,string,string,uint8,uint8,(string,bytes)[],(string,(uint8,bool)[])[],(address,uint256)[],(bool,bool,address[]),(uint8,uint256)[],(address,uint256),uint8))
function createCollection(CreateCollectionData memory data) public payable returns (address) {
require(false, stub_error);
data;
@@ -170,8 +170,6 @@
/// Collection properties
struct CreateCollectionData {
- /// Collection sponsor
- CrossAddress pending_sponsor;
/// Collection name
string name;
/// Collection description
@@ -192,11 +190,12 @@
CollectionNestingAndPermission nesting_settings;
/// Collection limits
CollectionLimitValue[] limits;
+ /// Collection sponsor
+ CrossAddress pending_sponsor;
/// Extra collection flags
CollectionFlags flags;
}
-/// Cross account struct
type CollectionFlags is uint8;
library CollectionFlagsLib {
@@ -207,13 +206,19 @@
/// External collections can't be managed using `unique` api
CollectionFlags constant externalField = CollectionFlags.wrap(1);
- /// Reserved bits
+ /// Reserved flags
function reservedField(uint8 value) public pure returns (CollectionFlags) {
require(value < 1 << 5, "out of bound value");
return CollectionFlags.wrap(value << 1);
}
}
+/// Cross account struct
+struct CrossAddress {
+ address eth;
+ uint256 sub;
+}
+
/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimitValue {
CollectionLimitField field;
@@ -250,12 +255,6 @@
bool collection_admin;
/// If set - only tokens from specified collections can be nested.
address[] restricted;
-}
-
-/// Cross account struct
-struct CrossAddress {
- address eth;
- uint256 sub;
}
/// Ethereum representation of Token Property Permissions.
@@ -292,10 +291,10 @@
/// Type of tokens in collection
enum CollectionMode {
- /// Fungible
- Fungible,
/// Nonfungible
Nonfungible,
+ /// Fungible
+ Fungible,
/// Refungible
Refungible
}
runtime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth--- a/runtime/common/ethereum/sponsoring/refungible.rs
+++ b/runtime/common/ethereum/sponsoring/refungible.rs
@@ -242,6 +242,7 @@
BurnFrom { .. }
| BurnFromCross { .. }
| MintBulk { .. }
+ | MintBulkCross { .. }
| MintBulkWithTokenUri { .. } => None,
MintCross { .. } => withdraw_create_item::<T>(
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -469,6 +469,39 @@
"inputs": [
{
"components": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct CrossAddress",
+ "name": "owner",
+ "type": "tuple"
+ },
+ {
+ "components": [
+ { "internalType": "string", "name": "key", "type": "string" },
+ { "internalType": "bytes", "name": "value", "type": "bytes" }
+ ],
+ "internalType": "struct Property[]",
+ "name": "properties",
+ "type": "tuple[]"
+ }
+ ],
+ "internalType": "struct MintTokenData[]",
+ "name": "data",
+ "type": "tuple[]"
+ }
+ ],
+ "name": "mintBulkCross",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "components": [
{ "internalType": "address", "name": "eth", "type": "address" },
{ "internalType": "uint256", "name": "sub", "type": "uint256" }
],
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -451,6 +451,39 @@
"inputs": [
{
"components": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct CrossAddress",
+ "name": "owner",
+ "type": "tuple"
+ },
+ {
+ "components": [
+ { "internalType": "string", "name": "key", "type": "string" },
+ { "internalType": "bytes", "name": "value", "type": "bytes" }
+ ],
+ "internalType": "struct Property[]",
+ "name": "properties",
+ "type": "tuple[]"
+ }
+ ],
+ "internalType": "struct MintTokenData[]",
+ "name": "tokenProperties",
+ "type": "tuple[]"
+ }
+ ],
+ "name": "mintBulkCross",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "components": [
{ "internalType": "address", "name": "eth", "type": "address" },
{ "internalType": "uint256", "name": "sub", "type": "uint256" }
],
tests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth--- a/tests/src/eth/api/CollectionHelpers.sol
+++ b/tests/src/eth/api/CollectionHelpers.sol
@@ -20,12 +20,12 @@
}
/// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x4135fff1
+/// @dev the ERC-165 identifier for this interface is 0x94e5af0d
interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
/// Create a collection
/// @return address Address of the newly created collection
- /// @dev EVM selector for this function is: 0xa765ee5b,
- /// or in textual repr: createCollection(((address,uint256),string,string,string,uint8,uint8,(string,bytes)[],(string,(uint8,bool)[])[],(address,uint256)[],(bool,bool,address[]),(uint8,uint256)[],uint8))
+ /// @dev EVM selector for this function is: 0x72b5bea7,
+ /// or in textual repr: createCollection((string,string,string,uint8,uint8,(string,bytes)[],(string,(uint8,bool)[])[],(address,uint256)[],(bool,bool,address[]),(uint8,uint256)[],(address,uint256),uint8))
function createCollection(CreateCollectionData memory data) external payable returns (address);
/// Create an NFT collection
@@ -103,8 +103,6 @@
/// Collection properties
struct CreateCollectionData {
- /// Collection sponsor
- CrossAddress pending_sponsor;
/// Collection name
string name;
/// Collection description
@@ -125,11 +123,12 @@
CollectionNestingAndPermission nesting_settings;
/// Collection limits
CollectionLimitValue[] limits;
+ /// Collection sponsor
+ CrossAddress pending_sponsor;
/// Extra collection flags
CollectionFlags flags;
}
-/// Cross account struct
type CollectionFlags is uint8;
library CollectionFlagsLib {
@@ -140,13 +139,19 @@
/// External collections can't be managed using `unique` api
CollectionFlags constant externalField = CollectionFlags.wrap(1);
- /// Reserved bits
+ /// Reserved flags
function reservedField(uint8 value) public pure returns (CollectionFlags) {
require(value < 1 << 5, "out of bound value");
return CollectionFlags.wrap(value << 1);
}
}
+/// Cross account struct
+struct CrossAddress {
+ address eth;
+ uint256 sub;
+}
+
/// [`CollectionLimits`](up_data_structs::CollectionLimits) field representation for EVM.
struct CollectionLimitValue {
CollectionLimitField field;
@@ -183,12 +188,6 @@
bool collection_admin;
/// If set - only tokens from specified collections can be nested.
address[] restricted;
-}
-
-/// Cross account struct
-struct CrossAddress {
- address eth;
- uint256 sub;
}
/// Ethereum representation of Token Property Permissions.
@@ -225,10 +224,10 @@
/// Type of tokens in collection
enum CollectionMode {
- /// Fungible
- Fungible,
/// Nonfungible
Nonfungible,
+ /// Fungible
+ Fungible,
/// Refungible
Refungible
}
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -551,7 +551,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x307b061a
+/// @dev the ERC-165 identifier for this interface is 0x9b397d16
interface ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -674,6 +674,12 @@
// /// or in textual repr: mintBulk(address,uint256[])
// function mintBulk(address to, uint256[] memory tokenIds) external returns (bool);
+ /// @notice Function to mint a token.
+ /// @param data Array of pairs of token owner and token's properties for minted token
+ /// @dev EVM selector for this function is: 0xab427b0c,
+ /// or in textual repr: mintBulkCross(((address,uint256),(string,bytes)[])[])
+ function mintBulkCross(MintTokenData[] memory data) external returns (bool);
+
// /// @notice Function to mint multiple tokens with the given tokenUris.
// /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
// /// numbers and first number should be obtained with `nextTokenId` method
@@ -705,6 +711,11 @@
string uri;
}
+struct MintTokenData {
+ CrossAddress owner;
+ Property[] properties;
+}
+
/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// @dev the ERC-165 identifier for this interface is 0x780e9d63
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -551,7 +551,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x95c0f66c
+/// @dev the ERC-165 identifier for this interface is 0x3e828d60
interface ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -668,6 +668,12 @@
// /// or in textual repr: mintBulk(address,uint256[])
// function mintBulk(address to, uint256[] memory tokenIds) external returns (bool);
+ /// @notice Function to mint a token.
+ /// @param tokenProperties Properties of minted token
+ /// @dev EVM selector for this function is: 0xab427b0c,
+ /// or in textual repr: mintBulkCross(((address,uint256),(string,bytes)[])[])
+ function mintBulkCross(MintTokenData[] memory tokenProperties) external returns (bool);
+
// /// @notice Function to mint multiple tokens with the given tokenUris.
// /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
// /// numbers and first number should be obtained with `nextTokenId` method
@@ -706,6 +712,11 @@
string uri;
}
+struct MintTokenData {
+ CrossAddress owner;
+ Property[] properties;
+}
+
/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// @dev the ERC-165 identifier for this interface is 0x780e9d63