From 788534ba419ee09f66cfdc2d976f4f63b11b7a26 Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Wed, 06 Jul 2022 10:27:47 +0000 Subject: [PATCH] Fix total pieces tests --- --- a/tests/src/createItem.test.ts +++ b/tests/src/createItem.test.ts @@ -118,8 +118,7 @@ } const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces; - expect(totalPieces.isSome).to.be.true; - expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces); + expect(totalPieces.toBigInt()).to.be.eq(amountPieces); }); }); @@ -143,8 +142,7 @@ } const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces; - expect(totalPieces.isSome).to.be.true; - expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces); + expect(totalPieces.toBigInt()).to.be.eq(amountPieces); }); }); @@ -169,8 +167,7 @@ } const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces; - expect(totalPieces.isSome).to.be.true; - expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces); + expect(totalPieces.toBigInt()).to.be.eq(amountPieces); }); }); }); @@ -255,7 +252,7 @@ const invalidTokenId = 1000_000; expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true; - expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.isNone).to.be.true; + expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n); }); }); @@ -266,7 +263,7 @@ const invalidTokenId = 1000_000; expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true; - expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.isNone).to.be.true; + expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n); }); }); @@ -277,7 +274,7 @@ const invalidTokenId = 1000_000; expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true; - expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.isNone).to.be.true; + expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n); }); }); }); --- a/tests/src/interfaces/augment-api-events.ts +++ b/tests/src/interfaces/augment-api-events.ts @@ -13,45 +13,45 @@ /** * A balance was set by root. **/ - BalanceSet: AugmentedEvent; + BalanceSet: AugmentedEvent; /** * Some amount was deposited (e.g. for transaction fees). **/ - Deposit: AugmentedEvent; + Deposit: AugmentedEvent; /** * An account was removed whose balance was non-zero but below ExistentialDeposit, * resulting in an outright loss. **/ - DustLost: AugmentedEvent; + DustLost: AugmentedEvent; /** * An account was created with some free balance. **/ - Endowed: AugmentedEvent; + Endowed: AugmentedEvent; /** * Some balance was reserved (moved from free to reserved). **/ - Reserved: AugmentedEvent; + Reserved: AugmentedEvent; /** * Some balance was moved from the reserve of the first account to the second account. * Final argument indicates the destination balance type. **/ - ReserveRepatriated: AugmentedEvent; + ReserveRepatriated: AugmentedEvent; /** * Some amount was removed from the account (e.g. for misbehavior). **/ - Slashed: AugmentedEvent; + Slashed: AugmentedEvent; /** * Transfer succeeded. **/ - Transfer: AugmentedEvent; + Transfer: AugmentedEvent; /** * Some balance was unreserved (moved from reserved to free). **/ - Unreserved: AugmentedEvent; + Unreserved: AugmentedEvent; /** * Some amount was withdrawn from the account (e.g. for transaction fees). **/ - Withdraw: AugmentedEvent; + Withdraw: AugmentedEvent; /** * Generic event **/ @@ -167,27 +167,27 @@ /** * Downward message executed with the given outcome. **/ - ExecutedDownward: AugmentedEvent; + ExecutedDownward: AugmentedEvent; /** * Downward message is invalid XCM. **/ - InvalidFormat: AugmentedEvent; + InvalidFormat: AugmentedEvent; /** * Downward message is overweight and was placed in the overweight queue. **/ - OverweightEnqueued: AugmentedEvent; + OverweightEnqueued: AugmentedEvent; /** * Downward message from the overweight queue was executed. **/ - OverweightServiced: AugmentedEvent; + OverweightServiced: AugmentedEvent; /** * Downward message is unsupported version of XCM. **/ - UnsupportedVersion: AugmentedEvent; + UnsupportedVersion: AugmentedEvent; /** * The weight limit for handling downward messages was reached. **/ - WeightExhausted: AugmentedEvent; + WeightExhausted: AugmentedEvent; /** * Generic event **/ @@ -241,19 +241,19 @@ /** * Downward messages were processed using the given weight. **/ - DownwardMessagesProcessed: AugmentedEvent; + DownwardMessagesProcessed: AugmentedEvent; /** * Some downward messages have been received and will be processed. **/ - DownwardMessagesReceived: AugmentedEvent; + DownwardMessagesReceived: AugmentedEvent; /** * An upgrade has been authorized. **/ - UpgradeAuthorized: AugmentedEvent; + UpgradeAuthorized: AugmentedEvent; /** * The validation function was applied as of the contained relay chain block number. **/ - ValidationFunctionApplied: AugmentedEvent; + ValidationFunctionApplied: AugmentedEvent; /** * The relay-chain aborted the upgrade process. **/ @@ -390,29 +390,29 @@ [key: string]: AugmentedEvent; }; rmrkCore: { - CollectionCreated: AugmentedEvent; - CollectionDestroyed: AugmentedEvent; - CollectionLocked: AugmentedEvent; - IssuerChanged: AugmentedEvent; - NFTAccepted: AugmentedEvent; - NFTBurned: AugmentedEvent; - NftMinted: AugmentedEvent; - NFTRejected: AugmentedEvent; - NFTSent: AugmentedEvent; - PrioritySet: AugmentedEvent; - PropertySet: AugmentedEvent, Bytes, Bytes]>; - ResourceAccepted: AugmentedEvent; - ResourceAdded: AugmentedEvent; - ResourceRemoval: AugmentedEvent; - ResourceRemovalAccepted: AugmentedEvent; + CollectionCreated: AugmentedEvent; + CollectionDestroyed: AugmentedEvent; + CollectionLocked: AugmentedEvent; + IssuerChanged: AugmentedEvent; + NFTAccepted: AugmentedEvent; + NFTBurned: AugmentedEvent; + NftMinted: AugmentedEvent; + NFTRejected: AugmentedEvent; + NFTSent: AugmentedEvent; + PrioritySet: AugmentedEvent; + PropertySet: AugmentedEvent, key: Bytes, value: Bytes], { collectionId: u32, maybeNftId: Option, key: Bytes, value: Bytes }>; + ResourceAccepted: AugmentedEvent; + ResourceAdded: AugmentedEvent; + ResourceRemoval: AugmentedEvent; + ResourceRemovalAccepted: AugmentedEvent; /** * Generic event **/ [key: string]: AugmentedEvent; }; rmrkEquip: { - BaseCreated: AugmentedEvent; - EquippablesUpdated: AugmentedEvent; + BaseCreated: AugmentedEvent; + EquippablesUpdated: AugmentedEvent; /** * Generic event **/ @@ -422,19 +422,19 @@ /** * The call for the provided hash was not found so the task has been aborted. **/ - CallLookupFailed: AugmentedEvent, Option, FrameSupportScheduleLookupError]>; + CallLookupFailed: AugmentedEvent, id: Option, error: FrameSupportScheduleLookupError], { task: ITuple<[u32, u32]>, id: Option, error: FrameSupportScheduleLookupError }>; /** * Canceled some task. **/ - Canceled: AugmentedEvent; + Canceled: AugmentedEvent; /** * Dispatched some task. **/ - Dispatched: AugmentedEvent, Option, Result]>; + Dispatched: AugmentedEvent, id: Option, result: Result], { task: ITuple<[u32, u32]>, id: Option, result: Result }>; /** * Scheduled some task. **/ - Scheduled: AugmentedEvent; + Scheduled: AugmentedEvent; /** * Generic event **/ @@ -454,15 +454,15 @@ /** * The \[sudoer\] just switched identity; the old key is supplied if one existed. **/ - KeyChanged: AugmentedEvent]>; + KeyChanged: AugmentedEvent], { oldSudoer: Option }>; /** * A sudo just took place. \[result\] **/ - Sudid: AugmentedEvent]>; + Sudid: AugmentedEvent], { sudoResult: Result }>; /** * A sudo just took place. \[result\] **/ - SudoAsDone: AugmentedEvent]>; + SudoAsDone: AugmentedEvent], { sudoResult: Result }>; /** * Generic event **/ @@ -476,23 +476,23 @@ /** * An extrinsic failed. **/ - ExtrinsicFailed: AugmentedEvent; + ExtrinsicFailed: AugmentedEvent; /** * An extrinsic completed successfully. **/ - ExtrinsicSuccess: AugmentedEvent; + ExtrinsicSuccess: AugmentedEvent; /** * An account was reaped. **/ - KilledAccount: AugmentedEvent; + KilledAccount: AugmentedEvent; /** * A new account was created. **/ - NewAccount: AugmentedEvent; + NewAccount: AugmentedEvent; /** * On on-chain remark happened. **/ - Remarked: AugmentedEvent; + Remarked: AugmentedEvent; /** * Generic event **/ @@ -502,31 +502,31 @@ /** * Some funds have been allocated. **/ - Awarded: AugmentedEvent; + Awarded: AugmentedEvent; /** * Some of our funds have been burnt. **/ - Burnt: AugmentedEvent; + Burnt: AugmentedEvent; /** * Some funds have been deposited. **/ - Deposit: AugmentedEvent; + Deposit: AugmentedEvent; /** * New proposal. **/ - Proposed: AugmentedEvent; + Proposed: AugmentedEvent; /** * A proposal was rejected; funds were slashed. **/ - Rejected: AugmentedEvent; + Rejected: AugmentedEvent; /** * Spending has finished; this is the amount that rolls over until next spend. **/ - Rollover: AugmentedEvent; + Rollover: AugmentedEvent; /** * We have ended a spend period and will now allocate funds. **/ - Spending: AugmentedEvent; + Spending: AugmentedEvent; /** * Generic event **/ @@ -629,15 +629,15 @@ /** * Claimed vesting. **/ - Claimed: AugmentedEvent; + Claimed: AugmentedEvent; /** * Added new vesting schedule. **/ - VestingScheduleAdded: AugmentedEvent; + VestingScheduleAdded: AugmentedEvent; /** * Updated vesting schedules. **/ - VestingSchedulesUpdated: AugmentedEvent; + VestingSchedulesUpdated: AugmentedEvent; /** * Generic event **/ --- a/tests/src/interfaces/augment-api-rpc.ts +++ b/tests/src/interfaces/augment-api-rpc.ts @@ -717,6 +717,10 @@ **/ topmostTokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable>>; /** + * Get total pieces of token + **/ + totalPieces: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable>>; + /** * Get amount of unique collection tokens **/ totalSupply: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable>; --- a/tests/src/interfaces/default/types.ts +++ b/tests/src/interfaces/default/types.ts @@ -2561,6 +2561,7 @@ export interface UpDataStructsTokenData extends Struct { readonly properties: Vec; readonly owner: Option; + readonly pieces: u128; } /** @name XcmDoubleEncoded */ --- a/tests/src/interfaces/lookup.ts +++ b/tests/src/interfaces/lookup.ts @@ -2859,7 +2859,8 @@ **/ UpDataStructsTokenData: { properties: 'Vec', - owner: 'Option' + owner: 'Option', + pieces: 'u128' }, /** * Lookup376: up_data_structs::RpcCollection --- a/tests/src/interfaces/types-lookup.ts +++ b/tests/src/interfaces/types-lookup.ts @@ -2977,6 +2977,7 @@ export interface UpDataStructsTokenData extends Struct { readonly properties: Vec; readonly owner: Option; + readonly pieces: u128; } /** @name UpDataStructsRpcCollection (376) */ -- gitstuff