@soundsright/chain
Version:
soundsright contracts
39 lines (38 loc) • 1.91 kB
TypeScript
import { Contract, ContractInterface, ethers, providers } from 'ethers';
import Connector from '@soundsright/connector';
import { CheckChainOptions, SignDomain, SignMessageTypes, SignMessageValue } from './types';
export declare abstract class BaseChain {
abstract get provider(): providers.BaseProvider;
abstract getContract(address: string, abi: ContractInterface): Contract;
getBalance(address: string): Promise<string>;
tryGet(txPromise: Promise<any>): Promise<any>;
checkTransaction(tx: any): Promise<boolean>;
tryTransaction(txPromise: Promise<any>): Promise<any>;
}
export declare class ProviderChain extends BaseChain {
chainId: number;
protected localProvider: providers.BaseProvider;
get provider(): ethers.providers.BaseProvider;
constructor(chainId: number);
setLocalProvider(chainId?: number): void;
getContract(address: string, abi: ContractInterface): Contract;
}
export declare class ConnectorChain extends BaseChain {
supportedChainId?: number;
connector: Connector;
get provider(): ethers.providers.BaseProvider;
get signer(): ethers.Signer;
get account(): string;
get chainId(): number;
get connectType(): import("@soundsright/connector").ConnectType;
constructor(supportedChainId?: number);
checkConnected(): void;
switchChain(chainId: number): Promise<void>;
getContract(address: string, abi: ContractInterface): Contract;
getUncheckedContract(address: string, abi: ContractInterface): Contract;
setSupportedChainId(chainId: number): void;
checkChain({ beforeSwitchChain, switchChainSuccess, switchChainFailed }?: CheckChainOptions): Promise<void>;
signMessage(message: string): Promise<string>;
signTypedMessage(domain: SignDomain, types: SignMessageTypes, value: SignMessageValue): any;
getBalance(address?: string): Promise<string>;
}