UNPKG

949 BTypeScriptView Raw
1// Copyright 2017-2018 @polkadot/api-provider authors & contributors
2// This software may be modified and distributed under the terms
3// of the ISC license. See the LICENSE file for details.
4
5import EventEmitter from 'eventemitter3';
6import { Logger } from '@polkadot/util/types';
7
8export type MockState$Subscription$Callback = (error: Error | null, value: any) => void;
9
10export type MockState$Subscriptions = {
11 [index: string]: {
12 callbacks: {
13 [index: number]: MockState$Subscription$Callback
14 },
15 lastValue: any
16 }
17};
18
19export type MockState$Db = {
20 [index: string]: Uint8Array
21};
22
23export type MockState$Requests = {
24 [index: string]: (db: MockState$Db, params: Array<any>) => string
25};
26
27export type MockState = {
28 emitter: EventEmitter,
29 l: Logger,
30 requests: MockState$Requests,
31 db: MockState$Db,
32 subscriptionId: number,
33 subscriptionMap: {
34 [index: number]: string
35 },
36 subscriptions: MockState$Subscriptions
37};