difftreelog
Merge pull request #986 from UniqueNetwork/feature/add_mint_bulk_cross
in: master
Add mintBulkCross to NFT and RFT collections
20 files changed
node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -425,7 +425,7 @@
.map(|cfg| &cfg.registry);
let task_manager =
sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)
- .map_err(|e| format!("Error: {:?}", e))?;
+ .map_err(|e| format!("Error: {e:?}"))?;
let info_provider = Some(timestamp_with_aura_info(12000));
runner.async_run(|config| -> Result<(Pin<Box<dyn Future<Output = _>>>, _)> {
pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -119,7 +119,7 @@
} else if self.sub == Default::default() {
Ok(Some(T::CrossAccountId::from_eth(self.eth)))
} else {
- Err(format!("All fields of cross account is non zeroed {:?}", self).into())
+ Err(format!("All fields of cross account is non zeroed {self:?}").into())
}
}
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -26,7 +26,7 @@
char::{REPLACEMENT_CHARACTER, decode_utf16},
convert::TryInto,
};
-use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};
+use evm_coder::{abi::AbiType, AbiCoder, ToLog, generate_stubgen, solidity_interface, types::*};
use frame_support::BoundedVec;
use up_data_structs::{
TokenId, PropertyPermission, PropertyKeyPermission, Property, CollectionId, PropertyKey,
@@ -64,6 +64,15 @@
},
}
+/// Token minting parameters
+#[derive(AbiCoder, Default, Debug)]
+pub struct MintTokenData {
+ /// Minted token owner
+ pub owner: eth::CrossAddress,
+ /// Minted token properties
+ pub properties: Vec<eth::Property>,
+}
+
frontier_contract! {
macro_rules! NonfungibleHandle_result {...}
impl<T: Config> Contract for NonfungibleHandle<T> {...}
@@ -981,13 +990,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<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 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.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -800,7 +800,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
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,
@@ -997,6 +997,17 @@
// return false;
// }
+ /// @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) public returns (bool) {
+ require(false, stub_error);
+ data;
+ 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
@@ -1044,6 +1055,14 @@
string uri;
}
+/// Token minting parameters
+struct MintTokenData {
+ /// Minted token owner
+ CrossAddress owner;
+ /// Minted token properties
+ 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/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -26,7 +26,7 @@
char::{REPLACEMENT_CHARACTER, decode_utf16},
convert::TryInto,
};
-use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};
+use evm_coder::{abi::AbiType, AbiCoder, ToLog, generate_stubgen, solidity_interface, types::*};
use frame_support::{BoundedBTreeMap, BoundedVec};
use pallet_common::{
CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
@@ -71,6 +71,24 @@
},
}
+/// Token minting parameters
+#[derive(AbiCoder, Default, Debug)]
+pub struct OwnerPieces {
+ /// Minted token owner
+ pub owner: eth::CrossAddress,
+ /// Number of token pieces
+ pub pieces: u128,
+}
+
+/// Token minting parameters
+#[derive(AbiCoder, Default, Debug)]
+pub struct MintTokenData {
+ /// Minted token owner and number of pieces
+ pub owners: Vec<OwnerPieces>,
+ /// Minted token properties
+ pub properties: Vec<eth::Property>,
+}
+
/// @title A contract that allows to set and delete token properties and change token property permissions.
#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
impl<T: Config> RefungibleHandle<T> {
@@ -1021,6 +1039,55 @@
Ok(true)
}
+ /// @notice Function to mint a token.
+ /// @param tokenProperties Properties of minted token
+ #[weight(if token_properties.len() == 1 {
+ <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(token_properties.iter().next().unwrap().owners.len() as u32)
+ } else {
+ <SelfWeightOf<T>>::create_multiple_items_ex_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<MintTokenData>,
+ ) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+ let has_multiple_tokens = token_properties.len() > 1;
+
+ let mut create_rft_data = Vec::with_capacity(token_properties.len());
+ for MintTokenData { owners, properties } in token_properties {
+ let has_multiple_owners = owners.len() > 1;
+ if has_multiple_tokens & has_multiple_owners {
+ return Err(
+ "creation of multiple tokens supported only if they have single owner each"
+ .into(),
+ );
+ }
+ let users: BoundedBTreeMap<_, _, _> = owners
+ .into_iter()
+ .map(|data| Ok((data.owner.into_sub_cross_account::<T>()?, data.pieces)))
+ .collect::<Result<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 0x4abaabdb
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: 0xdf7a5db7,
+ /// or in textual repr: mintBulkCross((((address,uint256),uint128)[],(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,22 @@
string uri;
}
+/// Token minting parameters
+struct MintTokenData {
+ /// Minted token owner and number of pieces
+ OwnerPieces[] owners;
+ /// Minted token properties
+ Property[] properties;
+}
+
+/// Token minting parameters
+struct OwnerPieces {
+ /// Minted token owner
+ CrossAddress owner;
+ /// Number of token pieces
+ uint128 pieces;
+}
+
/// @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/scheduler-v2/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/scheduler-v2/src/benchmarking.rs
+++ b/pallets/scheduler-v2/src/benchmarking.rs
@@ -136,8 +136,10 @@
let bound = EncodedCall::bound() as u32;
let mut len = match maybe_lookup_len {
Some(len) => {
- len.min(<T::Preimages as PreimageRecipient<T::Hash>>::MaxSize::get() - 2)
- .max(bound) - 3
+ len.clamp(
+ bound,
+ <T::Preimages as PreimageRecipient<T::Hash>>::MaxSize::get() - 2,
+ ) - 3
}
None => bound.saturating_sub(4),
};
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>(
runtime/common/tests/mod.rsdiffbeforeafterboth--- a/runtime/common/tests/mod.rs
+++ b/runtime/common/tests/mod.rs
@@ -33,7 +33,7 @@
const PARA_ID: u32 = 2037;
fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
- TPublic::Pair::from_string(&format!("//{}", seed), None)
+ TPublic::Pair::from_string(&format!("//{seed}"), None)
.expect("static values are valid; qed")
.public()
}
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.jsondiffbeforeafterboth1[2 {3 "anonymous": false,4 "inputs": [5 {6 "indexed": true,7 "internalType": "address",8 "name": "owner",9 "type": "address"10 },11 {12 "indexed": true,13 "internalType": "address",14 "name": "approved",15 "type": "address"16 },17 {18 "indexed": true,19 "internalType": "uint256",20 "name": "tokenId",21 "type": "uint256"22 }23 ],24 "name": "Approval",25 "type": "event"26 },27 {28 "anonymous": false,29 "inputs": [30 {31 "indexed": true,32 "internalType": "address",33 "name": "owner",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "operator",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "bool",45 "name": "approved",46 "type": "bool"47 }48 ],49 "name": "ApprovalForAll",50 "type": "event"51 },52 {53 "anonymous": false,54 "inputs": [55 {56 "indexed": true,57 "internalType": "uint256",58 "name": "tokenId",59 "type": "uint256"60 }61 ],62 "name": "TokenChanged",63 "type": "event"64 },65 {66 "anonymous": false,67 "inputs": [68 {69 "indexed": true,70 "internalType": "address",71 "name": "from",72 "type": "address"73 },74 {75 "indexed": true,76 "internalType": "address",77 "name": "to",78 "type": "address"79 },80 {81 "indexed": true,82 "internalType": "uint256",83 "name": "tokenId",84 "type": "uint256"85 }86 ],87 "name": "Transfer",88 "type": "event"89 },90 {91 "inputs": [92 {93 "components": [94 { "internalType": "address", "name": "eth", "type": "address" },95 { "internalType": "uint256", "name": "sub", "type": "uint256" }96 ],97 "internalType": "struct CrossAddress",98 "name": "newAdmin",99 "type": "tuple"100 }101 ],102 "name": "addCollectionAdminCross",103 "outputs": [],104 "stateMutability": "nonpayable",105 "type": "function"106 },107 {108 "inputs": [109 {110 "components": [111 { "internalType": "address", "name": "eth", "type": "address" },112 { "internalType": "uint256", "name": "sub", "type": "uint256" }113 ],114 "internalType": "struct CrossAddress",115 "name": "user",116 "type": "tuple"117 }118 ],119 "name": "addToCollectionAllowListCross",120 "outputs": [],121 "stateMutability": "nonpayable",122 "type": "function"123 },124 {125 "inputs": [126 {127 "components": [128 { "internalType": "address", "name": "eth", "type": "address" },129 { "internalType": "uint256", "name": "sub", "type": "uint256" }130 ],131 "internalType": "struct CrossAddress",132 "name": "user",133 "type": "tuple"134 }135 ],136 "name": "allowlistedCross",137 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],138 "stateMutability": "view",139 "type": "function"140 },141 {142 "inputs": [143 { "internalType": "address", "name": "approved", "type": "address" },144 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }145 ],146 "name": "approve",147 "outputs": [],148 "stateMutability": "nonpayable",149 "type": "function"150 },151 {152 "inputs": [153 { "internalType": "address", "name": "owner", "type": "address" }154 ],155 "name": "balanceOf",156 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],157 "stateMutability": "view",158 "type": "function"159 },160 {161 "inputs": [162 {163 "components": [164 { "internalType": "address", "name": "eth", "type": "address" },165 { "internalType": "uint256", "name": "sub", "type": "uint256" }166 ],167 "internalType": "struct CrossAddress",168 "name": "owner",169 "type": "tuple"170 }171 ],172 "name": "balanceOfCross",173 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],174 "stateMutability": "view",175 "type": "function"176 },177 {178 "inputs": [179 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }180 ],181 "name": "burn",182 "outputs": [],183 "stateMutability": "nonpayable",184 "type": "function"185 },186 {187 "inputs": [188 {189 "components": [190 { "internalType": "address", "name": "eth", "type": "address" },191 { "internalType": "uint256", "name": "sub", "type": "uint256" }192 ],193 "internalType": "struct CrossAddress",194 "name": "from",195 "type": "tuple"196 },197 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }198 ],199 "name": "burnFromCross",200 "outputs": [],201 "stateMutability": "nonpayable",202 "type": "function"203 },204 {205 "inputs": [206 {207 "components": [208 { "internalType": "address", "name": "eth", "type": "address" },209 { "internalType": "uint256", "name": "sub", "type": "uint256" }210 ],211 "internalType": "struct CrossAddress",212 "name": "newOwner",213 "type": "tuple"214 }215 ],216 "name": "changeCollectionOwnerCross",217 "outputs": [],218 "stateMutability": "nonpayable",219 "type": "function"220 },221 {222 "inputs": [],223 "name": "collectionAdmins",224 "outputs": [225 {226 "components": [227 { "internalType": "address", "name": "eth", "type": "address" },228 { "internalType": "uint256", "name": "sub", "type": "uint256" }229 ],230 "internalType": "struct CrossAddress[]",231 "name": "",232 "type": "tuple[]"233 }234 ],235 "stateMutability": "view",236 "type": "function"237 },238 {239 "inputs": [],240 "name": "collectionHelperAddress",241 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],242 "stateMutability": "view",243 "type": "function"244 },245 {246 "inputs": [],247 "name": "collectionLimits",248 "outputs": [249 {250 "components": [251 {252 "internalType": "enum CollectionLimitField",253 "name": "field",254 "type": "uint8"255 },256 {257 "components": [258 { "internalType": "bool", "name": "status", "type": "bool" },259 { "internalType": "uint256", "name": "value", "type": "uint256" }260 ],261 "internalType": "struct OptionUint256",262 "name": "value",263 "type": "tuple"264 }265 ],266 "internalType": "struct CollectionLimit[]",267 "name": "",268 "type": "tuple[]"269 }270 ],271 "stateMutability": "view",272 "type": "function"273 },274 {275 "inputs": [],276 "name": "collectionNesting",277 "outputs": [278 {279 "components": [280 { "internalType": "bool", "name": "token_owner", "type": "bool" },281 {282 "internalType": "bool",283 "name": "collection_admin",284 "type": "bool"285 },286 {287 "internalType": "address[]",288 "name": "restricted",289 "type": "address[]"290 }291 ],292 "internalType": "struct CollectionNestingAndPermission",293 "name": "",294 "type": "tuple"295 }296 ],297 "stateMutability": "view",298 "type": "function"299 },300 {301 "inputs": [],302 "name": "collectionOwner",303 "outputs": [304 {305 "components": [306 { "internalType": "address", "name": "eth", "type": "address" },307 { "internalType": "uint256", "name": "sub", "type": "uint256" }308 ],309 "internalType": "struct CrossAddress",310 "name": "",311 "type": "tuple"312 }313 ],314 "stateMutability": "view",315 "type": "function"316 },317 {318 "inputs": [319 { "internalType": "string[]", "name": "keys", "type": "string[]" }320 ],321 "name": "collectionProperties",322 "outputs": [323 {324 "components": [325 { "internalType": "string", "name": "key", "type": "string" },326 { "internalType": "bytes", "name": "value", "type": "bytes" }327 ],328 "internalType": "struct Property[]",329 "name": "",330 "type": "tuple[]"331 }332 ],333 "stateMutability": "view",334 "type": "function"335 },336 {337 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],338 "name": "collectionProperty",339 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],340 "stateMutability": "view",341 "type": "function"342 },343 {344 "inputs": [],345 "name": "collectionSponsor",346 "outputs": [347 {348 "components": [349 { "internalType": "address", "name": "eth", "type": "address" },350 { "internalType": "uint256", "name": "sub", "type": "uint256" }351 ],352 "internalType": "struct CrossAddress",353 "name": "",354 "type": "tuple"355 }356 ],357 "stateMutability": "view",358 "type": "function"359 },360 {361 "inputs": [],362 "name": "confirmCollectionSponsorship",363 "outputs": [],364 "stateMutability": "nonpayable",365 "type": "function"366 },367 {368 "inputs": [],369 "name": "contractAddress",370 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],371 "stateMutability": "view",372 "type": "function"373 },374 {375 "inputs": [376 { "internalType": "string[]", "name": "keys", "type": "string[]" }377 ],378 "name": "deleteCollectionProperties",379 "outputs": [],380 "stateMutability": "nonpayable",381 "type": "function"382 },383 {384 "inputs": [385 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },386 { "internalType": "string[]", "name": "keys", "type": "string[]" }387 ],388 "name": "deleteProperties",389 "outputs": [],390 "stateMutability": "nonpayable",391 "type": "function"392 },393 {394 "inputs": [],395 "name": "description",396 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],397 "stateMutability": "view",398 "type": "function"399 },400 {401 "inputs": [402 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }403 ],404 "name": "getApproved",405 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],406 "stateMutability": "view",407 "type": "function"408 },409 {410 "inputs": [],411 "name": "hasCollectionPendingSponsor",412 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],413 "stateMutability": "view",414 "type": "function"415 },416 {417 "inputs": [418 { "internalType": "address", "name": "owner", "type": "address" },419 { "internalType": "address", "name": "operator", "type": "address" }420 ],421 "name": "isApprovedForAll",422 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],423 "stateMutability": "view",424 "type": "function"425 },426 {427 "inputs": [428 {429 "components": [430 { "internalType": "address", "name": "eth", "type": "address" },431 { "internalType": "uint256", "name": "sub", "type": "uint256" }432 ],433 "internalType": "struct CrossAddress",434 "name": "user",435 "type": "tuple"436 }437 ],438 "name": "isOwnerOrAdminCross",439 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],440 "stateMutability": "view",441 "type": "function"442 },443 {444 "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],445 "name": "mint",446 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],447 "stateMutability": "nonpayable",448 "type": "function"449 },450 {451 "inputs": [452 {453 "components": [454 { "internalType": "address", "name": "eth", "type": "address" },455 { "internalType": "uint256", "name": "sub", "type": "uint256" }456 ],457 "internalType": "struct CrossAddress",458 "name": "to",459 "type": "tuple"460 },461 {462 "components": [463 { "internalType": "string", "name": "key", "type": "string" },464 { "internalType": "bytes", "name": "value", "type": "bytes" }465 ],466 "internalType": "struct Property[]",467 "name": "properties",468 "type": "tuple[]"469 }470 ],471 "name": "mintCross",472 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],473 "stateMutability": "nonpayable",474 "type": "function"475 },476 {477 "inputs": [478 { "internalType": "address", "name": "to", "type": "address" },479 { "internalType": "string", "name": "tokenUri", "type": "string" }480 ],481 "name": "mintWithTokenURI",482 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],483 "stateMutability": "nonpayable",484 "type": "function"485 },486 {487 "inputs": [],488 "name": "name",489 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],490 "stateMutability": "view",491 "type": "function"492 },493 {494 "inputs": [],495 "name": "nextTokenId",496 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],497 "stateMutability": "view",498 "type": "function"499 },500 {501 "inputs": [502 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }503 ],504 "name": "ownerOf",505 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],506 "stateMutability": "view",507 "type": "function"508 },509 {510 "inputs": [511 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }512 ],513 "name": "ownerOfCross",514 "outputs": [515 {516 "components": [517 { "internalType": "address", "name": "eth", "type": "address" },518 { "internalType": "uint256", "name": "sub", "type": "uint256" }519 ],520 "internalType": "struct CrossAddress",521 "name": "",522 "type": "tuple"523 }524 ],525 "stateMutability": "view",526 "type": "function"527 },528 {529 "inputs": [530 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },531 { "internalType": "string[]", "name": "keys", "type": "string[]" }532 ],533 "name": "properties",534 "outputs": [535 {536 "components": [537 { "internalType": "string", "name": "key", "type": "string" },538 { "internalType": "bytes", "name": "value", "type": "bytes" }539 ],540 "internalType": "struct Property[]",541 "name": "",542 "type": "tuple[]"543 }544 ],545 "stateMutability": "view",546 "type": "function"547 },548 {549 "inputs": [550 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },551 { "internalType": "string", "name": "key", "type": "string" }552 ],553 "name": "property",554 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],555 "stateMutability": "view",556 "type": "function"557 },558 {559 "inputs": [560 {561 "components": [562 { "internalType": "address", "name": "eth", "type": "address" },563 { "internalType": "uint256", "name": "sub", "type": "uint256" }564 ],565 "internalType": "struct CrossAddress",566 "name": "admin",567 "type": "tuple"568 }569 ],570 "name": "removeCollectionAdminCross",571 "outputs": [],572 "stateMutability": "nonpayable",573 "type": "function"574 },575 {576 "inputs": [],577 "name": "removeCollectionSponsor",578 "outputs": [],579 "stateMutability": "nonpayable",580 "type": "function"581 },582 {583 "inputs": [584 {585 "components": [586 { "internalType": "address", "name": "eth", "type": "address" },587 { "internalType": "uint256", "name": "sub", "type": "uint256" }588 ],589 "internalType": "struct CrossAddress",590 "name": "user",591 "type": "tuple"592 }593 ],594 "name": "removeFromCollectionAllowListCross",595 "outputs": [],596 "stateMutability": "nonpayable",597 "type": "function"598 },599 {600 "inputs": [601 { "internalType": "address", "name": "from", "type": "address" },602 { "internalType": "address", "name": "to", "type": "address" },603 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }604 ],605 "name": "safeTransferFrom",606 "outputs": [],607 "stateMutability": "nonpayable",608 "type": "function"609 },610 {611 "inputs": [612 { "internalType": "address", "name": "from", "type": "address" },613 { "internalType": "address", "name": "to", "type": "address" },614 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },615 { "internalType": "bytes", "name": "data", "type": "bytes" }616 ],617 "name": "safeTransferFrom",618 "outputs": [],619 "stateMutability": "nonpayable",620 "type": "function"621 },622 {623 "inputs": [624 { "internalType": "address", "name": "operator", "type": "address" },625 { "internalType": "bool", "name": "approved", "type": "bool" }626 ],627 "name": "setApprovalForAll",628 "outputs": [],629 "stateMutability": "nonpayable",630 "type": "function"631 },632 {633 "inputs": [634 { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }635 ],636 "name": "setCollectionAccess",637 "outputs": [],638 "stateMutability": "nonpayable",639 "type": "function"640 },641 {642 "inputs": [643 {644 "components": [645 {646 "internalType": "enum CollectionLimitField",647 "name": "field",648 "type": "uint8"649 },650 {651 "components": [652 { "internalType": "bool", "name": "status", "type": "bool" },653 { "internalType": "uint256", "name": "value", "type": "uint256" }654 ],655 "internalType": "struct OptionUint256",656 "name": "value",657 "type": "tuple"658 }659 ],660 "internalType": "struct CollectionLimit",661 "name": "limit",662 "type": "tuple"663 }664 ],665 "name": "setCollectionLimit",666 "outputs": [],667 "stateMutability": "nonpayable",668 "type": "function"669 },670 {671 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],672 "name": "setCollectionMintMode",673 "outputs": [],674 "stateMutability": "nonpayable",675 "type": "function"676 },677 {678 "inputs": [679 {680 "components": [681 { "internalType": "bool", "name": "token_owner", "type": "bool" },682 {683 "internalType": "bool",684 "name": "collection_admin",685 "type": "bool"686 },687 {688 "internalType": "address[]",689 "name": "restricted",690 "type": "address[]"691 }692 ],693 "internalType": "struct CollectionNestingAndPermission",694 "name": "collectionNestingAndPermissions",695 "type": "tuple"696 }697 ],698 "name": "setCollectionNesting",699 "outputs": [],700 "stateMutability": "nonpayable",701 "type": "function"702 },703 {704 "inputs": [705 {706 "components": [707 { "internalType": "string", "name": "key", "type": "string" },708 { "internalType": "bytes", "name": "value", "type": "bytes" }709 ],710 "internalType": "struct Property[]",711 "name": "properties",712 "type": "tuple[]"713 }714 ],715 "name": "setCollectionProperties",716 "outputs": [],717 "stateMutability": "nonpayable",718 "type": "function"719 },720 {721 "inputs": [722 {723 "components": [724 { "internalType": "address", "name": "eth", "type": "address" },725 { "internalType": "uint256", "name": "sub", "type": "uint256" }726 ],727 "internalType": "struct CrossAddress",728 "name": "sponsor",729 "type": "tuple"730 }731 ],732 "name": "setCollectionSponsorCross",733 "outputs": [],734 "stateMutability": "nonpayable",735 "type": "function"736 },737 {738 "inputs": [739 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },740 {741 "components": [742 { "internalType": "string", "name": "key", "type": "string" },743 { "internalType": "bytes", "name": "value", "type": "bytes" }744 ],745 "internalType": "struct Property[]",746 "name": "properties",747 "type": "tuple[]"748 }749 ],750 "name": "setProperties",751 "outputs": [],752 "stateMutability": "nonpayable",753 "type": "function"754 },755 {756 "inputs": [757 {758 "components": [759 { "internalType": "string", "name": "key", "type": "string" },760 {761 "components": [762 {763 "internalType": "enum TokenPermissionField",764 "name": "code",765 "type": "uint8"766 },767 { "internalType": "bool", "name": "value", "type": "bool" }768 ],769 "internalType": "struct PropertyPermission[]",770 "name": "permissions",771 "type": "tuple[]"772 }773 ],774 "internalType": "struct TokenPropertyPermission[]",775 "name": "permissions",776 "type": "tuple[]"777 }778 ],779 "name": "setTokenPropertyPermissions",780 "outputs": [],781 "stateMutability": "nonpayable",782 "type": "function"783 },784 {785 "inputs": [786 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }787 ],788 "name": "supportsInterface",789 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],790 "stateMutability": "view",791 "type": "function"792 },793 {794 "inputs": [],795 "name": "symbol",796 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],797 "stateMutability": "view",798 "type": "function"799 },800 {801 "inputs": [802 { "internalType": "uint256", "name": "index", "type": "uint256" }803 ],804 "name": "tokenByIndex",805 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],806 "stateMutability": "view",807 "type": "function"808 },809 {810 "inputs": [811 { "internalType": "uint256", "name": "token", "type": "uint256" }812 ],813 "name": "tokenContractAddress",814 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],815 "stateMutability": "view",816 "type": "function"817 },818 {819 "inputs": [820 { "internalType": "address", "name": "owner", "type": "address" },821 { "internalType": "uint256", "name": "index", "type": "uint256" }822 ],823 "name": "tokenOfOwnerByIndex",824 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],825 "stateMutability": "view",826 "type": "function"827 },828 {829 "inputs": [],830 "name": "tokenPropertyPermissions",831 "outputs": [832 {833 "components": [834 { "internalType": "string", "name": "key", "type": "string" },835 {836 "components": [837 {838 "internalType": "enum TokenPermissionField",839 "name": "code",840 "type": "uint8"841 },842 { "internalType": "bool", "name": "value", "type": "bool" }843 ],844 "internalType": "struct PropertyPermission[]",845 "name": "permissions",846 "type": "tuple[]"847 }848 ],849 "internalType": "struct TokenPropertyPermission[]",850 "name": "",851 "type": "tuple[]"852 }853 ],854 "stateMutability": "view",855 "type": "function"856 },857 {858 "inputs": [859 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }860 ],861 "name": "tokenURI",862 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],863 "stateMutability": "view",864 "type": "function"865 },866 {867 "inputs": [],868 "name": "totalSupply",869 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],870 "stateMutability": "view",871 "type": "function"872 },873 {874 "inputs": [875 { "internalType": "address", "name": "to", "type": "address" },876 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }877 ],878 "name": "transfer",879 "outputs": [],880 "stateMutability": "nonpayable",881 "type": "function"882 },883 {884 "inputs": [885 {886 "components": [887 { "internalType": "address", "name": "eth", "type": "address" },888 { "internalType": "uint256", "name": "sub", "type": "uint256" }889 ],890 "internalType": "struct CrossAddress",891 "name": "to",892 "type": "tuple"893 },894 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }895 ],896 "name": "transferCross",897 "outputs": [],898 "stateMutability": "nonpayable",899 "type": "function"900 },901 {902 "inputs": [903 { "internalType": "address", "name": "from", "type": "address" },904 { "internalType": "address", "name": "to", "type": "address" },905 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }906 ],907 "name": "transferFrom",908 "outputs": [],909 "stateMutability": "nonpayable",910 "type": "function"911 },912 {913 "inputs": [914 {915 "components": [916 { "internalType": "address", "name": "eth", "type": "address" },917 { "internalType": "uint256", "name": "sub", "type": "uint256" }918 ],919 "internalType": "struct CrossAddress",920 "name": "from",921 "type": "tuple"922 },923 {924 "components": [925 { "internalType": "address", "name": "eth", "type": "address" },926 { "internalType": "uint256", "name": "sub", "type": "uint256" }927 ],928 "internalType": "struct CrossAddress",929 "name": "to",930 "type": "tuple"931 },932 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }933 ],934 "name": "transferFromCross",935 "outputs": [],936 "stateMutability": "nonpayable",937 "type": "function"938 },939 {940 "inputs": [],941 "name": "uniqueCollectionType",942 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],943 "stateMutability": "view",944 "type": "function"945 }946]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,14 @@
string uri;
}
+/// Token minting parameters
+struct MintTokenData {
+ /// Minted token owner
+ CrossAddress owner;
+ /// Minted token properties
+ 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 0x4abaabdb
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: 0xdf7a5db7,
+ /// or in textual repr: mintBulkCross((((address,uint256),uint128)[],(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,22 @@
string uri;
}
+/// Token minting parameters
+struct MintTokenData {
+ /// Minted token owner and number of pieces
+ OwnerPieces[] owners;
+ /// Minted token properties
+ Property[] properties;
+}
+
+/// Token minting parameters
+struct OwnerPieces {
+ /// Minted token owner
+ CrossAddress owner;
+ /// Number of token pieces
+ uint128 pieces;
+}
+
/// @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/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -18,6 +18,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
import {ITokenPropertyPermission} from '../util/playgrounds/types';
+import {CREATE_COLLECTION_DATA_DEFAULTS, CollectionMode, CreateCollectionData, TokenPermissionField} from './util/playgrounds/types';
describe('Check ERC721 token URI for NFT', () => {
let donor: IKeyringPair;
@@ -197,6 +198,96 @@
}
});
+ itEth('Can perform mintBulkCross()', async ({helper}) => {
+ const caller = await helper.eth.createAccountWithBalance(donor);
+ const callerCross = helper.ethCrossAccount.fromAddress(caller);
+ const receiver = helper.eth.createAccount();
+ const receiverCross = helper.ethCrossAccount.fromAddress(receiver);
+
+ const permissions = [
+ {code: TokenPermissionField.Mutable, value: true},
+ {code: TokenPermissionField.TokenOwner, value: true},
+ {code: TokenPermissionField.CollectionAdmin, value: true},
+ ];
+ const {collectionAddress} = await helper.eth.createCollection(
+ caller,
+ {
+ ...CREATE_COLLECTION_DATA_DEFAULTS,
+ name: 'A',
+ description: 'B',
+ tokenPrefix: 'C',
+ collectionMode: 'nft',
+ adminList: [callerCross],
+ tokenPropertyPermissions: [
+ {key: 'key_0_0', permissions},
+ {key: 'key_1_0', permissions},
+ {key: 'key_1_1', permissions},
+ {key: 'key_2_0', permissions},
+ {key: 'key_2_1', permissions},
+ {key: 'key_2_2', permissions},
+ ],
+ },
+ ).send();
+
+ const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);
+ {
+ const nextTokenId = await contract.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+ const result = await contract.methods.mintBulkCross([
+ {
+ owner: receiverCross,
+ properties: [
+ {key: 'key_0_0', value: Buffer.from('value_0_0')},
+ ],
+ },
+ {
+ owner: receiverCross,
+ properties: [
+ {key: 'key_1_0', value: Buffer.from('value_1_0')},
+ {key: 'key_1_1', value: Buffer.from('value_1_1')},
+ ],
+ },
+ {
+ owner: receiverCross,
+ properties: [
+ {key: 'key_2_0', value: Buffer.from('value_2_0')},
+ {key: 'key_2_1', value: Buffer.from('value_2_1')},
+ {key: 'key_2_2', value: Buffer.from('value_2_2')},
+ ],
+ },
+ ]).send({from: caller});
+ const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);
+ const bulkSize = 3;
+ for(let i = 0; i < bulkSize; i++) {
+ const event = events[i];
+ expect(event.address).to.equal(collectionAddress);
+ expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.equal(receiver);
+ expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);
+ }
+
+ const properties = [
+ await contract.methods.properties(+nextTokenId, []).call(),
+ await contract.methods.properties(+nextTokenId + 1, []).call(),
+ await contract.methods.properties(+nextTokenId + 2, []).call(),
+ ];
+ expect(properties).to.be.deep.equal([
+ [
+ ['key_0_0', helper.getWeb3().utils.toHex('value_0_0')],
+ ],
+ [
+ ['key_1_0', helper.getWeb3().utils.toHex('value_1_0')],
+ ['key_1_1', helper.getWeb3().utils.toHex('value_1_1')],
+ ],
+ [
+ ['key_2_0', helper.getWeb3().utils.toHex('value_2_0')],
+ ['key_2_1', helper.getWeb3().utils.toHex('value_2_1')],
+ ['key_2_2', helper.getWeb3().utils.toHex('value_2_2')],
+ ],
+ ]);
+ }
+ });
+
itEth('Can perform burn()', async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -18,6 +18,7 @@
import {expect, itEth, usingEthPlaygrounds} from './util';
import {IKeyringPair} from '@polkadot/types/types';
import {ITokenPropertyPermission} from '../util/playgrounds/types';
+import {CREATE_COLLECTION_DATA_DEFAULTS, TokenPermissionField} from './util/playgrounds/types';
describe('Refungible: Plain calls', () => {
let donor: IKeyringPair;
@@ -125,6 +126,169 @@
}
});
+ itEth('Can perform mintBulkCross() with multiple tokens', async ({helper}) => {
+ const caller = await helper.eth.createAccountWithBalance(donor);
+ const callerCross = helper.ethCrossAccount.fromAddress(caller);
+ const receiver = helper.eth.createAccount();
+ const receiverCross = helper.ethCrossAccount.fromAddress(receiver);
+
+ const permissions = [
+ {code: TokenPermissionField.Mutable, value: true},
+ {code: TokenPermissionField.TokenOwner, value: true},
+ {code: TokenPermissionField.CollectionAdmin, value: true},
+ ];
+ const {collectionAddress} = await helper.eth.createCollection(
+ caller,
+ {
+ ...CREATE_COLLECTION_DATA_DEFAULTS,
+ name: 'A',
+ description: 'B',
+ tokenPrefix: 'C',
+ collectionMode: 'rft',
+ adminList: [callerCross],
+ tokenPropertyPermissions: [
+ {key: 'key_0_0', permissions},
+ {key: 'key_1_0', permissions},
+ {key: 'key_1_1', permissions},
+ {key: 'key_2_0', permissions},
+ {key: 'key_2_1', permissions},
+ {key: 'key_2_2', permissions},
+ ],
+ },
+ ).send();
+
+ const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
+ const nextTokenId = await contract.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+ const result = await contract.methods.mintBulkCross([
+ {
+ owners: [{
+ owner: receiverCross,
+ pieces: 1,
+ }],
+ properties: [
+ {key: 'key_0_0', value: Buffer.from('value_0_0')},
+ ],
+ },
+ {
+ owners: [{
+ owner: receiverCross,
+ pieces: 2,
+ }],
+ properties: [
+ {key: 'key_1_0', value: Buffer.from('value_1_0')},
+ {key: 'key_1_1', value: Buffer.from('value_1_1')},
+ ],
+ },
+ {
+ owners: [{
+ owner: receiverCross,
+ pieces: 1,
+ }],
+ properties: [
+ {key: 'key_2_0', value: Buffer.from('value_2_0')},
+ {key: 'key_2_1', value: Buffer.from('value_2_1')},
+ {key: 'key_2_2', value: Buffer.from('value_2_2')},
+ ],
+ },
+ ]).send({from: caller});
+ const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);
+ const bulkSize = 3;
+ for(let i = 0; i < bulkSize; i++) {
+ const event = events[i];
+ expect(event.address).to.equal(collectionAddress);
+ expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.equal(receiver);
+ expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);
+ }
+
+ const properties = [
+ await contract.methods.properties(+nextTokenId, []).call(),
+ await contract.methods.properties(+nextTokenId + 1, []).call(),
+ await contract.methods.properties(+nextTokenId + 2, []).call(),
+ ];
+ expect(properties).to.be.deep.equal([
+ [
+ ['key_0_0', helper.getWeb3().utils.toHex('value_0_0')],
+ ],
+ [
+ ['key_1_0', helper.getWeb3().utils.toHex('value_1_0')],
+ ['key_1_1', helper.getWeb3().utils.toHex('value_1_1')],
+ ],
+ [
+ ['key_2_0', helper.getWeb3().utils.toHex('value_2_0')],
+ ['key_2_1', helper.getWeb3().utils.toHex('value_2_1')],
+ ['key_2_2', helper.getWeb3().utils.toHex('value_2_2')],
+ ],
+ ]);
+ });
+
+ itEth('Can perform mintBulkCross() with multiple owners', async ({helper}) => {
+ const caller = await helper.eth.createAccountWithBalance(donor);
+ const callerCross = helper.ethCrossAccount.fromAddress(caller);
+ const receiver = helper.eth.createAccount();
+ const receiverCross = helper.ethCrossAccount.fromAddress(receiver);
+ const receiver2 = helper.eth.createAccount();
+ const receiver2Cross = helper.ethCrossAccount.fromAddress(receiver2);
+
+ const permissions = [
+ {code: TokenPermissionField.Mutable, value: true},
+ {code: TokenPermissionField.TokenOwner, value: true},
+ {code: TokenPermissionField.CollectionAdmin, value: true},
+ ];
+ const {collectionAddress} = await helper.eth.createCollection(
+ caller,
+ {
+ ...CREATE_COLLECTION_DATA_DEFAULTS,
+ name: 'A',
+ description: 'B',
+ tokenPrefix: 'C',
+ collectionMode: 'rft',
+ adminList: [callerCross],
+ tokenPropertyPermissions: [
+ {key: 'key_2_0', permissions},
+ {key: 'key_2_1', permissions},
+ {key: 'key_2_2', permissions},
+ ],
+ },
+ ).send();
+
+ const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
+ const nextTokenId = await contract.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+ const result = await contract.methods.mintBulkCross([{
+ owners: [
+ {
+ owner: receiverCross,
+ pieces: 1,
+ },
+ {
+ owner: receiver2Cross,
+ pieces: 2,
+ },
+ ],
+ properties: [
+ {key: 'key_2_0', value: Buffer.from('value_2_0')},
+ {key: 'key_2_1', value: Buffer.from('value_2_1')},
+ {key: 'key_2_2', value: Buffer.from('value_2_2')},
+ ],
+ }]).send({from: caller});
+ const event = result.events.Transfer;
+ expect(event.address).to.equal(collectionAddress);
+ expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');
+ expect(event.returnValues.tokenId).to.equal(`${+nextTokenId}`);
+
+ const properties = [
+ await contract.methods.properties(+nextTokenId, []).call(),
+ ];
+ expect(properties).to.be.deep.equal([[
+ ['key_2_0', helper.getWeb3().utils.toHex('value_2_0')],
+ ['key_2_1', helper.getWeb3().utils.toHex('value_2_1')],
+ ['key_2_2', helper.getWeb3().utils.toHex('value_2_2')],
+ ]]);
+ });
+
itEth('Can perform setApprovalForAll()', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
const operator = helper.eth.createAccount();
@@ -786,4 +950,70 @@
await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
});
+
+ itEth('[negative] Can perform mintBulkCross() with multiple owners and multiple tokens', async ({helper}) => {
+ const caller = await helper.eth.createAccountWithBalance(donor);
+ const callerCross = helper.ethCrossAccount.fromAddress(caller);
+ const receiver = helper.eth.createAccount();
+ const receiverCross = helper.ethCrossAccount.fromAddress(receiver);
+ const receiver2 = helper.eth.createAccount();
+ const receiver2Cross = helper.ethCrossAccount.fromAddress(receiver2);
+
+ const permissions = [
+ {code: TokenPermissionField.Mutable, value: true},
+ {code: TokenPermissionField.TokenOwner, value: true},
+ {code: TokenPermissionField.CollectionAdmin, value: true},
+ ];
+ const {collectionAddress} = await helper.eth.createCollection(
+ caller,
+ {
+ ...CREATE_COLLECTION_DATA_DEFAULTS,
+ name: 'A',
+ description: 'B',
+ tokenPrefix: 'C',
+ collectionMode: 'rft',
+ adminList: [callerCross],
+ tokenPropertyPermissions: [
+ {key: 'key_0_0', permissions},
+ {key: 'key_2_0', permissions},
+ {key: 'key_2_1', permissions},
+ {key: 'key_2_2', permissions},
+ ],
+ },
+ ).send();
+
+ const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
+ const nextTokenId = await contract.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+ const createData = [
+ {
+ owners: [{
+ owner: receiverCross,
+ pieces: 1,
+ }],
+ properties: [
+ {key: 'key_0_0', value: Buffer.from('value_0_0')},
+ ],
+ },
+ {
+ owners: [
+ {
+ owner: receiverCross,
+ pieces: 1,
+ },
+ {
+ owner: receiver2Cross,
+ pieces: 2,
+ },
+ ],
+ properties: [
+ {key: 'key_2_0', value: Buffer.from('value_2_0')},
+ {key: 'key_2_1', value: Buffer.from('value_2_1')},
+ {key: 'key_2_2', value: Buffer.from('value_2_2')},
+ ],
+ },
+ ];
+
+ await expect(contract.methods.mintBulkCross(createData).call({from: caller})).to.be.rejectedWith('creation of multiple tokens supported only if they have single owner each');
+ });
});