From 3912bc1fa3ad348a7165f0a63630a26d308a5845 Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Tue, 26 Apr 2022 06:58:35 +0000 Subject: [PATCH] CORE-302 Add camelCase aliases for limits --- --- a/primitives/data-structs/src/lib.rs +++ b/primitives/data-structs/src/lib.rs @@ -368,21 +368,30 @@ #[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct CollectionLimits { + #[serde(alias="accountTokenOwnershipLimit")] pub account_token_ownership_limit: Option, + #[serde(alias="sponsoredDataSize")] pub sponsored_data_size: Option, /// FIXME should we delete this or repurpose it? /// None - setVariableMetadata is not sponsored /// Some(v) - setVariableMetadata is sponsored /// if there is v block between txs + #[serde(alias="sponsoredDataRateLimit")] pub sponsored_data_rate_limit: Option, + #[serde(alias="tokenLimit")] pub token_limit: Option, - + // Timeouts for item types in passed blocks + #[serde(alias="sponsorTransferTimeout")] pub sponsor_transfer_timeout: Option, + #[serde(alias="sponsorApproveTimeout")] pub sponsor_approve_timeout: Option, + #[serde(alias="ownerCanTransfer")] pub owner_can_transfer: Option, + #[serde(alias="ownerCanDestroy")] pub owner_can_destroy: Option, + #[serde(alias="transfersEnabled")] pub transfers_enabled: Option, } --- a/tests/src/eth/createCollection.test.ts +++ b/tests/src/eth/createCollection.test.ts @@ -101,7 +101,7 @@ expect(collection.constOnChainSchema.toHuman()).to.be.eq(constShema); }); - itWeb3('Set limits', async ({api, web3}) => { + itWeb3.only('Set limits', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); const helper = collectionHelper(web3, owner); const result = await helper.methods.create721Collection('Const collection', '4', '4').send(); @@ -109,7 +109,7 @@ const limits = { accountTokenOwnershipLimit: 1000, sponsoredDataSize: 1024, - // sponsoredDataRateLimit: { sponsoringDisabled: null }, + sponsoredDataRateLimit: {Blocks: 30}, tokenLimit: 1000000, sponsorTransferTimeout: 6, sponsorApproveTimeout: 6, @@ -117,23 +117,14 @@ ownerCanDestroy: false, transfersEnabled: false, }; - const limitsJson = '{' + - '"account_token_ownership_limit": '+ limits.accountTokenOwnershipLimit +',' + - '"sponsored_data_size": ' + limits.sponsoredDataSize + ',' + - // '"sponsored_data_rate_limit": { sponsoringDisabled: null },' + - '"token_limit": ' + limits.tokenLimit + ',' + - '"sponsor_transfer_timeout": ' + limits.sponsorTransferTimeout + ',' + - '"sponsor_approve_timeout": ' + limits.sponsorApproveTimeout + ',' + - '"owner_can_transfer": ' + limits.ownerCanTransfer + ',' + - '"owner_can_destroy": ' + limits.ownerCanDestroy + ',' + - '"transfers_enabled": ' + limits.transfersEnabled + - '}'; + const limitsJson = JSON.stringify(limits, null, 1); await helper.methods.setLimits(collectionIdAddress, limitsJson).send(); const collection = (await getDetailedCollectionInfo(api, collectionId))!; expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.be.eq(limits.accountTokenOwnershipLimit); expect(collection.limits.sponsoredDataSize.unwrap().toNumber()).to.be.eq(limits.sponsoredDataSize); + expect(collection.limits.sponsoredDataRateLimit.unwrap().asBlocks.toNumber()).to.be.eq(limits.sponsoredDataRateLimit.Blocks); expect(collection.limits.tokenLimit.unwrap().toNumber()).to.be.eq(limits.tokenLimit); expect(collection.limits.sponsorTransferTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorTransferTimeout); expect(collection.limits.sponsorApproveTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorApproveTimeout); -- gitstuff