packageDocumentation module import { Wallet } from '@harmony-js/account' ; import { Messenger } from '@harmony-js/network' ; import { Transaction } from '@harmony-js/transaction' ; import { AbiCoder } from './abi/index' ; import { abiMapper } from './utils/mapper' ; import { ContractOptions } from './utils/options' ; import { AbiModel } from './models/types' ; import { AbiCoderClass } from './abi/api' ; import { MethodFactory } from './methods/methodFactory' ; import { EventFactory } from './events/eventFactory' ; import { ContractStatus } from './utils/status' ; export class Contract { methods : any ; events : any ; fallback : any = undefined ; receive : any = undefined ; abi : any = [ ] ; abiModel : any | AbiModel ; abiCoder : AbiCoderClass ; options : ContractOptions | any ; wallet : Wallet | any ; transaction ? : Transaction ; status : ContractStatus ; shardID : number ; errorFunc : string = 'Error(string)' ; errorFuncSig : string ; constructor ( abi = [ ] , address = '0x' , options = { } , wallet , status = ContractStatus . INITIALISED ) { this . abi = abi ; this . abiCoder = AbiCoder ( ) ; this . abiModel = abiMapper ( abi , this . abiCoder ) ; this . options = options ; this . address = this . options . address || address ; this . shardID = this . options . shardID || wallet . messenger . currentShard ; this . wallet = wallet ; this . methods = { } ; this . events = { } ; this . runMethodFactory ( ) ; this . runEventFactory ( ) ; this . status = status ; this . errorFuncSig = this . abiCoder . encodeFunctionSignature ( this . errorFunc ) ; } isInitialised ( ) { return this . status === ContractStatus . INITIALISED ; } isSigned ( ) { return this . status === ContractStatus . SIGNED ; } isSent ( ) { return this . status === ContractStatus . SENT ; } isDeployed ( ) { return this . status === ContractStatus . DEPLOYED ; } isRejected ( ) { return this . status === ContractStatus . REJECTED ; } isCalled ( ) { return this . status === ContractStatus . CALLED ; } setStatus ( status ) { this . status = status ; } get jsonInterface ( ) : any [ ] { return this . abiModel ; } set jsonInterface ( value ) { this . abiModel = abiMapper ( value , this . abiCoder ) ; this . runMethodFactory ( ) ; this . runEventFactory ( ) ; } get address ( ) { return this . options . address || this . address ; } set address ( value ) { this . options . address = value ; } get data ( ) { return this . options . data ; } set data ( value ) { this . options . data = value ; } deploy ( options ) { return this . methods . contractConstructor ( options ) ; } runMethodFactory ( ) { return new MethodFactory ( this ) . addMethodsToContract ( ) ; } runEventFactory ( ) { return new EventFactory ( this ) . addEventsToContract ( ) ; } connect ( wallet ) { this . wallet = wallet ; } setMessenger ( messenger ) { if ( this . wallet instanceof Wallet ) { this . wallet . setMessenger ( messenger ) ; } else { this . wallet . messenger = messenger ; } } }