git.delta.rocks / unique-network / refs/commits / 3912bc1fa3ad

difftreelog

CORE-302 Add camelCase aliases for limits

Trubnikov Sergey2022-04-26parent: #c89a233.patch.diff
in: master

2 files changed

modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
368#[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>,
373375
374 /// 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 sponsored
376 /// Some(v) - setVariableMetadata is sponsored378 /// Some(v) - setVariableMetadata is sponsored
377 /// if there is v block between txs379 /// if there is v block between txs
380 #[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 blocks
386 #[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}
388397
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
101 expect(collection.constOnChainSchema.toHuman()).to.be.eq(constShema);101 expect(collection.constOnChainSchema.toHuman()).to.be.eq(constShema);
102 });102 });
103103
104 itWeb3('Set limits', async ({api, web3}) => {104 itWeb3.only('Set limits', async ({api, web3}) => {
105 const owner = await createEthAccountWithBalance(api, web3);105 const owner = await createEthAccountWithBalance(api, web3);
106 const helper = collectionHelper(web3, owner);106 const helper = collectionHelper(web3, owner);
107 const result = await helper.methods.create721Collection('Const collection', '4', '4').send();107 const result = await helper.methods.create721Collection('Const collection', '4', '4').send();
108 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);108 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
109 const limits = {109 const limits = {
110 accountTokenOwnershipLimit: 1000,110 accountTokenOwnershipLimit: 1000,
111 sponsoredDataSize: 1024,111 sponsoredDataSize: 1024,
112 // sponsoredDataRateLimit: { sponsoringDisabled: null },112 sponsoredDataRateLimit: {Blocks: 30},
113 tokenLimit: 1000000,113 tokenLimit: 1000000,
114 sponsorTransferTimeout: 6,114 sponsorTransferTimeout: 6,
115 sponsorApproveTimeout: 6,115 sponsorApproveTimeout: 6,
116 ownerCanTransfer: false,116 ownerCanTransfer: false,
117 ownerCanDestroy: false,117 ownerCanDestroy: false,
118 transfersEnabled: false,118 transfersEnabled: false,
119 };119 };
120
120 const limitsJson = '{' +121 const limitsJson = JSON.stringify(limits, null, 1);
121 '"account_token_ownership_limit": '+ limits.accountTokenOwnershipLimit +',' +
122 '"sponsored_data_size": ' + limits.sponsoredDataSize + ',' +
123 // '"sponsored_data_rate_limit": { sponsoringDisabled: null },' +
124 '"token_limit": ' + limits.tokenLimit + ',' +
125 '"sponsor_transfer_timeout": ' + limits.sponsorTransferTimeout + ',' +
126 '"sponsor_approve_timeout": ' + limits.sponsorApproveTimeout + ',' +
127 '"owner_can_transfer": ' + limits.ownerCanTransfer + ',' +
128 '"owner_can_destroy": ' + limits.ownerCanDestroy + ',' +
129 '"transfers_enabled": ' + limits.transfersEnabled +
130 '}';
131
132 await helper.methods.setLimits(collectionIdAddress, limitsJson).send();122 await helper.methods.setLimits(collectionIdAddress, limitsJson).send();
133 123
134 const collection = (await getDetailedCollectionInfo(api, collectionId))!;124 const collection = (await getDetailedCollectionInfo(api, collectionId))!;
135 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.be.eq(limits.accountTokenOwnershipLimit);125 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.be.eq(limits.accountTokenOwnershipLimit);
136 expect(collection.limits.sponsoredDataSize.unwrap().toNumber()).to.be.eq(limits.sponsoredDataSize);126 expect(collection.limits.sponsoredDataSize.unwrap().toNumber()).to.be.eq(limits.sponsoredDataSize);
127 expect(collection.limits.sponsoredDataRateLimit.unwrap().asBlocks.toNumber()).to.be.eq(limits.sponsoredDataRateLimit.Blocks);
137 expect(collection.limits.tokenLimit.unwrap().toNumber()).to.be.eq(limits.tokenLimit);128 expect(collection.limits.tokenLimit.unwrap().toNumber()).to.be.eq(limits.tokenLimit);
138 expect(collection.limits.sponsorTransferTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorTransferTimeout);129 expect(collection.limits.sponsorTransferTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorTransferTimeout);
139 expect(collection.limits.sponsorApproveTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorApproveTimeout);130 expect(collection.limits.sponsorApproveTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorApproveTimeout);