@swaptoshi/dex-module
Version:
Klayr decentralized exchange (dex) on-chain module
36 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.slice = slice;
exports.toAddress = toAddress;
exports.toUint24 = toUint24;
function slice(_bytes, _start, _length) {
if (_length + 31 < _length || _start + _length < _start) {
throw new Error('slice_overflow');
}
if (_bytes.length < _start + _length) {
throw new Error('slice_outOfBounds');
}
return _bytes.subarray(_start, _length + _start);
}
function toAddress(_bytes, _start) {
if (_start + 8 < _start) {
throw new Error('toAddress_overflow');
}
if (_bytes.length < _start + 8) {
throw new Error('toAddress_outOfBounds');
}
const tempAddressBytes = _bytes.subarray(_start, _start + 8);
return tempAddressBytes;
}
function toUint24(_bytes, _start) {
if (_start + 3 < _start) {
throw new Error('toUint24_overflow');
}
if (_bytes.length < _start + 3) {
throw new Error('toUint24_outOfBounds');
}
const tempUintBytes = _bytes.subarray(_start, _start + 3);
const tempUint = tempUintBytes.readUIntBE(0, 3);
return tempUint;
}
//# sourceMappingURL=bytes_lib.js.map