difftreelog
Merge pull request #294 from UniqueNetwork/feature/create-collection-ex
in: master
Remove double option limit
6 files changed
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -27,6 +27,8 @@
use derivative::Derivative;
use scale_info::TypeInfo;
+mod migration;
+
pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;
pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;
pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;
@@ -319,7 +321,7 @@
/// None - setVariableMetadata is not sponsored
/// Some(v) - setVariableMetadata is sponsored
/// if there is v block between txs
- pub sponsored_data_rate_limit: Option<(Option<u32>,)>,
+ pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,
pub token_limit: Option<u32>,
// Timeouts for item types in passed blocks
@@ -366,13 +368,23 @@
self.transfers_enabled.unwrap_or(true)
}
pub fn sponsored_data_rate_limit(&self) -> Option<u32> {
- self.sponsored_data_rate_limit
- .unwrap_or((None,))
- .0
- .map(|v| v.min(MAX_SPONSOR_TIMEOUT))
+ match self
+ .sponsored_data_rate_limit
+ .unwrap_or(SponsoringRateLimit::SponsoringDisabled)
+ {
+ SponsoringRateLimit::SponsoringDisabled => None,
+ SponsoringRateLimit::Blocks(v) => Some(v.min(MAX_SPONSOR_TIMEOUT)),
+ }
}
}
+#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
+pub enum SponsoringRateLimit {
+ SponsoringDisabled,
+ Blocks(u32),
+}
+
/// BoundedVec doesn't supports serde
#[cfg(feature = "serde1")]
mod bounded_serde {
primitives/data-structs/src/migration.rsdiffbeforeafterboth--- /dev/null
+++ b/primitives/data-structs/src/migration.rs
@@ -0,0 +1,24 @@
+/// Storage migration is not required for this change, as SponsoringRateLimit has same encoding as Option<u32>
+#[test]
+fn sponsoring_rate_limit_has_same_encoding_as_option_u32() {
+ use crate::SponsoringRateLimit;
+ use codec::Encode;
+
+ fn limit_to_option(limit: SponsoringRateLimit) -> Option<u32> {
+ match limit {
+ SponsoringRateLimit::SponsoringDisabled => None,
+ SponsoringRateLimit::Blocks(v) => Some(v),
+ }
+ }
+
+ fn test_to_option(limit: SponsoringRateLimit) {
+ let encoded = limit.encode();
+ let option = limit_to_option(limit);
+ let encoded_option = option.encode();
+
+ assert_eq!(encoded, encoded_option);
+ }
+
+ test_to_option(SponsoringRateLimit::SponsoringDisabled);
+ test_to_option(SponsoringRateLimit::Blocks(10));
+}
tests/src/interfaces/augment-types.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-types.ts
+++ b/tests/src/interfaces/augment-types.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
-import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1AbridgedHrmpChannel, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpTrieStorageProof, SpVersionRuntimeVersion, UniqueRuntimeRuntime, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateNftData, UpDataStructsCreateReFungibleData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion, UpDataStructsSponsorshipState, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './unique';
+import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1AbridgedHrmpChannel, PolkadotPrimitivesV1PersistedValidationData, PolkadotPrimitivesV1UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpTrieStorageProof, SpVersionRuntimeVersion, UniqueRuntimeRuntime, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateNftData, UpDataStructsCreateReFungibleData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './unique';
import type { Data, StorageKey } from '@polkadot/types';
import type { BitVec, Bool, Bytes, I128, I16, I256, I32, I64, I8, Json, Null, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';
@@ -1167,6 +1167,7 @@
UpDataStructsCreateReFungibleData: UpDataStructsCreateReFungibleData;
UpDataStructsMetaUpdatePermission: UpDataStructsMetaUpdatePermission;
UpDataStructsSchemaVersion: UpDataStructsSchemaVersion;
+ UpDataStructsSponsoringRateLimit: UpDataStructsSponsoringRateLimit;
UpDataStructsSponsorshipState: UpDataStructsSponsorshipState;
UpgradeGoAhead: UpgradeGoAhead;
UpgradeRestriction: UpgradeRestriction;
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1513,11 +1513,19 @@
readonly type: 'ImageURL' | 'Unique';
}
+ /** @name UpDataStructsSponsoringRateLimit */
+ export interface UpDataStructsSponsoringRateLimit extends Enum {
+ readonly isSponsoringDisabled: boolean;
+ readonly isBlocks: boolean;
+ readonly asBlocks: u32;
+ readonly type: 'SponsoringDisabled' | 'Blocks';
+ }
+
/** @name UpDataStructsCollectionLimits (163) */
export interface UpDataStructsCollectionLimits extends Struct {
readonly accountTokenOwnershipLimit: Option<u32>;
readonly sponsoredDataSize: Option<u32>;
- readonly sponsoredDataRateLimit: Option<Option<u32>>;
+ readonly sponsoredDataRateLimit: Option<UpDataStructsSponsoringRateLimit>;
readonly tokenLimit: Option<u32>;
readonly sponsorTransferTimeout: Option<u32>;
readonly sponsorApproveTimeout: Option<u32>;
tests/src/interfaces/unique/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/types.ts
+++ b/tests/src/interfaces/unique/types.ts
@@ -1720,7 +1720,7 @@
export interface UpDataStructsCollectionLimits extends Struct {
readonly accountTokenOwnershipLimit: Option<u32>;
readonly sponsoredDataSize: Option<u32>;
- readonly sponsoredDataRateLimit: Option<Option<u32>>;
+ readonly sponsoredDataRateLimit: Option<UpDataStructsSponsoringRateLimit>;
readonly tokenLimit: Option<u32>;
readonly sponsorTransferTimeout: Option<u32>;
readonly sponsorApproveTimeout: Option<u32>;
@@ -1805,6 +1805,13 @@
readonly type: 'ImageURL' | 'Unique';
}
+/** @name UpDataStructsSponsoringRateLimit */
+export interface UpDataStructsSponsoringRateLimit extends Enum {
+ readonly isSponsoringDisabled: boolean;
+ readonly isBlocks: boolean;
+ readonly asBlocks: u32;
+}
+
/** @name UpDataStructsSponsorshipState */
export interface UpDataStructsSponsorshipState extends Enum {
readonly isDisabled: boolean;
tests/src/setVariableMetadataSponsoringRateLimit.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import {IKeyringPair} from '@polkadot/types/types';7import privateKey from './substrate/privateKey';8import usingApi from './substrate/substrate-api';9import {10 confirmSponsorshipExpectSuccess,11 createCollectionExpectSuccess,12 createItemExpectSuccess,13 findUnusedAddress,14 setCollectionLimitsExpectSuccess,15 setCollectionSponsorExpectSuccess,16 setVariableMetaDataExpectFailure,17 setVariableMetaDataExpectSuccess,18} from './util/helpers';1920describe('Integration Test setVariableMetadataSponsoringRateLimit', () => {21 let alice: IKeyringPair;22 let userWithNoBalance: IKeyringPair;2324 before(async () => {25 await usingApi(async (api) => {26 alice = privateKey('//Alice');27 userWithNoBalance = await findUnusedAddress(api);28 });29 });3031 it('sponsored setVariableMetaData can be called twice with pause for free', async () => {32 const collectionId = await createCollectionExpectSuccess();33 await setCollectionSponsorExpectSuccess(collectionId, alice.address);34 await confirmSponsorshipExpectSuccess(collectionId);35 await setCollectionLimitsExpectSuccess(alice, collectionId, {36 sponsoredDataRateLimit: 0,37 });3839 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);40 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]);41 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]);42 });4344 it('sponsored setVariableMetaData can\'t be called twice without pause for free', async () => {45 const collectionId = await createCollectionExpectSuccess();46 await setCollectionSponsorExpectSuccess(collectionId, alice.address);47 await confirmSponsorshipExpectSuccess(collectionId);48 await setCollectionLimitsExpectSuccess(alice, collectionId, {49 sponsoredDataRateLimit: 10,50 });5152 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);53 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]);54 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2, 3]);55 });5657 it('sponsored setVariableMetaData can\'t be called for free with variable metadata above collection limits', async () => {58 const collectionId = await createCollectionExpectSuccess();59 await setCollectionSponsorExpectSuccess(collectionId, alice.address);60 await confirmSponsorshipExpectSuccess(collectionId);61 await setCollectionLimitsExpectSuccess(alice, collectionId, {62 sponsoredDataRateLimit: 0,63 sponsoredDataSize: 1,64 });65 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);6667 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1]);68 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2]);69 });7071 it('Default value of rate limit does not sponsor setting variable metadata', async () => {72 const collectionId = await createCollectionExpectSuccess();73 await setCollectionSponsorExpectSuccess(collectionId, alice.address);74 await confirmSponsorshipExpectSuccess(collectionId);7576 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);77 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1]);78 });7980});1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import {IKeyringPair} from '@polkadot/types/types';7import {expect} from 'chai';8import privateKey from './substrate/privateKey';9import usingApi from './substrate/substrate-api';10import {11 confirmSponsorshipExpectSuccess,12 createCollectionExpectSuccess,13 createItemExpectSuccess,14 findUnusedAddress,15 getDetailedCollectionInfo,16 setCollectionLimitsExpectSuccess,17 setCollectionSponsorExpectSuccess,18 setVariableMetaDataExpectFailure,19 setVariableMetaDataExpectSuccess,20} from './util/helpers';2122describe('Integration Test setVariableMetadataSponsoringRateLimit', () => {23 let alice: IKeyringPair;24 let userWithNoBalance: IKeyringPair;2526 before(async () => {27 await usingApi(async (api) => {28 alice = privateKey('//Alice');29 userWithNoBalance = await findUnusedAddress(api);30 });31 });3233 it('sponsored setVariableMetaData can be called twice with pause for free', async () => {34 const collectionId = await createCollectionExpectSuccess();35 await setCollectionSponsorExpectSuccess(collectionId, alice.address);36 await confirmSponsorshipExpectSuccess(collectionId);37 await setCollectionLimitsExpectSuccess(alice, collectionId, {38 sponsoredDataRateLimit: {Blocks: 0},39 });4041 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);42 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]);43 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]);44 });4546 it('sponsored setVariableMetaData can\'t be called twice without pause for free', async () => {47 const collectionId = await createCollectionExpectSuccess();48 await setCollectionSponsorExpectSuccess(collectionId, alice.address);49 await confirmSponsorshipExpectSuccess(collectionId);50 await setCollectionLimitsExpectSuccess(alice, collectionId, {51 sponsoredDataRateLimit: {Blocks: 10},52 });5354 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);55 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]);56 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2, 3]);57 });5859 it('sponsored setVariableMetaData can\'t be called for free with variable metadata above collection limits', async () => {60 const collectionId = await createCollectionExpectSuccess();61 await setCollectionSponsorExpectSuccess(collectionId, alice.address);62 await confirmSponsorshipExpectSuccess(collectionId);63 await setCollectionLimitsExpectSuccess(alice, collectionId, {64 sponsoredDataRateLimit: {Blocks: 0},65 sponsoredDataSize: 1,66 });67 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);6869 await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1]);70 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2]);71 });7273 it('Default value of rate limit does not sponsor setting variable metadata', async () => {74 const collectionId = await createCollectionExpectSuccess();75 await setCollectionSponsorExpectSuccess(collectionId, alice.address);76 await confirmSponsorshipExpectSuccess(collectionId);7778 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address);79 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1]);80 });8182 it('sponsoring of data is disabled by default', async () => {83 await usingApi(async api => {84 const collectionId = await createCollectionExpectSuccess();8586 const collection = (await getDetailedCollectionInfo(api, collectionId))!;87 // limit is none = default is used88 expect(collection?.limits.sponsoredDataRateLimit.isNone);89 });90 });9192 it('sponsoring can be disabled explicitly', async () => {93 await usingApi(async api => {94 const collectionId = await createCollectionExpectSuccess();9596 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsoredDataRateLimit: {Blocks: 6}});97 {98 const collection = (await getDetailedCollectionInfo(api, collectionId))!;99 expect(collection?.limits.sponsoredDataRateLimit.unwrap().asBlocks.toNumber()).to.equal(6);100 }101102 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsoredDataRateLimit: 'SponsoringDisabled'});103 {104 const collection = (await getDetailedCollectionInfo(api, collectionId))!;105 // disabled sponsoring = default value106 expect(collection?.limits.sponsoredDataRateLimit.unwrap().isNone).to.true;107 }108 });109 });110});