ripple-binary-codec 1.5.0-beta.2 → 1.5.0-beta.3
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/dist/binary.d.ts +2 -1
- package/dist/binary.js +32 -30
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.js +31 -8
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +26 -0
- package/dist/enums/bytes.js +68 -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 +44 -115
- package/dist/enums/field.d.ts +30 -0
- package/dist/enums/field.js +65 -0
- package/dist/enums/field.js.map +1 -0
- package/dist/enums/index.js +69 -60
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +44 -115
- package/dist/enums/utils-renumber.js +14 -14
- package/dist/enums/utils-renumber.js.map +1 -1
- package/dist/enums/xrpl-definitions.d.ts +44 -0
- package/dist/enums/xrpl-definitions.js +69 -0
- package/dist/enums/xrpl-definitions.js.map +1 -0
- package/dist/hash-prefixes.js +3 -3
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.js +21 -43
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +2 -12
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +1 -1
- package/dist/ledger-hashes.js +51 -28
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.js +18 -21
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.js +78 -56
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.js +59 -40
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/serdes/bytes-list.d.ts +29 -0
- package/dist/serdes/bytes-list.js +48 -0
- package/dist/serdes/bytes-list.js.map +1 -0
- package/dist/shamap.js +70 -98
- package/dist/shamap.js.map +1 -1
- package/dist/types/account-id.js +18 -35
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.js +71 -88
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.js +10 -27
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.js +26 -44
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +6 -0
- package/dist/types/hash-128.js +23 -25
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.js +8 -25
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-256.js +8 -25
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.js +20 -38
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +20 -22
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.js +24 -41
- package/dist/types/issue.js.map +1 -1
- package/dist/types/path-set.js +57 -87
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +3 -3
- package/dist/types/serialized-type.js +35 -56
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.js +26 -46
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.js +49 -73
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.js +15 -32
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.js +16 -33
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +1 -1
- package/dist/types/uint-64.js +30 -47
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.js +15 -32
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +1 -1
- package/dist/types/uint.js +10 -27
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.js +23 -40
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-attestation-batch.js +42 -59
- package/dist/types/xchain-attestation-batch.js.map +1 -1
- package/dist/types/xchain-bridge.js +44 -61
- package/dist/types/xchain-bridge.js.map +1 -1
- package/package.json +4 -5
- package/test/amount.test.js +1 -1
- package/test/binary-json.test.js +1 -1
- package/test/binary-parser.test.js +4 -4
- package/test/binary-serializer.test.js +3 -3
- package/test/fixtures/codec-fixtures.json +58 -118
- package/test/hash.test.js +28 -2
- package/test/ledger.test.js +1 -1
- package/test/lower-case-hex.test.js +1 -1
- package/test/pseudo-transaction.test.js +1 -1
- package/test/quality.test.js +1 -1
- package/test/shamap.test.js +3 -3
- package/test/signing-data-encoding.test.js +25 -2
- package/test/tx-encode-decode.test.js +1 -1
- package/test/types.test.js +2 -2
- package/test/uint.test.js +2 -2
- package/test/x-address.test.js +1 -1
package/dist/types/hash-160.js
CHANGED
|
@@ -1,37 +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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.Hash160 = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const hash_1 = require("./hash");
|
|
5
|
+
const buffer_1 = require("buffer/");
|
|
21
6
|
/**
|
|
22
7
|
* Hash with a width of 160 bits
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function Hash160(bytes) {
|
|
9
|
+
class Hash160 extends hash_1.Hash {
|
|
10
|
+
constructor(bytes) {
|
|
27
11
|
if (bytes && bytes.byteLength === 0) {
|
|
28
12
|
bytes = Hash160.ZERO_160.bytes;
|
|
29
13
|
}
|
|
30
|
-
|
|
14
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Hash160.ZERO_160.bytes);
|
|
31
15
|
}
|
|
32
|
-
|
|
33
|
-
Hash160.ZERO_160 = new Hash160(buffer_1.Buffer.alloc(Hash160.width));
|
|
34
|
-
return Hash160;
|
|
35
|
-
}(hash_1.Hash));
|
|
16
|
+
}
|
|
36
17
|
exports.Hash160 = Hash160;
|
|
18
|
+
Hash160.width = 20;
|
|
19
|
+
Hash160.ZERO_160 = new Hash160(buffer_1.Buffer.alloc(Hash160.width));
|
|
37
20
|
//# 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;AAC7B,oCAAgC;AAEhC;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAc;QACxB,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,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/hash-256.js
CHANGED
|
@@ -1,34 +1,17 @@
|
|
|
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.Hash256 = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const hash_1 = require("./hash");
|
|
5
|
+
const buffer_1 = require("buffer/");
|
|
21
6
|
/**
|
|
22
7
|
* Hash with a width of 256 bits
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : Hash256.ZERO_256.bytes) || this;
|
|
9
|
+
class Hash256 extends hash_1.Hash {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Hash256.ZERO_256.bytes);
|
|
28
12
|
}
|
|
29
|
-
|
|
30
|
-
Hash256.ZERO_256 = new Hash256(buffer_1.Buffer.alloc(Hash256.width));
|
|
31
|
-
return Hash256;
|
|
32
|
-
}(hash_1.Hash));
|
|
13
|
+
}
|
|
33
14
|
exports.Hash256 = Hash256;
|
|
15
|
+
Hash256.width = 32;
|
|
16
|
+
Hash256.ZERO_256 = new Hash256(buffer_1.Buffer.alloc(Hash256.width));
|
|
34
17
|
//# 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;AAC7B,oCAAgC;AAEhC;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAa;QACvB,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,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/hash.js
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.Hash = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
|
+
const buffer_1 = require("buffer/");
|
|
21
6
|
/**
|
|
22
7
|
* Base class defining how to encode and decode hashes
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new Error("Invalid Hash length ".concat(_this.bytes.byteLength));
|
|
9
|
+
class Hash extends serialized_type_1.Comparable {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
super(bytes);
|
|
12
|
+
if (this.bytes.byteLength !== this.constructor.width) {
|
|
13
|
+
throw new Error(`Invalid Hash length ${this.bytes.byteLength}`);
|
|
30
14
|
}
|
|
31
|
-
return _this;
|
|
32
15
|
}
|
|
33
16
|
/**
|
|
34
17
|
* Construct a Hash object from an existing Hash object or a hex-string
|
|
35
18
|
*
|
|
36
19
|
* @param value A hash object or hex-string of a hash
|
|
37
20
|
*/
|
|
38
|
-
|
|
21
|
+
static from(value) {
|
|
39
22
|
if (value instanceof this) {
|
|
40
23
|
return value;
|
|
41
24
|
}
|
|
@@ -43,39 +26,39 @@ var Hash = /** @class */ (function (_super) {
|
|
|
43
26
|
return new this(buffer_1.Buffer.from(value, 'hex'));
|
|
44
27
|
}
|
|
45
28
|
throw new Error('Cannot construct Hash from given value');
|
|
46
|
-
}
|
|
29
|
+
}
|
|
47
30
|
/**
|
|
48
31
|
* Read a Hash object from a BinaryParser
|
|
49
32
|
*
|
|
50
33
|
* @param parser BinaryParser to read the hash from
|
|
51
34
|
* @param hint length of the bytes to read, optional
|
|
52
35
|
*/
|
|
53
|
-
|
|
36
|
+
static fromParser(parser, hint) {
|
|
54
37
|
return new this(parser.read(hint !== null && hint !== void 0 ? hint : this.width));
|
|
55
|
-
}
|
|
38
|
+
}
|
|
56
39
|
/**
|
|
57
40
|
* Overloaded operator for comparing two hash objects
|
|
58
41
|
*
|
|
59
42
|
* @param other The Hash to compare this to
|
|
60
43
|
*/
|
|
61
|
-
|
|
44
|
+
compareTo(other) {
|
|
62
45
|
return this.bytes.compare(this.constructor.from(other).bytes);
|
|
63
|
-
}
|
|
46
|
+
}
|
|
64
47
|
/**
|
|
65
48
|
* @returns the hex-string representation of this Hash
|
|
66
49
|
*/
|
|
67
|
-
|
|
50
|
+
toString() {
|
|
68
51
|
return this.toHex();
|
|
69
|
-
}
|
|
52
|
+
}
|
|
70
53
|
/**
|
|
71
54
|
* Returns four bits at the specified depth within a hash
|
|
72
55
|
*
|
|
73
56
|
* @param depth The depth of the four bits
|
|
74
57
|
* @returns The number represented by the four bits
|
|
75
58
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
nibblet(depth) {
|
|
60
|
+
const byteIx = depth > 0 ? (depth / 2) | 0 : 0;
|
|
61
|
+
let b = this.bytes[byteIx];
|
|
79
62
|
if (depth % 2 === 0) {
|
|
80
63
|
b = (b & 0xf0) >>> 4;
|
|
81
64
|
}
|
|
@@ -83,8 +66,7 @@ var Hash = /** @class */ (function (_super) {
|
|
|
83
66
|
b = b & 0x0f;
|
|
84
67
|
}
|
|
85
68
|
return b;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}(serialized_type_1.Comparable));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
89
71
|
exports.Hash = Hash;
|
|
90
72
|
//# sourceMappingURL=hash.js.map
|
package/dist/types/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/types/hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/types/hash.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C,oCAAgC;AAEhC;;GAEG;AACH,MAAM,IAAK,SAAQ,4BAAU;IAG3B,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,IAAI,CA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B,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;SACrB;aAAM;YACL,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;SACb;QACD,OAAO,CAAC,CAAA;IACV,CAAC;CACF;AAEQ,oBAAI"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import { UInt32 } from './uint-32';
|
|
|
14
14
|
import { UInt64 } from './uint-64';
|
|
15
15
|
import { UInt8 } from './uint-8';
|
|
16
16
|
import { Vector256 } from './vector-256';
|
|
17
|
-
import { XChainAttestationBatch } from './xchain-attestation-batch';
|
|
18
17
|
import { XChainBridge } from './xchain-bridge';
|
|
19
18
|
declare const coreTypes: {
|
|
20
19
|
AccountID: typeof AccountID;
|
|
@@ -33,7 +32,6 @@ declare const coreTypes: {
|
|
|
33
32
|
UInt32: typeof UInt32;
|
|
34
33
|
UInt64: typeof UInt64;
|
|
35
34
|
Vector256: typeof Vector256;
|
|
36
|
-
XChainAttestationBatch: typeof XChainAttestationBatch;
|
|
37
35
|
XChainBridge: typeof XChainBridge;
|
|
38
36
|
};
|
|
39
37
|
export { coreTypes };
|
package/dist/types/index.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.coreTypes = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var coreTypes = {
|
|
4
|
+
const enums_1 = require("../enums");
|
|
5
|
+
const account_id_1 = require("./account-id");
|
|
6
|
+
const amount_1 = require("./amount");
|
|
7
|
+
const blob_1 = require("./blob");
|
|
8
|
+
const currency_1 = require("./currency");
|
|
9
|
+
const hash_128_1 = require("./hash-128");
|
|
10
|
+
const hash_160_1 = require("./hash-160");
|
|
11
|
+
const hash_256_1 = require("./hash-256");
|
|
12
|
+
const issue_1 = require("./issue");
|
|
13
|
+
const path_set_1 = require("./path-set");
|
|
14
|
+
const st_array_1 = require("./st-array");
|
|
15
|
+
const st_object_1 = require("./st-object");
|
|
16
|
+
const uint_16_1 = require("./uint-16");
|
|
17
|
+
const uint_32_1 = require("./uint-32");
|
|
18
|
+
const uint_64_1 = require("./uint-64");
|
|
19
|
+
const uint_8_1 = require("./uint-8");
|
|
20
|
+
const vector_256_1 = require("./vector-256");
|
|
21
|
+
const xchain_bridge_1 = require("./xchain-bridge");
|
|
22
|
+
const coreTypes = {
|
|
24
23
|
AccountID: account_id_1.AccountID,
|
|
25
24
|
Amount: amount_1.Amount,
|
|
26
25
|
Blob: blob_1.Blob,
|
|
@@ -37,11 +36,10 @@ var coreTypes = {
|
|
|
37
36
|
UInt32: uint_32_1.UInt32,
|
|
38
37
|
UInt64: uint_64_1.UInt64,
|
|
39
38
|
Vector256: vector_256_1.Vector256,
|
|
40
|
-
XChainAttestationBatch: xchain_attestation_batch_1.XChainAttestationBatch,
|
|
41
39
|
XChainBridge: xchain_bridge_1.XChainBridge,
|
|
42
40
|
};
|
|
43
41
|
exports.coreTypes = coreTypes;
|
|
44
|
-
Object.values(enums_1.Field).forEach(
|
|
42
|
+
Object.values(enums_1.Field).forEach((field) => {
|
|
45
43
|
field.associatedType = coreTypes[field.type.name];
|
|
46
44
|
});
|
|
47
45
|
enums_1.Field['TransactionType'].associatedType = enums_1.TransactionType;
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,oCAKiB;AACjB,6CAAwC;AACxC,qCAAiC;AACjC,iCAA6B;AAC7B,yCAAqC;AACrC,yCAAoC;AACpC,yCAAoC;AACpC,yCAAoC;AACpC,mCAA+B;AAC/B,yCAAoC;AACpC,yCAAoC;AACpC,2CAAsC;AACtC,uCAAkC;AAClC,uCAAkC;AAClC,uCAAkC;AAClC,qCAAgC;AAChC,6CAAwC;AACxC,mDAA8C;AAE9C,MAAM,SAAS,GAAG;IAChB,SAAS,EAAT,sBAAS;IACT,MAAM,EAAN,eAAM;IACN,IAAI,EAAJ,WAAI;IACJ,QAAQ,EAAR,mBAAQ;IACR,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,KAAK,EAAL,aAAK;IACL,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,QAAQ,EAAR,oBAAQ;IACR,KAAK,EAAL,cAAK;IACL,MAAM,EAAN,gBAAM;IACN,MAAM,EAAN,gBAAM;IACN,MAAM,EAAN,gBAAM;IACN,SAAS,EAAT,sBAAS;IACT,YAAY,EAAZ,4BAAY;CACb,CAAA;AAUQ,8BAAS;AARlB,MAAM,CAAC,MAAM,CAAC,aAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;IACrC,KAAK,CAAC,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACnD,CAAC,CAAC,CAAA;AAEF,aAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,uBAAe,CAAA;AACzD,aAAK,CAAC,mBAAmB,CAAC,CAAC,cAAc,GAAG,yBAAiB,CAAA;AAC7D,aAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,uBAAe,CAAA"}
|
package/dist/types/issue.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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.Issue = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
const binary_parser_1 = require("../serdes/binary-parser");
|
|
5
|
+
const account_id_1 = require("./account-id");
|
|
6
|
+
const currency_1 = require("./currency");
|
|
7
|
+
const serialized_type_1 = require("./serialized-type");
|
|
8
|
+
const buffer_1 = require("buffer/");
|
|
24
9
|
/**
|
|
25
10
|
* Type guard for AmountObject
|
|
26
11
|
*/
|
|
27
12
|
function isIssueObject(arg) {
|
|
28
|
-
|
|
13
|
+
const keys = Object.keys(arg).sort();
|
|
29
14
|
if (keys.length === 1) {
|
|
30
15
|
return keys[0] === 'currency';
|
|
31
16
|
}
|
|
@@ -34,10 +19,9 @@ function isIssueObject(arg) {
|
|
|
34
19
|
/**
|
|
35
20
|
* Class for serializing/Deserializing Amounts
|
|
36
21
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : Issue.ZERO_ISSUED_CURRENCY.bytes) || this;
|
|
22
|
+
class Issue extends serialized_type_1.SerializedType {
|
|
23
|
+
constructor(bytes) {
|
|
24
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Issue.ZERO_ISSUED_CURRENCY.bytes);
|
|
41
25
|
}
|
|
42
26
|
/**
|
|
43
27
|
* Construct an amount from an IOU or string amount
|
|
@@ -46,53 +30,52 @@ var Issue = /** @class */ (function (_super) {
|
|
|
46
30
|
* representing an integer amount
|
|
47
31
|
* @returns An Amount object
|
|
48
32
|
*/
|
|
49
|
-
|
|
33
|
+
static from(value) {
|
|
50
34
|
if (value instanceof Issue) {
|
|
51
35
|
return value;
|
|
52
36
|
}
|
|
53
37
|
if (isIssueObject(value)) {
|
|
54
|
-
|
|
38
|
+
const currency = currency_1.Currency.from(value.currency).toBytes();
|
|
55
39
|
if (value.issuer == null) {
|
|
56
40
|
return new Issue(currency);
|
|
57
41
|
}
|
|
58
|
-
|
|
42
|
+
const issuer = account_id_1.AccountID.from(value.issuer).toBytes();
|
|
59
43
|
return new Issue(buffer_1.Buffer.concat([currency, issuer]));
|
|
60
44
|
}
|
|
61
45
|
throw new Error('Invalid type to construct an Amount');
|
|
62
|
-
}
|
|
46
|
+
}
|
|
63
47
|
/**
|
|
64
48
|
* Read an amount from a BinaryParser
|
|
65
49
|
*
|
|
66
50
|
* @param parser BinaryParser to read the Amount from
|
|
67
51
|
* @returns An Amount object
|
|
68
52
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
static fromParser(parser) {
|
|
54
|
+
const currency = parser.read(20);
|
|
71
55
|
if (new currency_1.Currency(currency).toJSON() === 'XRP') {
|
|
72
56
|
return new Issue(currency);
|
|
73
57
|
}
|
|
74
|
-
|
|
58
|
+
const currencyAndIssuer = [currency, parser.read(20)];
|
|
75
59
|
return new Issue(buffer_1.Buffer.concat(currencyAndIssuer));
|
|
76
|
-
}
|
|
60
|
+
}
|
|
77
61
|
/**
|
|
78
62
|
* Get the JSON representation of this Amount
|
|
79
63
|
*
|
|
80
64
|
* @returns the JSON interpretation of this.bytes
|
|
81
65
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
toJSON() {
|
|
67
|
+
const parser = new binary_parser_1.BinaryParser(this.toString());
|
|
68
|
+
const currency = currency_1.Currency.fromParser(parser);
|
|
85
69
|
if (currency.toJSON() === 'XRP') {
|
|
86
70
|
return { currency: currency.toJSON() };
|
|
87
71
|
}
|
|
88
|
-
|
|
72
|
+
const issuer = account_id_1.AccountID.fromParser(parser);
|
|
89
73
|
return {
|
|
90
74
|
currency: currency.toJSON(),
|
|
91
75
|
issuer: issuer.toJSON(),
|
|
92
76
|
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return Issue;
|
|
96
|
-
}(serialized_type_1.SerializedType));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
97
79
|
exports.Issue = Issue;
|
|
80
|
+
Issue.ZERO_ISSUED_CURRENCY = new Issue(buffer_1.Buffer.alloc(20));
|
|
98
81
|
//# sourceMappingURL=issue.js.map
|
package/dist/types/issue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../src/types/issue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../src/types/issue.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AAEtD,6CAAwC;AACxC,yCAAqC;AACrC,uDAA8D;AAC9D,oCAAgC;AAUhC;;GAEG;AACH,SAAS,aAAa,CAAC,GAAG;IACxB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAA;KAC9B;IACD,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAA;AAC5E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