UNPKG

@okxweb3/coin-stellar

Version:

@okxweb3/coin-stellar is a Stellar SDK for building Web3 wallets and applications. It supports Stellar and PI blockchains, enabling private key management, address generation, transaction signing, trustline creation, and asset transfers

35 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ScInt = void 0; const xdr_large_int_1 = require("./xdr_large_int"); class ScInt extends xdr_large_int_1.XdrLargeInt { constructor(value, opts) { var _a; const signed = value < 0; let type = (_a = opts === null || opts === void 0 ? void 0 : opts.type) !== null && _a !== void 0 ? _a : ''; if (type.startsWith('u') && signed) { throw TypeError(`specified type ${opts.type} yet negative (${value})`); } if (type === '') { type = signed ? 'i' : 'u'; const bitlen = nearestBigIntSize(value); switch (bitlen) { case 64: case 128: case 256: type += bitlen.toString(); break; default: throw RangeError(`expected 64/128/256 bits for input (${value}), got ${bitlen}`); } } super(type, value); } } exports.ScInt = ScInt; function nearestBigIntSize(bigI) { var _a; const bitlen = bigI.toString(2).length; return (_a = [64, 128, 256].find((len) => bitlen <= len)) !== null && _a !== void 0 ? _a : bitlen; } //# sourceMappingURL=sc_int.js.map