olympus-protocol-connector
Version:
Module made by Olympus Labs for easier access to the Olympus protocol through Javascript/Typescript
84 lines (83 loc) • 3 kB
TypeScript
import BigNumber from 'bignumber.js';
import { Tx } from '../interfaces/Tx';
import { TxStatus } from '../interfaces/Enums';
import { EstimateGasOption } from '../interfaces/EstimateGas';
import { ConfigOptions } from '../interfaces';
export declare class RpcService {
private static instance;
protected _rpc: any;
private chainId;
private _mainAddress;
private logger;
/**
* RpcService Singleton Instance;
*/
static readonly Instance: RpcService;
/**
* customize RpcService
* this method for customize client RpcService, can be override every methods.
* @param service RpcService
*/
static customize(service: RpcService): void;
/** web3 module export */
protected static readonly Web3: any;
/** default config export */
protected static readonly Config: ConfigOptions;
protected constructor(web3Url?: string);
private setChainId;
readonly MainAddress: string;
reset(web3Url?: string): void;
readonly eth: any;
readonly rpc: any;
toHex(number: any): number;
contract(abi: any, address: string): any;
fromWei(amount: BigNumber | number, unit?: string): any;
toWei(amount: BigNumber | number, unit: string): any;
byte32ToString(data: any): any;
version(): any;
isValidAddress(address: any): any;
getNonce(address: any): Promise<number>;
getTransactionReceipt(hash: string): Promise<{
status: string;
logs: any;
}>;
getTransactionsReceipts(hashes: string[]): Promise<any[]>;
getBalance(address: string): Promise<BigNumber>;
getGasPrice(): Promise<BigNumber>;
getGasLimit(): Promise<number>;
toAscii(hex: any): any;
toNumber(hexadecimal: number): number;
fromAscii(string: any): any;
connectContract(abi: any, address: string): any;
/**
* afterTxBuilt can be override by client
* @param caller to identify which method call this
* @param tx Tx
*/
afterTxBuilt(caller: string, tx: any): Promise<Tx>;
buildTx({ from, to, data, amount, gasPrice, gasLimit, caller, description }: {
from?: string;
to: string;
data: any;
amount?: BigNumber | number;
gasPrice?: BigNumber | number;
gasLimit?: BigNumber | number;
caller?: string;
description?: string;
}): Promise<Tx>;
protected createTx({ from, to, data, amount, gasPrice, gasLimit }: {
from?: string;
to: string;
data: any;
amount?: BigNumber | number;
gasPrice?: BigNumber | number;
gasLimit?: BigNumber | number;
}): Promise<Tx>;
sendTX(productAddress: string, data: any): Promise<Tx>;
send(tx: Tx): Promise<Tx>;
sendRawTransaction(tx: Tx): Promise<Tx>;
isTxSuccessful(hash: string): Promise<TxStatus>;
tryEstimateGas(option: EstimateGasOption, gasLimit?: number): Promise<number>;
estimateGas(option: EstimateGasOption): Promise<number>;
repeatTx(tx: Tx): Promise<Tx | null>;
}