difftreelog
Merge branch 'develop' into tests/eth-helpers
in: master
21 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,99 @@
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
+ .and_then(|limit| {
+ if let SponsoringRateLimit::Blocks(blocks) = limit {
+ Some((
+ EvmCollectionLimits::SponsoredDataRateLimit,
+ true,
+ blocks.into(),
+ ))
+ } else {
+ None
+ }
+ })
+ .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:
@@ -316,11 +410,22 @@
/// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
+ /// @param status enable\disable limit. Works only with `true`.
/// @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 +443,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);
pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -155,6 +155,31 @@
}
}
}
+
+/// [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
+#[derive(Debug, Default, Clone, Copy, AbiCoder)]
+#[repr(u8)]
+pub enum CollectionLimits {
+ /// How many tokens can a user have on one account.
+ #[default]
+ AccountTokenOwnership,
+ /// How many bytes of data are available for sponsorship.
+ SponsoredDataSize,
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ SponsoredDataRateLimit,
+ /// How many tokens can be mined into this collection.
+ TokenLimit,
+ /// Timeouts for transfer sponsoring.
+ SponsorTransferTimeout,
+ /// Timeout for sponsoring an approval in passed blocks.
+ SponsorApproveTimeout,
+ /// Whether the collection owner of the collection can send tokens (which belong to other users).
+ OwnerCanTransfer,
+ /// Can the collection owner burn other people's tokens.
+ OwnerCanDestroy,
+ /// Is it possible to send tokens from this collection between users.
+ TransferEnabled,
+}
#[derive(Default, Debug, Clone, Copy, AbiCoder)]
#[repr(u8)]
pub enum CollectionPermissions {
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -18,7 +18,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+/// @dev the ERC-165 identifier for this interface is 0x81172a75
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -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:
@@ -170,12 +191,18 @@
/// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
+ /// @param status enable\disable limit. Works only with `true`.
/// @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;
}
@@ -257,19 +284,19 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() public view returns (Tuple21 memory) {
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple26 memory) {
require(false, stub_error);
dummy;
- return Tuple21(false, new uint256[](0));
+ return Tuple26(false, new uint256[](0));
}
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() public view returns (Tuple24[] memory) {
+ function collectionNestingPermissions() public view returns (Tuple29[] memory) {
require(false, stub_error);
dummy;
- return new Tuple24[](0);
+ return new Tuple29[](0);
}
/// Set the collection access method.
@@ -449,17 +476,46 @@
}
/// @dev anonymous struct
-struct Tuple24 {
+struct Tuple29 {
CollectionPermissions field_0;
bool field_1;
}
/// @dev anonymous struct
-struct Tuple21 {
+struct Tuple26 {
bool field_0;
uint256[] field_1;
}
+/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
+enum CollectionLimits {
+ /// @dev How many tokens can a user have on one account.
+ AccountTokenOwnership,
+ /// @dev How many bytes of data are available for sponsorship.
+ SponsoredDataSize,
+ /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ SponsoredDataRateLimit,
+ /// @dev How many tokens can be mined into this collection.
+ TokenLimit,
+ /// @dev Timeouts for transfer sponsoring.
+ SponsorTransferTimeout,
+ /// @dev Timeout for sponsoring an approval in passed blocks.
+ SponsorApproveTimeout,
+ /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ OwnerCanTransfer,
+ /// @dev Can the collection owner burn other people's tokens.
+ OwnerCanDestroy,
+ /// @dev Is it possible to send tokens from this collection between users.
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple20 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev Property struct
struct Property {
string key;
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
@@ -42,18 +42,19 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple48[] memory permissions) public {
+ function setTokenPropertyPermissions(Tuple59[] memory permissions) public {
require(false, stub_error);
permissions;
dummy = 0;
}
+ /// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() public view returns (Tuple48[] memory) {
+ function tokenPropertyPermissions() public view returns (Tuple59[] memory) {
require(false, stub_error);
dummy;
- return new Tuple48[](0);
+ return new Tuple59[](0);
}
// /// @notice Set token property value.
@@ -132,26 +133,30 @@
bytes value;
}
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum EthTokenPermissions {
+ /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
+ /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
+ /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
/// @dev anonymous struct
-struct Tuple48 {
+struct Tuple59 {
string field_0;
- Tuple46[] field_1;
+ Tuple57[] field_1;
}
/// @dev anonymous struct
-struct Tuple46 {
+struct Tuple57 {
EthTokenPermissions field_0;
bool field_1;
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+/// @dev the ERC-165 identifier for this interface is 0x81172a75
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -291,6 +296,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:
@@ -303,12 +329,18 @@
/// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
+ /// @param status enable\disable limit. Works only with `true`.
/// @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;
}
@@ -390,19 +422,19 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() public view returns (Tuple34 memory) {
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple39 memory) {
require(false, stub_error);
dummy;
- return Tuple34(false, new uint256[](0));
+ return Tuple39(false, new uint256[](0));
}
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() public view returns (Tuple37[] memory) {
+ function collectionNestingPermissions() public view returns (Tuple42[] memory) {
require(false, stub_error);
dummy;
- return new Tuple37[](0);
+ return new Tuple42[](0);
}
/// Set the collection access method.
@@ -582,17 +614,46 @@
}
/// @dev anonymous struct
-struct Tuple37 {
+struct Tuple42 {
CollectionPermissions field_0;
bool field_1;
}
/// @dev anonymous struct
-struct Tuple34 {
+struct Tuple39 {
bool field_0;
uint256[] field_1;
}
+/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
+enum CollectionLimits {
+ /// @dev How many tokens can a user have on one account.
+ AccountTokenOwnership,
+ /// @dev How many bytes of data are available for sponsorship.
+ SponsoredDataSize,
+ /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ SponsoredDataRateLimit,
+ /// @dev How many tokens can be mined into this collection.
+ TokenLimit,
+ /// @dev Timeouts for transfer sponsoring.
+ SponsorTransferTimeout,
+ /// @dev Timeout for sponsoring an approval in passed blocks.
+ SponsorApproveTimeout,
+ /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ OwnerCanTransfer,
+ /// @dev Can the collection owner burn other people's tokens.
+ OwnerCanDestroy,
+ /// @dev Is it possible to send tokens from this collection between users.
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple33 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev anonymous struct
struct Tuple30 {
address field_0;
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
@@ -42,7 +42,7 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple53[] memory permissions) public {
+ function setTokenPropertyPermissions(Tuple58[] memory permissions) public {
require(false, stub_error);
permissions;
dummy = 0;
@@ -51,10 +51,10 @@
/// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() public view returns (Tuple53[] memory) {
+ function tokenPropertyPermissions() public view returns (Tuple58[] memory) {
require(false, stub_error);
dummy;
- return new Tuple53[](0);
+ return new Tuple58[](0);
}
// /// @notice Set token property value.
@@ -133,26 +133,30 @@
bytes value;
}
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum EthTokenPermissions {
+ /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
+ /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
+ /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
/// @dev anonymous struct
-struct Tuple53 {
+struct Tuple58 {
string field_0;
- Tuple51[] field_1;
+ Tuple56[] field_1;
}
/// @dev anonymous struct
-struct Tuple51 {
+struct Tuple56 {
EthTokenPermissions field_0;
bool field_1;
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+/// @dev the ERC-165 identifier for this interface is 0x81172a75
contract Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -292,6 +296,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:
@@ -304,12 +329,18 @@
/// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
+ /// @param status enable\disable limit. Works only with `true`.
/// @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;
}
@@ -391,19 +422,19 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() public view returns (Tuple33 memory) {
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple38 memory) {
require(false, stub_error);
dummy;
- return Tuple33(false, new uint256[](0));
+ return Tuple38(false, new uint256[](0));
}
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() public view returns (Tuple36[] memory) {
+ function collectionNestingPermissions() public view returns (Tuple41[] memory) {
require(false, stub_error);
dummy;
- return new Tuple36[](0);
+ return new Tuple41[](0);
}
/// Set the collection access method.
@@ -583,17 +614,46 @@
}
/// @dev anonymous struct
-struct Tuple36 {
+struct Tuple41 {
CollectionPermissions field_0;
bool field_1;
}
/// @dev anonymous struct
-struct Tuple33 {
+struct Tuple38 {
bool field_0;
uint256[] field_1;
}
+/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
+enum CollectionLimits {
+ /// @dev How many tokens can a user have on one account.
+ AccountTokenOwnership,
+ /// @dev How many bytes of data are available for sponsorship.
+ SponsoredDataSize,
+ /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ SponsoredDataRateLimit,
+ /// @dev How many tokens can be mined into this collection.
+ TokenLimit,
+ /// @dev Timeouts for transfer sponsoring.
+ SponsorTransferTimeout,
+ /// @dev Timeout for sponsoring an approval in passed blocks.
+ SponsorApproveTimeout,
+ /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ OwnerCanTransfer,
+ /// @dev Can the collection owner burn other people's tokens.
+ OwnerCanDestroy,
+ /// @dev Is it possible to send tokens from this collection between users.
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple32 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev anonymous struct
struct Tuple29 {
address field_0;
tests/src/eth/abi/fungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -208,6 +208,28 @@
},
{
"inputs": [],
+ "name": "collectionLimits",
+ "outputs": [
+ {
+ "components": [
+ {
+ "internalType": "enum CollectionLimits",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" },
+ { "internalType": "uint256", "name": "field_2", "type": "uint256" }
+ ],
+ "internalType": "struct Tuple20[]",
+ "name": "",
+ "type": "tuple[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionNestingPermissions",
"outputs": [
{
@@ -219,7 +241,7 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple24[]",
+ "internalType": "struct Tuple29[]",
"name": "",
"type": "tuple[]"
}
@@ -240,7 +262,7 @@
"type": "uint256[]"
}
],
- "internalType": "struct Tuple21",
+ "internalType": "struct Tuple26",
"name": "",
"type": "tuple"
}
@@ -453,7 +475,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/nonFungible.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 "name": "MintingFinished",56 "type": "event"57 },58 {59 "anonymous": false,60 "inputs": [61 {62 "indexed": true,63 "internalType": "address",64 "name": "from",65 "type": "address"66 },67 {68 "indexed": true,69 "internalType": "address",70 "name": "to",71 "type": "address"72 },73 {74 "indexed": true,75 "internalType": "uint256",76 "name": "tokenId",77 "type": "uint256"78 }79 ],80 "name": "Transfer",81 "type": "event"82 },83 {84 "inputs": [85 {86 "components": [87 { "internalType": "address", "name": "eth", "type": "address" },88 { "internalType": "uint256", "name": "sub", "type": "uint256" }89 ],90 "internalType": "struct EthCrossAccount",91 "name": "newAdmin",92 "type": "tuple"93 }94 ],95 "name": "addCollectionAdminCross",96 "outputs": [],97 "stateMutability": "nonpayable",98 "type": "function"99 },100 {101 "inputs": [102 {103 "components": [104 { "internalType": "address", "name": "eth", "type": "address" },105 { "internalType": "uint256", "name": "sub", "type": "uint256" }106 ],107 "internalType": "struct EthCrossAccount",108 "name": "user",109 "type": "tuple"110 }111 ],112 "name": "addToCollectionAllowListCross",113 "outputs": [],114 "stateMutability": "nonpayable",115 "type": "function"116 },117 {118 "inputs": [119 {120 "components": [121 { "internalType": "address", "name": "eth", "type": "address" },122 { "internalType": "uint256", "name": "sub", "type": "uint256" }123 ],124 "internalType": "struct EthCrossAccount",125 "name": "user",126 "type": "tuple"127 }128 ],129 "name": "allowlistedCross",130 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],131 "stateMutability": "view",132 "type": "function"133 },134 {135 "inputs": [136 { "internalType": "address", "name": "approved", "type": "address" },137 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }138 ],139 "name": "approve",140 "outputs": [],141 "stateMutability": "nonpayable",142 "type": "function"143 },144 {145 "inputs": [146 {147 "components": [148 { "internalType": "address", "name": "eth", "type": "address" },149 { "internalType": "uint256", "name": "sub", "type": "uint256" }150 ],151 "internalType": "struct EthCrossAccount",152 "name": "approved",153 "type": "tuple"154 },155 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }156 ],157 "name": "approveCross",158 "outputs": [],159 "stateMutability": "nonpayable",160 "type": "function"161 },162 {163 "inputs": [164 { "internalType": "address", "name": "owner", "type": "address" }165 ],166 "name": "balanceOf",167 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],168 "stateMutability": "view",169 "type": "function"170 },171 {172 "inputs": [173 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }174 ],175 "name": "burn",176 "outputs": [],177 "stateMutability": "nonpayable",178 "type": "function"179 },180 {181 "inputs": [182 {183 "components": [184 { "internalType": "address", "name": "eth", "type": "address" },185 { "internalType": "uint256", "name": "sub", "type": "uint256" }186 ],187 "internalType": "struct EthCrossAccount",188 "name": "from",189 "type": "tuple"190 },191 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }192 ],193 "name": "burnFromCross",194 "outputs": [],195 "stateMutability": "nonpayable",196 "type": "function"197 },198 {199 "inputs": [200 {201 "components": [202 { "internalType": "address", "name": "eth", "type": "address" },203 { "internalType": "uint256", "name": "sub", "type": "uint256" }204 ],205 "internalType": "struct EthCrossAccount",206 "name": "newOwner",207 "type": "tuple"208 }209 ],210 "name": "changeCollectionOwnerCross",211 "outputs": [],212 "stateMutability": "nonpayable",213 "type": "function"214 },215 {216 "inputs": [],217 "name": "collectionAdmins",218 "outputs": [219 {220 "components": [221 { "internalType": "address", "name": "eth", "type": "address" },222 { "internalType": "uint256", "name": "sub", "type": "uint256" }223 ],224 "internalType": "struct EthCrossAccount[]",225 "name": "",226 "type": "tuple[]"227 }228 ],229 "stateMutability": "view",230 "type": "function"231 },232 {233 "inputs": [],234 "name": "collectionHelperAddress",235 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],236 "stateMutability": "view",237 "type": "function"238 },239 {240 "inputs": [],241 "name": "collectionNestingPermissions",242 "outputs": [243 {244 "components": [245 {246 "internalType": "enum CollectionPermissions",247 "name": "field_0",248 "type": "uint8"249 },250 { "internalType": "bool", "name": "field_1", "type": "bool" }251 ],252 "internalType": "struct Tuple37[]",253 "name": "",254 "type": "tuple[]"255 }256 ],257 "stateMutability": "view",258 "type": "function"259 },260 {261 "inputs": [],262 "name": "collectionNestingRestrictedCollectionIds",263 "outputs": [264 {265 "components": [266 { "internalType": "bool", "name": "field_0", "type": "bool" },267 {268 "internalType": "uint256[]",269 "name": "field_1",270 "type": "uint256[]"271 }272 ],273 "internalType": "struct Tuple34",274 "name": "",275 "type": "tuple"276 }277 ],278 "stateMutability": "view",279 "type": "function"280 },281 {282 "inputs": [],283 "name": "collectionOwner",284 "outputs": [285 {286 "components": [287 { "internalType": "address", "name": "eth", "type": "address" },288 { "internalType": "uint256", "name": "sub", "type": "uint256" }289 ],290 "internalType": "struct EthCrossAccount",291 "name": "",292 "type": "tuple"293 }294 ],295 "stateMutability": "view",296 "type": "function"297 },298 {299 "inputs": [300 { "internalType": "string[]", "name": "keys", "type": "string[]" }301 ],302 "name": "collectionProperties",303 "outputs": [304 {305 "components": [306 { "internalType": "string", "name": "key", "type": "string" },307 { "internalType": "bytes", "name": "value", "type": "bytes" }308 ],309 "internalType": "struct Property[]",310 "name": "",311 "type": "tuple[]"312 }313 ],314 "stateMutability": "view",315 "type": "function"316 },317 {318 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],319 "name": "collectionProperty",320 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],321 "stateMutability": "view",322 "type": "function"323 },324 {325 "inputs": [],326 "name": "collectionSponsor",327 "outputs": [328 {329 "components": [330 { "internalType": "address", "name": "field_0", "type": "address" },331 { "internalType": "uint256", "name": "field_1", "type": "uint256" }332 ],333 "internalType": "struct Tuple30",334 "name": "",335 "type": "tuple"336 }337 ],338 "stateMutability": "view",339 "type": "function"340 },341 {342 "inputs": [],343 "name": "confirmCollectionSponsorship",344 "outputs": [],345 "stateMutability": "nonpayable",346 "type": "function"347 },348 {349 "inputs": [],350 "name": "contractAddress",351 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],352 "stateMutability": "view",353 "type": "function"354 },355 {356 "inputs": [357 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }358 ],359 "name": "crossOwnerOf",360 "outputs": [361 {362 "components": [363 { "internalType": "address", "name": "eth", "type": "address" },364 { "internalType": "uint256", "name": "sub", "type": "uint256" }365 ],366 "internalType": "struct EthCrossAccount",367 "name": "",368 "type": "tuple"369 }370 ],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 "name": "finishMinting",403 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],404 "stateMutability": "nonpayable",405 "type": "function"406 },407 {408 "inputs": [409 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }410 ],411 "name": "getApproved",412 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],413 "stateMutability": "view",414 "type": "function"415 },416 {417 "inputs": [],418 "name": "hasCollectionPendingSponsor",419 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],420 "stateMutability": "view",421 "type": "function"422 },423 {424 "inputs": [425 { "internalType": "address", "name": "owner", "type": "address" },426 { "internalType": "address", "name": "operator", "type": "address" }427 ],428 "name": "isApprovedForAll",429 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],430 "stateMutability": "view",431 "type": "function"432 },433 {434 "inputs": [435 {436 "components": [437 { "internalType": "address", "name": "eth", "type": "address" },438 { "internalType": "uint256", "name": "sub", "type": "uint256" }439 ],440 "internalType": "struct EthCrossAccount",441 "name": "user",442 "type": "tuple"443 }444 ],445 "name": "isOwnerOrAdminCross",446 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],447 "stateMutability": "view",448 "type": "function"449 },450 {451 "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],452 "name": "mint",453 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],454 "stateMutability": "nonpayable",455 "type": "function"456 },457 {458 "inputs": [459 { "internalType": "address", "name": "to", "type": "address" },460 { "internalType": "string", "name": "tokenUri", "type": "string" }461 ],462 "name": "mintWithTokenURI",463 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],464 "stateMutability": "nonpayable",465 "type": "function"466 },467 {468 "inputs": [],469 "name": "mintingFinished",470 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],471 "stateMutability": "view",472 "type": "function"473 },474 {475 "inputs": [],476 "name": "name",477 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],478 "stateMutability": "view",479 "type": "function"480 },481 {482 "inputs": [],483 "name": "nextTokenId",484 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],485 "stateMutability": "view",486 "type": "function"487 },488 {489 "inputs": [490 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }491 ],492 "name": "ownerOf",493 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],494 "stateMutability": "view",495 "type": "function"496 },497 {498 "inputs": [499 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },500 { "internalType": "string[]", "name": "keys", "type": "string[]" }501 ],502 "name": "properties",503 "outputs": [504 {505 "components": [506 { "internalType": "string", "name": "key", "type": "string" },507 { "internalType": "bytes", "name": "value", "type": "bytes" }508 ],509 "internalType": "struct Property[]",510 "name": "",511 "type": "tuple[]"512 }513 ],514 "stateMutability": "view",515 "type": "function"516 },517 {518 "inputs": [519 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },520 { "internalType": "string", "name": "key", "type": "string" }521 ],522 "name": "property",523 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],524 "stateMutability": "view",525 "type": "function"526 },527 {528 "inputs": [529 {530 "components": [531 { "internalType": "address", "name": "eth", "type": "address" },532 { "internalType": "uint256", "name": "sub", "type": "uint256" }533 ],534 "internalType": "struct EthCrossAccount",535 "name": "admin",536 "type": "tuple"537 }538 ],539 "name": "removeCollectionAdminCross",540 "outputs": [],541 "stateMutability": "nonpayable",542 "type": "function"543 },544 {545 "inputs": [],546 "name": "removeCollectionSponsor",547 "outputs": [],548 "stateMutability": "nonpayable",549 "type": "function"550 },551 {552 "inputs": [553 {554 "components": [555 { "internalType": "address", "name": "eth", "type": "address" },556 { "internalType": "uint256", "name": "sub", "type": "uint256" }557 ],558 "internalType": "struct EthCrossAccount",559 "name": "user",560 "type": "tuple"561 }562 ],563 "name": "removeFromCollectionAllowListCross",564 "outputs": [],565 "stateMutability": "nonpayable",566 "type": "function"567 },568 {569 "inputs": [570 { "internalType": "address", "name": "from", "type": "address" },571 { "internalType": "address", "name": "to", "type": "address" },572 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }573 ],574 "name": "safeTransferFrom",575 "outputs": [],576 "stateMutability": "nonpayable",577 "type": "function"578 },579 {580 "inputs": [581 { "internalType": "address", "name": "from", "type": "address" },582 { "internalType": "address", "name": "to", "type": "address" },583 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },584 { "internalType": "bytes", "name": "data", "type": "bytes" }585 ],586 "name": "safeTransferFrom",587 "outputs": [],588 "stateMutability": "nonpayable",589 "type": "function"590 },591 {592 "inputs": [593 { "internalType": "address", "name": "operator", "type": "address" },594 { "internalType": "bool", "name": "approved", "type": "bool" }595 ],596 "name": "setApprovalForAll",597 "outputs": [],598 "stateMutability": "nonpayable",599 "type": "function"600 },601 {602 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],603 "name": "setCollectionAccess",604 "outputs": [],605 "stateMutability": "nonpayable",606 "type": "function"607 },608 {609 "inputs": [610 { "internalType": "string", "name": "limit", "type": "string" },611 { "internalType": "uint256", "name": "value", "type": "uint256" }612 ],613 "name": "setCollectionLimit",614 "outputs": [],615 "stateMutability": "nonpayable",616 "type": "function"617 },618 {619 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],620 "name": "setCollectionMintMode",621 "outputs": [],622 "stateMutability": "nonpayable",623 "type": "function"624 },625 {626 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],627 "name": "setCollectionNesting",628 "outputs": [],629 "stateMutability": "nonpayable",630 "type": "function"631 },632 {633 "inputs": [634 { "internalType": "bool", "name": "enable", "type": "bool" },635 {636 "internalType": "address[]",637 "name": "collections",638 "type": "address[]"639 }640 ],641 "name": "setCollectionNesting",642 "outputs": [],643 "stateMutability": "nonpayable",644 "type": "function"645 },646 {647 "inputs": [648 {649 "components": [650 { "internalType": "string", "name": "key", "type": "string" },651 { "internalType": "bytes", "name": "value", "type": "bytes" }652 ],653 "internalType": "struct Property[]",654 "name": "properties",655 "type": "tuple[]"656 }657 ],658 "name": "setCollectionProperties",659 "outputs": [],660 "stateMutability": "nonpayable",661 "type": "function"662 },663 {664 "inputs": [665 {666 "components": [667 { "internalType": "address", "name": "eth", "type": "address" },668 { "internalType": "uint256", "name": "sub", "type": "uint256" }669 ],670 "internalType": "struct EthCrossAccount",671 "name": "sponsor",672 "type": "tuple"673 }674 ],675 "name": "setCollectionSponsorCross",676 "outputs": [],677 "stateMutability": "nonpayable",678 "type": "function"679 },680 {681 "inputs": [682 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },683 {684 "components": [685 { "internalType": "string", "name": "key", "type": "string" },686 { "internalType": "bytes", "name": "value", "type": "bytes" }687 ],688 "internalType": "struct Property[]",689 "name": "properties",690 "type": "tuple[]"691 }692 ],693 "name": "setProperties",694 "outputs": [],695 "stateMutability": "nonpayable",696 "type": "function"697 },698 {699 "inputs": [700 {701 "components": [702 { "internalType": "string", "name": "field_0", "type": "string" },703 {704 "components": [705 {706 "internalType": "enum EthTokenPermissions",707 "name": "field_0",708 "type": "uint8"709 },710 { "internalType": "bool", "name": "field_1", "type": "bool" }711 ],712 "internalType": "struct Tuple46[]",713 "name": "field_1",714 "type": "tuple[]"715 }716 ],717 "internalType": "struct Tuple48[]",718 "name": "permissions",719 "type": "tuple[]"720 }721 ],722 "name": "setTokenPropertyPermissions",723 "outputs": [],724 "stateMutability": "nonpayable",725 "type": "function"726 },727 {728 "inputs": [729 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }730 ],731 "name": "supportsInterface",732 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],733 "stateMutability": "view",734 "type": "function"735 },736 {737 "inputs": [],738 "name": "symbol",739 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],740 "stateMutability": "view",741 "type": "function"742 },743 {744 "inputs": [745 { "internalType": "uint256", "name": "index", "type": "uint256" }746 ],747 "name": "tokenByIndex",748 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],749 "stateMutability": "view",750 "type": "function"751 },752 {753 "inputs": [754 { "internalType": "address", "name": "owner", "type": "address" },755 { "internalType": "uint256", "name": "index", "type": "uint256" }756 ],757 "name": "tokenOfOwnerByIndex",758 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],759 "stateMutability": "view",760 "type": "function"761 },762 {763 "inputs": [],764 "name": "tokenPropertyPermissions",765 "outputs": [766 {767 "components": [768 { "internalType": "string", "name": "field_0", "type": "string" },769 {770 "components": [771 {772 "internalType": "enum EthTokenPermissions",773 "name": "field_0",774 "type": "uint8"775 },776 { "internalType": "bool", "name": "field_1", "type": "bool" }777 ],778 "internalType": "struct Tuple46[]",779 "name": "field_1",780 "type": "tuple[]"781 }782 ],783 "internalType": "struct Tuple48[]",784 "name": "",785 "type": "tuple[]"786 }787 ],788 "stateMutability": "view",789 "type": "function"790 },791 {792 "inputs": [793 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }794 ],795 "name": "tokenURI",796 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],797 "stateMutability": "view",798 "type": "function"799 },800 {801 "inputs": [],802 "name": "totalSupply",803 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],804 "stateMutability": "view",805 "type": "function"806 },807 {808 "inputs": [809 { "internalType": "address", "name": "to", "type": "address" },810 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }811 ],812 "name": "transfer",813 "outputs": [],814 "stateMutability": "nonpayable",815 "type": "function"816 },817 {818 "inputs": [819 {820 "components": [821 { "internalType": "address", "name": "eth", "type": "address" },822 { "internalType": "uint256", "name": "sub", "type": "uint256" }823 ],824 "internalType": "struct EthCrossAccount",825 "name": "to",826 "type": "tuple"827 },828 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }829 ],830 "name": "transferCross",831 "outputs": [],832 "stateMutability": "nonpayable",833 "type": "function"834 },835 {836 "inputs": [837 { "internalType": "address", "name": "from", "type": "address" },838 { "internalType": "address", "name": "to", "type": "address" },839 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }840 ],841 "name": "transferFrom",842 "outputs": [],843 "stateMutability": "nonpayable",844 "type": "function"845 },846 {847 "inputs": [848 {849 "components": [850 { "internalType": "address", "name": "eth", "type": "address" },851 { "internalType": "uint256", "name": "sub", "type": "uint256" }852 ],853 "internalType": "struct EthCrossAccount",854 "name": "from",855 "type": "tuple"856 },857 {858 "components": [859 { "internalType": "address", "name": "eth", "type": "address" },860 { "internalType": "uint256", "name": "sub", "type": "uint256" }861 ],862 "internalType": "struct EthCrossAccount",863 "name": "to",864 "type": "tuple"865 },866 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }867 ],868 "name": "transferFromCross",869 "outputs": [],870 "stateMutability": "nonpayable",871 "type": "function"872 },873 {874 "inputs": [],875 "name": "uniqueCollectionType",876 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],877 "stateMutability": "view",878 "type": "function"879 }880]tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -220,6 +220,28 @@
},
{
"inputs": [],
+ "name": "collectionLimits",
+ "outputs": [
+ {
+ "components": [
+ {
+ "internalType": "enum CollectionLimits",
+ "name": "field_0",
+ "type": "uint8"
+ },
+ { "internalType": "bool", "name": "field_1", "type": "bool" },
+ { "internalType": "uint256", "name": "field_2", "type": "uint256" }
+ ],
+ "internalType": "struct Tuple32[]",
+ "name": "",
+ "type": "tuple[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
"name": "collectionNestingPermissions",
"outputs": [
{
@@ -231,7 +253,7 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple36[]",
+ "internalType": "struct Tuple41[]",
"name": "",
"type": "tuple[]"
}
@@ -252,7 +274,7 @@
"type": "uint256[]"
}
],
- "internalType": "struct Tuple33",
+ "internalType": "struct Tuple38",
"name": "",
"type": "tuple"
}
@@ -589,7 +611,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",
@@ -691,12 +718,12 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple51[]",
+ "internalType": "struct Tuple56[]",
"name": "field_1",
"type": "tuple[]"
}
],
- "internalType": "struct Tuple53[]",
+ "internalType": "struct Tuple58[]",
"name": "permissions",
"type": "tuple[]"
}
@@ -766,12 +793,12 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple51[]",
+ "internalType": "struct Tuple56[]",
"name": "field_1",
"type": "tuple[]"
}
],
- "internalType": "struct Tuple53[]",
+ "internalType": "struct Tuple58[]",
"name": "",
"type": "tuple[]"
}
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+/// @dev the ERC-165 identifier for this interface is 0x81172a75
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -104,6 +104,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:
@@ -116,10 +133,15 @@
/// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
+ /// @param status enable\disable limit. Works only with `true`.
/// @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,
@@ -169,12 +191,12 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() external view returns (Tuple20 memory);
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple24 memory);
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() external view returns (Tuple23[] memory);
+ function collectionNestingPermissions() external view returns (Tuple27[] memory);
/// Set the collection access method.
/// @param mode Access mode
@@ -289,7 +311,7 @@
}
/// @dev anonymous struct
-struct Tuple23 {
+struct Tuple27 {
CollectionPermissions field_0;
bool field_1;
}
@@ -300,11 +322,40 @@
}
/// @dev anonymous struct
-struct Tuple20 {
+struct Tuple24 {
bool field_0;
uint256[] field_1;
}
+/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
+enum CollectionLimits {
+ /// @dev How many tokens can a user have on one account.
+ AccountTokenOwnership,
+ /// @dev How many bytes of data are available for sponsorship.
+ SponsoredDataSize,
+ /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ SponsoredDataRateLimit,
+ /// @dev How many tokens can be mined into this collection.
+ TokenLimit,
+ /// @dev Timeouts for transfer sponsoring.
+ SponsorTransferTimeout,
+ /// @dev Timeout for sponsoring an approval in passed blocks.
+ SponsorApproveTimeout,
+ /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ OwnerCanTransfer,
+ /// @dev Can the collection owner burn other people's tokens.
+ OwnerCanDestroy,
+ /// @dev Is it possible to send tokens from this collection between users.
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple19 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev Property struct
struct Property {
string key;
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -30,11 +30,12 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple43[] memory permissions) external;
+ function setTokenPropertyPermissions(Tuple52[] memory permissions) external;
+ /// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() external view returns (Tuple43[] memory);
+ function tokenPropertyPermissions() external view returns (Tuple52[] memory);
// /// @notice Set token property value.
// /// @dev Throws error if `msg.sender` has no permission to edit the property.
@@ -85,26 +86,30 @@
bytes value;
}
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum EthTokenPermissions {
+ /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
+ /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
+ /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
/// @dev anonymous struct
-struct Tuple43 {
+struct Tuple52 {
string field_0;
- Tuple41[] field_1;
+ Tuple50[] field_1;
}
/// @dev anonymous struct
-struct Tuple41 {
+struct Tuple50 {
EthTokenPermissions field_0;
bool field_1;
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+/// @dev the ERC-165 identifier for this interface is 0x81172a75
interface Collection is Dummy, ERC165 {
// /// Set collection property.
// ///
@@ -195,6 +200,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:
@@ -207,10 +229,15 @@
/// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
+ /// @param status enable\disable limit. Works only with `true`.
/// @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,
@@ -260,12 +287,12 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() external view returns (Tuple31 memory);
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple35 memory);
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() external view returns (Tuple34[] memory);
+ function collectionNestingPermissions() external view returns (Tuple38[] memory);
/// Set the collection access method.
/// @param mode Access mode
@@ -380,7 +407,7 @@
}
/// @dev anonymous struct
-struct Tuple34 {
+struct Tuple38 {
CollectionPermissions field_0;
bool field_1;
}
@@ -391,11 +418,40 @@
}
/// @dev anonymous struct
-struct Tuple31 {
+struct Tuple35 {
bool field_0;
uint256[] field_1;
}
+/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
+enum CollectionLimits {
+ /// @dev How many tokens can a user have on one account.
+ AccountTokenOwnership,
+ /// @dev How many bytes of data are available for sponsorship.
+ SponsoredDataSize,
+ /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ SponsoredDataRateLimit,
+ /// @dev How many tokens can be mined into this collection.
+ TokenLimit,
+ /// @dev Timeouts for transfer sponsoring.
+ SponsorTransferTimeout,
+ /// @dev Timeout for sponsoring an approval in passed blocks.
+ SponsorApproveTimeout,
+ /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ OwnerCanTransfer,
+ /// @dev Can the collection owner burn other people's tokens.
+ OwnerCanDestroy,
+ /// @dev Is it possible to send tokens from this collection between users.
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple30 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev anonymous struct
struct Tuple27 {
address field_0;
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -30,12 +30,12 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple47[] memory permissions) external;
+ function setTokenPropertyPermissions(Tuple51[] memory permissions) external;
/// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() external view returns (Tuple47[] memory);
+ function tokenPropertyPermissions() external view returns (Tuple51[] memory);
// /// @notice Set token property value.
// /// @dev Throws error if `msg.sender` has no permission to edit the property.
@@ -86,26 +86,30 @@
bytes value;
}
+/// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
enum EthTokenPermissions {
+ /// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
Mutable,
+ /// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
TokenOwner,
+ /// @dev Permission to change the property for the owner of the token. See [`up_data_structs::PropertyPermission::collection_admin`]
CollectionAdmin
}
/// @dev anonymous struct
-struct Tuple47 {
+struct Tuple51 {
string field_0;
- Tuple45[] field_1;
+ Tuple49[] field_1;
}
/// @dev anonymous struct
-struct Tuple45 {
+struct Tuple49 {
EthTokenPermissions field_0;
bool field_1;
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xb5e1747f
+/// @dev the ERC-165 identifier for this interface is 0x81172a75
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:
@@ -208,10 +229,15 @@
/// "ownerCanTransfer",
/// "ownerCanDestroy",
/// "transfersEnabled"
+ /// @param status enable\disable limit. Works only with `true`.
/// @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,
@@ -261,12 +287,12 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() external view returns (Tuple30 memory);
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple34 memory);
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() external view returns (Tuple33[] memory);
+ function collectionNestingPermissions() external view returns (Tuple37[] memory);
/// Set the collection access method.
/// @param mode Access mode
@@ -381,7 +407,7 @@
}
/// @dev anonymous struct
-struct Tuple33 {
+struct Tuple37 {
CollectionPermissions field_0;
bool field_1;
}
@@ -392,11 +418,40 @@
}
/// @dev anonymous struct
-struct Tuple30 {
+struct Tuple34 {
bool field_0;
uint256[] field_1;
}
+/// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
+enum CollectionLimits {
+ /// @dev How many tokens can a user have on one account.
+ AccountTokenOwnership,
+ /// @dev How many bytes of data are available for sponsorship.
+ SponsoredDataSize,
+ /// @dev In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
+ SponsoredDataRateLimit,
+ /// @dev How many tokens can be mined into this collection.
+ TokenLimit,
+ /// @dev Timeouts for transfer sponsoring.
+ SponsorTransferTimeout,
+ /// @dev Timeout for sponsoring an approval in passed blocks.
+ SponsorApproveTimeout,
+ /// @dev Whether the collection owner of the collection can send tokens (which belong to other users).
+ OwnerCanTransfer,
+ /// @dev Can the collection owner burn other people's tokens.
+ OwnerCanDestroy,
+ /// @dev Is it possible to send tokens from this collection between users.
+ TransferEnabled
+}
+
+/// @dev anonymous struct
+struct Tuple29 {
+ CollectionLimits field_0;
+ bool field_1;
+ uint256 field_2;
+}
+
/// @dev anonymous struct
struct Tuple26 {
address field_0;
tests/src/eth/collectionLimits.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionLimits.test.ts
+++ b/tests/src/eth/collectionLimits.test.ts
@@ -1,6 +1,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Pallets} from '../util';
import {expect, itEth, usingEthPlaygrounds} from './util';
+import {CollectionLimits} from './util/playgrounds/types';
describe('Can set collection limits', () => {
@@ -44,20 +45,33 @@
transfersEnabled: false,
};
- const collection = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
- await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
- await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
- await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
- await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
- await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
- await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
- await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
- await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
- await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
+ const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
+ await collectionEvm.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
+ // Check limits from sub:
const data = (await helper.rft.getData(collectionId))!;
expect(data.raw.limits).to.deep.eq(expectedLimits);
expect(await helper.collection.getEffectiveLimits(collectionId)).to.deep.eq(expectedLimits);
+ // Check limits from eth:
+ const limitsEvm = await collectionEvm.methods.collectionLimits().call({from: owner});
+ expect(limitsEvm).to.have.length(9);
+ expect(limitsEvm[0]).to.deep.eq([CollectionLimits.AccountTokenOwnership.toString(), true, limits.accountTokenOwnershipLimit.toString()]);
+ expect(limitsEvm[1]).to.deep.eq([CollectionLimits.SponsoredDataSize.toString(), true, limits.sponsoredDataSize.toString()]);
+ expect(limitsEvm[2]).to.deep.eq([CollectionLimits.SponsoredDataRateLimit.toString(), true, limits.sponsoredDataRateLimit.toString()]);
+ expect(limitsEvm[3]).to.deep.eq([CollectionLimits.TokenLimit.toString(), true, limits.tokenLimit.toString()]);
+ expect(limitsEvm[4]).to.deep.eq([CollectionLimits.SponsorTransferTimeout.toString(), true, limits.sponsorTransferTimeout.toString()]);
+ expect(limitsEvm[5]).to.deep.eq([CollectionLimits.SponsorApproveTimeout.toString(), true, limits.sponsorApproveTimeout.toString()]);
+ expect(limitsEvm[6]).to.deep.eq([CollectionLimits.OwnerCanTransfer.toString(), true, limits.ownerCanTransfer.toString()]);
+ expect(limitsEvm[7]).to.deep.eq([CollectionLimits.OwnerCanDestroy.toString(), true, limits.ownerCanDestroy.toString()]);
+ expect(limitsEvm[8]).to.deep.eq([CollectionLimits.TransferEnabled.toString(), true, limits.transfersEnabled.toString()]);
}));
});
@@ -84,17 +98,48 @@
const owner = await helper.eth.createAccountWithBalance(donor);
const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'ISNI', 18);
const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
+
+ // Cannot set non-existing limit
await expect(collectionEvm.methods
- .setCollectionLimit('badLimit', '1')
- .call()).to.be.rejectedWith('unknown limit "badLimit"');
-
+ .setCollectionLimit(9, true, 1)
+ .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"');
+
+ // Cannot disable limits
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, false, 200)
+ .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert user can\'t disable limits');
+
await expect(collectionEvm.methods
- .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
.call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
-
+
await expect(collectionEvm.methods
- .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
+ .setCollectionLimit(CollectionLimits.TransferEnabled, true, 3)
.call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
+
+ expect(() => collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.SponsoredDataSize, true, -1).send()).to.throw('value out-of-bounds');
}));
+
+ [
+ {case: 'nft' as const, requiredPallets: []},
+ {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+ {case: 'ft' as const, requiredPallets: []},
+ ].map(testCase =>
+ itEth.ifWithPallets(`Non-owner and non-admin cannot set collection limits for ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const nonOwner = await helper.eth.createAccountWithBalance(donor);
+ const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'FLO', 18);
+
+ const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+ .call({from: nonOwner}))
+ .to.be.rejectedWith('NoPermission');
+
+ await expect(collectionEvm.methods
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+ .send({from: nonOwner}))
+ .to.be.rejected;
+ }));
});
-
\ No newline at end of file
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -18,6 +18,7 @@
import {evmToAddress} from '@polkadot/util-crypto';
import {Pallets, requirePalletsOrSkip} from '../util';
import {expect, itEth, usingEthPlaygrounds} from './util';
+import { CollectionLimits } from './util/playgrounds/types';
const DECIMALS = 18;
@@ -196,7 +197,7 @@
}
{
await expect(peasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
@@ -221,7 +222,7 @@
}
{
await expect(peasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -17,6 +17,7 @@
import {evmToAddress} from '@polkadot/util-crypto';
import {IKeyringPair} from '@polkadot/types/types';
import {expect, itEth, usingEthPlaygrounds} from './util';
+import { CollectionLimits } from './util/playgrounds/types';
describe('Create NFT collection from EVM', () => {
@@ -207,7 +208,7 @@
}
{
await expect(malfeasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
@@ -232,7 +233,7 @@
}
{
await expect(malfeasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -18,6 +18,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Pallets, requirePalletsOrSkip} from '../util';
import {expect, itEth, usingEthPlaygrounds} from './util';
+import {CollectionLimits} from './util/playgrounds/types';
describe('Create RFT collection from EVM', () => {
@@ -239,7 +240,7 @@
}
{
await expect(peasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
@@ -264,7 +265,7 @@
}
{
await expect(peasantCollection.methods
- .setCollectionLimit('accountTokenOwnershipLimit', '1000')
+ .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
.call()).to.be.rejectedWith(EXPECTED_ERROR);
}
});
tests/src/eth/events.test.tsdiffbeforeafterboth--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -19,7 +19,7 @@
import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';
import {IEvent, TCollectionMode} from '../util/playgrounds/types';
import {Pallets, requirePalletsOrSkip} from '../util';
-import {EthTokenPermissions, NormalizedEvent} from './util/playgrounds/types';
+import {CollectionLimits, EthTokenPermissions, NormalizedEvent} from './util/playgrounds/types';
let donor: IKeyringPair;
@@ -234,7 +234,7 @@
});
const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);
{
- await collection.methods.setCollectionLimit('ownerCanTransfer', 0n).send({from: owner});
+ await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, 0).send({from: owner});
await helper.wait.newBlocks(1);
expect(ethEvents).to.be.like([
{
tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -24,4 +24,15 @@
Mutable,
TokenOwner,
CollectionAdmin
-}
\ No newline at end of file
+}
+export enum CollectionLimits {
+ AccountTokenOwnership,
+ SponsoredDataSize,
+ SponsoredDataRateLimit,
+ TokenLimit,
+ SponsorTransferTimeout,
+ SponsorApproveTimeout,
+ OwnerCanTransfer,
+ OwnerCanDestroy,
+ TransferEnabled
+}
tests/src/pallet-presence.test.tsdiffbeforeafterboth--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -84,6 +84,7 @@
);
} else if (chain.eq('UNIQUE')) {
// Insert Unique additional pallets here
+ requiredPallets.push(foreignAssets);
}
});
});