Socket
Socket
Sign inDemoInstall

ripple-binary-codec

Package Overview
Dependencies
Maintainers
4
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ripple-binary-codec - npm Package Compare versions

Comparing version 1.0.4-beta.0 to 1.0.4-beta.1

dist/index.js.LICENSE.txt

2

dist/binary.d.ts

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { BinaryParser } from "./serdes/binary-parser";

@@ -7,2 +6,3 @@ import { AccountID } from "./types/account-id";

import { JsonObject } from "./types/serialized-type";
import { Buffer } from "buffer/";
/**

@@ -9,0 +9,0 @@ * Construct a BinaryParser

@@ -1,3 +0,3 @@

/// <reference types="node" />
import { SerializedType } from "../types/serialized-type";
import { Buffer } from "buffer/";
declare class Bytes {

@@ -4,0 +4,0 @@ readonly name: string;

@@ -6,2 +6,3 @@ "use strict";

var serialized_type_1 = require("../types/serialized-type");
var buffer_1 = require("buffer/");
var TYPE_WIDTH = 2;

@@ -30,3 +31,3 @@ var LEDGER_ENTRY_WIDTH = 2;

}
return Buffer.from(header);
return buffer_1.Buffer.from(header);
}

@@ -41,3 +42,3 @@ /*

this.ordinalWidth = ordinalWidth;
this.bytes = Buffer.alloc(ordinalWidth);
this.bytes = buffer_1.Buffer.alloc(ordinalWidth);
for (var i = 0; i < ordinalWidth; i++) {

@@ -44,0 +45,0 @@ this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
/**

@@ -3,0 +3,0 @@ * Maps HashPrefix names to their byte representation

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HashPrefix = void 0;
var buffer_1 = require("buffer/");
/**

@@ -11,4 +12,4 @@ * Write a 32 bit integer to a Buffer

function bytes(uint32) {
var result = Buffer.alloc(4);
result.writeUInt32BE(uint32);
var result = buffer_1.Buffer.alloc(4);
result.writeUInt32BE(uint32, 0);
return result;

@@ -15,0 +16,0 @@ }

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { Hash256 } from "./types/hash-256";
import { BytesList } from "./serdes/binary-serializer";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Class for hashing with SHA512

@@ -1,3 +0,3 @@

/// <reference types="node" />
import { Decimal } from "decimal.js";
import { Buffer } from "buffer/";
/**

@@ -4,0 +4,0 @@ * class for encoding and decoding quality

@@ -7,2 +7,3 @@ "use strict";

var bigInt = require("big-integer");
var buffer_1 = require("buffer/");
/**

@@ -35,3 +36,3 @@ * class for encoding and decoding quality

quality.decode = function (quality) {
var bytes = Buffer.from(quality, "hex").slice(-8);
var bytes = buffer_1.Buffer.from(quality, "hex").slice(-8);
var exponent = bytes[0] - 100;

@@ -38,0 +39,0 @@ var mantissa = new decimal_js_1.Decimal("0x" + bytes.slice(1).toString("hex"));

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { FieldInstance } from "../enums";
import { SerializedType } from "../types/serialized-type";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * BinaryParser is used to compute fields and values from a HexString

@@ -6,2 +6,3 @@ "use strict";

var enums_1 = require("../enums");
var buffer_1 = require("buffer/");
/**

@@ -17,3 +18,3 @@ * BinaryParser is used to compute fields and values from a HexString

function BinaryParser(hexBytes) {
this.bytes = Buffer.from(hexBytes, "hex");
this.bytes = buffer_1.Buffer.from(hexBytes, "hex");
}

@@ -20,0 +21,0 @@ /**

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { FieldInstance } from "../enums";
import { SerializedType } from "../types/serialized-type";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Bytes list is a collection of buffer objects

@@ -5,2 +5,3 @@ "use strict";

var assert = require("assert");
var buffer_1 = require("buffer/");
/**

@@ -19,3 +20,3 @@ * Bytes list is a collection of buffer objects

BytesList.prototype.getLength = function () {
return Buffer.concat(this.bytesArray).byteLength;
return buffer_1.Buffer.concat(this.bytesArray).byteLength;
};

@@ -29,3 +30,3 @@ /**

BytesList.prototype.put = function (bytesArg) {
var bytes = Buffer.from(bytesArg); // Temporary, to catch instances of Uint8Array being passed in
var bytes = buffer_1.Buffer.from(bytesArg); // Temporary, to catch instances of Uint8Array being passed in
this.bytesArray.push(bytes);

@@ -43,3 +44,3 @@ return this;

BytesList.prototype.toBytes = function () {
return Buffer.concat(this.bytesArray);
return buffer_1.Buffer.concat(this.bytesArray);
};

@@ -99,3 +100,3 @@ BytesList.prototype.toHex = function () {

BinarySerializer.prototype.encodeVariableLength = function (length) {
var lenBytes = Buffer.alloc(3);
var lenBytes = buffer_1.Buffer.alloc(3);
if (length <= 192) {

@@ -102,0 +103,0 @@ lenBytes[0] = length;

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { Hash256 } from "./types/hash-256";
import { BytesList } from "./serdes/binary-serializer";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Abstract class describing a SHAMapNode

@@ -21,2 +21,3 @@ "use strict";

var hashes_1 = require("./hashes");
var buffer_1 = require("buffer/");
/**

@@ -60,3 +61,3 @@ * Abstract class describing a SHAMapNode

ShaMapLeaf.prototype.hashPrefix = function () {
return this.item === undefined ? Buffer.alloc(0) : this.item.hashPrefix();
return this.item === undefined ? buffer_1.Buffer.alloc(0) : this.item.hashPrefix();
};

@@ -63,0 +64,0 @@ /**

@@ -1,3 +0,3 @@

/// <reference types="node" />
import { Hash160 } from "./hash-160";
import { Buffer } from "buffer/";
/**

@@ -4,0 +4,0 @@ * Class defining how to encode and decode an AccountID

@@ -19,2 +19,3 @@ "use strict";

var hash_160_1 = require("./hash-160");
var buffer_1 = require("buffer/");
var HEX_REGEX = /^[A-F0-9]{40}$/;

@@ -44,3 +45,3 @@ /**

return HEX_REGEX.test(value)
? new AccountID(Buffer.from(value, "hex"))
? new AccountID(buffer_1.Buffer.from(value, "hex"))
: this.fromBase58(value);

@@ -57,3 +58,3 @@ }

AccountID.fromBase58 = function (value) {
return new AccountID(ripple_address_codec_1.decodeAccountID(value));
return new AccountID(buffer_1.Buffer.from(ripple_address_codec_1.decodeAccountID(value)));
};

@@ -74,5 +75,7 @@ /**

AccountID.prototype.toBase58 = function () {
/* eslint-disable @typescript-eslint/no-explicit-any */
return ripple_address_codec_1.encodeAccountID(this.bytes);
/* eslint-enable @typescript-eslint/no-explicit-any */
};
AccountID.defaultAccountID = new AccountID(Buffer.alloc(20));
AccountID.defaultAccountID = new AccountID(buffer_1.Buffer.alloc(20));
return AccountID;

