import type { ec } from 'elliptic'; export type AElfAddress = string; export type AElfBlockHeight = number; export type AElfChainId = string; export type PublicKey = { x: string; y: string; }; export type AElfWallet = { address: string; privateKey?: string; childWallet?: string; BIP44Path?: string; keyPair?: ec.KeyPair; }; export type Block = { Body: any; Header: any; BlockSize: number; BlockHash: string; }; export type NightElfErrorMessage = { message: { Data: any; Code: null | string; Details: null | string; Message: null | string; ValidationErrors: null | string; }; }; export type NightElfResult = { error: number; errorMessage: string & NightElfErrorMessage; from: 'contentNightElf'; result: T | undefined; sid: string; }; export type AElfSDKError = { code: number; error: any; mag: string; }; export type ChainStatus = { BestChainHash: string; BestChainHeight: AElfBlockHeight; Branches: { [key: string]: number; }; ChainId: AElfChainId; GenesisBlockHash: string; GenesisContractAddress: string; LastIrreversibleBlockHash: string; LastIrreversibleBlockHeight: number; LongestChainHash: string; LongestChainHeight: number; NotLinkedBlocks: any; }; export type AElfTransaction = { From: string; To: string; RefBlockNumber: AElfBlockHeight; RefBlockPrefix: string; Params: string; Signature: string; MethodName: string; }; export type TransactionStatus = 'MINED' | 'PENDING' | 'NOT_EXISTED' | 'FAILED' | 'CONFLICT' | 'PENDING_VALIDATION' | 'NODE_VALIDATION_FAILED'; export type Log = { Address: string; Name: string; Indexed: Array; NonIndexed: string; }; export type TransactionResult = { TransactionId: string; Status: TransactionStatus; BlockHash: string | null; BlockNumber: AElfBlockHeight; Bloom: string | null; Error: any; Logs: Array; ReturnValue: any; Transaction: AElfTransaction | null; TransactionSize: number; }; export type ExtensionInfo = { detail: string; error: number; errorMessage: string & NightElfErrorMessage; from: 'contentNightElf'; sid: string; }; export type ChainMethodResult = T & NightElfResult & AElfSDKError; export interface IAElfRPCMethods { /** * * Get contract instance * It is different from the wallet created by Aelf.wallet.getWalletByPrivateKey(); * There is only one value named address; */ contractAt(address: string, wallet: AElfWallet): Promise>; /** * Get block information by block hash. */ getBlock(blockHash: string, includeTransactions?: boolean): Promise>; /** * Get block information by block height. */ getBlockByHeight(blockHeight: number, includeTransactions?: boolean): Promise>; /** * Get current best height of the chain. */ getBlockHeight(): Promise>; /** * Get chain state */ getChainState(...args: unknown[]): Promise>; /** * Get chain status */ getChainStatus(...args: unknown[]): Promise>; /** * Get the protobuf definitions related to a contract */ getContractFileDescriptorSet(contractAddress: string): Promise>; /** * Get the transaction pool status. */ getTransactionPoolStatus(): Promise>; /** * Get the result of a transaction */ getTxResult(transactionId: string): Promise>; /** * Get multiple transaction results in a block */ getTxResults(blockHash: string, offset?: number, limit?: number): Promise>>; /** * Broadcast a transaction */ sendTransaction(...args: unknown[]): Promise>; /** * Broadcast a transactions */ sendTransactions(...args: unknown[]): Promise>; }