ripple-binary-codec 1.0.1 → 1.0.3-mpt-beta
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 +10 -3
- package/dist/binary.d.ts +34 -20
- package/dist/binary.js +51 -34
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +9 -9
- package/dist/coretypes.js +33 -9
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +25 -0
- package/dist/enums/bytes.js +63 -0
- package/dist/enums/bytes.js.map +1 -0
- package/dist/enums/constants.d.ts +4 -0
- package/dist/enums/constants.js +8 -0
- package/dist/enums/constants.js.map +1 -0
- package/dist/enums/definitions.json +3066 -1760
- package/dist/enums/field.d.ts +28 -0
- package/dist/enums/field.js +58 -0
- package/dist/enums/field.js.map +1 -0
- package/dist/enums/index.d.ts +12 -46
- package/dist/enums/index.js +22 -110
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +3073 -0
- package/dist/enums/utils-renumber.js +20 -20
- package/dist/enums/utils-renumber.js.map +1 -1
- package/dist/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/enums/xrpl-definitions-base.js +59 -0
- package/dist/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/enums/xrpl-definitions.d.ts +21 -0
- package/dist/enums/xrpl-definitions.js +29 -0
- package/dist/enums/xrpl-definitions.js.map +1 -0
- package/dist/hash-prefixes.d.ts +1 -2
- package/dist/hash-prefixes.js +7 -6
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.d.ts +7 -8
- package/dist/hashes.js +23 -44
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +16 -17
- package/dist/index.js +65 -40
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +6 -3
- package/dist/ledger-hashes.js +40 -33
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +3 -4
- package/dist/quality.js +20 -19
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +8 -6
- package/dist/serdes/binary-parser.js +74 -64
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +10 -11
- package/dist/serdes/binary-serializer.js +50 -48
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.d.ts +6 -7
- package/dist/shamap.js +74 -97
- package/dist/shamap.js.map +1 -1
- package/dist/src/binary.d.ts +90 -0
- package/dist/src/binary.js +128 -0
- package/dist/src/binary.js.map +1 -0
- package/dist/src/coretypes.d.ts +9 -0
- package/dist/src/coretypes.js +48 -0
- package/dist/src/coretypes.js.map +1 -0
- package/dist/src/enums/bytes.d.ts +25 -0
- package/dist/src/enums/bytes.js +63 -0
- package/dist/src/enums/bytes.js.map +1 -0
- package/dist/src/enums/constants.d.ts +4 -0
- package/dist/src/enums/constants.js +8 -0
- package/dist/src/enums/constants.js.map +1 -0
- package/dist/src/enums/definitions.json +3068 -0
- package/dist/src/enums/field.d.ts +28 -0
- package/dist/src/enums/field.js +58 -0
- package/dist/src/enums/field.js.map +1 -0
- package/dist/src/enums/index.d.ts +12 -0
- package/dist/src/enums/index.js +31 -0
- package/dist/src/enums/index.js.map +1 -0
- package/dist/src/enums/utils-renumber.d.ts +101 -0
- package/dist/src/enums/utils-renumber.js +127 -0
- package/dist/src/enums/utils-renumber.js.map +1 -0
- package/dist/src/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/src/enums/xrpl-definitions-base.js +59 -0
- package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/src/enums/xrpl-definitions.d.ts +21 -0
- package/dist/src/enums/xrpl-definitions.js +29 -0
- package/dist/src/enums/xrpl-definitions.js.map +1 -0
- package/dist/src/hash-prefixes.d.ts +5 -0
- package/dist/src/hash-prefixes.js +41 -0
- package/dist/src/hash-prefixes.js.map +1 -0
- package/dist/src/hashes.d.ts +50 -0
- package/dist/src/hashes.js +76 -0
- package/dist/src/hashes.js.map +1 -0
- package/dist/src/index.d.ts +64 -0
- package/dist/src/index.js +123 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ledger-hashes.d.ts +48 -0
- package/dist/src/ledger-hashes.js +141 -0
- package/dist/src/ledger-hashes.js.map +1 -0
- package/dist/src/quality.d.ts +21 -0
- package/dist/src/quality.js +42 -0
- package/dist/src/quality.js.map +1 -0
- package/dist/src/serdes/binary-parser.d.ts +100 -0
- package/dist/src/serdes/binary-parser.js +194 -0
- package/dist/src/serdes/binary-parser.js.map +1 -0
- package/dist/src/serdes/binary-serializer.d.ts +81 -0
- package/dist/src/serdes/binary-serializer.js +149 -0
- package/dist/src/serdes/binary-serializer.js.map +1 -0
- package/dist/src/shamap.d.ts +102 -0
- package/dist/src/shamap.js +172 -0
- package/dist/src/shamap.js.map +1 -0
- package/dist/src/types/account-id.d.ts +35 -0
- package/dist/src/types/account-id.js +69 -0
- package/dist/src/types/account-id.js.map +1 -0
- package/dist/src/types/amount.d.ts +91 -0
- package/dist/src/types/amount.js +289 -0
- package/dist/src/types/amount.js.map +1 -0
- package/dist/src/types/blob.d.ts +24 -0
- package/dist/src/types/blob.js +43 -0
- package/dist/src/types/blob.js.map +1 -0
- package/dist/src/types/currency.d.ts +28 -0
- package/dist/src/types/currency.js +127 -0
- package/dist/src/types/currency.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +16 -0
- package/dist/src/types/hash-128.js +32 -0
- package/dist/src/types/hash-128.js.map +1 -0
- package/dist/src/types/hash-160.d.ts +10 -0
- package/dist/src/types/hash-160.js +19 -0
- package/dist/src/types/hash-160.js.map +1 -0
- package/dist/src/types/hash-192.d.ts +10 -0
- package/dist/src/types/hash-192.js +19 -0
- package/dist/src/types/hash-192.js.map +1 -0
- package/dist/src/types/hash-256.d.ts +10 -0
- package/dist/src/types/hash-256.js +16 -0
- package/dist/src/types/hash-256.js.map +1 -0
- package/dist/src/types/hash.d.ts +40 -0
- package/dist/src/types/hash.js +73 -0
- package/dist/src/types/hash.js.map +1 -0
- package/dist/src/types/index.d.ts +19 -0
- package/dist/src/types/index.js +64 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +38 -0
- package/dist/src/types/issue.js +81 -0
- package/dist/src/types/issue.js.map +1 -0
- package/dist/src/types/path-set.d.ts +36 -0
- package/dist/src/types/path-set.js +233 -0
- package/dist/src/types/path-set.js.map +1 -0
- package/dist/src/types/serialized-type.d.ts +70 -0
- package/dist/src/types/serialized-type.js +105 -0
- package/dist/src/types/serialized-type.js.map +1 -0
- package/dist/src/types/st-array.d.ts +31 -0
- package/dist/src/types/st-array.js +86 -0
- package/dist/src/types/st-array.js.map +1 -0
- package/dist/src/types/st-object.d.ts +32 -0
- package/dist/src/types/st-object.js +155 -0
- package/dist/src/types/st-object.js.map +1 -0
- package/dist/src/types/uint-16.d.ts +24 -0
- package/dist/src/types/uint-16.js +45 -0
- package/dist/src/types/uint-16.js.map +1 -0
- package/dist/src/types/uint-32.d.ts +24 -0
- package/dist/src/types/uint-32.js +50 -0
- package/dist/src/types/uint-32.js.map +1 -0
- package/dist/src/types/uint-64.d.ts +37 -0
- package/dist/src/types/uint-64.js +86 -0
- package/dist/src/types/uint-64.js.map +1 -0
- package/dist/src/types/uint-8.d.ts +24 -0
- package/dist/src/types/uint-8.js +46 -0
- package/dist/src/types/uint-8.js.map +1 -0
- package/dist/src/types/uint.d.ts +29 -0
- package/dist/src/types/uint.js +47 -0
- package/dist/src/types/uint.js.map +1 -0
- package/dist/src/types/vector-256.d.ts +30 -0
- package/dist/src/types/vector-256.js +73 -0
- package/dist/src/types/vector-256.js.map +1 -0
- package/dist/src/types/xchain-bridge.d.ts +44 -0
- package/dist/src/types/xchain-bridge.js +102 -0
- package/dist/src/types/xchain-bridge.js.map +1 -0
- package/dist/src/utils.d.ts +47 -0
- package/dist/src/utils.js +137 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/account-id.d.ts +2 -3
- package/dist/types/account-id.js +29 -37
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +33 -10
- package/dist/types/amount.js +181 -101
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +3 -4
- package/dist/types/blob.js +16 -27
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +5 -13
- package/dist/types/currency.js +52 -65
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +8 -3
- package/dist/types/hash-128.js +23 -22
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +2 -3
- package/dist/types/hash-160.js +7 -24
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +10 -0
- package/dist/types/hash-192.js +19 -0
- package/dist/types/hash-192.js.map +1 -0
- package/dist/types/hash-256.d.ts +2 -3
- package/dist/types/hash-256.js +7 -22
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.d.ts +4 -5
- package/dist/types/hash.js +25 -39
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +19 -33
- package/dist/types/index.js +44 -24
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +38 -0
- package/dist/types/issue.js +81 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/path-set.d.ts +2 -2
- package/dist/types/path-set.js +73 -94
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +26 -18
- package/dist/types/serialized-type.js +50 -60
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +7 -4
- package/dist/types/st-array.js +36 -47
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.d.ts +8 -5
- package/dist/types/st-object.js +73 -74
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +3 -4
- package/dist/types/uint-16.js +20 -33
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +3 -4
- package/dist/types/uint-32.js +23 -36
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +5 -6
- package/dist/types/uint-64.js +44 -48
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +3 -4
- package/dist/types/uint-8.js +21 -33
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +5 -5
- package/dist/types/uint.js +17 -27
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.d.ts +3 -4
- package/dist/types/vector-256.js +28 -45
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +44 -0
- package/dist/types/xchain-bridge.js +102 -0
- package/dist/types/xchain-bridge.js.map +1 -0
- package/dist/utils.d.ts +47 -0
- package/dist/utils.js +137 -0
- package/dist/utils.js.map +1 -0
- package/package.json +23 -33
- package/src/README.md +5 -0
- package/src/binary.ts +194 -0
- package/src/coretypes.ts +31 -0
- package/src/enums/README.md +144 -0
- package/src/enums/bytes.ts +74 -0
- package/src/enums/constants.ts +4 -0
- package/src/enums/definitions.json +3073 -0
- package/src/enums/field.ts +84 -0
- package/src/enums/index.ts +34 -0
- package/src/enums/utils-renumber.ts +134 -0
- package/src/enums/xrpl-definitions-base.ts +111 -0
- package/src/enums/xrpl-definitions.ts +32 -0
- package/src/hash-prefixes.ts +40 -0
- package/src/hashes.ts +75 -0
- package/src/index.ts +153 -0
- package/src/ledger-hashes.ts +191 -0
- package/src/quality.ts +38 -0
- package/src/serdes/binary-parser.ts +228 -0
- package/src/serdes/binary-serializer.ts +166 -0
- package/src/shamap.ts +186 -0
- package/src/types/account-id.ts +86 -0
- package/src/types/amount.ts +362 -0
- package/src/types/blob.ts +46 -0
- package/src/types/currency.ts +140 -0
- package/src/types/hash-128.ts +33 -0
- package/src/types/hash-160.ts +19 -0
- package/src/types/hash-192.ts +19 -0
- package/src/types/hash-256.ts +15 -0
- package/src/types/hash.ts +83 -0
- package/src/types/index.ts +66 -0
- package/src/types/issue.ts +96 -0
- package/src/types/path-set.ts +290 -0
- package/src/types/serialized-type.ts +122 -0
- package/src/types/st-array.ts +113 -0
- package/src/types/st-object.ts +192 -0
- package/src/types/uint-16.ts +53 -0
- package/src/types/uint-32.ts +59 -0
- package/src/types/uint-64.ts +104 -0
- package/src/types/uint-8.ts +52 -0
- package/src/types/uint.ts +60 -0
- package/src/types/vector-256.ts +79 -0
- package/src/types/xchain-bridge.ts +128 -0
- package/src/utils.ts +152 -0
- package/HISTORY.md +0 -71
- package/test/amount.test.js +0 -43
- package/test/binary-json.test.js +0 -47
- package/test/binary-parser.test.js +0 -397
- package/test/binary-serializer.test.js +0 -248
- package/test/fixtures/account-tx-transactions.db +0 -0
- package/test/fixtures/codec-fixtures.json +0 -4466
- package/test/fixtures/data-driven-tests.json +0 -3721
- package/test/fixtures/delivermin-tx-binary.json +0 -1
- package/test/fixtures/delivermin-tx.json +0 -98
- package/test/fixtures/deposit-preauth-tx-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx-meta-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx.json +0 -58
- package/test/fixtures/escrow-cancel-binary.json +0 -1
- package/test/fixtures/escrow-cancel-tx.json +0 -6
- package/test/fixtures/escrow-create-binary.json +0 -1
- package/test/fixtures/escrow-create-tx.json +0 -10
- package/test/fixtures/escrow-finish-binary.json +0 -1
- package/test/fixtures/escrow-finish-meta-binary.json +0 -1
- package/test/fixtures/escrow-finish-tx.json +0 -95
- package/test/fixtures/ledger-full-38129.json +0 -1
- package/test/fixtures/ledger-full-40000.json +0 -1
- package/test/fixtures/negative-unl.json +0 -12
- package/test/fixtures/payment-channel-claim-binary.json +0 -1
- package/test/fixtures/payment-channel-claim-tx.json +0 -8
- package/test/fixtures/payment-channel-create-binary.json +0 -1
- package/test/fixtures/payment-channel-create-tx.json +0 -11
- package/test/fixtures/payment-channel-fund-binary.json +0 -1
- package/test/fixtures/payment-channel-fund-tx.json +0 -7
- package/test/fixtures/signerlistset-tx-binary.json +0 -1
- package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
- package/test/fixtures/signerlistset-tx.json +0 -94
- package/test/fixtures/x-codec-fixtures.json +0 -188
- package/test/hash.test.js +0 -68
- package/test/ledger.test.js +0 -29
- package/test/lower-case-hex.test.js +0 -45
- package/test/pseudo-transaction.test.js +0 -38
- package/test/quality.test.js +0 -15
- package/test/shamap.test.js +0 -88
- package/test/signing-data-encoding.test.js +0 -129
- package/test/tx-encode-decode.test.js +0 -80
- package/test/types.test.js +0 -34
- package/test/uint.test.js +0 -40
- package/test/utils.js +0 -29
- package/test/x-address.test.js +0 -147
package/dist/types/blob.js
CHANGED
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.Blob = void 0;
|
|
17
|
-
|
|
4
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
18
6
|
/**
|
|
19
7
|
* Variable length encoded type
|
|
20
8
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return _super.call(this, bytes) || this;
|
|
9
|
+
class Blob extends serialized_type_1.SerializedType {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
super(bytes);
|
|
25
12
|
}
|
|
26
13
|
/**
|
|
27
14
|
* Defines how to read a Blob from a BinaryParser
|
|
@@ -30,25 +17,27 @@ var Blob = /** @class */ (function (_super) {
|
|
|
30
17
|
* @param hint The length of the blob, computed by readVariableLengthLength() and passed in
|
|
31
18
|
* @returns A Blob object
|
|
32
19
|
*/
|
|
33
|
-
|
|
20
|
+
static fromParser(parser, hint) {
|
|
34
21
|
return new Blob(parser.read(hint));
|
|
35
|
-
}
|
|
22
|
+
}
|
|
36
23
|
/**
|
|
37
24
|
* Create a Blob object from a hex-string
|
|
38
25
|
*
|
|
39
26
|
* @param value existing Blob object or a hex-string
|
|
40
27
|
* @returns A Blob object
|
|
41
28
|
*/
|
|
42
|
-
|
|
29
|
+
static from(value) {
|
|
43
30
|
if (value instanceof Blob) {
|
|
44
31
|
return value;
|
|
45
32
|
}
|
|
46
|
-
if (typeof value ===
|
|
47
|
-
|
|
33
|
+
if (typeof value === 'string') {
|
|
34
|
+
if (!/^[A-F0-9]*$/iu.test(value)) {
|
|
35
|
+
throw new Error('Cannot construct Blob from a non-hex string');
|
|
36
|
+
}
|
|
37
|
+
return new Blob((0, utils_1.hexToBytes)(value));
|
|
48
38
|
}
|
|
49
|
-
throw new Error(
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}(serialized_type_1.SerializedType));
|
|
39
|
+
throw new Error('Cannot construct Blob from value given');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
53
42
|
exports.Blob = Blob;
|
|
54
43
|
//# sourceMappingURL=blob.js.map
|
package/dist/types/blob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/types/blob.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/types/blob.ts"],"names":[],"mappings":";;;AAAA,uDAAkD;AAElD,mDAAoD;AAEpD;;GAEG;AACH,MAAM,IAAK,SAAQ,gCAAc;IAC/B,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,MAAoB,EAAE,IAAY;QAClD,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACpC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAA0B,KAAQ;QAC3C,IAAI,KAAK,YAAY,IAAI,EAAE;YACzB,OAAO,KAAK,CAAA;SACb;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBAChC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;aAC/D;YACD,OAAO,IAAI,IAAI,CAAC,IAAA,kBAAU,EAAC,KAAK,CAAC,CAAC,CAAA;SACnC;QAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;IAC3D,CAAC;CACF;AAEQ,oBAAI"}
|
package/dist/types/currency.d.ts
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import { Hash160 } from "./hash-160";
|
|
1
|
+
import { Hash160 } from './hash-160';
|
|
3
2
|
/**
|
|
4
3
|
* Class defining how to encode and decode Currencies
|
|
5
4
|
*/
|
|
6
5
|
declare class Currency extends Hash160 {
|
|
7
6
|
static readonly XRP: Currency;
|
|
8
|
-
private readonly _iso
|
|
9
|
-
|
|
10
|
-
constructor(byteBuf: Buffer);
|
|
11
|
-
/**
|
|
12
|
-
* Tells if this currency is native
|
|
13
|
-
*
|
|
14
|
-
* @returns true if native, false if not
|
|
15
|
-
*/
|
|
16
|
-
isNative(): boolean;
|
|
7
|
+
private readonly _iso;
|
|
8
|
+
constructor(byteBuf: Uint8Array);
|
|
17
9
|
/**
|
|
18
10
|
* Return the ISO code of this currency
|
|
19
11
|
*
|
|
20
|
-
* @returns ISO code if it exists, else
|
|
12
|
+
* @returns ISO code if it exists, else null
|
|
21
13
|
*/
|
|
22
|
-
iso(): string |
|
|
14
|
+
iso(): string | null;
|
|
23
15
|
/**
|
|
24
16
|
* Constructs a Currency object
|
|
25
17
|
*
|
package/dist/types/currency.js
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.Currency = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
const hash_160_1 = require("./hash-160");
|
|
5
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
6
|
+
const XRP_HEX_REGEX = /^0{40}$/;
|
|
7
|
+
const ISO_REGEX = /^[A-Z0-9a-z?!@#$%^&*(){}[\]|]{3}$/;
|
|
8
|
+
const HEX_REGEX = /^[A-F0-9]{40}$/;
|
|
9
|
+
// eslint-disable-next-line no-control-regex
|
|
10
|
+
const STANDARD_FORMAT_HEX_REGEX = /^0{24}[\x00-\x7F]{6}0{10}$/;
|
|
20
11
|
/**
|
|
21
12
|
* Convert an ISO code to a currency bytes representation
|
|
22
13
|
*/
|
|
23
14
|
function isoToBytes(iso) {
|
|
24
|
-
|
|
25
|
-
if (iso !==
|
|
26
|
-
|
|
15
|
+
const bytes = new Uint8Array(20);
|
|
16
|
+
if (iso !== 'XRP') {
|
|
17
|
+
const isoBytes = iso.split('').map((c) => c.charCodeAt(0));
|
|
27
18
|
bytes.set(isoBytes, 12);
|
|
28
19
|
}
|
|
29
20
|
return bytes;
|
|
@@ -34,6 +25,16 @@ function isoToBytes(iso) {
|
|
|
34
25
|
function isIsoCode(iso) {
|
|
35
26
|
return ISO_REGEX.test(iso);
|
|
36
27
|
}
|
|
28
|
+
function isoCodeFromHex(code) {
|
|
29
|
+
const iso = (0, utils_1.hexToString)((0, utils_1.bytesToHex)(code));
|
|
30
|
+
if (iso === 'XRP') {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (isIsoCode(iso)) {
|
|
34
|
+
return iso;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
37
38
|
/**
|
|
38
39
|
* Tests if hex is a valid hex-string
|
|
39
40
|
*/
|
|
@@ -44,10 +45,10 @@ function isHex(hex) {
|
|
|
44
45
|
* Tests if a string is a valid representation of a currency
|
|
45
46
|
*/
|
|
46
47
|
function isStringRepresentation(input) {
|
|
47
|
-
return
|
|
48
|
+
return input.length === 3 || isHex(input);
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
|
-
* Tests if a
|
|
51
|
+
* Tests if a Uint8Array is a valid representation of a currency
|
|
51
52
|
*/
|
|
52
53
|
function isBytesArray(bytes) {
|
|
53
54
|
return bytes.byteLength === 20;
|
|
@@ -56,85 +57,71 @@ function isBytesArray(bytes) {
|
|
|
56
57
|
* Ensures that a value is a valid representation of a currency
|
|
57
58
|
*/
|
|
58
59
|
function isValidRepresentation(input) {
|
|
59
|
-
return input instanceof
|
|
60
|
+
return input instanceof Uint8Array
|
|
60
61
|
? isBytesArray(input)
|
|
61
62
|
: isStringRepresentation(input);
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
|
-
* Generate bytes from a string or
|
|
65
|
+
* Generate bytes from a string or UInt8Array representation of a currency
|
|
65
66
|
*/
|
|
66
67
|
function bytesFromRepresentation(input) {
|
|
67
68
|
if (!isValidRepresentation(input)) {
|
|
68
|
-
throw new Error(
|
|
69
|
+
throw new Error(`Unsupported Currency representation: ${input}`);
|
|
69
70
|
}
|
|
70
|
-
return input.length === 3 ? isoToBytes(input) :
|
|
71
|
+
return input.length === 3 ? isoToBytes(input) : (0, utils_1.hexToBytes)(input);
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
74
|
* Class defining how to encode and decode Currencies
|
|
74
75
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
76
|
+
class Currency extends hash_160_1.Hash160 {
|
|
77
|
+
constructor(byteBuf) {
|
|
78
|
+
super(byteBuf !== null && byteBuf !== void 0 ? byteBuf : Currency.XRP.bytes);
|
|
79
|
+
const hex = (0, utils_1.bytesToHex)(this.bytes);
|
|
80
|
+
if (XRP_HEX_REGEX.test(hex)) {
|
|
81
|
+
this._iso = 'XRP';
|
|
82
|
+
}
|
|
83
|
+
else if (STANDARD_FORMAT_HEX_REGEX.test(hex)) {
|
|
84
|
+
this._iso = isoCodeFromHex(this.bytes.slice(12, 15));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this._iso = null;
|
|
88
88
|
}
|
|
89
|
-
var lossLessISO = onlyISO && iso !== "XRP" && ISO_REGEX.test(iso);
|
|
90
|
-
_this._isNative = onlyISO && code.toString("hex") === "000000";
|
|
91
|
-
_this._iso = _this._isNative ? "XRP" : lossLessISO ? iso : undefined;
|
|
92
|
-
return _this;
|
|
93
89
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Tells if this currency is native
|
|
96
|
-
*
|
|
97
|
-
* @returns true if native, false if not
|
|
98
|
-
*/
|
|
99
|
-
Currency.prototype.isNative = function () {
|
|
100
|
-
return this._isNative;
|
|
101
|
-
};
|
|
102
90
|
/**
|
|
103
91
|
* Return the ISO code of this currency
|
|
104
92
|
*
|
|
105
|
-
* @returns ISO code if it exists, else
|
|
93
|
+
* @returns ISO code if it exists, else null
|
|
106
94
|
*/
|
|
107
|
-
|
|
95
|
+
iso() {
|
|
108
96
|
return this._iso;
|
|
109
|
-
}
|
|
97
|
+
}
|
|
110
98
|
/**
|
|
111
99
|
* Constructs a Currency object
|
|
112
100
|
*
|
|
113
101
|
* @param val Currency object or a string representation of a currency
|
|
114
102
|
*/
|
|
115
|
-
|
|
103
|
+
static from(value) {
|
|
116
104
|
if (value instanceof Currency) {
|
|
117
105
|
return value;
|
|
118
106
|
}
|
|
119
|
-
if (typeof value ===
|
|
107
|
+
if (typeof value === 'string') {
|
|
120
108
|
return new Currency(bytesFromRepresentation(value));
|
|
121
109
|
}
|
|
122
|
-
throw new Error(
|
|
123
|
-
}
|
|
110
|
+
throw new Error('Cannot construct Currency from value given');
|
|
111
|
+
}
|
|
124
112
|
/**
|
|
125
113
|
* Gets the JSON representation of a currency
|
|
126
114
|
*
|
|
127
115
|
* @returns JSON representation
|
|
128
116
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (iso !==
|
|
117
|
+
toJSON() {
|
|
118
|
+
const iso = this.iso();
|
|
119
|
+
if (iso !== null) {
|
|
132
120
|
return iso;
|
|
133
121
|
}
|
|
134
|
-
return this.bytes
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return Currency;
|
|
138
|
-
}(hash_160_1.Hash160));
|
|
122
|
+
return (0, utils_1.bytesToHex)(this.bytes);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
139
125
|
exports.Currency = Currency;
|
|
126
|
+
Currency.XRP = new Currency(new Uint8Array(20));
|
|
140
127
|
//# sourceMappingURL=currency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../src/types/currency.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../src/types/currency.ts"],"names":[],"mappings":"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"}
|
package/dist/types/hash-128.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import { Hash } from "./hash";
|
|
1
|
+
import { Hash } from './hash';
|
|
3
2
|
/**
|
|
4
3
|
* Hash with a width of 128 bits
|
|
5
4
|
*/
|
|
6
5
|
declare class Hash128 extends Hash {
|
|
7
6
|
static readonly width = 16;
|
|
8
7
|
static readonly ZERO_128: Hash128;
|
|
9
|
-
constructor(bytes:
|
|
8
|
+
constructor(bytes: Uint8Array);
|
|
9
|
+
/**
|
|
10
|
+
* Get the hex representation of a hash-128 bytes, allowing unset
|
|
11
|
+
*
|
|
12
|
+
* @returns hex String of this.bytes
|
|
13
|
+
*/
|
|
14
|
+
toHex(): string;
|
|
10
15
|
}
|
|
11
16
|
export { Hash128 };
|
package/dist/types/hash-128.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.Hash128 = void 0;
|
|
17
|
-
|
|
4
|
+
const hash_1 = require("./hash");
|
|
5
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
18
6
|
/**
|
|
19
7
|
* Hash with a width of 128 bits
|
|
20
8
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
class Hash128 extends hash_1.Hash {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
if (bytes && bytes.byteLength === 0) {
|
|
12
|
+
bytes = Hash128.ZERO_128.bytes;
|
|
13
|
+
}
|
|
14
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Hash128.ZERO_128.bytes);
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Get the hex representation of a hash-128 bytes, allowing unset
|
|
18
|
+
*
|
|
19
|
+
* @returns hex String of this.bytes
|
|
20
|
+
*/
|
|
21
|
+
toHex() {
|
|
22
|
+
const hex = (0, utils_1.bytesToHex)(this.toBytes());
|
|
23
|
+
if (/^0+$/.exec(hex)) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
return hex;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
30
29
|
exports.Hash128 = Hash128;
|
|
30
|
+
Hash128.width = 16;
|
|
31
|
+
Hash128.ZERO_128 = new Hash128(new Uint8Array(Hash128.width));
|
|
31
32
|
//# sourceMappingURL=hash-128.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-128.js","sourceRoot":"","sources":["../../src/types/hash-128.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash-128.js","sourceRoot":"","sources":["../../src/types/hash-128.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,mDAAoD;AAEpD;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAiB;QAC3B,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,EAAE;YACnC,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAA;SAC/B;QAED,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QACtC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACpB,OAAO,EAAE,CAAA;SACV;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;;AAGM,0BAAO;AAzBE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAY,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/hash-160.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { Hash } from "./hash";
|
|
1
|
+
import { Hash } from './hash';
|
|
3
2
|
/**
|
|
4
3
|
* Hash with a width of 160 bits
|
|
5
4
|
*/
|
|
6
5
|
declare class Hash160 extends Hash {
|
|
7
6
|
static readonly width = 20;
|
|
8
7
|
static readonly ZERO_160: Hash160;
|
|
9
|
-
constructor(bytes?:
|
|
8
|
+
constructor(bytes?: Uint8Array);
|
|
10
9
|
}
|
|
11
10
|
export { Hash160 };
|
package/dist/types/hash-160.js
CHANGED
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.Hash160 = void 0;
|
|
17
|
-
|
|
4
|
+
const hash_1 = require("./hash");
|
|
18
5
|
/**
|
|
19
6
|
* Hash with a width of 160 bits
|
|
20
7
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function Hash160(bytes) {
|
|
24
|
-
var _this = this;
|
|
8
|
+
class Hash160 extends hash_1.Hash {
|
|
9
|
+
constructor(bytes) {
|
|
25
10
|
if (bytes && bytes.byteLength === 0) {
|
|
26
11
|
bytes = Hash160.ZERO_160.bytes;
|
|
27
12
|
}
|
|
28
|
-
|
|
29
|
-
return _this;
|
|
13
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Hash160.ZERO_160.bytes);
|
|
30
14
|
}
|
|
31
|
-
|
|
32
|
-
Hash160.ZERO_160 = new Hash160(Buffer.alloc(Hash160.width));
|
|
33
|
-
return Hash160;
|
|
34
|
-
}(hash_1.Hash));
|
|
15
|
+
}
|
|
35
16
|
exports.Hash160 = Hash160;
|
|
17
|
+
Hash160.width = 20;
|
|
18
|
+
Hash160.ZERO_160 = new Hash160(new Uint8Array(Hash160.width));
|
|
36
19
|
//# sourceMappingURL=hash-160.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-160.js","sourceRoot":"","sources":["../../src/types/hash-160.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash-160.js","sourceRoot":"","sources":["../../src/types/hash-160.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAkB;QAC5B,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,EAAE;YACnC,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAA;SAC/B;QAED,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;;AAGM,0BAAO;AAZE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAY,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Hash192 = void 0;
|
|
4
|
+
const hash_1 = require("./hash");
|
|
5
|
+
/**
|
|
6
|
+
* Hash with a width of 192 bits
|
|
7
|
+
*/
|
|
8
|
+
class Hash192 extends hash_1.Hash {
|
|
9
|
+
constructor(bytes) {
|
|
10
|
+
if (bytes && bytes.byteLength === 0) {
|
|
11
|
+
bytes = Hash192.ZERO_192.bytes;
|
|
12
|
+
}
|
|
13
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Hash192.ZERO_192.bytes);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.Hash192 = Hash192;
|
|
17
|
+
Hash192.width = 24;
|
|
18
|
+
Hash192.ZERO_192 = new Hash192(new Uint8Array(Hash192.width));
|
|
19
|
+
//# sourceMappingURL=hash-192.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-192.js","sourceRoot":"","sources":["../../src/types/hash-192.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAkB;QAC5B,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,EAAE;YACnC,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAA;SAC/B;QAED,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;;AAGM,0BAAO;AAZE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAY,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/hash-256.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { Hash } from "./hash";
|
|
1
|
+
import { Hash } from './hash';
|
|
3
2
|
/**
|
|
4
3
|
* Hash with a width of 256 bits
|
|
5
4
|
*/
|
|
6
5
|
declare class Hash256 extends Hash {
|
|
7
6
|
static readonly width = 32;
|
|
8
7
|
static readonly ZERO_256: Hash256;
|
|
9
|
-
constructor(bytes:
|
|
8
|
+
constructor(bytes: Uint8Array);
|
|
10
9
|
}
|
|
11
10
|
export { Hash256 };
|
package/dist/types/hash-256.js
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.Hash256 = void 0;
|
|
17
|
-
|
|
4
|
+
const hash_1 = require("./hash");
|
|
18
5
|
/**
|
|
19
6
|
* Hash with a width of 256 bits
|
|
20
7
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : Hash256.ZERO_256.bytes) || this;
|
|
8
|
+
class Hash256 extends hash_1.Hash {
|
|
9
|
+
constructor(bytes) {
|
|
10
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Hash256.ZERO_256.bytes);
|
|
25
11
|
}
|
|
26
|
-
|
|
27
|
-
Hash256.ZERO_256 = new Hash256(Buffer.alloc(Hash256.width));
|
|
28
|
-
return Hash256;
|
|
29
|
-
}(hash_1.Hash));
|
|
12
|
+
}
|
|
30
13
|
exports.Hash256 = Hash256;
|
|
14
|
+
Hash256.width = 32;
|
|
15
|
+
Hash256.ZERO_256 = new Hash256(new Uint8Array(Hash256.width));
|
|
31
16
|
//# sourceMappingURL=hash-256.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-256.js","sourceRoot":"","sources":["../../src/types/hash-256.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash-256.js","sourceRoot":"","sources":["../../src/types/hash-256.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;;AAGM,0BAAO;AARE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAG,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/hash.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { BinaryParser } from "../serdes/binary-parser";
|
|
1
|
+
import { Comparable } from './serialized-type';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
4
3
|
/**
|
|
5
4
|
* Base class defining how to encode and decode hashes
|
|
6
5
|
*/
|
|
7
|
-
declare class Hash extends Comparable {
|
|
6
|
+
declare class Hash extends Comparable<Hash | string> {
|
|
8
7
|
static readonly width: number;
|
|
9
|
-
constructor(bytes:
|
|
8
|
+
constructor(bytes: Uint8Array);
|
|
10
9
|
/**
|
|
11
10
|
* Construct a Hash object from an existing Hash object or a hex-string
|
|
12
11
|
*
|