UNPKG

2.23 kBTypeScriptView Raw
1/// <reference types="node" />
2import EventEmitter from 'events';
3import { Client } from './client';
4import { Address } from './address';
5/**
6 * The EvmContract class streamlines interaction with a contract that was
7 * deployed on a Loom DAppChain EVM.
8 * Each instance of this class is bound to a specific contract, and provides a simple way of calling
9 * into and querying that contract.
10 *
11 * A contract instance can be used to listen to events emitted by the corresponding smart contract,
12 * there is currently only one type of event. The event subscription API matches the NodeJS
13 * EventEmitter API.
14 */
15export declare class EvmContract extends EventEmitter {
16 static readonly EVENT: string;
17 private _client;
18 address: Address;
19 caller: Address;
20 /**
21 * @param params Parameters.
22 * @param params.contractAddr Address of a contract on the Loom DAppChain EVM.
23 * @param params.callerAddr: Address of the caller, generated from the public key of the tx signer,
24 * e.g. `new Address(client.chainId, LocalAddress.fromPublicKey(pubKey))`
25 * @param params.client: Client to use to communicate with the contract.
26 */
27 constructor(params: {
28 contractAddr: Address;
29 callerAddr: Address;
30 client: Client;
31 });
32 /**
33 * Calls a contract method that mutates state.
34 * The call into the contract is accomplished by committing a tx to the DAppChain.
35 * @param args ABI encoded function signature and input paramters.
36 * @returns A promise that will be resolved with return value (if any) of the contract method.
37 */
38 callAsync(args: number[], output?: Uint8Array): Promise<Uint8Array | void>;
39 /**
40 * Calls a method of a contract running on an EVM that doesn't mutate state.
41 * This method is usually used to query the current contract state, it doesn't commit any txs.
42 * @param args ABI encoded function signature and input paramters.
43 * @returns A promise that will be resolved with the return value of the contract method.
44 */
45 staticCallAsync(args: number[], output?: Uint8Array): Promise<Uint8Array | void>;
46 private _emitContractEvent;
47}