@web3-vue-org2/math-wallet
Version:
64 lines (63 loc) • 2.72 kB
TypeScript
import type { Actions, AddEthereumChainParameter, Provider } from '@web3-vue-org2/types';
import { Connector } from '@web3-vue-org2/types';
type MathWalletProvider = Provider & {
isMathWallet?: boolean;
isConnected?: () => boolean;
wallet_addEthereumChain: (data: {
params: [any];
}) => void;
get chainId(): string;
};
declare global {
interface Window {
ethereum?: MathWalletProvider;
}
}
export declare class NoMathWalletError extends Error {
constructor();
}
export declare class NoMathAddressError extends Error {
constructor();
}
/**
* @param onError - Handler to report errors thrown from eventListeners.
*/
export interface MathWalletConstructorArgs {
actions: Actions;
onError?: (error: Error) => void;
}
export declare class MathWallet extends Connector {
/** {@inheritdoc Connector.provider} */
provider?: MathWalletProvider;
private eagerConnection?;
constructor({ actions, onError }: MathWalletConstructorArgs);
private onConnect;
private onDisconnect;
private onChainChanged;
private onAccountsChanged;
private isomorphicInitialize;
/** {@inheritdoc Connector.connectEagerly} */
connectEagerly(): Promise<void>;
/**
* Initiates a connection.
*
* @param desiredChainIdOrChainParameters - If defined, indicates the desired chain to connect to. If the user is
* already connected to this chain, no additional steps will be taken. Otherwise, the user will be prompted to switch
* to the chain, if one of two conditions is met: either they already have it added in their extension, or the
* argument is of type AddEthereumChainParameter, in which case the user will be prompted to add the chain with the
* specified parameters first, before being prompted to switch.
* @param times activate 方法被循环调用的次数
*/
protected _activate(desiredChainIdOrChainParameters?: number | AddEthereumChainParameter, times?: number): Promise<void>;
/**
* Initiates a connection.
*
* @param desiredChainIdOrChainParameters - If defined, indicates the desired chain to connect to. If the user is
* already connected to this chain, no additional steps will be taken. Otherwise, the user will be prompted to switch
* to the chain, if one of two conditions is met: either they already have it added in their extension, or the
* argument is of type AddEthereumChainParameter, in which case the user will be prompted to add the chain with the
* specified parameters first, before being prompted to switch.
*/
activate(desiredChainIdOrChainParameters?: number | AddEthereumChainParameter): Promise<void>;
}
export {};