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
--- 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<u32>,
+	#[serde(alias="sponsoredDataSize")]
 	pub sponsored_data_size: Option<u32>,
 
 	/// 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<SponsoringRateLimit>,
+	#[serde(alias="tokenLimit")]
 	pub token_limit: Option<u32>,
-
+	
 	// Timeouts for item types in passed blocks
+	#[serde(alias="sponsorTransferTimeout")]
 	pub sponsor_transfer_timeout: Option<u32>,
+	#[serde(alias="sponsorApproveTimeout")]
 	pub sponsor_approve_timeout: Option<u32>,
+	#[serde(alias="ownerCanTransfer")]
 	pub owner_can_transfer: Option<bool>,
+	#[serde(alias="ownerCanDestroy")]
 	pub owner_can_destroy: Option<bool>,
+	#[serde(alias="transfersEnabled")]
 	pub transfers_enabled: Option<bool>,
 }
 
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);