From a8a10aec0c54aad7b6162de0c2dd69a3a7b4678c Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 14 Oct 2020 19:38:06 +0200 Subject: [PATCH] Manual testcase for Tuples (#2201) * Manual testcase for Tuples * Unused import * Length check --- packages/api/src/checkTypes.manual.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/api/src/checkTypes.manual.ts b/packages/api/src/checkTypes.manual.ts index c7dfcb2562..5da6533507 100644 --- a/packages/api/src/checkTypes.manual.ts +++ b/packages/api/src/checkTypes.manual.ts @@ -3,7 +3,7 @@ // Simple non-runnable checks to test type definitions in the editor itself -import { Balance, Header, Index } from '@polkadot/types/interfaces'; +import { AccountId, Balance, Header, Index } from '@polkadot/types/interfaces'; import { IExtrinsic, IMethod } from '@polkadot/types/types'; import { ApiPromise } from '@polkadot/api'; @@ -71,6 +71,20 @@ async function query (api: ApiPromise, keyring: TestKeyringMap): Promise { console.log(multiRes); + // events destructing + api.query.system.events((records): void => { + records.forEach(({ event, phase }): void => { + if (phase.isApplyExtrinsic) { + // Dunno... this should work + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // @ts-ignore + const [accountId, value]: [AccountId, Balance] = event.data; + + console.log(`${accountId} has ${value.toHuman()}`); + } + }); + }); + // at queries const events = await api.query.system.events.at('0x12345');