eulith-web3js
Version:
Official Eulith Typescript client library
71 lines (70 loc) • 3.21 kB
TypeScript
import * as Web3Core from "web3-core";
import { AbstractProvider, RequestArguments, TransactionConfig, TransactionReceipt } from "web3-core";
import { JsonRpcPayload, JsonRpcResponse } from "web3-core-helpers";
import { AxiosInstance } from "axios";
import * as Eulith from "./index";
import { Auth } from "./auth";
/**
* The main EulithProvider class that wraps around Web3js to expose Eulith services
* in addition to the expected functionality of a normal Web3js provider.
*/
export declare class Provider implements AbstractProvider {
readonly network: Eulith.Networks.Network;
connected?: boolean;
private readonly serverURL_;
private readonly fetcherInstance_;
private signer_;
private static nextID_;
private readonly logger_;
private readonly auth_;
private readonly httpConfig_;
tradingKeyAddress?: string;
safeAddress?: string;
atomicTxId?: string;
constructor({ signer, network, auth, logger, fetcherInstance, tradingKeyAddress, safeAddress, atomicTxId, }: {
signer?: Eulith.Signing.SigningService;
network: Eulith.Networks.Network;
auth: Auth.Token;
logger?: Eulith.Logging.ILogger | null;
fetcherInstance?: AxiosInstance;
tradingKeyAddress?: string | null;
safeAddress?: string | null;
atomicTxId?: string | null;
});
/**
* Many APIs in the Eulith client library allow specifying either a provider or web3 (as a short-hand to get its underlying provider).
* This utility just maps either one to itself or underlying provider.
*/
static ProviderOrWeb3(providerOrWeb3: Eulith.Provider | Eulith.Web3): Eulith.Provider;
/**
* Get the logger associated with this provider
*/
get logger(): Eulith.Logging.ILogger;
clone(): Eulith.Provider;
/**
* Get the default signer associated with this provider
*/
get signer(): Eulith.Signing.SigningService;
setSigner(signer: Eulith.Signing.SigningService): void;
getUrlParams(): {};
setTradingKeyAddress(tradingKeyAddress: string): void;
setSafeAddress(safeAddress: string): void;
setAtomicTxId(atomicTxId: string): void;
setAtomicTxParams(tradingKeyAddress: string, atomicTxId: string, safeAddress?: string): void;
/**
* Sign the provided unsigned transactionConfig, send it to the network and return the result
*/
signAndSendTransaction(transactionConfig: TransactionConfig, signer: Eulith.Signing.SigningService): Promise<string>;
/**
* Send an already signed transaction
*/
sendSignedTransaction(signedTx: Web3Core.SignedTransaction): Promise<string>;
/**
* Shorthand for signing, sending, and waiting for the receipt
*/
signAndSendTransactionAndWait(transactionConfig: TransactionConfig, signer: Eulith.Signing.SigningService, timeoutInMS?: number): Promise<TransactionReceipt>;
sendAsync(payload: JsonRpcPayload, callback?: (error: Error | null, result?: JsonRpcResponse) => Promise<unknown> | void): void;
send(payload: JsonRpcPayload, callback: (error: Error | null, result?: JsonRpcResponse) => unknown): void;
request(args: RequestArguments): Promise<any>;
private req_;
}