@metamask/eth-ledger-bridge-keyring
Version:
A MetaMask compatible keyring, for ledger hardware wallets
1 lines • 1.31 kB
Source Map (JSON)
{"version":3,"file":"mock-error.mjs","sourceRoot":"","sources":["../../../src/dmk/__testhelpers__/mock-error.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,iDAA6C;AAEjF;;;;;;;;;GASG;AACH,MAAM,UAAU,6BAA6B,CAC3C,SAAqB;IAErB,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,cAAc,MAAM,CAAC,SAAS,CAAC,EAAE;QAC1C,SAAS;QACT,aAAa,EAAE,SAAS;KACqB,CAAC;AAClD,CAAC","sourcesContent":["import type { DeviceExchangeError } from '@ledgerhq/device-management-kit';\n\nimport { ETH_APP_COMMAND_ERROR_TAG } from '../eth-get-app-configuration-command';\n\n/**\n * Construct a mock {@link DeviceExchangeError} for tests.\n *\n * The DMK `DeviceExchangeError` is normally raised inside the DMK runtime;\n * tests need a structurally-equivalent value without going through DMK.\n * This helper centralises the cast so test files don't each roll their own.\n *\n * @param errorCode - The hex error code to embed (e.g. `'6985'`).\n * @returns A mock `DeviceExchangeError<TErrorCode>`.\n */\nexport function createMockDeviceExchangeError<TErrorCode = string>(\n errorCode: TErrorCode,\n): DeviceExchangeError<TErrorCode> {\n return {\n _tag: ETH_APP_COMMAND_ERROR_TAG,\n message: `DMK error: ${String(errorCode)}`,\n errorCode,\n originalError: undefined,\n } as unknown as DeviceExchangeError<TErrorCode>;\n}\n"]}