git.delta.rocks / unique-network / refs/commits / 8de7cb2be37a

difftreelog

CORE-238 fix pr

Trubnikov Sergey2022-04-05parent: #af948bc.patch.diff
in: master

2 files changed

modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -428,7 +428,8 @@
 			return None;
 		}
 
-		let limits = collection.unwrap().limits;
+		let collection = collection.unwrap();
+		let limits = collection.limits;
 		let effective_limits = CollectionLimits {
 			account_token_ownership_limit: Some(limits.account_token_ownership_limit()),
 			sponsored_data_size: Some(limits.sponsored_data_size()),
@@ -438,7 +439,13 @@
 					.unwrap_or(SponsoringRateLimit::SponsoringDisabled),
 			),
 			token_limit: Some(limits.token_limit()),
-			sponsor_transfer_timeout: Some(limits.sponsor_transfer_timeout(MAX_SPONSOR_TIMEOUT)),
+			sponsor_transfer_timeout: Some(limits.sponsor_transfer_timeout(
+				match collection.mode {
+					CollectionMode::NFT => NFT_SPONSOR_TRANSFER_TIMEOUT,
+					CollectionMode::Fungible(_) => FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+					CollectionMode::ReFungible => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+				},
+			)),
 			sponsor_approve_timeout: Some(limits.sponsor_approve_timeout()),
 			owner_can_transfer: Some(limits.owner_can_transfer()),
 			owner_can_destroy: Some(limits.owner_can_destroy()),
modifiedtests/src/limits.test.tsdiffbeforeafterboth
409 expect(limits).to.be.any;409 expect(limits).to.be.any;
410 410
411 // Check that limits is undefined411 // Check that limits is undefined
412 expect(limits.accountTokenOwnershipLimit.isNone).to.be.true;412 expect(limits.accountTokenOwnershipLimit.toHuman()).to.be.null;
413 expect(limits.sponsoredDataSize.isNone).to.be.true;413 expect(limits.sponsoredDataSize.toHuman()).to.be.null;
414 expect(limits.sponsoredDataRateLimit.isNone).to.be.true;414 expect(limits.sponsoredDataRateLimit.toHuman()).to.be.null;
415 expect(limits.tokenLimit.isNone).to.be.true;415 expect(limits.tokenLimit.toHuman()).to.be.null;
416 expect(limits.sponsorTransferTimeout.isNone).to.be.true;416 expect(limits.sponsorTransferTimeout.toHuman()).to.be.null;
417 expect(limits.sponsorApproveTimeout.isNone).to.be.true;417 expect(limits.sponsorApproveTimeout.toHuman()).to.be.null;
418 expect(limits.ownerCanTransfer.isNone).to.be.true;418 expect(limits.ownerCanTransfer.toHuman()).to.be.null;
419 expect(limits.ownerCanDestroy.isNone).to.be.true;419 expect(limits.ownerCanDestroy.toHuman()).to.be.null;
420 expect(limits.transfersEnabled.isNone).to.be.true;420 expect(limits.transfersEnabled.toHuman()).to.be.null;
421 }421 }
422422
423 {423 {
424 const limits = await api.rpc.unique.effectiveCollectionLimits(11111);424 const limits = await api.rpc.unique.effectiveCollectionLimits(11111);
425 expect(limits.isNone).to.be.true;425 expect(limits.toHuman()).to.be.null;
426 }426 }
427427
428 {428 {
429 const limitsOpt = await api.rpc.unique.effectiveCollectionLimits(collectionId);429 const limitsOpt = await api.rpc.unique.effectiveCollectionLimits(collectionId);
430 expect(limitsOpt.isNone).to.be.false;430 expect(limitsOpt.isNone).to.be.false;
431 const limits = limitsOpt.unwrap();431 const limits = limitsOpt.unwrap();
432432
433 console.log(limits);
434 expect(limits.accountTokenOwnershipLimit.isSome).to.be.true;433 expect(limits.accountTokenOwnershipLimit.toHuman()).to.be.eq('100,000');
435 expect(limits.sponsoredDataSize.isSome).to.be.true;434 expect(limits.sponsoredDataSize.toHuman()).to.be.eq('2,048');
436 expect(limits.sponsoredDataRateLimit.isSome).to.be.true;435 expect(limits.sponsoredDataRateLimit.toHuman()).to.be.eq('SponsoringDisabled');
437 expect(limits.tokenLimit.isSome).to.be.true;436 expect(limits.tokenLimit.toHuman()).to.be.eq('4,294,967,295');
438 expect(limits.sponsorTransferTimeout.isSome).to.be.true;437 expect(limits.sponsorTransferTimeout.toHuman()).to.be.eq('5');
439 expect(limits.sponsorApproveTimeout.isSome).to.be.true;438 expect(limits.sponsorApproveTimeout.toHuman()).to.be.eq('5');
440 expect(limits.ownerCanTransfer.isSome).to.be.true;439 expect(limits.ownerCanTransfer.toHuman()).to.be.true;
441 expect(limits.ownerCanDestroy.isSome).to.be.true;440 expect(limits.ownerCanDestroy.toHuman()).to.be.true;
442 expect(limits.transfersEnabled.isSome).to.be.true;441 expect(limits.transfersEnabled.toHuman()).to.be.true;
443 }442 }
444 });443 });
445 });444 });