/*!----------------------------------------------------------- * Copyright (c) IJS Technologies. All rights reserved. * Released under dual AGPLv3/commercial license * https://ijs.network *-----------------------------------------------------------*/ import { ConfirmationObject, TransactionReceipt } from './web3'; import { BigNumber } from 'bignumber.js'; import { Erc20 } from './contracts/erc20'; import { IAbiDefinition, MessageTypes, TypedMessage } from './types'; import { IEventBusRegistry } from './eventBus'; export { TransactionReceipt, ConfirmationObject }; export declare function toString(value: any): any; export type stringArray = string | _stringArray; export interface _stringArray extends Array { } export interface IWalletUtils { fromDecimals(value: BigNumber | number | string, decimals?: number): BigNumber; fromWei(value: any, unit?: string): string; hexToUtf8(value: string): string; sha3(value: string): string; stringToBytes(value: string | stringArray, nByte?: number): string | string[]; stringToBytes32(value: string | stringArray): string | string[]; toDecimals(value: BigNumber | number | string, decimals?: number): BigNumber; toString(value: any): string; toUtf8(value: any): string; toWei(value: string, unit?: string): string; } export interface IWalletTransaction { hash: string; nonce: bigint; blockHash: string | null; blockNumber: bigint | null; transactionIndex: bigint | null; from: string; to: string | null; value: BigNumber; gasPrice: BigNumber; maxPriorityFeePerGas?: bigint | string | BigNumber; maxFeePerGas?: bigint | string | BigNumber; gas: bigint; input: string; } export interface IWalletBlockTransactionObject { number: bigint; hash: string; parentHash: string; nonce: string; sha3Uncles: string; logsBloom: string; transactionRoot: string; stateRoot: string; receiptsRoot: string; miner: string; extraData: string; gasLimit: bigint; gasUsed: bigint; timestamp: bigint | string; baseFeePerGas?: bigint; size: bigint; difficulty: bigint; totalDifficulty: bigint; uncles: string[]; transactions: IWalletTransaction[]; } export interface ITokenInfo { name: string; symbol: string; totalSupply: BigNumber; decimals: number; } export interface IBatchRequestResult { key: string; result: any; } export interface IBatchRequestObj { batch: any; promises: Promise[]; execute: (batch: IBatchRequestObj, promises: Promise[]) => Promise; } export interface IConnectWalletEventPayload { userTriggeredConnect?: boolean; [key: string]: any; } export interface IWallet { account: IAccount; accounts: Promise; address: string; balance: Promise; balanceOf(address: string): Promise; _call(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; chainId: number; createAccount(): IAccount; decode(abi: any, event: Log | EventLog, raw?: { data: string; topics: string[]; }): Event; decodeErrorMessage(msg: string): any; decodeEventData(data: Log, events?: any): Promise; decodeLog(inputs: any, hexString: string, topics: any): any; decodeParameters(types: string[], hexString: string): any; encodeParameters(types: string[], values: any[]): string; defaultAccount: string; getAbiEvents(abi: any[]): any; getAbiTopics(abi: any[], eventNames: string[]): any[]; getBlock(blockHashOrBlockNumber?: number | string, returnTransactionObjects?: boolean): Promise; getBlockNumber(): Promise; getBlockTimestamp(blockHashOrBlockNumber?: number | string): Promise; getChainId(): Promise; getContractAbi(address: string): any; getContractAbiEvents(address: string): any; getTransaction(transactionHash: string): Promise; methods(...args: any): Promise; privateKey: string; recoverSigner(msg: string, signature: string): Promise; registerAbi(abi: any[] | string, address?: string | string[], handler?: any): string; registerAbiContracts(abiHash: string, address: string | string[], handler?: any): any; send(to: string, amount: number): Promise; _send(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; scanEvents(fromBlock: number, toBlock?: number | string, topics?: any, events?: any, address?: string | string[]): Promise; scanEvents(params: { fromBlock: number; toBlock?: number | string; topics?: any; events?: any; address?: string | string[]; }): Promise; signMessage(msg: string): Promise; signTransaction(tx: any, privateKey?: string): Promise; soliditySha3(...val: any[]): string; toChecksumAddress(address: string): string; isAddress(address: string): boolean; tokenInfo(address: string): Promise; _txData(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; _txObj(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; utils: IWalletUtils; verifyMessage(account: string, msg: string, signature: string): Promise; multiCall(calls: { to: string; data: string; }[], gasBuffer?: string): Promise<{ results: string[]; lastSuccessIndex: BigNumber; }>; doMulticall(contracts: IMulticallContractCall[], gasBuffer?: string): Promise; encodeFunctionCall>(contract: T, methodName: F, params: string[]): string; decodeAbiEncodedParameters>(contract: T, methodName: F, hexString: string): any; } export interface IClientWallet extends IWallet { init(): Promise; blockGasLimit(): Promise; clientSideProvider: IClientSideProvider; initClientWallet(config: IClientWalletConfig): void; connect(clientSideProvider: IClientSideProvider, eventPayload?: Record): Promise; disconnect(): Promise; getGasPrice(): Promise; getTransaction(transactionHash: string): Promise; getTransactionReceipt(transactionHash: string): Promise; isConnected: boolean; provider: any; registerEvent(abi: any, eventMap: { [topics: string]: any; }, address: string, handler: any): any; registerSendTxEvents(eventsOptions: ISendTxEventsOptions): void; sendSignedTransaction(signedTransaction: string): Promise; sendTransaction(transaction: Transaction): Promise; signTypedDataV4(data: TypedMessage): Promise; switchNetwork(chainId: number): Promise; transactionCount(): Promise; getNetworkInfo(chainId: number): INetwork; setNetworkInfo(network: INetwork): void; setMultipleNetworksInfo(networks: INetwork[]): void; registerWalletEvent(sender: any, event: string, callback: Function): IEventBusRegistry; unregisterWalletEvent(registry: IEventBusRegistry): void; unregisterAllWalletEvents(): void; destoryRpcWalletInstance(instanceId: string): void; initRpcWallet(config: IRpcWalletConfig): string; encrypt: (key: string) => Promise; decrypt: (data: string) => Promise; } export interface IRpcWallet extends IWallet { init(): Promise; instanceId: string; isConnected: boolean; switchNetwork(chainId: number): Promise; registerWalletEvent(sender: any, event: string, callback: Function): IEventBusRegistry; unregisterAllWalletEvents(): void; unregisterWalletEvent(registry: IEventBusRegistry): void; } export interface IContractMethod { call: any; estimateGas(...params: any[]): Promise; encodeABI(): string; } export interface IContract { deploy(params: { data: string; arguments?: any[]; }): IContractMethod; methods: { [methodName: string]: (...params: any[]) => IContractMethod; }; options: { address: string; }; } export interface Event { name: string; address: string; blockNumber: bigint; logIndex: bigint; topics: string[]; transactionHash: string; transactionIndex: bigint; data: any; rawData: any; } export interface Log { address: string; data: string; topics: Array; logIndex: bigint; transactionHash?: string; transactionIndex: bigint; blockHash?: string; type?: string; blockNumber: bigint; } export interface EventLog { event: string; address: string; returnValues: any; logIndex: bigint; transactionIndex: bigint; transactionHash: string; blockHash: string; blockNumber: bigint; raw?: { data: string; topics: string[]; }; } export interface Transaction { from?: string; to?: string; nonce?: number; gas?: number; gasLimit?: number; gasPrice?: BigNumber | number; data?: string; value?: BigNumber | number; } export interface TransactionOptions { from?: string; to?: string; nonce?: number; gas?: number; gasLimit?: number; gasPrice?: string | BigNumber | number; data?: string; value?: BigNumber | number | string; } export interface IKMS { } export interface IAccount { address: string; privateKey?: string; kms?: IKMS; sign?(): Promise; signTransaction?(): Promise; } export interface ITokenOption { address: string; symbol: string; decimals: number; image?: string; } export interface INetwork { image?: string; networkCode?: string; networkType?: string; chainId?: number; chainName: string; nativeCurrency: { name: string; symbol: string; decimals: number; }; rpcUrls: string[]; blockExplorerUrls?: string[]; iconUrls?: string[]; } export interface IClientSideProviderEvents { onAccountChanged?: (account: string) => void; onChainChanged?: (chainId: string) => void; onConnect?: (connectInfo: any) => void; onDisconnect?: (error: any) => void; } export interface IMulticallInfo { chainId: number; contractAddress: string; gasBuffer: string; } export type NetworksMapType = { [chainId: number]: INetwork; }; export type MulticallInfoMapType = { [chainId: number]: IMulticallInfo; }; export interface IMulticallContractCall { to: string; contract: IAbiDefinition; methodName: string; params: any[]; } export interface IRpcWalletConfig { networks: INetwork[]; defaultChainId?: number; infuraId: string; multicalls?: IMulticallInfo[]; } export interface IClientWalletConfig { defaultChainId: number; networks: INetwork[]; infuraId: string; multicalls?: IMulticallInfo[]; } export interface IClientProviderOptions { name?: string; image?: string; infuraId?: string; useDefaultProvider?: boolean; [key: string]: any; } export interface IClientSideProvider { name: string; displayName: string; provider: any; selectedAddress: string; image: string; homepage?: string; events?: IClientSideProviderEvents; options?: IClientProviderOptions; installed(): boolean; isConnected(): boolean; connect: (eventPayload?: Record) => Promise; disconnect: () => Promise; switchNetwork?: (chainId: number, onChainChanged?: (chainId: string) => void) => Promise; encrypt: (key: string) => Promise; decrypt: (data: string) => Promise; } export declare class EthereumProvider implements IClientSideProvider { protected wallet: Wallet; protected _events?: IClientSideProviderEvents; protected _options?: IClientProviderOptions; protected _isConnected: boolean; protected _name: string; protected _image: string; protected _selectedAddress: string; onAccountChanged: (account: string) => void; onChainChanged: (chainId: string) => void; onConnect: (connectInfo: any) => void; onDisconnect: (error: any) => void; private handleAccountsChanged; private handleChainChanged; private handleConnect; private handleDisconnect; constructor(wallet: Wallet, events?: IClientSideProviderEvents, options?: IClientProviderOptions); get name(): string; get displayName(): string; get provider(): any; get image(): string; installed(): boolean; get events(): IClientSideProviderEvents; get options(): IClientProviderOptions; get selectedAddress(): string; protected toChecksumAddress(address: string): string; protected removeListeners(): void; private _handleAccountsChanged; protected initEvents(): void; connect(eventPayload?: IConnectWalletEventPayload): Promise; disconnect(): Promise; isConnected(): boolean; addToken(option: ITokenOption, type?: string): Promise; switchNetwork(chainId: number): Promise; encrypt(key: string): Promise; decrypt(data: string): Promise; } export declare class MetaMaskProvider extends EthereumProvider { get displayName(): string; get image(): string; get homepage(): string; installed(): boolean; encrypt(key: string): Promise; decrypt(data: string): Promise; } export declare class Web3ModalProvider extends EthereumProvider { private _provider; constructor(wallet: Wallet, events?: IClientSideProviderEvents, options?: IClientProviderOptions); get name(): string; get displayName(): string; get provider(): any; get image(): string; get homepage(): any; installed(): boolean; get options(): IClientProviderOptions; private initializeWeb3Modal; connect(eventPayload?: IConnectWalletEventPayload): Promise; disconnect(): Promise; } export interface ISendTxEventsOptions { transactionHash?: (error: Error, receipt?: string) => void; confirmation?: (receipt: any) => void; } export declare class Wallet implements IClientWallet { protected _ethersProvider: any; protected _ethersSigner: any; protected _defaultAccount: string; protected _account: IAccount; private _accounts; protected _provider: any; private _eventTopicAbi; private _eventHandler; protected _sendTxEventHandler: ISendTxEventsOptions; protected _contracts: {}; protected _blockGasLimit: number; private _networksMap; private _multicallInfoMap; chainId: number; clientSideProvider: IClientSideProvider; private _infuraId; protected _utils: IWalletUtils; private static _rpcWalletPoolMap; protected _walletEventIds: Set; constructor(provider?: any, account?: IAccount | IAccount[]); private static readonly instance; static getInstance(): IWallet; static getClientInstance(): IClientWallet; static getRpcWalletInstance(instanceId: string): IRpcWallet; private fromWei; private toWei; private hexToUtf8; private toUtf8; init(): Promise; protected privateKeyToAccount(privateKey: string): IAccount; get isConnected(): boolean; switchNetwork(chainId: number): Promise; initClientWallet(config: IClientWalletConfig): void; registerWalletEvent(sender: any, event: string, callback: Function): IEventBusRegistry; unregisterWalletEvent(registry: IEventBusRegistry): void; unregisterAllWalletEvents(): void; destoryRpcWalletInstance(instanceId: string): void; private generateUUID; initRpcWallet(config: IRpcWalletConfig): string; setDefaultProvider(): void; connect(clientSideProvider: IClientSideProvider, eventPayload?: IConnectWalletEventPayload): Promise; disconnect(): Promise; encrypt(key: string): Promise; decrypt(data: string): Promise; get accounts(): Promise; get address(): string; get account(): IAccount; set account(value: IAccount); get infuraId(): string; set infuraId(value: string); get networksMap(): NetworksMapType; get multicallInfoMap(): MulticallInfoMapType; set multicallInfoMap(value: MulticallInfoMapType); getNetworkInfo(chainId: number): INetwork; setNetworkInfo(network: INetwork): void; setMultipleNetworksInfo(networks: INetwork[]): void; createAccount(): IAccount; decodeLog(inputs: any, hexString: string, topics: any): any; get defaultAccount(): string; set defaultAccount(address: string); getChainId(): Promise; get provider(): any; set provider(value: any); sendSignedTransaction(tx: string): Promise; signTransaction(tx: any, privateKey?: string): Promise; registerSendTxEvents(eventsOptions: ISendTxEventsOptions): void; _call(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; protected _createTxData(signer: any, abiHash: string, address: string, methodName: string, params?: any[]): Promise; protected _createTxObj(address: string, txData: any, options?: number | BigNumber | TransactionOptions): Promise; _txObj(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; protected getSigner(): Promise; protected extractEthersErrorInfo(errorString: string): { action: string; reason: string; errorCode: number; message: string; }; _send(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; _txData(abiHash: string, address: string, methodName: string, params?: any[], options?: number | BigNumber | TransactionOptions): Promise; methods(...args: any): Promise; get balance(): Promise; balanceOf(address: string): Promise; recoverSigner(msg: string, signature: string): Promise; getBlock(blockHashOrBlockNumber?: number | string, returnTransactionObjects?: boolean): Promise; getBlockNumber(): Promise; getBlockTimestamp(blockHashOrBlockNumber?: number | string): Promise; set privateKey(value: string); private sha3; registerEvent(abi: any, eventMap: { [topics: string]: any; }, address: string, handler: any): Promise; private _abiHashDict; private _abiContractDict; private _abiAddressDict; private _abiEventDict; getAbiEvents(abi: any[]): any; getAbiTopics(abi: any[], eventNames?: string[]): any[]; getContractAbi(address: string): any; getContractAbiEvents(address: string): any; registerAbi(abi: any[] | string, address?: string | string[], handler?: any): string; registerAbiContracts(abiHash: string, address: string | string[], handler?: any): void; decode(abi: any, event: Log | EventLog, raw?: { data: string; topics: string[]; }): Event; decodeEventData(data: Log, events?: any): Promise; encodeParameters(types: string[], values: any[]): string; decodeParameters(types: string[], hexString: string): any; scanEvents(params: { fromBlock: number; toBlock?: number | string; topics?: any; events?: any; address?: string | string[]; }): Promise; scanEvents(fromBlock: number, toBlock?: number | string, topics?: any, events?: any, address?: string | string[]): Promise; send(to: string, amount: number | BigNumber): Promise; estimateGas(tx: TransactionOptions): Promise; setBlockTime(time: number): Promise; increaseBlockTime(value: number): Promise; signMessage(msg: string): Promise; signTypedDataV4(data: TypedMessage): Promise; recoverTypedSignatureV4(data: TypedMessage, signature: string): Promise; token(tokenAddress: string, decimals?: number): Erc20; tokenInfo(tokenAddress: string): Promise; get utils(): IWalletUtils; verifyMessage(account: string, msg: string, signature: string): Promise; private _gasLimit; blockGasLimit(): Promise; getGasPrice(): Promise; transactionCount(): Promise; private monitorTransactionEvents; protected convertEthersTransactionReceipt(ethersReceipt: any): TransactionReceipt; sendTransaction(transaction: TransactionOptions): Promise; getTransaction(transactionHash: string): Promise; getTransactionReceipt(transactionHash: string): Promise; call(transaction: Transaction): Promise; decodeErrorMessage(msg: string): string; protected inferSolidityType(value: any): string; soliditySha3(...val: any[]): string; toChecksumAddress(address: string): string; isAddress(address: string): boolean; multiCall(calls: { to: string; data: string; }[], gasBuffer?: string): Promise<{ results: string[]; lastSuccessIndex: BigNumber; }>; doMulticall(contracts: IMulticallContractCall[], gasBuffer?: string): Promise; encodeFunctionCall>(contract: T, methodName: F, params: string[]): string; decodeAbiEncodedParameters>(contract: T, methodName: F, hexString: string): any; } export declare class RpcWallet extends Wallet implements IRpcWallet { static rpcWalletRegistry: Record; instanceId: string; private _address; get address(): string; set address(value: string); setProvider(provider: any): void; get isConnected(): boolean; static getRpcWallet(chainId: number): IRpcWallet; switchNetwork(chainId: number): Promise; initWalletEvents(): void; registerWalletEvent(sender: any, event: string, callback: Function): IEventBusRegistry; }