UNPKG

2.32 kBTypeScriptView Raw
1import { Event, Log, RawAction, SmartContractDefinition, SmartContractIterOptions } from '@neo-one/client-common';
2import { Client } from './Client';
3/**
4 * An object representing a smart contract defined by the `definition` property, in particular, the `ABI` of the definition.
5 */
6export interface SmartContract<TClient extends Client = Client, TEvent extends Event<string, any> = Event> {
7 /**
8 * The `SmartContractDefinition` that generated this `SmartContract` object.
9 */
10 readonly definition: SmartContractDefinition;
11 /**
12 * The underlying `Client` used by this `SmartContract`.
13 */
14 readonly client: TClient;
15 /**
16 * Iterate over the events emitted by the smart contract.
17 *
18 * @returns an `AsyncIterable` over the events emitted by the smart contract.
19 */
20 readonly iterEvents: (options?: SmartContractIterOptions) => AsyncIterable<TEvent>;
21 /**
22 * Iterate over the logs emitted by the smart contract.
23 *
24 * @returns an `AsyncIterable` over the logs emitted by the smart contract.
25 */
26 readonly iterLogs: (options?: SmartContractIterOptions) => AsyncIterable<Log>;
27 /**
28 * Iterate over the events and logs emitted by the smart contract.
29 *
30 * @returns an `AsyncIterable` over the events and logs emitted by the smart contract.
31 */
32 readonly iterActions: (options?: SmartContractIterOptions) => AsyncIterable<TEvent | Log>;
33 /**
34 * Converts a `RawAction`, typically from the raw results found in a `Block` to a processed `Action` or `undefined` if the action is not recognized by the ABI.
35 *
36 * @returns `Action` if the `action` parameter is recognized by the `ABI` of the smart contract, `undefined` otherwise.
37 */
38 readonly convertAction: (action: RawAction) => TEvent | Log | undefined;
39}
40export interface SmartContractAny extends SmartContract {
41 readonly [key: string]: any;
42}
43/**
44 * Client which controls a local NEO•ONE toolchain.
45 */
46export interface LocalClient {
47 /**
48 * Returns the local toolchain's NEO Tracker url.
49 */
50 readonly getNEOTrackerURL: () => Promise<string | undefined>;
51 /**
52 * Resets the local toolchain to its initial state by resetting the local developer network and redeploying contracts.
53 */
54 readonly reset: () => Promise<void>;
55}