UNPKG

@dapplets/dapplet-extension

Version:
148 lines (147 loc) 5.87 kB
import * as ethers from 'ethers'; import * as NearApi from 'near-api-js'; import ModuleInfo from '../../background/models/moduleInfo'; import VersionInfo from '../../background/models/versionInfo'; import { NotificationPayload } from '../../common/models/notification'; import { LoginRequest, NearNetworks, SandboxEnvironmentVariables } from '../../common/types'; import { IOverlayManager } from '../overlay/interfaces'; import { AppStorage } from './appStorage'; import ConnectedAccounts from './connectedAccounts'; import { Connection, EventDef } from './connection'; import { IEtherneumWallet } from './ethereum/types'; import { EventBus } from './events/eventBus'; import { LoginSession } from './login/login-session'; import { LoginHooks, LoginRequestSettings } from './login/types'; import { State } from './state'; type Abi = any; type OverlayConnection<T> = Connection<T> & { id: string; isOpen(): boolean; close(): void; onClose(callback: () => void): OverlayConnection<T>; useState(state: State<T>): OverlayConnection<T>; }; interface WalletConnection { authMethod: 'ethereum/sepolia' | 'ethereum/xdai' | 'near/testnet' | 'near/mainnet'; isConnected(): Promise<boolean>; connect(): Promise<void>; disconnect(): Promise<void>; } export interface IEthWallet extends IEtherneumWallet, WalletConnection { authMethod: 'ethereum/sepolia' | 'ethereum/xdai'; } export type INearWallet = NearApi.ConnectedWalletAccount & WalletConnection & { authMethod: 'near/testnet' | 'near/mainnet'; }; export declare class Core { utils: typeof ethers.ethers.utils; BigNumber: typeof ethers.ethers.BigNumber; ethers: typeof ethers; near: typeof NearApi; events: EventBus; manifest: VersionInfo; connectedAccounts: ConnectedAccounts; storage: AppStorage; overlayManager: IOverlayManager; connectedAccountsUpdateListener: () => void; walletsUpdateListener: () => void; shareLinkListener: (data: any) => void; actionListener: () => void; homeListener: () => void; private _env; private _loginSesssionsMap; constructor(manifest: VersionInfo, connectedAccounts: ConnectedAccounts, storage: AppStorage, overlayManager: IOverlayManager, env: SandboxEnvironmentVariables, moduleEventBus: EventBus); private _alertOrConfirm; alert(message: string): Promise<void>; confirm(message: string): Promise<boolean>; notify(payloadOrMessage: NotificationPayload | string): Promise<void>; openPage(url: string): Promise<void>; onConnectedAccountsUpdate(listener: () => void): void; onWalletsUpdate(listener: () => void): void; onAction(listener: () => void): void; onHome(listener: () => void): void; onShareLink(listener: (data: any) => void): void; getPreferredConnectedAccountsNetwork(): Promise<NearNetworks>; overlay<T>(cfg: { name: string; url?: string; title: string; source?: string; module?: any; }, eventDef?: EventDef<any>): OverlayConnection<any>; overlay<T>(cfg: { name: string; url?: string; title: string; source?: string; module?: any; }, eventDef?: EventDef<any>): OverlayConnection<T>; overlay<T>(cfg: { name?: string; url: string; title: string; source?: string; module?: any; }, eventDef?: EventDef<any>): OverlayConnection<T>; wallet(cfg: { authMethods: ('ethereum/sepolia' | 'ethereum/xdai')[]; }): Promise<IEthWallet>; wallet(cfg: { authMethods: ('near/testnet' | 'near/mainnet')[]; }): Promise<INearWallet>; wallet(cfg: { authMethods: ('ethereum/sepolia' | 'ethereum/xdai' | 'near/testnet' | 'near/mainnet')[]; }): Promise<IEthWallet | INearWallet>; wallet(cfg: { type: 'ethereum'; network: 'xdai'; username?: string; domainId?: number; fullname?: string; img?: string; }, eventDef?: EventDef<any>, app?: string): Promise<WalletConnection & IEtherneumWallet>; wallet(cfg: { type: 'ethereum'; network: 'sepolia'; username?: string; domainId?: number; fullname?: string; img?: string; }, eventDef?: EventDef<any>, app?: string): Promise<WalletConnection & IEtherneumWallet>; wallet(cfg: { type: 'near'; network: 'testnet'; username?: string; domainId?: number; fullname?: string; img?: string; }, eventDef?: EventDef<any>, app?: string): Promise<WalletConnection & NearApi.ConnectedWalletAccount>; wallet(cfg: { type: 'near'; network: 'mainnet'; username?: string; domainId?: number; fullname?: string; img?: string; }, eventDef?: EventDef<any>, app?: string): Promise<WalletConnection & NearApi.ConnectedWalletAccount>; contract(type: 'ethereum' | 'ethereum/xdai', address: string, options: Abi): Promise<any>; contract(type: 'near', address: string, options: { viewMethods: string[]; changeMethods: string[]; network?: 'mainnet' | 'testnet'; }): Promise<any>; sessions(): Promise<LoginSession[]>; login(request: LoginRequest & LoginHooks, settings?: LoginRequestSettings & LoginHooks): Promise<LoginSession>; login(request: (LoginRequest & LoginHooks)[], settings?: LoginRequestSettings & LoginHooks): Promise<LoginSession[]>; state<T>(defaultState: T, type?: string): State<T>; createShareLink(targetUrl: string, modulePayload: any): string; getManifest(moduleName?: string): Promise<Omit<ModuleInfo, 'interfaces'> & VersionInfo>; connect<T>(cfg: { url: string; }, defaultState: T): Connection<T>; extension: { satisfied: (statement: string) => boolean; }; private _isExtensionVersionSatisfied; } export {};