UNPKG

@aeternity/aepp-sdk

Version:

SDK for the æternity blockchain

59 lines (58 loc) 2.36 kB
import type { BaseProvider } from '@metamask/providers'; import AccountBaseFactory from './BaseFactory.js'; import AccountMetamask, { snapId } from './Metamask.js'; interface SnapDetails { blocked: boolean; enabled: boolean; id: typeof snapId; version: string; initialPermissions: Record<string, unknown>; } /** * A factory class that generates instances of AccountMetamask. * @see {@link https://www.npmjs.com/package/@aeternity-snap/plugin | Aeternity snap} * @category account */ export default class AccountMetamaskFactory extends AccountBaseFactory { #private; /** * @deprecated this class is not intended to provide raw access to the provider */ get provider(): BaseProvider; /** * @param provider - Connection to MetaMask to use */ constructor(provider?: BaseProvider); /** * Request MetaMask to install Aeternity snap. * @deprecated use `requestSnap` instead */ installSnap(): Promise<SnapDetails>; /** * Request MetaMask to install Aeternity snap or connect it to the current aepp. * MetaMask can have only one Aeternity snap version installed at a time. * This method is intended to upgrade the snap to a specified version if needed by the aepp. * If Aeternity snap is installed but wasn't used by the aepp, then the user still needs to approve the connection. * If the currently installed version corresponds to the version range, then the snap won't be upgraded. * To downgrade the snap, the user must manually uninstall the current version. * @param version - Snap version range (e.g. `1`, `0.1.*`, `^0.0.9`, `~0.0.9`; `>=0.0.9 <0.1.0`) * (default: a version range supported by sdk) */ requestSnap(version?: string): Promise<SnapDetails>; /** * It throws an exception if MetaMask or Aeternity snap has an incompatible version or is not * installed or is not connected to the aepp. * @deprecated use `requestSnap` instead */ ensureReady(): Promise<void>; /** * @returns the version of snap installed in MetaMask */ getSnapVersion(): Promise<string>; /** * Get an instance of AccountMetaMask for a given account index. * @param accountIndex - Index of account */ initialize(accountIndex: number): Promise<AccountMetamask>; } export {};