difftreelog
CORE-302 Add camelCase aliases for limits
in: master
2 files changed
primitives/data-structs/src/lib.rsdiffbeforeafterboth368#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]368#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]369#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]369#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]370pub struct CollectionLimits {370pub struct CollectionLimits {371 #[serde(alias="accountTokenOwnershipLimit")]371 pub account_token_ownership_limit: Option<u32>,372 pub account_token_ownership_limit: Option<u32>,373 #[serde(alias="sponsoredDataSize")]372 pub sponsored_data_size: Option<u32>,374 pub sponsored_data_size: Option<u32>,373375374 /// FIXME should we delete this or repurpose it?376 /// FIXME should we delete this or repurpose it?375 /// None - setVariableMetadata is not sponsored377 /// None - setVariableMetadata is not sponsored376 /// Some(v) - setVariableMetadata is sponsored378 /// Some(v) - setVariableMetadata is sponsored377 /// if there is v block between txs379 /// if there is v block between txs380 #[serde(alias="sponsoredDataRateLimit")]378 pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,381 pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,382 #[serde(alias="tokenLimit")]379 pub token_limit: Option<u32>,383 pub token_limit: Option<u32>,380384 381 // Timeouts for item types in passed blocks385 // Timeouts for item types in passed blocks386 #[serde(alias="sponsorTransferTimeout")]382 pub sponsor_transfer_timeout: Option<u32>,387 pub sponsor_transfer_timeout: Option<u32>,388 #[serde(alias="sponsorApproveTimeout")]383 pub sponsor_approve_timeout: Option<u32>,389 pub sponsor_approve_timeout: Option<u32>,390 #[serde(alias="ownerCanTransfer")]384 pub owner_can_transfer: Option<bool>,391 pub owner_can_transfer: Option<bool>,392 #[serde(alias="ownerCanDestroy")]385 pub owner_can_destroy: Option<bool>,393 pub owner_can_destroy: Option<bool>,394 #[serde(alias="transfersEnabled")]386 pub transfers_enabled: Option<bool>,395 pub transfers_enabled: Option<bool>,387}396}388397tests/src/eth/createCollection.test.tsdiffbeforeafterboth--- 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);