@@ -79,0 +82,0 @@ }(hash_160_1.Hash160));

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { BinaryParser } from "../serdes/binary-parser";
import { JsonObject, SerializedType } from "./serialized-type";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Interface for JSON objects that represent amounts

@@ -23,2 +23,3 @@ "use strict";

var bigInt = require("big-integer");
var buffer_1 = require("buffer/");
/**

@@ -69,10 +70,10 @@ * Constants for validating amounts

}
var amount = Buffer.alloc(8);
var amount = buffer_1.Buffer.alloc(8);
if (typeof value === "string") {
Amount.assertXrpIsValid(value);
var number = bigInt(value);
var intBuf = [Buffer.alloc(4), Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(number.shiftRight(32)));
intBuf[1].writeUInt32BE(Number(number.and(mask)));
amount = Buffer.concat(intBuf);
var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(number.shiftRight(32)), 0);
intBuf[1].writeUInt32BE(Number(number.and(mask)), 0);
amount = buffer_1.Buffer.concat(intBuf);
amount[0] |= 0x40;

@@ -93,6 +94,6 @@ return new Amount(amount);

var num = bigInt(integerNumberString);
var intBuf = [Buffer.alloc(4), Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(num.shiftRight(32)));
intBuf[1].writeUInt32BE(Number(num.and(mask)));
amount = Buffer.concat(intBuf);
var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(num.shiftRight(32)), 0);
intBuf[1].writeUInt32BE(Number(num.and(mask)), 0);
amount = buffer_1.Buffer.concat(intBuf);
amount[0] |= 0x80;

@@ -109,3 +110,3 @@ if (number.gt(new decimal_js_1.Decimal(0))) {

var issuer = account_id_1.AccountID.from(value.issuer).toBytes();
return new Amount(Buffer.concat([amount, currency, issuer]));
return new Amount(buffer_1.Buffer.concat([amount, currency, issuer]));
}

@@ -136,4 +137,4 @@ throw new Error("Invalid type to construct an Amount");

bytes[0] &= 0x3f;
var msb = bigInt(bytes.slice(0, 4).readUInt32BE());
var lsb = bigInt(bytes.slice(4).readUInt32BE());
var msb = bigInt(bytes.slice(0, 4).readUInt32BE(0));
var lsb = bigInt(bytes.slice(4).readUInt32BE(0));
var num = msb.shiftLeft(32).or(lsb);

@@ -222,3 +223,3 @@ return "" + sign + num.toString();

};
Amount.defaultAmount = new Amount(Buffer.from("4000000000000000", "hex"));
Amount.defaultAmount = new Amount(buffer_1.Buffer.from("4000000000000000", "hex"));
return Amount;

@@ -225,0 +226,0 @@ }(serialized_type_1.SerializedType));

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { SerializedType } from "./serialized-type";
import { BinaryParser } from "../serdes/binary-parser";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Variable length encoded type

@@ -18,2 +18,3 @@ "use strict";

var serialized_type_1 = require("./serialized-type");
var buffer_1 = require("buffer/");
/**

@@ -48,3 +49,3 @@ * Variable length encoded type

if (typeof value === "string") {
return new Blob(Buffer.from(value, "hex"));
return new Blob(buffer_1.Buffer.from(value, "hex"));
}

@@ -51,0 +52,0 @@ throw new Error("Cannot construct Blob from value given");

@@ -1,3 +0,3 @@

/// <reference types="node" />
import { Hash160 } from "./hash-160";
import { Buffer } from "buffer/";
/**

@@ -4,0 +4,0 @@ * Class defining how to encode and decode Currencies

@@ -18,2 +18,3 @@ "use strict";

var hash_160_1 = require("./hash-160");
var buffer_1 = require("buffer/");
var ISO_REGEX = /^[A-Z0-9]{3}$/;

@@ -25,3 +26,3 @@ var HEX_REGEX = /^[A-F0-9]{40}$/;

function isoToBytes(iso) {
var bytes = Buffer.alloc(20);
var bytes = buffer_1.Buffer.alloc(20);
if (iso !== "XRP") {

@@ -61,3 +62,3 @@ var isoBytes = iso.split("").map(function (c) { return c.charCodeAt(0); });

function isValidRepresentation(input) {
return input instanceof Buffer
return input instanceof buffer_1.Buffer
? isBytesArray(input)

@@ -73,3 +74,3 @@ : isStringRepresentation(input);

}
return input.length === 3 ? isoToBytes(input) : Buffer.from(input, "hex");
return input.length === 3 ? isoToBytes(input) : buffer_1.Buffer.from(input, "hex");
}

@@ -140,3 +141,3 @@ /**

};
Currency.XRP = new Currency(Buffer.alloc(20));
Currency.XRP = new Currency(buffer_1.Buffer.alloc(20));
return Currency;

@@ -143,0 +144,0 @@ }(hash_160_1.Hash160));

@@ -1,3 +0,3 @@

/// <reference types="node" />
import { Hash } from "./hash";
import { Buffer } from "buffer/";
/**

@@ -4,0 +4,0 @@ * Hash with a width of 128 bits

@@ -18,2 +18,3 @@ "use strict";

var hash_1 = require("./hash");
var buffer_1 = require("buffer/");
/**

@@ -28,3 +29,3 @@ * Hash with a width of 128 bits

Hash128.width = 16;
Hash128.ZERO_128 = new Hash128(Buffer.alloc(Hash128.width));
Hash128.ZERO_128 = new Hash128(buffer_1.Buffer.alloc(Hash128.width));
return Hash128;

@@ -31,0 +32,0 @@ }(hash_1.Hash));

@@ -1,3 +0,3 @@

/// <reference types="node" />
import { Hash } from "./hash";
import { Buffer } from "buffer/";
/**

@@ -4,0 +4,0 @@ * Hash with a width of 160 bits

@@ -18,2 +18,3 @@ "use strict";

var hash_1 = require("./hash");
var buffer_1 = require("buffer/");
/**

@@ -33,3 +34,3 @@ * Hash with a width of 160 bits

Hash160.width = 20;
Hash160.ZERO_160 = new Hash160(Buffer.alloc(Hash160.width));
Hash160.ZERO_160 = new Hash160(buffer_1.Buffer.alloc(Hash160.width));
return Hash160;

@@ -36,0 +37,0 @@ }(hash_1.Hash));

@@ -1,3 +0,3 @@

/// <reference types="node" />
import { Hash } from "./hash";
import { Buffer } from "buffer/";
/**

@@ -4,0 +4,0 @@ * Hash with a width of 256 bits

@@ -18,2 +18,3 @@ "use strict";

var hash_1 = require("./hash");
var buffer_1 = require("buffer/");
/**

@@ -28,3 +29,3 @@ * Hash with a width of 256 bits

Hash256.width = 32;
Hash256.ZERO_256 = new Hash256(Buffer.alloc(Hash256.width));
Hash256.ZERO_256 = new Hash256(buffer_1.Buffer.alloc(Hash256.width));
return Hash256;

@@ -31,0 +32,0 @@ }(hash_1.Hash));

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { Comparable } from "./serialized-type";
import { BinaryParser } from "../serdes/binary-parser";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Base class defining how to encode and decode hashes

@@ -18,2 +18,3 @@ "use strict";

var serialized_type_1 = require("./serialized-type");
var buffer_1 = require("buffer/");
/**

@@ -41,3 +42,3 @@ * Base class defining how to encode and decode hashes

if (typeof value === "string") {
return new this(Buffer.from(value, "hex"));
return new this(buffer_1.Buffer.from(value, "hex"));
}

@@ -61,3 +62,3 @@ throw new Error("Cannot construct Hash from given value");

Hash.prototype.compareTo = function (other) {
return Buffer.compare(this.bytes, this.constructor.from(other).bytes);
return this.bytes.compare(this.constructor.from(other).bytes);
};

@@ -64,0 +65,0 @@ /**

@@ -21,2 +21,3 @@ "use strict";

var serialized_type_1 = require("./serialized-type");
var buffer_1 = require("buffer/");
/**

@@ -67,3 +68,3 @@ * Constants for separating Paths in a PathSet

}
var bytes = [Buffer.from([0])];
var bytes = [buffer_1.Buffer.from([0])];
if (value.account) {

@@ -81,3 +82,3 @@ bytes.push(account_id_1.AccountID.from(value.account).toBytes());

}
return new Hop(Buffer.concat(bytes));
return new Hop(buffer_1.Buffer.concat(bytes));
};

@@ -92,3 +93,3 @@ /**

var type = parser.readUInt8();
var bytes = [Buffer.from([type])];
var bytes = [buffer_1.Buffer.from([type])];
if (type & TYPE_ACCOUNT) {

@@ -103,3 +104,3 @@ bytes.push(parser.read(account_id_1.AccountID.width));

}
return new Hop(Buffer.concat(bytes));
return new Hop(buffer_1.Buffer.concat(bytes));
};

@@ -162,3 +163,3 @@ /**

});
return new Path(Buffer.concat(bytes));
return new Path(buffer_1.Buffer.concat(bytes));
};

@@ -180,3 +181,3 @@ /**

}
return new Path(Buffer.concat(bytes));
return new Path(buffer_1.Buffer.concat(bytes));
};

@@ -220,6 +221,6 @@ /**

bytes_1.push(Path.from(path).toBytes());
bytes_1.push(Buffer.from([PATH_SEPARATOR_BYTE]));
bytes_1.push(buffer_1.Buffer.from([PATH_SEPARATOR_BYTE]));
});
bytes_1[bytes_1.length - 1] = Buffer.from([PATHSET_END_BYTE]);
return new PathSet(Buffer.concat(bytes_1));
bytes_1[bytes_1.length - 1] = buffer_1.Buffer.from([PATHSET_END_BYTE]);
return new PathSet(buffer_1.Buffer.concat(bytes_1));
}

@@ -243,3 +244,3 @@ throw new Error("Cannot construct PathSet from given value");

}
return new PathSet(Buffer.concat(bytes));
return new PathSet(buffer_1.Buffer.concat(bytes));
};

@@ -246,0 +247,0 @@ /**

@@ -1,5 +0,5 @@

/// <reference types="node" />
import { BytesList } from "../serdes/binary-serializer";
import { BinaryParser } from "../serdes/binary-parser";
import * as bigInt from "big-integer";
import { Buffer } from "buffer/";
declare type JSON = string | number | boolean | null | undefined | JSON[] | JsonObject;

@@ -6,0 +6,0 @@ declare type JsonObject = {

@@ -18,2 +18,3 @@ "use strict";

var binary_serializer_1 = require("../serdes/binary-serializer");
var buffer_1 = require("buffer/");
/**

@@ -24,4 +25,4 @@ * The base class for all binary-codec types

function SerializedType(bytes) {
this.bytes = Buffer.alloc(0);
this.bytes = bytes !== null && bytes !== void 0 ? bytes : Buffer.alloc(0);
this.bytes = buffer_1.Buffer.alloc(0);
this.bytes = bytes !== null && bytes !== void 0 ? bytes : buffer_1.Buffer.alloc(0);
}

@@ -28,0 +29,0 @@ SerializedType.fromParser = function (parser, hint) {

@@ -20,5 +20,6 @@ "use strict";

var binary_parser_1 = require("../serdes/binary-parser");
var ARRAY_END_MARKER = Buffer.from([0xf1]);
var buffer_1 = require("buffer/");
var ARRAY_END_MARKER = buffer_1.Buffer.from([0xf1]);
var ARRAY_END_MARKER_NAME = "ArrayEndMarker";
var OBJECT_END_MARKER = Buffer.from([0xe1]);
var OBJECT_END_MARKER = buffer_1.Buffer.from([0xe1]);
/**

@@ -54,3 +55,3 @@ * TypeGuard for Array<JsonObject>

bytes.push(ARRAY_END_MARKER);
return new STArray(Buffer.concat(bytes));
return new STArray(buffer_1.Buffer.concat(bytes));
};

@@ -73,3 +74,3 @@ /**

bytes_1.push(ARRAY_END_MARKER);
return new STArray(Buffer.concat(bytes_1));
return new STArray(buffer_1.Buffer.concat(bytes_1));
}

@@ -76,0 +77,0 @@ throw new Error("Cannot construct Currency from value given");

@@ -22,3 +22,4 @@ "use strict";

var binary_serializer_1 = require("../serdes/binary-serializer");
var OBJECT_END_MARKER_BYTE = Buffer.from([0xe1]);
var buffer_1 = require("buffer/");
var OBJECT_END_MARKER_BYTE = buffer_1.Buffer.from([0xe1]);
var OBJECT_END_MARKER = "ObjectEndMarker";

@@ -25,0 +26,0 @@ var ST_OBJECT = "STObject";

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { UInt } from "./uint";
import { BinaryParser } from "../serdes/binary-parser";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Derived UInt class for serializing/deserializing 16 bit UInt

@@ -18,2 +18,3 @@ "use strict";

var uint_1 = require("./uint");
var buffer_1 = require("buffer/");
/**

@@ -40,4 +41,4 @@ * Derived UInt class for serializing/deserializing 16 bit UInt

if (typeof val === "number") {
var buf = Buffer.alloc(UInt16.width);
buf.writeUInt16BE(val);
var buf = buffer_1.Buffer.alloc(UInt16.width);
buf.writeUInt16BE(val, 0);
return new UInt16(buf);

@@ -53,6 +54,6 @@ }

UInt16.prototype.valueOf = function () {
return this.bytes.readUInt16BE();
return this.bytes.readUInt16BE(0);
};
UInt16.width = 16 / 8; // 2
UInt16.defaultUInt16 = new UInt16(Buffer.alloc(UInt16.width));
UInt16.defaultUInt16 = new UInt16(buffer_1.Buffer.alloc(UInt16.width));
return UInt16;

@@ -59,0 +60,0 @@ }(uint_1.UInt));

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { UInt } from "./uint";
import { BinaryParser } from "../serdes/binary-parser";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Derived UInt class for serializing/deserializing 32 bit UInt

@@ -18,2 +18,3 @@ "use strict";

var uint_1 = require("./uint");
var buffer_1 = require("buffer/");
/**

@@ -39,10 +40,10 @@ * Derived UInt class for serializing/deserializing 32 bit UInt

}
var buf = Buffer.alloc(UInt32.width);
var buf = buffer_1.Buffer.alloc(UInt32.width);
if (typeof val === "string") {
var num = Number.parseInt(val);
buf.writeUInt32BE(num);
buf.writeUInt32BE(num, 0);
return new UInt32(buf);
}
if (typeof val === "number") {
buf.writeUInt32BE(val);
buf.writeUInt32BE(val, 0);
return new UInt32(buf);

@@ -58,6 +59,6 @@ }

UInt32.prototype.valueOf = function () {
return this.bytes.readUInt32BE();
return this.bytes.readUInt32BE(0);
};
UInt32.width = 32 / 8; // 4
UInt32.defaultUInt32 = new UInt32(Buffer.alloc(UInt32.width));
UInt32.defaultUInt32 = new UInt32(buffer_1.Buffer.alloc(UInt32.width));
return UInt32;

@@ -64,0 +65,0 @@ }(uint_1.UInt));

@@ -1,5 +0,5 @@

/// <reference types="node" />
import { UInt } from "./uint";
import { BinaryParser } from "../serdes/binary-parser";
import * as bigInt from "big-integer";
import { Buffer } from "buffer/";
/**

@@ -6,0 +6,0 @@ * Derived UInt class for serializing/deserializing 64 bit UInt

@@ -20,2 +20,3 @@ "use strict";

var big_integer_1 = require("big-integer");
var buffer_1 = require("buffer/");
var HEX_REGEX = /^[A-F0-9]{16}$/;

@@ -44,3 +45,3 @@ var mask = bigInt(0x00000000ffffffff);

}
var buf = Buffer.alloc(UInt64.width);
var buf = buffer_1.Buffer.alloc(UInt64.width);
if (typeof val === "number") {

@@ -51,6 +52,6 @@ if (val < 0) {

var number = bigInt(val);
var intBuf = [Buffer.alloc(4), Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(number.shiftRight(32)));
intBuf[1].writeUInt32BE(Number(number.and(mask)));
return new UInt64(Buffer.concat(intBuf));
var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(number.shiftRight(32)), 0);
intBuf[1].writeUInt32BE(Number(number.and(mask)), 0);
return new UInt64(buffer_1.Buffer.concat(intBuf));
}

@@ -61,10 +62,10 @@ if (typeof val === "string") {

}
buf = Buffer.from(val, "hex");
buf = buffer_1.Buffer.from(val, "hex");
return new UInt64(buf);
}
if (big_integer_1.isInstance(val)) {
var intBuf = [Buffer.alloc(4), Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(val.shiftRight(bigInt(32))));
intBuf[1].writeUInt32BE(Number(val.and(mask)));
return new UInt64(Buffer.concat(intBuf));
var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
intBuf[0].writeUInt32BE(Number(val.shiftRight(bigInt(32))), 0);
intBuf[1].writeUInt32BE(Number(val.and(mask)), 0);
return new UInt64(buffer_1.Buffer.concat(intBuf));
}

@@ -87,4 +88,4 @@ throw new Error("Cannot construct UInt64 from given value");

UInt64.prototype.valueOf = function () {
var msb = bigInt(this.bytes.slice(0, 4).readUInt32BE());
var lsb = bigInt(this.bytes.slice(4).readUInt32BE());
var msb = bigInt(this.bytes.slice(0, 4).readUInt32BE(0));
var lsb = bigInt(this.bytes.slice(4).readUInt32BE(0));
return msb.shiftLeft(bigInt(32)).or(lsb);

@@ -101,3 +102,3 @@ };

UInt64.width = 64 / 8; // 8
UInt64.defaultUInt64 = new UInt64(Buffer.alloc(UInt64.width));
UInt64.defaultUInt64 = new UInt64(buffer_1.Buffer.alloc(UInt64.width));
return UInt64;

@@ -104,0 +105,0 @@ }(uint_1.UInt));

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { UInt } from "./uint";
import { BinaryParser } from "../serdes/binary-parser";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Derived UInt class for serializing/deserializing 8 bit UInt

@@ -18,2 +18,3 @@ "use strict";

var uint_1 = require("./uint");
var buffer_1 = require("buffer/");
/**

@@ -40,4 +41,4 @@ * Derived UInt class for serializing/deserializing 8 bit UInt

if (typeof val === "number") {
var buf = Buffer.alloc(UInt8.width);
buf.writeUInt8(val);
var buf = buffer_1.Buffer.alloc(UInt8.width);
buf.writeUInt8(val, 0);
return new UInt8(buf);

@@ -53,6 +54,6 @@ }

UInt8.prototype.valueOf = function () {
return this.bytes.readUInt8();
return this.bytes.readUInt8(0);
};
UInt8.width = 8 / 8; // 1
UInt8.defaultUInt8 = new UInt8(Buffer.alloc(UInt8.width));
UInt8.defaultUInt8 = new UInt8(buffer_1.Buffer.alloc(UInt8.width));
return UInt8;

@@ -59,0 +60,0 @@ }(uint_1.UInt));

@@ -1,4 +0,4 @@

/// <reference types="node" />
import * as bigInt from "big-integer";
import { Comparable } from "./serialized-type";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Base class for serializing and deserializing unsigned integers.

@@ -1,4 +0,4 @@

/// <reference types="node" />
import { SerializedType } from "./serialized-type";
import { BinaryParser } from "../serdes/binary-parser";
import { Buffer } from "buffer/";
/**

@@ -5,0 +5,0 @@ * Class for serializing and deserializing vectors of Hash256

{
"name": "ripple-binary-codec",
"version": "1.0.4-beta.0",
"version": "1.0.4-beta.1",
"description": "XRP Ledger binary codec",

@@ -15,3 +15,5 @@ "files": [

"dependencies": {
"assert": "^2.0.0",
"big-integer": "^1.6.48",
"buffer": "5.6.0",
"create-hash": "^1.2.0",

@@ -18,0 +20,0 @@ "decimal.js": "^10.2.0",

@@ -14,2 +14,3 @@ /* eslint-disable func-style */

const { BytesList } = require("../dist/serdes/binary-serializer");
const { Buffer } = require("buffer/");

@@ -16,0 +17,0 @@ const __ = hexOnly;

@@ -9,2 +9,3 @@ /* eslint-disable func-style */

const bigInt = require("big-integer");
const { Buffer } = require("buffer/");

@@ -11,0 +12,0 @@ const { loadFixture } = require("./utils");

const { coreTypes } = require("../dist/types");
const { Hash160, Hash256, AccountID, Currency } = coreTypes;
const { Buffer } = require("buffer/");

@@ -4,0 +5,0 @@ describe("Hash160", function () {

@@ -5,2 +5,3 @@ const { ShaMap } = require("../dist/shamap.js");

const { loadFixture } = require("./utils");
const { Buffer } = require("buffer/");

@@ -7,0 +8,0 @@ function now() {

const fs = require("fs");
const { Buffer } = require('buffer/')

@@ -3,0 +4,0 @@ function hexOnly(hex) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc