difftreelog
added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`
in: master
15 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -37,6 +37,7 @@
Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,
eth::{
EthCrossAccount, convert_cross_account_to_uint256, CollectionPermissions as EvmPermissions,
+ CollectionLimits as EvmCollectionLimits,
},
weights::WeightInfo,
};
@@ -304,6 +305,101 @@
Ok(result)
}
+ /// Get current collection limits.
+ ///
+ /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
+ /// "accountTokenOwnershipLimit",
+ /// "sponsoredDataSize",
+ /// "sponsoredDataRateLimit",
+ /// "tokenLimit",
+ /// "sponsorTransferTimeout",
+ /// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
+ /// Return `false` if a limit not set.
+ fn collection_limits(&self) -> Result<Vec<(EvmCollectionLimits, bool, uint256)>> {
+ let convert_value_limit = |limit: EvmCollectionLimits,
+ value: Option<u32>|
+ -> (EvmCollectionLimits, bool, uint256) {
+ value
+ .map(|v| (limit, true, v.into()))
+ .unwrap_or((limit, false, Default::default()))
+ };
+
+ let convert_bool_limit = |limit: EvmCollectionLimits,
+ value: Option<bool>|
+ -> (EvmCollectionLimits, bool, uint256) {
+ value
+ .map(|v| {
+ (
+ limit,
+ true,
+ if v {
+ uint256::from(1)
+ } else {
+ Default::default()
+ },
+ )
+ })
+ .unwrap_or((limit, false, Default::default()))
+ };
+
+ let limits = &self.collection.limits;
+
+ Ok(vec![
+ convert_value_limit(
+ EvmCollectionLimits::AccountTokenOwnership,
+ limits.account_token_ownership_limit,
+ ),
+ convert_value_limit(
+ EvmCollectionLimits::SponsoredDataSize,
+ limits.sponsored_data_size,
+ ),
+ limits
+ .sponsored_data_rate_limit
+ .map(|limit| {
+ (
+ EvmCollectionLimits::SponsoredDataRateLimit,
+ match limit {
+ SponsoringRateLimit::Blocks(_) => true,
+ _ => false,
+ },
+ match limit {
+ SponsoringRateLimit::Blocks(blocks) => blocks.into(),
+ _ => Default::default(),
+ },
+ )
+ })
+ .unwrap_or((
+ EvmCollectionLimits::SponsoredDataRateLimit,
+ false,
+ Default::default(),
+ )),
+ convert_value_limit(EvmCollectionLimits::TokenLimit, limits.token_limit),
+ convert_value_limit(
+ EvmCollectionLimits::SponsorTransferTimeout,
+ limits.sponsor_transfer_timeout,
+ ),
+ convert_value_limit(
+ EvmCollectionLimits::SponsorApproveTimeout,
+ limits.sponsor_approve_timeout,
+ ),
+ convert_bool_limit(
+ EvmCollectionLimits::OwnerCanTransfer,
+ limits.owner_can_transfer,
+ ),
+ convert_bool_limit(
+ EvmCollectionLimits::OwnerCanDestroy,
+ limits.owner_can_destroy,
+ ),
+ convert_bool_limit(
+ EvmCollectionLimits::TransferEnabled,
+ limits.transfers_enabled,
+ ),
+ ])
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -318,9 +414,19 @@
/// "transfersEnabled"
/// @param value Value of the limit.
#[solidity(rename_selector = "setCollectionLimit")]
- fn set_int_limit(&mut self, caller: caller, limit: string, value: uint256) -> Result<void> {
+ fn set_collection_limit(
+ &mut self,
+ caller: caller,
+ limit: EvmCollectionLimits,
+ status: bool,
+ value: uint256,
+ ) -> Result<void> {
self.consume_store_reads_and_writes(1, 1)?;
+ if !status {
+ return Err(Error::Revert("user can't disable limits".into()));
+ }
+
let value = value
.try_into()
.map_err(|_| Error::Revert(format!("can't convert value to u32 \"{}\"", value)))?;
@@ -338,35 +444,35 @@
let mut limits = self.limits.clone();
- match limit.as_str() {
- "accountTokenOwnershipLimit" => {
+ match limit {
+ EvmCollectionLimits::AccountTokenOwnership => {
limits.account_token_ownership_limit = Some(value);
}
- "sponsoredDataSize" => {
+ EvmCollectionLimits::SponsoredDataSize => {
limits.sponsored_data_size = Some(value);
}
- "sponsoredDataRateLimit" => {
+ EvmCollectionLimits::SponsoredDataRateLimit => {
limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(value));
}
- "tokenLimit" => {
+ EvmCollectionLimits::TokenLimit => {
limits.token_limit = Some(value);
}
- "sponsorTransferTimeout" => {
+ EvmCollectionLimits::SponsorTransferTimeout => {
limits.sponsor_transfer_timeout = Some(value);
}
- "sponsorApproveTimeout" => {
+ EvmCollectionLimits::SponsorApproveTimeout => {
limits.sponsor_approve_timeout = Some(value);
}
- "ownerCanTransfer" => {
+ EvmCollectionLimits::OwnerCanTransfer => {
limits.owner_can_transfer = Some(convert_value_to_bool()?);
}
- "ownerCanDestroy" => {
+ EvmCollectionLimits::OwnerCanDestroy => {
limits.owner_can_destroy = Some(convert_value_to_bool()?);
}
- "transfersEnabled" => {
+ EvmCollectionLimits::TransferEnabled => {
limits.transfers_enabled = Some(convert_value_to_bool()?);
}
- _ => return Err(Error::Revert(format!("unknown limit \"{}\"", limit))),
+ _ => return Err(Error::Revert(format!("unknown limit \"{:?}\"", limit))),
}
let caller = T::CrossAccountId::from_eth(caller);
@@ -778,3 +884,31 @@
})
}
}
+
+fn convert_value_limit<V: Into<uint256> + Copy>(
+ limit: EvmCollectionLimits,
+ value: &Option<V>,
+) -> (EvmCollectionLimits, bool, uint256) {
+ value
+ .map(|v| (limit, true, v.into()))
+ .unwrap_or((limit, false, Default::default()))
+}
+
+fn convert_bool_limit(
+ limit: EvmCollectionLimits,
+ value: &Option<bool>,
+) -> (EvmCollectionLimits, bool, uint256) {
+ value
+ .map(|v| {
+ (
+ limit,
+ true,
+ if v {
+ uint256::from(1)
+ } else {
+ Default::default()
+ },
+ )
+ })
+ .unwrap_or((limit, false, Default::default()))
+}
pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -155,6 +155,20 @@
}
}
}
+#[derive(Debug, Default, Clone, Copy, AbiCoder)]
+#[repr(u8)]
+pub enum CollectionLimits {
+ #[default]
+ AccountTokenOwnership,
+ SponsoredDataSize,
+ SponsoredDataRateLimit,
+ TokenLimit,
+ SponsorTransferTimeout,
+ SponsorApproveTimeout,
+ OwnerCanTransfer,
+ OwnerCanDestroy,
+ TransferEnabled,
+}
#[derive(Default, Debug, Clone, Copy, AbiCoder)]
#[repr(u8)]
pub enum CollectionPermissions {
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -158,6 +158,27 @@
return Tuple8(0x0000000000000000000000000000000000000000, 0);
}
+ /// Get current collection limits.
+ ///
+ /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
+ /// "accountTokenOwnershipLimit",
+ /// "sponsoredDataSize",
+ /// "sponsoredDataRateLimit",
+ /// "tokenLimit",
+ /// "sponsorTransferTimeout",
+ /// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
+ /// Return `false` if a limit not set.
+ /// @dev EVM selector for this function is: 0xf63bc572,
+ /// or in textual repr: collectionLimits()
+ function collectionLimits() public view returns (Tuple20[] memory) {
+ require(false, stub_error);
+ dummy;
+ return new Tuple20[](0);
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -171,11 +192,16 @@
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x4ad890a8,
- /// or in textual repr: setCollectionLimit(string,uint256)
- function setCollectionLimit(string memory limit, uint256 value) public {
+ /// @dev EVM selector for this function is: 0x88150bd0,
+ /// or in textual repr: setCollectionLimit(uint8,bool,uint256)
+ function setCollectionLimit(
+ CollectionLimits limit,
+ bool status,
+ uint256 value
+ ) public {
require(false, stub_error);
limit;
+ status;
value;
dummy = 0;
}
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -291,6 +291,27 @@
return Tuple30(0x0000000000000000000000000000000000000000, 0);
}
+ /// Get current collection limits.
+ ///
+ /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
+ /// "accountTokenOwnershipLimit",
+ /// "sponsoredDataSize",
+ /// "sponsoredDataRateLimit",
+ /// "tokenLimit",
+ /// "sponsorTransferTimeout",
+ /// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
+ /// Return `false` if a limit not set.
+ /// @dev EVM selector for this function is: 0xf63bc572,
+ /// or in textual repr: collectionLimits()
+ function collectionLimits() public view returns (Tuple33[] memory) {
+ require(false, stub_error);
+ dummy;
+ return new Tuple33[](0);
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -304,11 +325,16 @@
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x4ad890a8,
- /// or in textual repr: setCollectionLimit(string,uint256)
- function setCollectionLimit(string memory limit, uint256 value) public {
+ /// @dev EVM selector for this function is: 0x88150bd0,
+ /// or in textual repr: setCollectionLimit(uint8,bool,uint256)
+ function setCollectionLimit(
+ CollectionLimits limit,
+ bool status,
+ uint256 value
+ ) public {
require(false, stub_error);
limit;
+ status;
value;
dummy = 0;
}
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -292,6 +292,27 @@
return Tuple29(0x0000000000000000000000000000000000000000, 0);
}
+ /// Get current collection limits.
+ ///
+ /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
+ /// "accountTokenOwnershipLimit",
+ /// "sponsoredDataSize",
+ /// "sponsoredDataRateLimit",
+ /// "tokenLimit",
+ /// "sponsorTransferTimeout",
+ /// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
+ /// Return `false` if a limit not set.
+ /// @dev EVM selector for this function is: 0xf63bc572,
+ /// or in textual repr: collectionLimits()
+ function collectionLimits() public view returns (Tuple32[] memory) {
+ require(false, stub_error);
+ dummy;
+ return new Tuple32[](0);
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -305,11 +326,16 @@
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x4ad890a8,
- /// or in textual repr: setCollectionLimit(string,uint256)
- function setCollectionLimit(string memory limit, uint256 value) public {
+ /// @dev EVM selector for this function is: 0x88150bd0,
+ /// or in textual repr: setCollectionLimit(uint8,bool,uint256)
+ function setCollectionLimit(
+ CollectionLimits limit,
+ bool status,
+ uint256 value
+ ) public {
require(false, stub_error);
limit;
+ status;
value;
dummy = 0;
}
tests/src/eth/abi/fungible.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": "spender",15 "type": "address"16 },17 {18 "indexed": false,19 "internalType": "uint256",20 "name": "value",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": "from",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "to",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "uint256",45 "name": "value",46 "type": "uint256"47 }48 ],49 "name": "Transfer",50 "type": "event"51 },52 {53 "inputs": [54 {55 "components": [56 { "internalType": "address", "name": "eth", "type": "address" },57 { "internalType": "uint256", "name": "sub", "type": "uint256" }58 ],59 "internalType": "struct EthCrossAccount",60 "name": "newAdmin",61 "type": "tuple"62 }63 ],64 "name": "addCollectionAdminCross",65 "outputs": [],66 "stateMutability": "nonpayable",67 "type": "function"68 },69 {70 "inputs": [71 {72 "components": [73 { "internalType": "address", "name": "eth", "type": "address" },74 { "internalType": "uint256", "name": "sub", "type": "uint256" }75 ],76 "internalType": "struct EthCrossAccount",77 "name": "user",78 "type": "tuple"79 }80 ],81 "name": "addToCollectionAllowListCross",82 "outputs": [],83 "stateMutability": "nonpayable",84 "type": "function"85 },86 {87 "inputs": [88 { "internalType": "address", "name": "owner", "type": "address" },89 { "internalType": "address", "name": "spender", "type": "address" }90 ],91 "name": "allowance",92 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],93 "stateMutability": "view",94 "type": "function"95 },96 {97 "inputs": [98 {99 "components": [100 { "internalType": "address", "name": "eth", "type": "address" },101 { "internalType": "uint256", "name": "sub", "type": "uint256" }102 ],103 "internalType": "struct EthCrossAccount",104 "name": "user",105 "type": "tuple"106 }107 ],108 "name": "allowlistedCross",109 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],110 "stateMutability": "view",111 "type": "function"112 },113 {114 "inputs": [115 { "internalType": "address", "name": "spender", "type": "address" },116 { "internalType": "uint256", "name": "amount", "type": "uint256" }117 ],118 "name": "approve",119 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],120 "stateMutability": "nonpayable",121 "type": "function"122 },123 {124 "inputs": [125 {126 "components": [127 { "internalType": "address", "name": "eth", "type": "address" },128 { "internalType": "uint256", "name": "sub", "type": "uint256" }129 ],130 "internalType": "struct EthCrossAccount",131 "name": "spender",132 "type": "tuple"133 },134 { "internalType": "uint256", "name": "amount", "type": "uint256" }135 ],136 "name": "approveCross",137 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],138 "stateMutability": "nonpayable",139 "type": "function"140 },141 {142 "inputs": [143 { "internalType": "address", "name": "owner", "type": "address" }144 ],145 "name": "balanceOf",146 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],147 "stateMutability": "view",148 "type": "function"149 },150 {151 "inputs": [152 {153 "components": [154 { "internalType": "address", "name": "eth", "type": "address" },155 { "internalType": "uint256", "name": "sub", "type": "uint256" }156 ],157 "internalType": "struct EthCrossAccount",158 "name": "from",159 "type": "tuple"160 },161 { "internalType": "uint256", "name": "amount", "type": "uint256" }162 ],163 "name": "burnFromCross",164 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],165 "stateMutability": "nonpayable",166 "type": "function"167 },168 {169 "inputs": [170 {171 "components": [172 { "internalType": "address", "name": "eth", "type": "address" },173 { "internalType": "uint256", "name": "sub", "type": "uint256" }174 ],175 "internalType": "struct EthCrossAccount",176 "name": "newOwner",177 "type": "tuple"178 }179 ],180 "name": "changeCollectionOwnerCross",181 "outputs": [],182 "stateMutability": "nonpayable",183 "type": "function"184 },185 {186 "inputs": [],187 "name": "collectionAdmins",188 "outputs": [189 {190 "components": [191 { "internalType": "address", "name": "eth", "type": "address" },192 { "internalType": "uint256", "name": "sub", "type": "uint256" }193 ],194 "internalType": "struct EthCrossAccount[]",195 "name": "",196 "type": "tuple[]"197 }198 ],199 "stateMutability": "view",200 "type": "function"201 },202 {203 "inputs": [],204 "name": "collectionHelperAddress",205 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],206 "stateMutability": "view",207 "type": "function"208 },209 {210 "inputs": [],211 "name": "collectionNestingPermissions",212 "outputs": [213 {214 "components": [215 {216 "internalType": "enum CollectionPermissions",217 "name": "field_0",218 "type": "uint8"219 },220 { "internalType": "bool", "name": "field_1", "type": "bool" }221 ],222 "internalType": "struct Tuple24[]",223 "name": "",224 "type": "tuple[]"225 }226 ],227 "stateMutability": "view",228 "type": "function"229 },230 {231 "inputs": [],232 "name": "collectionNestingRestrictedCollectionIds",233 "outputs": [234 {235 "components": [236 { "internalType": "bool", "name": "field_0", "type": "bool" },237 {238 "internalType": "uint256[]",239 "name": "field_1",240 "type": "uint256[]"241 }242 ],243 "internalType": "struct Tuple21",244 "name": "",245 "type": "tuple"246 }247 ],248 "stateMutability": "view",249 "type": "function"250 },251 {252 "inputs": [],253 "name": "collectionOwner",254 "outputs": [255 {256 "components": [257 { "internalType": "address", "name": "eth", "type": "address" },258 { "internalType": "uint256", "name": "sub", "type": "uint256" }259 ],260 "internalType": "struct EthCrossAccount",261 "name": "",262 "type": "tuple"263 }264 ],265 "stateMutability": "view",266 "type": "function"267 },268 {269 "inputs": [270 { "internalType": "string[]", "name": "keys", "type": "string[]" }271 ],272 "name": "collectionProperties",273 "outputs": [274 {275 "components": [276 { "internalType": "string", "name": "key", "type": "string" },277 { "internalType": "bytes", "name": "value", "type": "bytes" }278 ],279 "internalType": "struct Property[]",280 "name": "",281 "type": "tuple[]"282 }283 ],284 "stateMutability": "view",285 "type": "function"286 },287 {288 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],289 "name": "collectionProperty",290 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],291 "stateMutability": "view",292 "type": "function"293 },294 {295 "inputs": [],296 "name": "collectionSponsor",297 "outputs": [298 {299 "components": [300 { "internalType": "address", "name": "field_0", "type": "address" },301 { "internalType": "uint256", "name": "field_1", "type": "uint256" }302 ],303 "internalType": "struct Tuple8",304 "name": "",305 "type": "tuple"306 }307 ],308 "stateMutability": "view",309 "type": "function"310 },311 {312 "inputs": [],313 "name": "confirmCollectionSponsorship",314 "outputs": [],315 "stateMutability": "nonpayable",316 "type": "function"317 },318 {319 "inputs": [],320 "name": "contractAddress",321 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],322 "stateMutability": "view",323 "type": "function"324 },325 {326 "inputs": [],327 "name": "decimals",328 "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],329 "stateMutability": "view",330 "type": "function"331 },332 {333 "inputs": [334 { "internalType": "string[]", "name": "keys", "type": "string[]" }335 ],336 "name": "deleteCollectionProperties",337 "outputs": [],338 "stateMutability": "nonpayable",339 "type": "function"340 },341 {342 "inputs": [],343 "name": "description",344 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],345 "stateMutability": "view",346 "type": "function"347 },348 {349 "inputs": [],350 "name": "hasCollectionPendingSponsor",351 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],352 "stateMutability": "view",353 "type": "function"354 },355 {356 "inputs": [357 {358 "components": [359 { "internalType": "address", "name": "eth", "type": "address" },360 { "internalType": "uint256", "name": "sub", "type": "uint256" }361 ],362 "internalType": "struct EthCrossAccount",363 "name": "user",364 "type": "tuple"365 }366 ],367 "name": "isOwnerOrAdminCross",368 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],369 "stateMutability": "view",370 "type": "function"371 },372 {373 "inputs": [374 { "internalType": "address", "name": "to", "type": "address" },375 { "internalType": "uint256", "name": "amount", "type": "uint256" }376 ],377 "name": "mint",378 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],379 "stateMutability": "nonpayable",380 "type": "function"381 },382 {383 "inputs": [384 {385 "components": [386 { "internalType": "address", "name": "field_0", "type": "address" },387 { "internalType": "uint256", "name": "field_1", "type": "uint256" }388 ],389 "internalType": "struct Tuple8[]",390 "name": "amounts",391 "type": "tuple[]"392 }393 ],394 "name": "mintBulk",395 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],396 "stateMutability": "nonpayable",397 "type": "function"398 },399 {400 "inputs": [],401 "name": "name",402 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],403 "stateMutability": "view",404 "type": "function"405 },406 {407 "inputs": [408 {409 "components": [410 { "internalType": "address", "name": "eth", "type": "address" },411 { "internalType": "uint256", "name": "sub", "type": "uint256" }412 ],413 "internalType": "struct EthCrossAccount",414 "name": "admin",415 "type": "tuple"416 }417 ],418 "name": "removeCollectionAdminCross",419 "outputs": [],420 "stateMutability": "nonpayable",421 "type": "function"422 },423 {424 "inputs": [],425 "name": "removeCollectionSponsor",426 "outputs": [],427 "stateMutability": "nonpayable",428 "type": "function"429 },430 {431 "inputs": [432 {433 "components": [434 { "internalType": "address", "name": "eth", "type": "address" },435 { "internalType": "uint256", "name": "sub", "type": "uint256" }436 ],437 "internalType": "struct EthCrossAccount",438 "name": "user",439 "type": "tuple"440 }441 ],442 "name": "removeFromCollectionAllowListCross",443 "outputs": [],444 "stateMutability": "nonpayable",445 "type": "function"446 },447 {448 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],449 "name": "setCollectionAccess",450 "outputs": [],451 "stateMutability": "nonpayable",452 "type": "function"453 },454 {455 "inputs": [456 { "internalType": "string", "name": "limit", "type": "string" },457 { "internalType": "uint256", "name": "value", "type": "uint256" }458 ],459 "name": "setCollectionLimit",460 "outputs": [],461 "stateMutability": "nonpayable",462 "type": "function"463 },464 {465 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],466 "name": "setCollectionMintMode",467 "outputs": [],468 "stateMutability": "nonpayable",469 "type": "function"470 },471 {472 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],473 "name": "setCollectionNesting",474 "outputs": [],475 "stateMutability": "nonpayable",476 "type": "function"477 },478 {479 "inputs": [480 { "internalType": "bool", "name": "enable", "type": "bool" },481 {482 "internalType": "address[]",483 "name": "collections",484 "type": "address[]"485 }486 ],487 "name": "setCollectionNesting",488 "outputs": [],489 "stateMutability": "nonpayable",490 "type": "function"491 },492 {493 "inputs": [494 {495 "components": [496 { "internalType": "string", "name": "key", "type": "string" },497 { "internalType": "bytes", "name": "value", "type": "bytes" }498 ],499 "internalType": "struct Property[]",500 "name": "properties",501 "type": "tuple[]"502 }503 ],504 "name": "setCollectionProperties",505 "outputs": [],506 "stateMutability": "nonpayable",507 "type": "function"508 },509 {510 "inputs": [511 {512 "components": [513 { "internalType": "address", "name": "eth", "type": "address" },514 { "internalType": "uint256", "name": "sub", "type": "uint256" }515 ],516 "internalType": "struct EthCrossAccount",517 "name": "sponsor",518 "type": "tuple"519 }520 ],521 "name": "setCollectionSponsorCross",522 "outputs": [],523 "stateMutability": "nonpayable",524 "type": "function"525 },526 {527 "inputs": [528 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }529 ],530 "name": "supportsInterface",531 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],532 "stateMutability": "view",533 "type": "function"534 },535 {536 "inputs": [],537 "name": "symbol",538 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],539 "stateMutability": "view",540 "type": "function"541 },542 {543 "inputs": [],544 "name": "totalSupply",545 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],546 "stateMutability": "view",547 "type": "function"548 },549 {550 "inputs": [551 { "internalType": "address", "name": "to", "type": "address" },552 { "internalType": "uint256", "name": "amount", "type": "uint256" }553 ],554 "name": "transfer",555 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],556 "stateMutability": "nonpayable",557 "type": "function"558 },559 {560 "inputs": [561 {562 "components": [563 { "internalType": "address", "name": "eth", "type": "address" },564 { "internalType": "uint256", "name": "sub", "type": "uint256" }565 ],566 "internalType": "struct EthCrossAccount",567 "name": "to",568 "type": "tuple"569 },570 { "internalType": "uint256", "name": "amount", "type": "uint256" }571 ],572 "name": "transferCross",573 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],574 "stateMutability": "nonpayable",575 "type": "function"576 },577 {578 "inputs": [579 { "internalType": "address", "name": "from", "type": "address" },580 { "internalType": "address", "name": "to", "type": "address" },581 { "internalType": "uint256", "name": "amount", "type": "uint256" }582 ],583 "name": "transferFrom",584 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],585 "stateMutability": "nonpayable",586 "type": "function"587 },588 {589 "inputs": [590 {591 "components": [592 { "internalType": "address", "name": "eth", "type": "address" },593 { "internalType": "uint256", "name": "sub", "type": "uint256" }594 ],595 "internalType": "struct EthCrossAccount",596 "name": "from",597 "type": "tuple"598 },599 {600 "components": [601 { "internalType": "address", "name": "eth", "type": "address" },602 { "internalType": "uint256", "name": "sub", "type": "uint256" }603 ],604 "internalType": "struct EthCrossAccount",605 "name": "to",606 "type": "tuple"607 },608 { "internalType": "uint256", "name": "amount", "type": "uint256" }609 ],610 "name": "transferFromCross",611 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],612 "stateMutability": "nonpayable",613 "type": "function"614 },615 {616 "inputs": [],617 "name": "uniqueCollectionType",618 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],619 "stateMutability": "view",620 "type": "function"621 }622]1[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": "spender",15 "type": "address"16 },17 {18 "indexed": false,19 "internalType": "uint256",20 "name": "value",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": "from",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "to",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "uint256",45 "name": "value",46 "type": "uint256"47 }48 ],49 "name": "Transfer",50 "type": "event"51 },52 {53 "inputs": [54 {55 "components": [56 { "internalType": "address", "name": "eth", "type": "address" },57 { "internalType": "uint256", "name": "sub", "type": "uint256" }58 ],59 "internalType": "struct EthCrossAccount",60 "name": "newAdmin",61 "type": "tuple"62 }63 ],64 "name": "addCollectionAdminCross",65 "outputs": [],66 "stateMutability": "nonpayable",67 "type": "function"68 },69 {70 "inputs": [71 {72 "components": [73 { "internalType": "address", "name": "eth", "type": "address" },74 { "internalType": "uint256", "name": "sub", "type": "uint256" }75 ],76 "internalType": "struct EthCrossAccount",77 "name": "user",78 "type": "tuple"79 }80 ],81 "name": "addToCollectionAllowListCross",82 "outputs": [],83 "stateMutability": "nonpayable",84 "type": "function"85 },86 {87 "inputs": [88 { "internalType": "address", "name": "owner", "type": "address" },89 { "internalType": "address", "name": "spender", "type": "address" }90 ],91 "name": "allowance",92 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],93 "stateMutability": "view",94 "type": "function"95 },96 {97 "inputs": [98 {99 "components": [100 { "internalType": "address", "name": "eth", "type": "address" },101 { "internalType": "uint256", "name": "sub", "type": "uint256" }102 ],103 "internalType": "struct EthCrossAccount",104 "name": "user",105 "type": "tuple"106 }107 ],108 "name": "allowlistedCross",109 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],110 "stateMutability": "view",111 "type": "function"112 },113 {114 "inputs": [115 { "internalType": "address", "name": "spender", "type": "address" },116 { "internalType": "uint256", "name": "amount", "type": "uint256" }117 ],118 "name": "approve",119 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],120 "stateMutability": "nonpayable",121 "type": "function"122 },123 {124 "inputs": [125 {126 "components": [127 { "internalType": "address", "name": "eth", "type": "address" },128 { "internalType": "uint256", "name": "sub", "type": "uint256" }129 ],130 "internalType": "struct EthCrossAccount",131 "name": "spender",132 "type": "tuple"133 },134 { "internalType": "uint256", "name": "amount", "type": "uint256" }135 ],136 "name": "approveCross",137 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],138 "stateMutability": "nonpayable",139 "type": "function"140 },141 {142 "inputs": [143 { "internalType": "address", "name": "owner", "type": "address" }144 ],145 "name": "balanceOf",146 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],147 "stateMutability": "view",148 "type": "function"149 },150 {151 "inputs": [152 {153 "components": [154 { "internalType": "address", "name": "eth", "type": "address" },155 { "internalType": "uint256", "name": "sub", "type": "uint256" }156 ],157 "internalType": "struct EthCrossAccount",158 "name": "from",159 "type": "tuple"160 },161 { "internalType": "uint256", "name": "amount", "type": "uint256" }162 ],163 "name": "burnFromCross",164 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],165 "stateMutability": "nonpayable",166 "type": "function"167 },168 {169 "inputs": [170 {171 "components": [172 { "internalType": "address", "name": "eth", "type": "address" },173 { "internalType": "uint256", "name": "sub", "type": "uint256" }174 ],175 "internalType": "struct EthCrossAccount",176 "name": "newOwner",177 "type": "tuple"178 }179 ],180 "name": "changeCollectionOwnerCross",181 "outputs": [],182 "stateMutability": "nonpayable",183 "type": "function"184 },185 {186 "inputs": [],187 "name": "collectionAdmins",188 "outputs": [189 {190 "components": [191 { "internalType": "address", "name": "eth", "type": "address" },192 { "internalType": "uint256", "name": "sub", "type": "uint256" }193 ],194 "internalType": "struct EthCrossAccount[]",195 "name": "",196 "type": "tuple[]"197 }198 ],199 "stateMutability": "view",200 "type": "function"201 },202 {203 "inputs": [],204 "name": "collectionHelperAddress",205 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],206 "stateMutability": "view",207 "type": "function"208 },209 {210 "inputs": [],211<<<<<<< HEAD212 "name": "collectionNestingPermissions",213=======214 "name": "collectionLimits",215>>>>>>> 32e011ce... added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`216 "outputs": [217 {218 "components": [219 {220<<<<<<< HEAD221 "internalType": "enum CollectionPermissions",222 "name": "field_0",223 "type": "uint8"224 },225 { "internalType": "bool", "name": "field_1", "type": "bool" }226 ],227 "internalType": "struct Tuple24[]",228=======229 "internalType": "enum CollectionLimits",230 "name": "field_0",231 "type": "uint8"232 },233 { "internalType": "bool", "name": "field_1", "type": "bool" },234 { "internalType": "uint256", "name": "field_2", "type": "uint256" }235 ],236 "internalType": "struct Tuple20[]",237>>>>>>> 32e011ce... added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`238 "name": "",239 "type": "tuple[]"240 }241 ],242 "stateMutability": "view",243 "type": "function"244 },245 {246 "inputs": [],247<<<<<<< HEAD248 "name": "collectionNestingRestrictedCollectionIds",249 "outputs": [250 {251 "components": [252 { "internalType": "bool", "name": "field_0", "type": "bool" },253 {254 "internalType": "uint256[]",255 "name": "field_1",256 "type": "uint256[]"257 }258 ],259 "internalType": "struct Tuple21",260 "name": "",261 "type": "tuple"262 }263 ],264 "stateMutability": "view",265 "type": "function"266 },267 {268 "inputs": [],269=======270>>>>>>> 32e011ce... added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`271 "name": "collectionOwner",272 "outputs": [273 {274 "components": [275 { "internalType": "address", "name": "eth", "type": "address" },276 { "internalType": "uint256", "name": "sub", "type": "uint256" }277 ],278 "internalType": "struct EthCrossAccount",279 "name": "",280 "type": "tuple"281 }282 ],283 "stateMutability": "view",284 "type": "function"285 },286 {287 "inputs": [288 { "internalType": "string[]", "name": "keys", "type": "string[]" }289 ],290 "name": "collectionProperties",291 "outputs": [292 {293 "components": [294 { "internalType": "string", "name": "key", "type": "string" },295 { "internalType": "bytes", "name": "value", "type": "bytes" }296 ],297 "internalType": "struct Property[]",298 "name": "",299 "type": "tuple[]"300 }301 ],302 "stateMutability": "view",303 "type": "function"304 },305 {306 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],307 "name": "collectionProperty",308 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],309 "stateMutability": "view",310 "type": "function"311 },312 {313 "inputs": [],314 "name": "collectionSponsor",315 "outputs": [316 {317 "components": [318 { "internalType": "address", "name": "field_0", "type": "address" },319 { "internalType": "uint256", "name": "field_1", "type": "uint256" }320 ],321 "internalType": "struct Tuple8",322 "name": "",323 "type": "tuple"324 }325 ],326 "stateMutability": "view",327 "type": "function"328 },329 {330 "inputs": [],331 "name": "confirmCollectionSponsorship",332 "outputs": [],333 "stateMutability": "nonpayable",334 "type": "function"335 },336 {337 "inputs": [],338 "name": "contractAddress",339 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],340 "stateMutability": "view",341 "type": "function"342 },343 {344 "inputs": [],345 "name": "decimals",346 "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],347 "stateMutability": "view",348 "type": "function"349 },350 {351 "inputs": [352 { "internalType": "string[]", "name": "keys", "type": "string[]" }353 ],354 "name": "deleteCollectionProperties",355 "outputs": [],356 "stateMutability": "nonpayable",357 "type": "function"358 },359 {360 "inputs": [],361 "name": "description",362 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],363 "stateMutability": "view",364 "type": "function"365 },366 {367 "inputs": [],368 "name": "hasCollectionPendingSponsor",369 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],370 "stateMutability": "view",371 "type": "function"372 },373 {374 "inputs": [375 {376 "components": [377 { "internalType": "address", "name": "eth", "type": "address" },378 { "internalType": "uint256", "name": "sub", "type": "uint256" }379 ],380 "internalType": "struct EthCrossAccount",381 "name": "user",382 "type": "tuple"383 }384 ],385 "name": "isOwnerOrAdminCross",386 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],387 "stateMutability": "view",388 "type": "function"389 },390 {391 "inputs": [392 { "internalType": "address", "name": "to", "type": "address" },393 { "internalType": "uint256", "name": "amount", "type": "uint256" }394 ],395 "name": "mint",396 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],397 "stateMutability": "nonpayable",398 "type": "function"399 },400 {401 "inputs": [402 {403 "components": [404 { "internalType": "address", "name": "field_0", "type": "address" },405 { "internalType": "uint256", "name": "field_1", "type": "uint256" }406 ],407 "internalType": "struct Tuple8[]",408 "name": "amounts",409 "type": "tuple[]"410 }411 ],412 "name": "mintBulk",413 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],414 "stateMutability": "nonpayable",415 "type": "function"416 },417 {418 "inputs": [],419 "name": "name",420 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],421 "stateMutability": "view",422 "type": "function"423 },424 {425 "inputs": [426 {427 "components": [428 { "internalType": "address", "name": "eth", "type": "address" },429 { "internalType": "uint256", "name": "sub", "type": "uint256" }430 ],431 "internalType": "struct EthCrossAccount",432 "name": "admin",433 "type": "tuple"434 }435 ],436 "name": "removeCollectionAdminCross",437 "outputs": [],438 "stateMutability": "nonpayable",439 "type": "function"440 },441 {442 "inputs": [],443 "name": "removeCollectionSponsor",444 "outputs": [],445 "stateMutability": "nonpayable",446 "type": "function"447 },448 {449 "inputs": [450 {451 "components": [452 { "internalType": "address", "name": "eth", "type": "address" },453 { "internalType": "uint256", "name": "sub", "type": "uint256" }454 ],455 "internalType": "struct EthCrossAccount",456 "name": "user",457 "type": "tuple"458 }459 ],460 "name": "removeFromCollectionAllowListCross",461 "outputs": [],462 "stateMutability": "nonpayable",463 "type": "function"464 },465 {466 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],467 "name": "setCollectionAccess",468 "outputs": [],469 "stateMutability": "nonpayable",470 "type": "function"471 },472 {473 "inputs": [474 {475 "internalType": "enum CollectionLimits",476 "name": "limit",477 "type": "uint8"478 },479 { "internalType": "bool", "name": "status", "type": "bool" },480 { "internalType": "uint256", "name": "value", "type": "uint256" }481 ],482 "name": "setCollectionLimit",483 "outputs": [],484 "stateMutability": "nonpayable",485 "type": "function"486 },487 {488 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],489 "name": "setCollectionMintMode",490 "outputs": [],491 "stateMutability": "nonpayable",492 "type": "function"493 },494 {495 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],496 "name": "setCollectionNesting",497 "outputs": [],498 "stateMutability": "nonpayable",499 "type": "function"500 },501 {502 "inputs": [503 { "internalType": "bool", "name": "enable", "type": "bool" },504 {505 "internalType": "address[]",506 "name": "collections",507 "type": "address[]"508 }509 ],510 "name": "setCollectionNesting",511 "outputs": [],512 "stateMutability": "nonpayable",513 "type": "function"514 },515 {516 "inputs": [517 {518 "components": [519 { "internalType": "string", "name": "key", "type": "string" },520 { "internalType": "bytes", "name": "value", "type": "bytes" }521 ],522 "internalType": "struct Property[]",523 "name": "properties",524 "type": "tuple[]"525 }526 ],527 "name": "setCollectionProperties",528 "outputs": [],529 "stateMutability": "nonpayable",530 "type": "function"531 },532 {533 "inputs": [534 {535 "components": [536 { "internalType": "address", "name": "eth", "type": "address" },537 { "internalType": "uint256", "name": "sub", "type": "uint256" }538 ],539 "internalType": "struct EthCrossAccount",540 "name": "sponsor",541 "type": "tuple"542 }543 ],544 "name": "setCollectionSponsorCross",545 "outputs": [],546 "stateMutability": "nonpayable",547 "type": "function"548 },549 {550 "inputs": [551 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }552 ],553 "name": "supportsInterface",554 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],555 "stateMutability": "view",556 "type": "function"557 },558 {559 "inputs": [],560 "name": "symbol",561 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],562 "stateMutability": "view",563 "type": "function"564 },565 {566 "inputs": [],567 "name": "totalSupply",568 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],569 "stateMutability": "view",570 "type": "function"571 },572 {573 "inputs": [574 { "internalType": "address", "name": "to", "type": "address" },575 { "internalType": "uint256", "name": "amount", "type": "uint256" }576 ],577 "name": "transfer",578 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],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 EthCrossAccount",590 "name": "to",591 "type": "tuple"592 },593 { "internalType": "uint256", "name": "amount", "type": "uint256" }594 ],595 "name": "transferCross",596 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],597 "stateMutability": "nonpayable",598 "type": "function"599 },600 {601 "inputs": [602 { "internalType": "address", "name": "from", "type": "address" },603 { "internalType": "address", "name": "to", "type": "address" },604 { "internalType": "uint256", "name": "amount", "type": "uint256" }605 ],606 "name": "transferFrom",607 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],608 "stateMutability": "nonpayable",609 "type": "function"610 },611 {612 "inputs": [613 {614 "components": [615 { "internalType": "address", "name": "eth", "type": "address" },616 { "internalType": "uint256", "name": "sub", "type": "uint256" }617 ],618 "internalType": "struct EthCrossAccount",619 "name": "from",620 "type": "tuple"621 },622 {623 "components": [624 { "internalType": "address", "name": "eth", "type": "address" },625 { "internalType": "uint256", "name": "sub", "type": "uint256" }626 ],627 "internalType": "struct EthCrossAccount",628 "name": "to",629 "type": "tuple"630 },631 { "internalType": "uint256", "name": "amount", "type": "uint256" }632 ],633 "name": "transferFromCross",634 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],635 "stateMutability": "nonpayable",636 "type": "function"637 },638 {639 "inputs": [],640 "name": "uniqueCollectionType",641 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],642 "stateMutability": "view",643 "type": "function"644 }645]tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -607,7 +607,12 @@
},
{
"inputs": [
- { "internalType": "string", "name": "limit", "type": "string" },
+ {
+ "internalType": "enum CollectionLimits",
+ "name": "limit",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "status", "type": "bool" },
{ "internalType": "uint256", "name": "value", "type": "uint256" }
],
"name": "setCollectionLimit",
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -589,7 +589,12 @@
},
{
"inputs": [
- { "internalType": "string", "name": "limit", "type": "string" },
+ {
+ "internalType": "enum CollectionLimits",
+ "name": "limit",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "status", "type": "bool" },
{ "internalType": "uint256", "name": "value", "type": "uint256" }
],
"name": "setCollectionLimit",
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,11 @@
}
/// @title A contract that allows you to work with collections.
+<<<<<<< HEAD
/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+=======
+/// @dev the ERC-165 identifier for this interface is 0xf8ebdec0
+>>>>>>> 32e011ce... added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -104,6 +108,23 @@
/// or in textual repr: collectionSponsor()
function collectionSponsor() external view returns (Tuple8 memory);
+ /// Get current collection limits.
+ ///
+ /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
+ /// "accountTokenOwnershipLimit",
+ /// "sponsoredDataSize",
+ /// "sponsoredDataRateLimit",
+ /// "tokenLimit",
+ /// "sponsorTransferTimeout",
+ /// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
+ /// Return `false` if a limit not set.
+ /// @dev EVM selector for this function is: 0xf63bc572,
+ /// or in textual repr: collectionLimits()
+ function collectionLimits() external view returns (Tuple19[] memory);
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -117,9 +138,13 @@
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x4ad890a8,
- /// or in textual repr: setCollectionLimit(string,uint256)
- function setCollectionLimit(string memory limit, uint256 value) external;
+ /// @dev EVM selector for this function is: 0x88150bd0,
+ /// or in textual repr: setCollectionLimit(uint8,bool,uint256)
+ function setCollectionLimit(
+ CollectionLimits limit,
+ bool status,
+ uint256 value
+ ) external;
/// Get contract address.
/// @dev EVM selector for this function is: 0xf6b4dfb4,
@@ -288,6 +313,7 @@
uint256 sub;
}
+<<<<<<< HEAD
/// @dev anonymous struct
struct Tuple23 {
CollectionPermissions field_0;
@@ -303,6 +329,25 @@
struct Tuple20 {
bool field_0;
uint256[] field_1;
+=======
+enum CollectionLimits {
+ AccountTokenOwnership,
+ SponsoredDataSize,
+ SponsoredDataRateLimit,
+ TokenLimit,
+ SponsorTransferTimeout,
+ SponsorApproveTimeout,
+ OwnerCanTransfer,
+ OwnerCanDestroy,
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple19 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+>>>>>>> 32e011ce... added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`
}
/// @dev Property struct
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -104,7 +104,11 @@
}
/// @title A contract that allows you to work with collections.
+<<<<<<< HEAD
/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+=======
+/// @dev the ERC-165 identifier for this interface is 0xf8ebdec0
+>>>>>>> 32e011ce... added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -195,6 +199,23 @@
/// or in textual repr: collectionSponsor()
function collectionSponsor() external view returns (Tuple27 memory);
+ /// Get current collection limits.
+ ///
+ /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
+ /// "accountTokenOwnershipLimit",
+ /// "sponsoredDataSize",
+ /// "sponsoredDataRateLimit",
+ /// "tokenLimit",
+ /// "sponsorTransferTimeout",
+ /// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
+ /// Return `false` if a limit not set.
+ /// @dev EVM selector for this function is: 0xf63bc572,
+ /// or in textual repr: collectionLimits()
+ function collectionLimits() external view returns (Tuple30[] memory);
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -208,9 +229,13 @@
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x4ad890a8,
- /// or in textual repr: setCollectionLimit(string,uint256)
- function setCollectionLimit(string memory limit, uint256 value) external;
+ /// @dev EVM selector for this function is: 0x88150bd0,
+ /// or in textual repr: setCollectionLimit(uint8,bool,uint256)
+ function setCollectionLimit(
+ CollectionLimits limit,
+ bool status,
+ uint256 value
+ ) external;
/// Get contract address.
/// @dev EVM selector for this function is: 0xf6b4dfb4,
@@ -379,6 +404,25 @@
uint256 sub;
}
+enum CollectionLimits {
+ AccountTokenOwnership,
+ SponsoredDataSize,
+ SponsoredDataRateLimit,
+ TokenLimit,
+ SponsorTransferTimeout,
+ SponsorApproveTimeout,
+ OwnerCanTransfer,
+ OwnerCanDestroy,
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple30 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev anonymous struct
struct Tuple34 {
CollectionPermissions field_0;
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -105,7 +105,11 @@
}
/// @title A contract that allows you to work with collections.
+<<<<<<< HEAD
/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+=======
+/// @dev the ERC-165 identifier for this interface is 0xf8ebdec0
+>>>>>>> 32e011ce... added `collectionLimits` function in `Collection` interface, changed signture for `setCollectionLimit`
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -196,6 +200,23 @@
/// or in textual repr: collectionSponsor()
function collectionSponsor() external view returns (Tuple26 memory);
+ /// Get current collection limits.
+ ///
+ /// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
+ /// "accountTokenOwnershipLimit",
+ /// "sponsoredDataSize",
+ /// "sponsoredDataRateLimit",
+ /// "tokenLimit",
+ /// "sponsorTransferTimeout",
+ /// "sponsorApproveTimeout"
+ /// "ownerCanTransfer",
+ /// "ownerCanDestroy",
+ /// "transfersEnabled"
+ /// Return `false` if a limit not set.
+ /// @dev EVM selector for this function is: 0xf63bc572,
+ /// or in textual repr: collectionLimits()
+ function collectionLimits() external view returns (Tuple29[] memory);
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -209,9 +230,13 @@
/// "ownerCanDestroy",
/// "transfersEnabled"
/// @param value Value of the limit.
- /// @dev EVM selector for this function is: 0x4ad890a8,
- /// or in textual repr: setCollectionLimit(string,uint256)
- function setCollectionLimit(string memory limit, uint256 value) external;
+ /// @dev EVM selector for this function is: 0x88150bd0,
+ /// or in textual repr: setCollectionLimit(uint8,bool,uint256)
+ function setCollectionLimit(
+ CollectionLimits limit,
+ bool status,
+ uint256 value
+ ) external;
/// Get contract address.
/// @dev EVM selector for this function is: 0xf6b4dfb4,
@@ -380,6 +405,25 @@
uint256 sub;
}
+enum CollectionLimits {
+ AccountTokenOwnership,
+ SponsoredDataSize,
+ SponsoredDataRateLimit,
+ TokenLimit,
+ SponsorTransferTimeout,
+ SponsorApproveTimeout,
+ OwnerCanTransfer,
+ OwnerCanDestroy,
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple29 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev anonymous struct
struct Tuple33 {
CollectionPermissions field_0;
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -17,7 +17,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {evmToAddress} from '@polkadot/util-crypto';
import {Pallets, requirePalletsOrSkip} from '../util';
-import {expect, itEth, usingEthPlaygrounds} from './util';
+import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';
const DECIMALS = 18;
@@ -79,6 +79,56 @@
expect(await collection.methods.description().call()).to.deep.equal(description);
});
+ itEth('Set limits', async ({helper}) => {
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'INSI');
+ const limits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
+ ownerCanTransfer: 0,
+ ownerCanDestroy: 0,
+ transfersEnabled: 0,
+ };
+
+ const expectedLimits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
+ ownerCanTransfer: false,
+ ownerCanDestroy: false,
+ transfersEnabled: false,
+ };
+
+ const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
+ await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
+
+ const data = (await helper.rft.getData(collectionId))!;
+ expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+ expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+ expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+ expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+ expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+ expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+ expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+ expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+ expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
+ });
+
itEth('Collection address exist', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';
@@ -197,6 +247,7 @@
{
await expect(peasantCollection.methods
.setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
@@ -224,5 +275,31 @@
.setCollectionLimit('accountTokenOwnershipLimit', '1000')
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
- });
+ });
+
+ itEth('(!negative test!) Set limits', async ({helper}) => {
+
+ const invalidLimits = {
+ accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+ transfersEnabled: 3,
+ };
+
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');
+ const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
+ await expect(collectionEvm.methods
+ .setCollectionLimit(20, true, '1')
+ .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"');
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
+ .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)
+ .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
+ });
+
+
+
});
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -16,7 +16,7 @@
import {evmToAddress} from '@polkadot/util-crypto';
import {IKeyringPair} from '@polkadot/types/types';
-import {expect, itEth, usingEthPlaygrounds} from './util';
+import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';
describe('Create NFT collection from EVM', () => {
@@ -120,6 +120,56 @@
expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);
});
+ itEth('Set limits', async ({helper}) => {
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');
+ const limits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
+ ownerCanTransfer: 0,
+ ownerCanDestroy: 0,
+ transfersEnabled: 0,
+ };
+
+ const expectedLimits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
+ ownerCanTransfer: false,
+ ownerCanDestroy: false,
+ transfersEnabled: false,
+ };
+
+ const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+ await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
+
+ const data = (await helper.rft.getData(collectionId))!;
+ expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+ expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+ expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+ expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+ expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+ expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+ expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+ expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+ expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
+ });
+
itEth('Collection address exist', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';
@@ -207,7 +257,7 @@
}
{
await expect(malfeasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
@@ -232,11 +282,30 @@
}
{
await expect(malfeasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
+ itEth('(!negative test!) Set limits', async ({helper}) => {
+ const invalidLimits = {
+ accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+ transfersEnabled: 3,
+ };
+
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
+ const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
+ .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)
+ .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
+ });
+
itEth('destroyCollection', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -17,7 +17,7 @@
import {evmToAddress} from '@polkadot/util-crypto';
import {IKeyringPair} from '@polkadot/types/types';
import {Pallets, requirePalletsOrSkip} from '../util';
-import {expect, itEth, usingEthPlaygrounds} from './util';
+import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';
describe('Create RFT collection from EVM', () => {
@@ -152,6 +152,56 @@
expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
});
+ itEth('Set limits', async ({helper}) => {
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'INSI');
+ const limits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
+ ownerCanTransfer: 0,
+ ownerCanDestroy: 0,
+ transfersEnabled: 0,
+ };
+
+ const expectedLimits = {
+ accountTokenOwnershipLimit: 1000,
+ sponsoredDataSize: 1024,
+ sponsoredDataRateLimit: 30,
+ tokenLimit: 1000000,
+ sponsorTransferTimeout: 6,
+ sponsorApproveTimeout: 6,
+ ownerCanTransfer: false,
+ ownerCanDestroy: false,
+ transfersEnabled: false,
+ };
+
+ const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
+ await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
+ await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
+
+ const data = (await helper.rft.getData(collectionId))!;
+ expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+ expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+ expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+ expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+ expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+ expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+ expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+ expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+ expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
+ });
+
itEth('Collection address exist', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';
@@ -239,7 +289,7 @@
}
{
await expect(peasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
@@ -264,10 +314,29 @@
}
{
await expect(peasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
+
+ itEth('(!negative test!) Set limits', async ({helper}) => {
+ const invalidLimits = {
+ accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+ transfersEnabled: 3,
+ };
+
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
+ const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
+ .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)
+ .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
+ });
itEth('destroyCollection', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
tests/src/eth/util/index.tsdiffbeforeafterboth--- a/tests/src/eth/util/index.ts
+++ b/tests/src/eth/util/index.ts
@@ -26,6 +26,17 @@
Allowlisted = 1,
Generous = 2,
}
+export enum CollectionLimits {
+ AccountTokenOwnership,
+ SponsoredDataSize,
+ SponsoredDataRateLimit,
+ TokenLimit,
+ SponsorTransferTimeout,
+ SponsorApproveTimeout,
+ OwnerCanTransfer,
+ OwnerCanDestroy,
+ TransferEnabled
+}
export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair>) => Promise<void>) => {
const silentConsole = new SilentConsole();