ripple-binary-codec 1.1.3-beta.1 → 1.1.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -107
- package/dist/binary.d.ts +6 -6
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +8 -8
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/definitions.json +190 -4
- package/dist/enums/index.d.ts +6 -5
- package/dist/enums/index.js +2 -1
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/utils-renumber.js +7 -7
- package/dist/enums/utils-renumber.js.map +1 -1
- package/dist/hash-prefixes.d.ts +1 -1
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.d.ts +3 -3
- package/dist/hashes.js +3 -3
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +3 -3
- package/dist/ledger-hashes.js +4 -4
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +2 -2
- package/dist/quality.js +2 -2
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +3 -3
- package/dist/serdes/binary-parser.js +8 -8
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +5 -5
- package/dist/serdes/binary-serializer.js +11 -8
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.d.ts +3 -3
- package/dist/shamap.js +2 -2
- package/dist/shamap.js.map +1 -1
- package/dist/types/account-id.d.ts +2 -2
- package/dist/types/account-id.js +5 -5
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +3 -3
- package/dist/types/amount.js +15 -15
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +3 -3
- package/dist/types/blob.js +3 -3
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +5 -12
- package/dist/types/currency.js +28 -29
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +2 -2
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +2 -2
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-256.d.ts +2 -2
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.d.ts +3 -3
- package/dist/types/hash.js +3 -3
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +15 -15
- package/dist/types/index.js +3 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/path-set.d.ts +2 -2
- package/dist/types/path-set.js +2 -2
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +4 -4
- package/dist/types/serialized-type.js +3 -3
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +2 -2
- package/dist/types/st-array.js +3 -3
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.d.ts +2 -2
- package/dist/types/st-object.js +16 -11
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +3 -3
- package/dist/types/uint-16.js +2 -2
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +3 -3
- package/dist/types/uint-32.js +3 -3
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +4 -4
- package/dist/types/uint-64.js +7 -7
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +3 -3
- package/dist/types/uint-8.js +2 -2
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +3 -3
- package/dist/types/uint.js +1 -1
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.d.ts +3 -3
- package/dist/types/vector-256.js +4 -4
- package/dist/types/vector-256.js.map +1 -1
- package/package.json +3 -3
- package/test/amount.test.js +29 -29
- package/test/binary-json.test.js +24 -26
- package/test/binary-parser.test.js +226 -228
- package/test/binary-serializer.test.js +194 -169
- package/test/fixtures/data-driven-tests.json +2 -790
- package/test/fixtures/negative-unl.json +4 -4
- package/test/fixtures/nf-token.json +547 -0
- package/test/hash.test.js +79 -75
- package/test/ledger.test.js +19 -19
- package/test/lower-case-hex.test.js +29 -28
- package/test/pseudo-transaction.test.js +26 -26
- package/test/quality.test.js +13 -13
- package/test/shamap.test.js +54 -54
- package/test/signing-data-encoding.test.js +79 -79
- package/test/tx-encode-decode.test.js +63 -63
- package/test/types.test.js +23 -23
- package/test/uint.test.js +107 -107
- package/test/x-address.test.js +106 -106
- package/HISTORY.md +0 -86
package/dist/types/st-object.js
CHANGED
|
@@ -21,12 +21,12 @@ var binary_parser_1 = require("../serdes/binary-parser");
|
|
|
21
21
|
var binary_serializer_1 = require("../serdes/binary-serializer");
|
|
22
22
|
var buffer_1 = require("buffer/");
|
|
23
23
|
var OBJECT_END_MARKER_BYTE = buffer_1.Buffer.from([0xe1]);
|
|
24
|
-
var OBJECT_END_MARKER =
|
|
25
|
-
var ST_OBJECT =
|
|
26
|
-
var DESTINATION =
|
|
27
|
-
var ACCOUNT =
|
|
28
|
-
var SOURCE_TAG =
|
|
29
|
-
var DEST_TAG =
|
|
24
|
+
var OBJECT_END_MARKER = 'ObjectEndMarker';
|
|
25
|
+
var ST_OBJECT = 'STObject';
|
|
26
|
+
var DESTINATION = 'Destination';
|
|
27
|
+
var ACCOUNT = 'Account';
|
|
28
|
+
var SOURCE_TAG = 'SourceTag';
|
|
29
|
+
var DEST_TAG = 'DestinationTag';
|
|
30
30
|
/**
|
|
31
31
|
* Break down an X-Address into an account and a tag
|
|
32
32
|
*
|
|
@@ -55,9 +55,9 @@ function handleXAddress(field, xAddress) {
|
|
|
55
55
|
*/
|
|
56
56
|
function checkForDuplicateTags(obj1, obj2) {
|
|
57
57
|
if (!(obj1[SOURCE_TAG] === undefined || obj2[SOURCE_TAG] === undefined))
|
|
58
|
-
throw new Error(
|
|
58
|
+
throw new Error('Cannot have Account X-Address and SourceTag');
|
|
59
59
|
if (!(obj1[DEST_TAG] === undefined || obj2[DEST_TAG] === undefined))
|
|
60
|
-
throw new Error(
|
|
60
|
+
throw new Error('Cannot have Destination X-Address and DestinationTag');
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Class for Serializing/Deserializing objects
|
|
@@ -102,12 +102,13 @@ var STObject = /** @class */ (function (_super) {
|
|
|
102
102
|
}
|
|
103
103
|
var list = new binary_serializer_1.BytesList();
|
|
104
104
|
var bytes = new binary_serializer_1.BinarySerializer(list);
|
|
105
|
+
var isUnlModify = false;
|
|
105
106
|
var xAddressDecoded = Object.entries(value).reduce(function (acc, _a) {
|
|
106
107
|
var _b;
|
|
107
108
|
var key = _a[0], val = _a[1];
|
|
108
109
|
var handled = undefined;
|
|
109
|
-
if (ripple_address_codec_1.isValidXAddress(val)) {
|
|
110
|
-
handled = handleXAddress(key, val);
|
|
110
|
+
if (val && ripple_address_codec_1.isValidXAddress(val.toString())) {
|
|
111
|
+
handled = handleXAddress(key, val.toString());
|
|
111
112
|
checkForDuplicateTags(handled, value);
|
|
112
113
|
}
|
|
113
114
|
return Object.assign(acc, handled !== null && handled !== void 0 ? handled : (_b = {}, _b[key] = val, _b));
|
|
@@ -127,7 +128,11 @@ var STObject = /** @class */ (function (_super) {
|
|
|
127
128
|
}
|
|
128
129
|
sorted.forEach(function (field) {
|
|
129
130
|
var associatedValue = field.associatedType.from(xAddressDecoded[field.name]);
|
|
130
|
-
|
|
131
|
+
if (associatedValue.name === 'UNLModify') {
|
|
132
|
+
isUnlModify = true;
|
|
133
|
+
}
|
|
134
|
+
var isUnlModifyWorkaround = field.name == 'Account' && isUnlModify;
|
|
135
|
+
bytes.writeFieldAndValue(field, associatedValue, isUnlModifyWorkaround);
|
|
131
136
|
if (field.type.name === ST_OBJECT) {
|
|
132
137
|
bytes.put(OBJECT_END_MARKER_BYTE);
|
|
133
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"st-object.js","sourceRoot":"","sources":["../../src/types/st-object.ts"],"names":[],"mappings":";;;;;;;;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AAC,IAAI,CAAC,CAC5B,CAAA;YACD,IAAK,eAAoC,CAAC,IAAI,KAAK,WAAW,EAAE;gBAC9D,WAAW,GAAG,IAAI,CAAA;aACnB;YACD,IAAM,qBAAqB,GAAG,KAAK,CAAC,IAAI,IAAI,SAAS,IAAI,WAAW,CAAA;YACpE,KAAK,CAAC,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,qBAAqB,CAAC,CAAA;YACvE,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;gBACjC,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;aAClC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACrC,CAAC;IAED;;;;OAIG;IACH,yBAAM,GAAN;QACE,IAAM,YAAY,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QACtD,IAAM,WAAW,GAAG,EAAE,CAAA;QAEtB,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE;YAC1B,IAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,CAAA;YACtC,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;gBACpC,MAAK;aACN;YACD,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAA;SACtE;QAED,OAAO,WAAW,CAAA;IACpB,CAAC;IACH,eAAC;AAAD,CAAC,AA7GD,CAAuB,gCAAc,GA6GpC;AAEQ,4BAAQ"}
|
package/dist/types/uint-16.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UInt } from
|
|
2
|
-
import { BinaryParser } from
|
|
3
|
-
import { Buffer } from
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { Buffer } from 'buffer/';
|
|
4
4
|
/**
|
|
5
5
|
* Derived UInt class for serializing/deserializing 16 bit UInt
|
|
6
6
|
*/
|
package/dist/types/uint-16.js
CHANGED
|
@@ -36,12 +36,12 @@ var UInt16 = /** @class */ (function (_super) {
|
|
|
36
36
|
if (val instanceof UInt16) {
|
|
37
37
|
return val;
|
|
38
38
|
}
|
|
39
|
-
if (typeof val ===
|
|
39
|
+
if (typeof val === 'number') {
|
|
40
40
|
var buf = buffer_1.Buffer.alloc(UInt16.width);
|
|
41
41
|
buf.writeUInt16BE(val, 0);
|
|
42
42
|
return new UInt16(buf);
|
|
43
43
|
}
|
|
44
|
-
throw new Error(
|
|
44
|
+
throw new Error('Can not construct UInt16 with given value');
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
47
|
* get the value of a UInt16 object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-16.js","sourceRoot":"","sources":["../../src/types/uint-16.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"uint-16.js","sourceRoot":"","sources":["../../src/types/uint-16.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA6B;AAE7B,kCAAgC;AAEhC;;GAEG;AACH;IAAqB,0BAAI;IAIvB,gBAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;IAC5C,CAAC;IAEM,iBAAU,GAAjB,UAAkB,MAAoB;QACpC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED;;;;OAIG;IACI,WAAI,GAAX,UAAuC,GAAM;QAC3C,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAA;SACX;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACtC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC9D,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC;IArCyB,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;IACrC,oBAAa,GAAW,IAAI,MAAM,CAAC,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAqChF,aAAC;CAAA,AAvCD,CAAqB,WAAI,GAuCxB;AAEQ,wBAAM"}
|
package/dist/types/uint-32.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UInt } from
|
|
2
|
-
import { BinaryParser } from
|
|
3
|
-
import { Buffer } from
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { Buffer } from 'buffer/';
|
|
4
4
|
/**
|
|
5
5
|
* Derived UInt class for serializing/deserializing 32 bit UInt
|
|
6
6
|
*/
|
package/dist/types/uint-32.js
CHANGED
|
@@ -37,16 +37,16 @@ var UInt32 = /** @class */ (function (_super) {
|
|
|
37
37
|
return val;
|
|
38
38
|
}
|
|
39
39
|
var buf = buffer_1.Buffer.alloc(UInt32.width);
|
|
40
|
-
if (typeof val ===
|
|
40
|
+
if (typeof val === 'string') {
|
|
41
41
|
var num = Number.parseInt(val);
|
|
42
42
|
buf.writeUInt32BE(num, 0);
|
|
43
43
|
return new UInt32(buf);
|
|
44
44
|
}
|
|
45
|
-
if (typeof val ===
|
|
45
|
+
if (typeof val === 'number') {
|
|
46
46
|
buf.writeUInt32BE(val, 0);
|
|
47
47
|
return new UInt32(buf);
|
|
48
48
|
}
|
|
49
|
-
throw new Error(
|
|
49
|
+
throw new Error('Cannot construct UInt32 from given value');
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* get the value of a UInt32 object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-32.js","sourceRoot":"","sources":["../../src/types/uint-32.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"uint-32.js","sourceRoot":"","sources":["../../src/types/uint-32.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA6B;AAE7B,kCAAgC;AAEhC;;GAEG;AACH;IAAqB,0BAAI;IAIvB,gBAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;IAC5C,CAAC;IAEM,iBAAU,GAAjB,UAAkB,MAAoB;QACpC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED;;;;OAIG;IACI,WAAI,GAAX,UAAgD,GAAM;QACpD,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAA;SACX;QAED,IAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAEtC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;YAChC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;IAC7D,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC;IA5CyB,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;IACrC,oBAAa,GAAW,IAAI,MAAM,CAAC,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IA4ChF,aAAC;CAAA,AA9CD,CAAqB,WAAI,GA8CxB;AAEQ,wBAAM"}
|
package/dist/types/uint-64.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UInt } from
|
|
2
|
-
import { BinaryParser } from
|
|
3
|
-
import * as bigInt from
|
|
4
|
-
import { Buffer } from
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import * as bigInt from 'big-integer';
|
|
4
|
+
import { Buffer } from 'buffer/';
|
|
5
5
|
/**
|
|
6
6
|
* Derived UInt class for serializing/deserializing 64 bit UInt
|
|
7
7
|
*/
|
package/dist/types/uint-64.js
CHANGED
|
@@ -42,9 +42,9 @@ var UInt64 = /** @class */ (function (_super) {
|
|
|
42
42
|
return val;
|
|
43
43
|
}
|
|
44
44
|
var buf = buffer_1.Buffer.alloc(UInt64.width);
|
|
45
|
-
if (typeof val ===
|
|
45
|
+
if (typeof val === 'number') {
|
|
46
46
|
if (val < 0) {
|
|
47
|
-
throw new Error(
|
|
47
|
+
throw new Error('value must be an unsigned integer');
|
|
48
48
|
}
|
|
49
49
|
var number = bigInt(val);
|
|
50
50
|
var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
|
|
@@ -52,12 +52,12 @@ var UInt64 = /** @class */ (function (_super) {
|
|
|
52
52
|
intBuf[1].writeUInt32BE(Number(number.and(mask)), 0);
|
|
53
53
|
return new UInt64(buffer_1.Buffer.concat(intBuf));
|
|
54
54
|
}
|
|
55
|
-
if (typeof val ===
|
|
55
|
+
if (typeof val === 'string') {
|
|
56
56
|
if (!HEX_REGEX.test(val)) {
|
|
57
57
|
throw new Error(val + " is not a valid hex-string");
|
|
58
58
|
}
|
|
59
|
-
var strBuf = val.padStart(16,
|
|
60
|
-
buf = buffer_1.Buffer.from(strBuf,
|
|
59
|
+
var strBuf = val.padStart(16, '0');
|
|
60
|
+
buf = buffer_1.Buffer.from(strBuf, 'hex');
|
|
61
61
|
return new UInt64(buf);
|
|
62
62
|
}
|
|
63
63
|
if (big_integer_1.isInstance(val)) {
|
|
@@ -66,7 +66,7 @@ var UInt64 = /** @class */ (function (_super) {
|
|
|
66
66
|
intBuf[1].writeUInt32BE(Number(val.and(mask)), 0);
|
|
67
67
|
return new UInt64(buffer_1.Buffer.concat(intBuf));
|
|
68
68
|
}
|
|
69
|
-
throw new Error(
|
|
69
|
+
throw new Error('Cannot construct UInt64 from given value');
|
|
70
70
|
};
|
|
71
71
|
/**
|
|
72
72
|
* The JSON representation of a UInt64 object
|
|
@@ -74,7 +74,7 @@ var UInt64 = /** @class */ (function (_super) {
|
|
|
74
74
|
* @returns a hex-string
|
|
75
75
|
*/
|
|
76
76
|
UInt64.prototype.toJSON = function () {
|
|
77
|
-
return this.bytes.toString(
|
|
77
|
+
return this.bytes.toString('hex').toUpperCase();
|
|
78
78
|
};
|
|
79
79
|
/**
|
|
80
80
|
* Get the value of the UInt64
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-64.js","sourceRoot":"","sources":["../../src/types/uint-64.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"uint-64.js","sourceRoot":"","sources":["../../src/types/uint-64.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA6B;A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,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1D,IAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;QACvD,OAAO,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAxFyB,YAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,IAAI;IACrC,oBAAa,GAAW,IAAI,MAAM,CAAC,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAwFhF,aAAC;CAAA,AA1FD,CAAqB,WAAI,GA0FxB;AAEQ,wBAAM"}
|
package/dist/types/uint-8.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UInt } from
|
|
2
|
-
import { BinaryParser } from
|
|
3
|
-
import { Buffer } from
|
|
1
|
+
import { UInt } from './uint';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { Buffer } from 'buffer/';
|
|
4
4
|
/**
|
|
5
5
|
* Derived UInt class for serializing/deserializing 8 bit UInt
|
|
6
6
|
*/
|
package/dist/types/uint-8.js
CHANGED
|
@@ -36,12 +36,12 @@ var UInt8 = /** @class */ (function (_super) {
|
|
|
36
36
|
if (val instanceof UInt8) {
|
|
37
37
|
return val;
|
|
38
38
|
}
|
|
39
|
-
if (typeof val ===
|
|
39
|
+
if (typeof val === 'number') {
|
|
40
40
|
var buf = buffer_1.Buffer.alloc(UInt8.width);
|
|
41
41
|
buf.writeUInt8(val, 0);
|
|
42
42
|
return new UInt8(buf);
|
|
43
43
|
}
|
|
44
|
-
throw new Error(
|
|
44
|
+
throw new Error('Cannot construct UInt8 from given value');
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
47
|
* get the value of a UInt8 object
|
package/dist/types/uint-8.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint-8.js","sourceRoot":"","sources":["../../src/types/uint-8.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"uint-8.js","sourceRoot":"","sources":["../../src/types/uint-8.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA6B;AAE7B,kCAAgC;AAEhC;;GAEG;AACH;IAAoB,yBAAI;IAItB,eAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC;IAC1C,CAAC;IAEM,gBAAU,GAAjB,UAAkB,MAAoB;QACpC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED;;;;OAIG;IACI,UAAI,GAAX,UAAsC,GAAM;QAC1C,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,OAAO,GAAG,CAAA;SACX;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACrC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YACtB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;SACtB;QAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAC5D,CAAC;IAED;;;;OAIG;IACH,uBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAChC,CAAC;IArCyB,WAAK,GAAW,CAAC,GAAG,CAAC,CAAA,CAAC,IAAI;IACpC,kBAAY,GAAU,IAAI,KAAK,CAAC,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAqC5E,YAAC;CAAA,AAvCD,CAAoB,WAAI,GAuCvB;AAEQ,sBAAK"}
|
package/dist/types/uint.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as bigInt from
|
|
2
|
-
import { Comparable } from
|
|
3
|
-
import { Buffer } from
|
|
1
|
+
import * as bigInt from 'big-integer';
|
|
2
|
+
import { Comparable } from './serialized-type';
|
|
3
|
+
import { Buffer } from 'buffer/';
|
|
4
4
|
/**
|
|
5
5
|
* Base class for serializing and deserializing unsigned integers.
|
|
6
6
|
*/
|
package/dist/types/uint.js
CHANGED
|
@@ -49,7 +49,7 @@ var UInt = /** @class */ (function (_super) {
|
|
|
49
49
|
*/
|
|
50
50
|
UInt.prototype.toJSON = function () {
|
|
51
51
|
var val = this.valueOf();
|
|
52
|
-
return typeof val ===
|
|
52
|
+
return typeof val === 'number' ? val : val.toString();
|
|
53
53
|
};
|
|
54
54
|
return UInt;
|
|
55
55
|
}(serialized_type_1.Comparable));
|
package/dist/types/uint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint.js","sourceRoot":"","sources":["../../src/types/uint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"uint.js","sourceRoot":"","sources":["../../src/types/uint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,qDAA8C;AAG9C;;;;;;GAMG;AACH,SAAS,OAAO,CACd,EAA8B,EAC9B,EAA8B;IAE9B,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC;AAED;;GAEG;AACH;IAA4B,wBAAU;IAGpC,cAAY,KAAa;eACvB,kBAAM,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,wBAAS,GAAT,UAAU,KAAW;QACnB,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACH,qBAAM,GAAN;QACE,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAC1B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvD,CAAC;IAQH,WAAC;AAAD,CAAC,AAjCD,CAA4B,4BAAU,GAiCrC;AAEQ,oBAAI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SerializedType } from
|
|
2
|
-
import { BinaryParser } from
|
|
3
|
-
import { Buffer } from
|
|
1
|
+
import { SerializedType } from './serialized-type';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
import { Buffer } from 'buffer/';
|
|
4
4
|
/**
|
|
5
5
|
* Class for serializing and deserializing vectors of Hash256
|
|
6
6
|
*/
|
package/dist/types/vector-256.js
CHANGED
|
@@ -21,7 +21,7 @@ var binary_serializer_1 = require("../serdes/binary-serializer");
|
|
|
21
21
|
* TypeGuard for Array<string>
|
|
22
22
|
*/
|
|
23
23
|
function isStrings(arg) {
|
|
24
|
-
return Array.isArray(arg) && (arg.length === 0 || typeof arg[0] ===
|
|
24
|
+
return Array.isArray(arg) && (arg.length === 0 || typeof arg[0] === 'string');
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Class for serializing and deserializing vectors of Hash256
|
|
@@ -64,7 +64,7 @@ var Vector256 = /** @class */ (function (_super) {
|
|
|
64
64
|
});
|
|
65
65
|
return new Vector256(bytesList_1.toBytes());
|
|
66
66
|
}
|
|
67
|
-
throw new Error(
|
|
67
|
+
throw new Error('Cannot construct Vector256 from given value');
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
70
|
* Return an Array of hex-strings represented by this.bytes
|
|
@@ -73,13 +73,13 @@ var Vector256 = /** @class */ (function (_super) {
|
|
|
73
73
|
*/
|
|
74
74
|
Vector256.prototype.toJSON = function () {
|
|
75
75
|
if (this.bytes.byteLength % 32 !== 0) {
|
|
76
|
-
throw new Error(
|
|
76
|
+
throw new Error('Invalid bytes for Vector256');
|
|
77
77
|
}
|
|
78
78
|
var result = [];
|
|
79
79
|
for (var i = 0; i < this.bytes.byteLength; i += 32) {
|
|
80
80
|
result.push(this.bytes
|
|
81
81
|
.slice(i, i + 32)
|
|
82
|
-
.toString(
|
|
82
|
+
.toString('hex')
|
|
83
83
|
.toUpperCase());
|
|
84
84
|
}
|
|
85
85
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-256.js","sourceRoot":"","sources":["../../src/types/vector-256.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"vector-256.js","sourceRoot":"","sources":["../../src/types/vector-256.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkD;AAElD,uCAAoC;AACpC,iEAAuD;AAGvD;;GAEG;AACH,SAAS,SAAS,CAAC,GAAG;IACpB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;AAC/E,CAAC;AAED;;GAEG;AACH;IAAwB,6BAAc;IACpC,mBAAY,KAAa;eACvB,kBAAM,KAAK,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,oBAAU,GAAjB,UAAkB,MAAoB,EAAE,IAAa;QACnD,IAAM,SAAS,GAAG,IAAI,6BAAS,EAAE,CAAA;QACjC,IAAM,KAAK,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,M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AAQ,CAAC,KAAK,CAAC;iBACf,WAAW,EAAE,CACjB,CAAA;SACF;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IACH,gBAAC;AAAD,CAAC,AAjED,CAAwB,gCAAc,GAiErC;AAEQ,8BAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ripple-binary-codec",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4-beta.2",
|
|
4
4
|
"description": "XRP Ledger binary codec",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/*",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"big-integer": "^1.6.48",
|
|
18
18
|
"create-hash": "^1.2.0",
|
|
19
19
|
"decimal.js": "^10.2.0",
|
|
20
|
-
"ripple-address-codec": "
|
|
20
|
+
"ripple-address-codec": "4.1.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/jest": "^26.0.7",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=10.22.0",
|
|
58
|
-
"
|
|
58
|
+
"npm": ">=6.0.0"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/test/amount.test.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const { loadFixture } = require(
|
|
2
|
-
const { coreTypes } = require(
|
|
3
|
-
const { Amount } = coreTypes
|
|
4
|
-
const fixtures = loadFixture(
|
|
1
|
+
const { loadFixture } = require('./utils')
|
|
2
|
+
const { coreTypes } = require('../dist/types')
|
|
3
|
+
const { Amount } = coreTypes
|
|
4
|
+
const fixtures = loadFixture('data-driven-tests.json')
|
|
5
5
|
|
|
6
6
|
function amountErrorTests() {
|
|
7
7
|
fixtures.values_tests
|
|
8
|
-
.filter((obj) => obj.type ===
|
|
8
|
+
.filter((obj) => obj.type === 'Amount')
|
|
9
9
|
.forEach((f) => {
|
|
10
10
|
// We only want these with errors
|
|
11
11
|
if (!f.error) {
|
|
12
|
-
return
|
|
12
|
+
return
|
|
13
13
|
}
|
|
14
14
|
const testName =
|
|
15
|
-
`${JSON.stringify(f.test_json)}\n\tis invalid ` + `because: ${f.error}
|
|
15
|
+
`${JSON.stringify(f.test_json)}\n\tis invalid ` + `because: ${f.error}`
|
|
16
16
|
it(testName, () => {
|
|
17
17
|
expect(() => {
|
|
18
|
-
Amount.from(f.test_json)
|
|
19
|
-
JSON.stringify(f.test_json)
|
|
20
|
-
}).toThrow()
|
|
21
|
-
})
|
|
22
|
-
})
|
|
18
|
+
Amount.from(f.test_json)
|
|
19
|
+
JSON.stringify(f.test_json)
|
|
20
|
+
}).toThrow()
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
describe(
|
|
26
|
-
it(
|
|
27
|
-
expect(Amount.from(
|
|
28
|
-
expect(Amount.from(
|
|
25
|
+
describe('Amount', function () {
|
|
26
|
+
it('can be parsed from', function () {
|
|
27
|
+
expect(Amount.from('1000000') instanceof Amount).toBe(true)
|
|
28
|
+
expect(Amount.from('1000000').toJSON()).toEqual('1000000')
|
|
29
29
|
const fixture = {
|
|
30
|
-
value:
|
|
31
|
-
issuer:
|
|
32
|
-
currency:
|
|
33
|
-
}
|
|
34
|
-
const amt = Amount.from(fixture)
|
|
30
|
+
value: '1',
|
|
31
|
+
issuer: '0000000000000000000000000000000000000000',
|
|
32
|
+
currency: 'USD',
|
|
33
|
+
}
|
|
34
|
+
const amt = Amount.from(fixture)
|
|
35
35
|
const rewritten = {
|
|
36
|
-
value:
|
|
37
|
-
issuer:
|
|
38
|
-
currency:
|
|
39
|
-
}
|
|
40
|
-
expect(amt.toJSON()).toEqual(rewritten)
|
|
41
|
-
})
|
|
42
|
-
amountErrorTests()
|
|
43
|
-
})
|
|
36
|
+
value: '1',
|
|
37
|
+
issuer: 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
|
|
38
|
+
currency: 'USD',
|
|
39
|
+
}
|
|
40
|
+
expect(amt.toJSON()).toEqual(rewritten)
|
|
41
|
+
})
|
|
42
|
+
amountErrorTests()
|
|
43
|
+
})
|
package/test/binary-json.test.js
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
|
-
const fixtures = require(
|
|
2
|
-
const { decode, encode, decodeLedgerData } = require(
|
|
1
|
+
const fixtures = require('./fixtures/codec-fixtures.json')
|
|
2
|
+
const { decode, encode, decodeLedgerData } = require('../dist')
|
|
3
3
|
|
|
4
4
|
function json(object) {
|
|
5
|
-
return JSON.stringify(object)
|
|
5
|
+
return JSON.stringify(object)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
function truncateForDisplay(longStr) {
|
|
9
|
-
return `${longStr.slice(0, 10)} ... ${longStr.slice(-10)}
|
|
9
|
+
return `${longStr.slice(0, 10)} ... ${longStr.slice(-10)}`
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
describe(
|
|
12
|
+
describe('ripple-binary-codec', function () {
|
|
13
13
|
function makeSuite(name, entries) {
|
|
14
14
|
describe(name, function () {
|
|
15
15
|
entries.forEach((t, testN) => {
|
|
16
|
-
// eslint-disable-next-line max-len
|
|
17
16
|
test(`${name}[${testN}] can encode ${truncateForDisplay(
|
|
18
|
-
json(t.json)
|
|
17
|
+
json(t.json),
|
|
19
18
|
)} to ${truncateForDisplay(t.binary)}`, () => {
|
|
20
|
-
expect(encode(t.json)).toEqual(t.binary)
|
|
21
|
-
})
|
|
22
|
-
// eslint-disable-next-line max-len
|
|
19
|
+
expect(encode(t.json)).toEqual(t.binary)
|
|
20
|
+
})
|
|
23
21
|
test(`${name}[${testN}] can decode ${truncateForDisplay(
|
|
24
|
-
t.binary
|
|
22
|
+
t.binary,
|
|
25
23
|
)} to ${truncateForDisplay(json(t.json))}`, () => {
|
|
26
|
-
const decoded = decode(t.binary)
|
|
27
|
-
expect(decoded).toEqual(t.json)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
})
|
|
24
|
+
const decoded = decode(t.binary)
|
|
25
|
+
expect(decoded).toEqual(t.json)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
})
|
|
31
29
|
}
|
|
32
|
-
makeSuite(
|
|
33
|
-
makeSuite(
|
|
30
|
+
makeSuite('transactions', fixtures.transactions)
|
|
31
|
+
makeSuite('accountState', fixtures.accountState)
|
|
34
32
|
|
|
35
|
-
describe(
|
|
33
|
+
describe('ledgerData', function () {
|
|
36
34
|
if (fixtures.ledgerData) {
|
|
37
35
|
fixtures.ledgerData.forEach((t, testN) => {
|
|
38
36
|
test(`ledgerData[${testN}] can decode ${t.binary} to ${json(
|
|
39
|
-
t.json
|
|
37
|
+
t.json,
|
|
40
38
|
)}`, () => {
|
|
41
|
-
const decoded = decodeLedgerData(t.binary)
|
|
42
|
-
expect(t.json).toEqual(decoded)
|
|
43
|
-
})
|
|
44
|
-
})
|
|
39
|
+
const decoded = decodeLedgerData(t.binary)
|
|
40
|
+
expect(t.json).toEqual(decoded)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
45
43
|
}
|
|
46
|
-
})
|
|
47
|
-
})
|
|
44
|
+
})
|
|
45
|
+
})
|