UNPKG

@metamask/eth-ledger-bridge-keyring

Version:
58 lines 1.82 kB
function $importDefault(module) { if (module?.__esModule) { return module.default; } return module; } import $LedgerHwAppEth from "@ledgerhq/hw-app-eth"; const LedgerHwAppEth = $importDefault($LedgerHwAppEth); import { Buffer } from "buffer"; export class MetaMaskLedgerHwAppEth extends LedgerHwAppEth { constructor() { super(...arguments); this.mainAppName = 'BOLOS'; this.ethAppName = 'Ethereum'; this.transportEncoding = 'ascii'; } /** * Method to open ethereum application on ledger device. * */ async openEthApp() { await this.transport.send(0xe0, 0xd8, 0x00, 0x00, Buffer.from(this.ethAppName, this.transportEncoding)); } /** * Method to close all running application on ledger device. * */ async closeApps() { await this.transport.send(0xb0, 0xa7, 0x00, 0x00); } /** * Method to retrieve the name and version of the running application in ledger device. * * @returns An object contains appName and version. */ async getAppNameAndVersion() { const response = await this.transport.send(0xb0, 0x01, 0x00, 0x00); if (response[0] !== 1) { throw new Error('Incorrect format return from getAppNameAndVersion.'); } let i = 1; const nameLength = response[i] ?? 0; i += 1; const appName = response .slice(i, (i += nameLength)) .toString(this.transportEncoding); const versionLength = response[i] ?? 0; i += 1; const version = response .slice(i, (i += versionLength)) .toString(this.transportEncoding); return { appName, version, }; } } //# sourceMappingURL=ledger-hw-app.mjs.map