@ledgerhq/hw-app-starknet
Version:
Ledger Hardware Wallet Starknet Application API
2 lines (1 loc) • 1.05 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./node_modules/.pnpm/bn.js@5.2.1/node_modules/bn.js/lib/bn.cjs"),c=require("starknet"),u=2147483648;function h(e){if(!e.startsWith("m/2645"))throw new Error("Path should start with 'm/2645' (e.g 'm/2645'/1195502025'/1148870696'/0'/0'/0')");const i=e.split("/"),a=new Uint8Array((i.length-1)*4),f=new DataView(a.buffer);for(let r=1;r<i.length;r+=1){let n=0,t=i[r];t.endsWith("'")&&(n+=u,t=t.slice(0,-1));const o=Number(t);if(Number.isNaN(o))throw new Error(`Invalid path : ${t} is not a number.`);if(o>=u)throw new Error("Incorrect child value (bigger or equal to 0x80000000)");n+=o,f.setUint32(4*(r-1),n)}return a}function l(e){return/^0x[0-9a-f]*$/i.test(e)}function w(e){if(typeof e=="bigint"||typeof e=="number")return new s(e.toString());if(typeof e=="string")return e=e.toLowerCase(),l(e)?new s(c.encode.removeHexPrefix(e),"hex"):new s(e);throw new Error("Invalid input type for sanitizeHexBN")}exports.isHex=l;exports.serializePath=h;exports.toBN=w;