export namespace AschContract { export interface SandboxConfig { entry: string dataDir: string logDir: string logLevelConfig?: { defaultLogLevel: any, [loggerName: string] : any }, memoryConfig?: { maxSemiSpace?: number maxOldSpace?: number }, debug?: boolean } interface SandboxCallResult { success: boolean; gas?: number; errCode?: string; error?: string; data?: T; transfers?: Array<{ recipientAddress: string, amount: string, currency: string }>; stateChangesHash?: string; } type ContractContext = any type StatePath = Array export class EventEmitter { addListener(event: string | symbol, listener: (...args: any[]) => void): this; on(event: string | symbol, listener: (...args: any[]) => void): this; once(event: string | symbol, listener: (...args: any[]) => void): this; removeListener(event: string | symbol, listener: (...args: any[]) => void): this; off(event: string | symbol, listener: (...args: any[]) => void): this; removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; listeners(event: string | symbol): Function[]; rawListeners(event: string | symbol): Function[]; emit(event: string | symbol, ...args: any[]): boolean; listenerCount(type: string | symbol): number; // Added in Node 6... prependListener(event: string | symbol, listener: (...args: any[]) => void): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; eventNames(): Array; } /// export class SandboxConnector extends EventEmitter { constructor(config: SandboxConfig); readonly vmVersion: string; connect(): Promise; disconnect(): Promise; getLastCommittedHeight(): Promise; registerContract(gasLimit: number, context: ContractContext, contractId: number, contractName: string, contractCode: string): Promise>; loadContracts(contractNames: string[]): Promise>; callContract(gasLimit: number, context: ContractContext, contractName: string, method: string, ...args: any[]): Promise>; payContract(gasLimit: number, context: ContractContext, contractName: string, payableMethod: string | undefined, amount: bigint, currency: string, ...extArgs: any): Promise>; getConstant(contractName: string, method: string, ...args: any[]): Promise>; queryState(contractName: string, path: StatePath): Promise>; cancelChanges(contractName?: string): Promise>; confirmChanges(contractName?: string): Promise>; commit(height: number): Promise>; rollback(toHeight?: number): Promise>; calcTransactionStorageGas(transaction: Transaction): number; readonly loadedContracts: Map; readonly config: SandboxConfig; readonly connected: boolean; } export const CONTRACT_INITIALIZER_METHOD = "__init__"; export const ASCH_CONTRACT_CLASS_NAME = "AschContract"; export interface ParameterMetadata { index: number; name: string; type: TypeInfo; optional: boolean; reset?: boolean; } export interface TypeInfo { text: string; name: string; kind: TypeKind; typeArguments?: TypeInfo[]; } export enum TypeKind { unknow = -1, primitive = 0, stateCollection = 1, customeState = 2, array = 11, interface = 12 } export interface MethodMetadata { name: string; parameters: ParameterMetadata[]; returnType?: TypeInfo; public: boolean; isConstructor?: boolean; payable?: boolean; defaultPayable?: boolean; constant?: boolean; } export interface StateMetadata { name: string; public: boolean; readonly: boolean; type: TypeInfo; } export interface PropertyMetadata { name: string; optional: boolean; type: TypeInfo; } export interface ConstVariable { name: string; type: TypeInfo; } export interface DataInterface { name: string; flat: boolean; properties: PropertyMetadata[]; } export interface CustomeStateType { name: string; flat: boolean; constructorMethod?: MethodMetadata; properties: PropertyMetadata[]; } export interface ContractMetadataObject { className: string; constVariables: ConstVariable[]; dataInterfaces: DataInterface[]; customeTypes: CustomeStateType[]; states: StateMetadata[]; methods: MethodMetadata[]; } export interface ContractMetadata extends ContractMetadataObject { getInterfaceType(name: string): DataInterface | undefined; getCustomeType(nane: string): CustomeStateType | undefined; getState(name: string): StateMetadata | undefined; getMethod(name: string): MethodMetadata | undefined; updateMethod(name: string, method: MethodMetadata): void; toJSONObject(): ContractMetadataObject; } export class ContractMetadataMananger implements ContractMetadata { static fromJSONObject(json: ContractMetadataObject): ContractMetadataMananger; toJSONObject(): ContractMetadataObject; className: string; readonly states: StateMetadata[]; readonly methods: MethodMetadata[]; readonly customeTypes: CustomeStateType[]; readonly constVariables: ConstVariable[]; readonly dataInterfaces: DataInterface[]; updateMethod(name: string, method: MethodMetadata): void; getCustomeType(name: string): CustomeStateType | undefined; getInterfaceType(name: string): DataInterface | undefined; getState(name: string): StateMetadata | undefined; getMethod(name: string): MethodMetadata | undefined; registerConstVariables(variables: ConstVariable[]): void; registerDataInterface(dataInterface: DataInterface): void; registerState(state: StateMetadata): void; registerCustomeStateType(customeState: CustomeStateType): void; registerContractClass(contract: { className: string; states: StateMetadata[]; methods: MethodMetadata[]; }): void; registerMethod(method: MethodMetadata): void; } export enum LogLevel { log = 0, trace = 1, debug = 2, info = 3, warn = 4, error = 5, fatal = 6, all = 0, none = 7 } export interface Logger { level: LogLevel; readonly logEnabled: boolean; readonly traceEnabled: boolean; readonly debugEnabled: boolean; readonly infoEnabled: boolean; readonly warnEnabled: boolean; readonly errorEnaled: boolean; readonly fatalEnabled: boolean; log(...params: any[]): void; trace(...params: any[]): void; debug(...params: any[]): void; info(...params: any[]): void; warn(...params: any[]): void; error(...params: any[]): void; fatal(...params: any[]): void; } export interface LogFactory { createLog: (name: string, level: LogLevel, output: LogOutput) => Logger; } export class NopLogger { readonly logEnabled: boolean; readonly traceEnabled: boolean; readonly debugEnabled: boolean; readonly infoEnabled: boolean; readonly warnEnabled: boolean; readonly errorEnaled: boolean; readonly fatalEnabled: boolean; level: LogLevel; readonly name: string | undefined; constructor(); log(...params: any[]): void; trace(...params: any[]): void; debug(...params: any[]): void; info(...params: any[]): void; warn(...params: any[]): void; error(...params: any[]): void; fatal(...params: any[]): void; } export enum LogOutput { file = "file", console = "console" } export interface LogConfig { level?: LogLevel; output?: LogOutput; filter?: (data: any) => void; } export interface LogLevelConfig { defaultLogLevel: LogLevel; [loggerName: string]: LogLevel; } export class LogManager { static readonly defaultLogOutput: LogOutput; static getParentLogger(name?: string, level?: LogLevel): Logger; static parentLogger: Logger; static initLogMananger(logDir: string, defaultLogOutput: LogOutput, levelConfig: LogLevelConfig): void; static readonly levelConfig: LogLevelConfig; static readonly defaultLogLevel: LogLevel; static getLogger(name?: string, config?: LogConfig): Logger; } }