@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
9 lines (6 loc) • 375 B
text/typescript
export const isNoErrorReturnCode = (code: number): boolean => code === 0x9000;
export const getPath = (path: string): string =>
path && path.substr(0, 2) !== "m/" ? `m/${path}` : path;
export const isError = (r: { returnCode: number; errorMessage?: string }): void => {
if (!isNoErrorReturnCode(r.returnCode)) throw new Error(`${r.returnCode} - ${r.errorMessage}`);
};