@transia/ripple-binary-codec 2.5.4-alpha.0 → 2.5.5-alpha.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/dist/enums/definitions.json +1308 -974
- package/dist/enums/src/enums/definitions.json +1313 -974
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/src/enums/definitions.json +1308 -974
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/types/hash-128.js +1 -1
- package/dist/src/types/hash-128.js.map +1 -1
- package/dist/src/types/hash-160.js +1 -1
- package/dist/src/types/hash-160.js.map +1 -1
- package/dist/src/types/hash-192.js +1 -1
- package/dist/src/types/hash-192.js.map +1 -1
- package/dist/src/types/index.d.ts +2 -1
- package/dist/src/types/index.js +4 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/int-32.d.ts +33 -0
- package/dist/src/types/int-32.js +64 -0
- package/dist/src/types/int-32.js.map +1 -0
- package/dist/src/types/int.d.ts +38 -0
- package/dist/src/types/int.js +57 -0
- package/dist/src/types/int.js.map +1 -0
- package/dist/src/types/issue.d.ts +10 -13
- package/dist/src/types/issue.js +42 -29
- package/dist/src/types/issue.js.map +1 -1
- package/dist/src/types/st-number.js +88 -33
- package/dist/src/types/st-number.js.map +1 -1
- package/dist/src/types/st-object.d.ts +3 -3
- package/dist/src/types/st-object.js +12 -12
- package/dist/src/types/st-object.js.map +1 -1
- package/dist/src/types/uint-16.js +2 -2
- package/dist/src/types/uint-16.js.map +1 -1
- package/dist/src/types/uint-32.js +1 -1
- package/dist/src/types/uint-32.js.map +1 -1
- package/dist/src/types/uint-64.js +1 -1
- package/dist/src/types/uint-64.js.map +1 -1
- package/dist/src/types/uint-8.js +1 -1
- package/dist/src/types/uint-8.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/hash-128.js +1 -1
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.js +1 -1
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.js +1 -1
- package/dist/types/hash-192.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +4 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/int-32.d.ts +33 -0
- package/dist/types/int-32.js +64 -0
- package/dist/types/int-32.js.map +1 -0
- package/dist/types/int.d.ts +38 -0
- package/dist/types/int.js +57 -0
- package/dist/types/int.js.map +1 -0
- package/dist/types/issue.d.ts +10 -13
- package/dist/types/issue.js +42 -29
- package/dist/types/issue.js.map +1 -1
- package/dist/types/st-number.js +88 -33
- package/dist/types/st-number.js.map +1 -1
- package/dist/types/st-object.d.ts +3 -3
- package/dist/types/st-object.js +12 -12
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.js +2 -2
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.js +1 -1
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.js +1 -1
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.js +1 -1
- package/dist/types/uint-8.js.map +1 -1
- package/package.json +8 -5
- package/src/enums/definitions.json +1313 -974
- package/src/index.ts +1 -3
- package/src/types/hash-128.ts +1 -1
- package/src/types/hash-160.ts +1 -1
- package/src/types/hash-192.ts +1 -1
- package/src/types/index.ts +3 -0
- package/src/types/int-32.ts +72 -0
- package/src/types/int.ts +75 -0
- package/src/types/issue.ts +90 -57
- package/src/types/st-number.ts +107 -31
- package/src/types/st-object.ts +77 -73
- package/src/types/uint-16.ts +2 -2
- package/src/types/uint-32.ts +1 -1
- package/src/types/uint-64.ts +1 -1
- package/src/types/uint-8.ts +1 -1
package/dist/src/index.js
CHANGED
|
@@ -85,9 +85,6 @@ function encodeForMultisigning(json, signer, definitions) {
|
|
|
85
85
|
if (typeof json !== 'object') {
|
|
86
86
|
throw new Error();
|
|
87
87
|
}
|
|
88
|
-
if (json['SigningPubKey'] !== '') {
|
|
89
|
-
throw new Error();
|
|
90
|
-
}
|
|
91
88
|
const definitionsOpt = definitions ? { definitions } : undefined;
|
|
92
89
|
return (0, utils_1.bytesToHex)(multiSigningData(json, signer, definitionsOpt));
|
|
93
90
|
}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AACzD,mDAAkD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AACzD,mDAAkD;AA4JhD,iGA5JO,gCAAgB,OA4JP;AAzJlB,mCAIgB;AAwJd,oGA3JA,2BAAmB,OA2JA;AAFnB,kGAxJA,yBAAiB,OAwJA;AAGjB,oGA1JA,2BAAmB,OA0JA;AAxJrB,+DAA0D;AAsJxD,gGAtJO,kCAAe,OAsJP;AArJjB,mCAAmC;AAwJjC,0FAxJO,iBAAS,OAwJP;AAvJX,qDAAsD;AAEtD,MAAM,EACJ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,GAAG,kBAAM,CAAA;AAEV;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,MAAc,EAAE,WAAiC;IAC/D,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;KAC/C;IACD,OAAO,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAC1C,CAAC;AAmHC,wBAAM;AAjHR;;;;;;;GAOG;AACH,SAAS,MAAM,CAAC,IAAY,EAAE,WAAiC;IAC7D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,KAAK,EAAE,CAAA;KAClB;IACD,OAAO,IAAA,kBAAU,EAAC,eAAe,CAAC,IAAkB,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAAA;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AAa;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,IAAI,KAAK,EAAE,CAAA;KAClB;IACD,OAAO,IAAA,kBAAU,EAAC,mBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AAC1C,CAAC;AAsBC,sCAAa;AApBf;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAa;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,IAAI,KAAK,EAAE,CAAA;KAClB;IACD,OAAO,mBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;AACzC,CAAC;AAUC,sCAAa"}
|
|
@@ -9,7 +9,7 @@ const serialized_type_1 = require("./serialized-type");
|
|
|
9
9
|
*/
|
|
10
10
|
class Hash128 extends hash_1.Hash {
|
|
11
11
|
constructor(bytes) {
|
|
12
|
-
if (bytes
|
|
12
|
+
if ((bytes === null || bytes === void 0 ? void 0 : bytes.byteLength) === 0) {
|
|
13
13
|
bytes = Hash128.ZERO_128.bytes;
|
|
14
14
|
}
|
|
15
15
|
super(bytes !== null && bytes !== void 0 ? bytes : Hash128.ZERO_128.bytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-128.js","sourceRoot":"","sources":["../../../src/types/hash-128.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,qDAAsD;AACtD,uDAAoD;AAEpD;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAiB;QAC3B,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"hash-128.js","sourceRoot":"","sources":["../../../src/types/hash-128.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,qDAAsD;AACtD,uDAAoD;AAEpD;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAiB;QAC3B,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,MAAK,CAAC,EAAE;YAC3B,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;IAED,QAAQ;QACN,OAAO,kCAAgB,CAAC,WAAW,CAAA;IACrC,CAAC;;AAGM,0BAAO;AA7BE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAY,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
|
@@ -8,7 +8,7 @@ const serialized_type_1 = require("./serialized-type");
|
|
|
8
8
|
*/
|
|
9
9
|
class Hash160 extends hash_1.Hash {
|
|
10
10
|
constructor(bytes) {
|
|
11
|
-
if (bytes
|
|
11
|
+
if ((bytes === null || bytes === void 0 ? void 0 : bytes.byteLength) === 0) {
|
|
12
12
|
bytes = Hash160.ZERO_160.bytes;
|
|
13
13
|
}
|
|
14
14
|
super(bytes !== null && bytes !== void 0 ? bytes : Hash160.ZERO_160.bytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-160.js","sourceRoot":"","sources":["../../../src/types/hash-160.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,uDAAoD;AAEpD;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAkB;QAC5B,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"hash-160.js","sourceRoot":"","sources":["../../../src/types/hash-160.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,uDAAoD;AAEpD;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAkB;QAC5B,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,MAAK,CAAC,EAAE;YAC3B,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,QAAQ;QACN,OAAO,kCAAgB,CAAC,WAAW,CAAA;IACrC,CAAC;;AAGM,0BAAO;AAhBE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAY,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
|
@@ -8,7 +8,7 @@ const serialized_type_1 = require("./serialized-type");
|
|
|
8
8
|
*/
|
|
9
9
|
class Hash192 extends hash_1.Hash {
|
|
10
10
|
constructor(bytes) {
|
|
11
|
-
if (bytes
|
|
11
|
+
if ((bytes === null || bytes === void 0 ? void 0 : bytes.byteLength) === 0) {
|
|
12
12
|
bytes = Hash192.ZERO_192.bytes;
|
|
13
13
|
}
|
|
14
14
|
super(bytes !== null && bytes !== void 0 ? bytes : Hash192.ZERO_192.bytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-192.js","sourceRoot":"","sources":["../../../src/types/hash-192.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,uDAAoD;AAEpD;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAkB;QAC5B,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"hash-192.js","sourceRoot":"","sources":["../../../src/types/hash-192.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,uDAAoD;AAEpD;;GAEG;AACH,MAAM,OAAQ,SAAQ,WAAI;IAIxB,YAAY,KAAkB;QAC5B,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,MAAK,CAAC,EAAE;YAC3B,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,QAAQ;QACN,OAAO,kCAAgB,CAAC,WAAW,CAAA;IACrC,CAAC;;AAGM,0BAAO;AAhBE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAY,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
|
@@ -8,6 +8,7 @@ import { Hash128 } from './hash-128';
|
|
|
8
8
|
import { Hash160 } from './hash-160';
|
|
9
9
|
import { Hash192 } from './hash-192';
|
|
10
10
|
import { Hash256 } from './hash-256';
|
|
11
|
+
import { Int32 } from './int-32';
|
|
11
12
|
import { PathSet } from './path-set';
|
|
12
13
|
import { STArray } from './st-array';
|
|
13
14
|
import { STObject } from './st-object';
|
|
@@ -18,4 +19,4 @@ import { UInt8 } from './uint-8';
|
|
|
18
19
|
import { Vector256 } from './vector-256';
|
|
19
20
|
import { type SerializedType } from './serialized-type';
|
|
20
21
|
declare const coreTypes: Record<string, typeof SerializedType>;
|
|
21
|
-
export { coreTypes, AccountID, Amount, Blob, Currency, Data, DataType, Hash128, Hash160, Hash192, Hash256, PathSet, STArray, STObject, UInt8, UInt16, UInt32, UInt64, Vector256, };
|
|
22
|
+
export { coreTypes, AccountID, Amount, Blob, Currency, Data, DataType, Hash128, Hash160, Hash192, Hash256, Int32, PathSet, STArray, STObject, UInt8, UInt16, UInt32, UInt64, Vector256, };
|
package/dist/src/types/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Vector256 = exports.UInt64 = exports.UInt32 = exports.UInt16 = exports.UInt8 = exports.STObject = exports.STArray = exports.PathSet = exports.Hash256 = exports.Hash192 = exports.Hash160 = exports.Hash128 = exports.DataType = exports.Data = exports.Currency = exports.Blob = exports.Amount = exports.AccountID = exports.coreTypes = void 0;
|
|
3
|
+
exports.Vector256 = exports.UInt64 = exports.UInt32 = exports.UInt16 = exports.UInt8 = exports.STObject = exports.STArray = exports.PathSet = exports.Int32 = exports.Hash256 = exports.Hash192 = exports.Hash160 = exports.Hash128 = exports.DataType = exports.Data = exports.Currency = exports.Blob = exports.Amount = exports.AccountID = exports.coreTypes = void 0;
|
|
4
4
|
const account_id_1 = require("./account-id");
|
|
5
5
|
Object.defineProperty(exports, "AccountID", { enumerable: true, get: function () { return account_id_1.AccountID; } });
|
|
6
6
|
const amount_1 = require("./amount");
|
|
@@ -21,6 +21,8 @@ const hash_192_1 = require("./hash-192");
|
|
|
21
21
|
Object.defineProperty(exports, "Hash192", { enumerable: true, get: function () { return hash_192_1.Hash192; } });
|
|
22
22
|
const hash_256_1 = require("./hash-256");
|
|
23
23
|
Object.defineProperty(exports, "Hash256", { enumerable: true, get: function () { return hash_256_1.Hash256; } });
|
|
24
|
+
const int_32_1 = require("./int-32");
|
|
25
|
+
Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return int_32_1.Int32; } });
|
|
24
26
|
const issue_1 = require("./issue");
|
|
25
27
|
const st_number_1 = require("./st-number");
|
|
26
28
|
const path_set_1 = require("./path-set");
|
|
@@ -52,6 +54,7 @@ const coreTypes = {
|
|
|
52
54
|
Hash160: hash_160_1.Hash160,
|
|
53
55
|
Hash192: hash_192_1.Hash192,
|
|
54
56
|
Hash256: hash_256_1.Hash256,
|
|
57
|
+
Int32: int_32_1.Int32,
|
|
55
58
|
Issue: issue_1.Issue,
|
|
56
59
|
Number: st_number_1.STNumber,
|
|
57
60
|
PathSet: path_set_1.PathSet,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAyDtC,0FAzDO,sBAAS,OAyDP;AAxDX,qCAAiC;AAyD/B,uFAzDO,eAAM,OAyDP;AAxDR,iCAA6B;AAyD3B,qFAzDO,WAAI,OAyDP;AAxDN,yCAAqC;AAyDnC,yFAzDO,mBAAQ,OAyDP;AAxDV,iCAA6B;AAyD3B,qFAzDO,WAAI,OAyDP;AAxDN,yCAAqC;AAyDnC,yFAzDO,mBAAQ,OAyDP;AAxDV,yCAAoC;AAyDlC,wFAzDO,kBAAO,OAyDP;AAxDT,yCAAoC;AAyDlC,wFAzDO,kBAAO,OAyDP;AAxDT,yCAAoC;AAyDlC,wFAzDO,kBAAO,OAyDP;AAxDT,yCAAoC;AAyDlC,wFAzDO,kBAAO,OAyDP;AAxDT,qCAAgC;AAyD9B,sFAzDO,cAAK,OAyDP;AAxDP,mCAA+B;AAC/B,2CAAsC;AACtC,yCAAoC;AAuDlC,wFAvDO,kBAAO,OAuDP;AAtDT,yCAAoC;AAuDlC,wFAvDO,kBAAO,OAuDP;AAtDT,2CAAsC;AAuDpC,yFAvDO,oBAAQ,OAuDP;AAtDV,uCAAkC;AAwDhC,uFAxDO,gBAAM,OAwDP;AAvDR,uCAAkC;AAwDhC,uFAxDO,gBAAM,OAwDP;AAvDR,uCAAkC;AAwDhC,uFAxDO,gBAAM,OAwDP;AAvDR,qCAAgC;AAoD9B,sFApDO,cAAK,OAoDP;AAnDP,6CAAwC;AAuDtC,0FAvDO,sBAAS,OAuDP;AAtDX,mDAA8C;AAE9C,oCAA8C;AAE9C,MAAM,SAAS,GAA0C;IACvD,SAAS,EAAT,sBAAS;IACT,MAAM,EAAN,eAAM;IACN,IAAI,EAAJ,WAAI;IACJ,QAAQ,EAAR,mBAAQ;IACR,IAAI,EAAJ,WAAI;IACJ,QAAQ,EAAR,mBAAQ;IACR,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,OAAO,EAAP,kBAAO;IACP,KAAK,EAAL,cAAK;IACL,KAAK,EAAL,aAAK;IACL,MAAM,EAAE,oBAAQ;IAChB,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;AAQC,8BAAS;AANX,2GAA2G;AAC3G,gFAAgF;AAChF,8FAA8F;AAC9F,2BAAmB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Int } from './int';
|
|
2
|
+
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Derived Int class for serializing/deserializing signed 32-bit integers.
|
|
5
|
+
*/
|
|
6
|
+
declare class Int32 extends Int {
|
|
7
|
+
protected static readonly width: number;
|
|
8
|
+
static readonly defaultInt32: Int32;
|
|
9
|
+
static readonly MIN_VALUE: number;
|
|
10
|
+
static readonly MAX_VALUE: number;
|
|
11
|
+
constructor(bytes: Uint8Array);
|
|
12
|
+
/**
|
|
13
|
+
* Construct an Int32 from a BinaryParser
|
|
14
|
+
*
|
|
15
|
+
* @param parser BinaryParser to read Int32 from
|
|
16
|
+
* @returns An Int32 object
|
|
17
|
+
*/
|
|
18
|
+
static fromParser(parser: BinaryParser): Int;
|
|
19
|
+
/**
|
|
20
|
+
* Construct an Int32 object from a number or string
|
|
21
|
+
*
|
|
22
|
+
* @param val Int32 object, number, or string
|
|
23
|
+
* @returns An Int32 object
|
|
24
|
+
*/
|
|
25
|
+
static from<T extends Int32 | number | string>(val: T): Int32;
|
|
26
|
+
/**
|
|
27
|
+
* Get the value of the Int32 object
|
|
28
|
+
*
|
|
29
|
+
* @returns the signed 32-bit integer represented by this.bytes
|
|
30
|
+
*/
|
|
31
|
+
valueOf(): number;
|
|
32
|
+
}
|
|
33
|
+
export { Int32 };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Int32 = void 0;
|
|
4
|
+
const int_1 = require("./int");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
/**
|
|
7
|
+
* Derived Int class for serializing/deserializing signed 32-bit integers.
|
|
8
|
+
*/
|
|
9
|
+
class Int32 extends int_1.Int {
|
|
10
|
+
constructor(bytes) {
|
|
11
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Int32.defaultInt32.bytes);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Construct an Int32 from a BinaryParser
|
|
15
|
+
*
|
|
16
|
+
* @param parser BinaryParser to read Int32 from
|
|
17
|
+
* @returns An Int32 object
|
|
18
|
+
*/
|
|
19
|
+
static fromParser(parser) {
|
|
20
|
+
return new Int32(parser.read(Int32.width));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Construct an Int32 object from a number or string
|
|
24
|
+
*
|
|
25
|
+
* @param val Int32 object, number, or string
|
|
26
|
+
* @returns An Int32 object
|
|
27
|
+
*/
|
|
28
|
+
static from(val) {
|
|
29
|
+
if (val instanceof Int32) {
|
|
30
|
+
return val;
|
|
31
|
+
}
|
|
32
|
+
const buf = new Uint8Array(Int32.width);
|
|
33
|
+
if (typeof val === 'string') {
|
|
34
|
+
const num = Number(val);
|
|
35
|
+
if (!Number.isFinite(num) || !Number.isInteger(num)) {
|
|
36
|
+
throw new Error(`Cannot construct Int32 from string: ${val}`);
|
|
37
|
+
}
|
|
38
|
+
Int32.checkIntRange('Int32', num, Int32.MIN_VALUE, Int32.MAX_VALUE);
|
|
39
|
+
(0, utils_1.writeInt32BE)(buf, num, 0);
|
|
40
|
+
return new Int32(buf);
|
|
41
|
+
}
|
|
42
|
+
if (typeof val === 'number' && Number.isInteger(val)) {
|
|
43
|
+
Int32.checkIntRange('Int32', val, Int32.MIN_VALUE, Int32.MAX_VALUE);
|
|
44
|
+
(0, utils_1.writeInt32BE)(buf, val, 0);
|
|
45
|
+
return new Int32(buf);
|
|
46
|
+
}
|
|
47
|
+
throw new Error('Cannot construct Int32 from given value');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the value of the Int32 object
|
|
51
|
+
*
|
|
52
|
+
* @returns the signed 32-bit integer represented by this.bytes
|
|
53
|
+
*/
|
|
54
|
+
valueOf() {
|
|
55
|
+
return (0, utils_1.readInt32BE)(this.bytes, 0);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Int32 = Int32;
|
|
59
|
+
Int32.width = 32 / 8; // 4 bytes
|
|
60
|
+
Int32.defaultInt32 = new Int32(new Uint8Array(Int32.width));
|
|
61
|
+
// Signed 32-bit integer range
|
|
62
|
+
Int32.MIN_VALUE = -2147483648; // -2^31
|
|
63
|
+
Int32.MAX_VALUE = 2147483647; // 2^31 - 1
|
|
64
|
+
//# sourceMappingURL=int-32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"int-32.js","sourceRoot":"","sources":["../../../src/types/int-32.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAE3B,oCAAoD;AAEpD;;GAEG;AACH,MAAM,KAAM,SAAQ,SAAG;IAQrB,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,OAAO,IAAI,K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AAE,CAAC,CAAC,CAAA;IACnC,CAAC;;AAGM,sBAAK;AA/Dc,WAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,UAAU;AAC3C,kBAAY,GAAU,IAAI,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AAE5E,8BAA8B;AACd,eAAS,GAAW,CAAC,UAAU,CAAA,CAAC,QAAQ;AACxC,eAAS,GAAW,UAAU,CAAA,CAAC,WAAW"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Comparable } from './serialized-type';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for serializing and deserializing signed integers.
|
|
4
|
+
*/
|
|
5
|
+
declare abstract class Int extends Comparable<Int | number> {
|
|
6
|
+
protected static width: number;
|
|
7
|
+
constructor(bytes: Uint8Array);
|
|
8
|
+
/**
|
|
9
|
+
* Overload of compareTo for Comparable
|
|
10
|
+
*
|
|
11
|
+
* @param other other Int to compare this to
|
|
12
|
+
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
13
|
+
*/
|
|
14
|
+
compareTo(other: Int | number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Convert an Int object to JSON
|
|
17
|
+
*
|
|
18
|
+
* @returns number or string represented by this.bytes
|
|
19
|
+
*/
|
|
20
|
+
toJSON(): number | string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the value of the Int represented by this.bytes
|
|
23
|
+
*
|
|
24
|
+
* @returns the value
|
|
25
|
+
*/
|
|
26
|
+
abstract valueOf(): number | bigint;
|
|
27
|
+
/**
|
|
28
|
+
* Validate that a number is within the specified signed integer range
|
|
29
|
+
*
|
|
30
|
+
* @param typeName The name of the type (for error messages)
|
|
31
|
+
* @param val The number to validate
|
|
32
|
+
* @param min The minimum allowed value
|
|
33
|
+
* @param max The maximum allowed value
|
|
34
|
+
* @throws Error if the value is out of range
|
|
35
|
+
*/
|
|
36
|
+
static checkIntRange(typeName: string, val: number | bigint, min: number | bigint, max: number | bigint): void;
|
|
37
|
+
}
|
|
38
|
+
export { Int };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Int = void 0;
|
|
4
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
|
+
/**
|
|
6
|
+
* Compare numbers and bigInts n1 and n2
|
|
7
|
+
*
|
|
8
|
+
* @param n1 First object to compare
|
|
9
|
+
* @param n2 Second object to compare
|
|
10
|
+
* @returns -1, 0, or 1, depending on how the two objects compare
|
|
11
|
+
*/
|
|
12
|
+
function compare(n1, n2) {
|
|
13
|
+
return n1 < n2 ? -1 : n1 == n2 ? 0 : 1;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Base class for serializing and deserializing signed integers.
|
|
17
|
+
*/
|
|
18
|
+
class Int extends serialized_type_1.Comparable {
|
|
19
|
+
constructor(bytes) {
|
|
20
|
+
super(bytes);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Overload of compareTo for Comparable
|
|
24
|
+
*
|
|
25
|
+
* @param other other Int to compare this to
|
|
26
|
+
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
27
|
+
*/
|
|
28
|
+
compareTo(other) {
|
|
29
|
+
return compare(this.valueOf(), other.valueOf());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert an Int object to JSON
|
|
33
|
+
*
|
|
34
|
+
* @returns number or string represented by this.bytes
|
|
35
|
+
*/
|
|
36
|
+
toJSON() {
|
|
37
|
+
const val = this.valueOf();
|
|
38
|
+
return typeof val === 'number' ? val : val.toString();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Validate that a number is within the specified signed integer range
|
|
42
|
+
*
|
|
43
|
+
* @param typeName The name of the type (for error messages)
|
|
44
|
+
* @param val The number to validate
|
|
45
|
+
* @param min The minimum allowed value
|
|
46
|
+
* @param max The maximum allowed value
|
|
47
|
+
* @throws Error if the value is out of range
|
|
48
|
+
*/
|
|
49
|
+
// eslint-disable-next-line max-params -- for error clarity in browsers
|
|
50
|
+
static checkIntRange(typeName, val, min, max) {
|
|
51
|
+
if (val < min || val > max) {
|
|
52
|
+
throw new Error(`Invalid ${typeName}: ${val} must be >= ${min} and <= ${max}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Int = Int;
|
|
57
|
+
//# sourceMappingURL=int.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"int.js","sourceRoot":"","sources":["../../../src/types/int.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,EAAmB,EAAE,EAAmB;IACvD,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,MAAe,GAAI,SAAQ,4BAAwB;IAGjD,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,KAAmB;QAC3B,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,MAAM,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;IASD;;;;;;;;OAQG;IACH,uEAAuE;IACvE,MAAM,CAAC,aAAa,CAClB,QAAgB,EAChB,GAAoB,EACpB,GAAoB,EACpB,GAAoB;QAEpB,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,EAAE;YAC1B,MAAM,IAAI,KAAK,CACb,WAAW,QAAQ,KAAK,GAAG,eAAe,GAAG,WAAW,GAAG,EAAE,CAC9D,CAAA;SACF;IACH,CAAC;CACF;AAEQ,kBAAG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BinaryParser } from
|
|
2
|
-
import { JsonObject, SerializedType, SerializedTypeID } from
|
|
1
|
+
import { BinaryParser } from "../serdes/binary-parser";
|
|
2
|
+
import { JsonObject, SerializedType, SerializedTypeID } from "./serialized-type";
|
|
3
3
|
interface XRPIssue extends JsonObject {
|
|
4
4
|
currency: string;
|
|
5
5
|
}
|
|
@@ -15,31 +15,28 @@ interface MPTIssue extends JsonObject {
|
|
|
15
15
|
*/
|
|
16
16
|
type IssueObject = XRPIssue | IOUIssue | MPTIssue;
|
|
17
17
|
/**
|
|
18
|
-
* Class for serializing/Deserializing
|
|
18
|
+
* Class for serializing/Deserializing Issue
|
|
19
19
|
*/
|
|
20
20
|
declare class Issue extends SerializedType {
|
|
21
|
-
static readonly
|
|
21
|
+
static readonly XRP_ISSUE: Issue;
|
|
22
22
|
constructor(bytes: Uint8Array);
|
|
23
23
|
/**
|
|
24
|
-
* Construct
|
|
24
|
+
* Construct Issue from XRPIssue, IOUIssue or MPTIssue
|
|
25
25
|
*
|
|
26
|
-
* @param value An
|
|
27
|
-
* representing an integer amount
|
|
26
|
+
* @param value An object representing an XRPIssue, IOUIssue or MPTIssue
|
|
28
27
|
* @returns An Issue object
|
|
29
28
|
*/
|
|
30
29
|
static from<T extends Issue | IssueObject>(value: T): Issue;
|
|
31
30
|
/**
|
|
32
|
-
* Read
|
|
31
|
+
* Read Issue from a BinaryParser
|
|
33
32
|
*
|
|
34
|
-
* @param parser BinaryParser to read the
|
|
35
|
-
* @param hint The number of bytes to consume from the parser.
|
|
36
|
-
* For an MPT amount, pass 24 (the fixed length for Hash192).
|
|
33
|
+
* @param parser BinaryParser to read the Issue from
|
|
37
34
|
*
|
|
38
35
|
* @returns An Issue object
|
|
39
36
|
*/
|
|
40
|
-
static fromParser(parser: BinaryParser
|
|
37
|
+
static fromParser(parser: BinaryParser): Issue;
|
|
41
38
|
/**
|
|
42
|
-
* Get the JSON representation of this
|
|
39
|
+
* Get the JSON representation of this IssueObject
|
|
43
40
|
*
|
|
44
41
|
* @returns the JSON interpretation of this.bytes
|
|
45
42
|
*/
|
package/dist/src/types/issue.js
CHANGED
|
@@ -7,28 +7,30 @@ const account_id_1 = require("./account-id");
|
|
|
7
7
|
const currency_1 = require("./currency");
|
|
8
8
|
const serialized_type_1 = require("./serialized-type");
|
|
9
9
|
const hash_192_1 = require("./hash-192");
|
|
10
|
+
const utils_2 = require("../utils");
|
|
10
11
|
/**
|
|
11
12
|
* Type guard for Issue Object
|
|
12
13
|
*/
|
|
13
14
|
function isIssueObject(arg) {
|
|
14
15
|
const keys = Object.keys(arg).sort();
|
|
15
|
-
const isXRP = keys.length === 1 && keys[0] ===
|
|
16
|
-
const isIOU = keys.length === 2 && keys[0] ===
|
|
17
|
-
const isMPT = keys.length === 1 && keys[0] ===
|
|
16
|
+
const isXRP = keys.length === 1 && keys[0] === "currency";
|
|
17
|
+
const isIOU = keys.length === 2 && keys[0] === "currency" && keys[1] === "issuer";
|
|
18
|
+
const isMPT = keys.length === 1 && keys[0] === "mpt_issuance_id";
|
|
18
19
|
return isXRP || isIOU || isMPT;
|
|
19
20
|
}
|
|
21
|
+
const MPT_WIDTH = 44;
|
|
22
|
+
const NO_ACCOUNT = account_id_1.AccountID.from("0000000000000000000000000000000000000001");
|
|
20
23
|
/**
|
|
21
|
-
* Class for serializing/Deserializing
|
|
24
|
+
* Class for serializing/Deserializing Issue
|
|
22
25
|
*/
|
|
23
26
|
class Issue extends serialized_type_1.SerializedType {
|
|
24
27
|
constructor(bytes) {
|
|
25
|
-
super(bytes !== null && bytes !== void 0 ? bytes : Issue.
|
|
28
|
+
super(bytes !== null && bytes !== void 0 ? bytes : Issue.XRP_ISSUE.bytes);
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
28
|
-
* Construct
|
|
31
|
+
* Construct Issue from XRPIssue, IOUIssue or MPTIssue
|
|
29
32
|
*
|
|
30
|
-
* @param value An
|
|
31
|
-
* representing an integer amount
|
|
33
|
+
* @param value An object representing an XRPIssue, IOUIssue or MPTIssue
|
|
32
34
|
* @returns An Issue object
|
|
33
35
|
*/
|
|
34
36
|
static from(value) {
|
|
@@ -49,47 +51,58 @@ class Issue extends serialized_type_1.SerializedType {
|
|
|
49
51
|
// MPT case
|
|
50
52
|
if (value.mpt_issuance_id) {
|
|
51
53
|
const mptIssuanceIdBytes = hash_192_1.Hash192.from(value.mpt_issuance_id.toString()).toBytes();
|
|
52
|
-
|
|
54
|
+
const issuerAccount = mptIssuanceIdBytes.slice(4);
|
|
55
|
+
const sequence = Number((0, utils_2.readUInt32BE)(mptIssuanceIdBytes.slice(0, 4), 0)); // sequence is in Big-endian format in mpt_issuance_id
|
|
56
|
+
// Convert to Little-endian
|
|
57
|
+
const sequenceBuffer = new Uint8Array(4);
|
|
58
|
+
new DataView(sequenceBuffer.buffer).setUint32(0, sequence, true);
|
|
59
|
+
return new Issue((0, utils_1.concat)([issuerAccount, NO_ACCOUNT.toBytes(), sequenceBuffer]));
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
|
-
throw new Error(
|
|
62
|
+
throw new Error("Invalid type to construct an Issue");
|
|
56
63
|
}
|
|
57
64
|
/**
|
|
58
|
-
* Read
|
|
65
|
+
* Read Issue from a BinaryParser
|
|
59
66
|
*
|
|
60
|
-
* @param parser BinaryParser to read the
|
|
61
|
-
* @param hint The number of bytes to consume from the parser.
|
|
62
|
-
* For an MPT amount, pass 24 (the fixed length for Hash192).
|
|
67
|
+
* @param parser BinaryParser to read the Issue from
|
|
63
68
|
*
|
|
64
69
|
* @returns An Issue object
|
|
65
70
|
*/
|
|
66
|
-
static fromParser(parser
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
static fromParser(parser) {
|
|
72
|
+
// XRP
|
|
73
|
+
const currencyOrAccount = parser.read(20);
|
|
74
|
+
if (new currency_1.Currency(currencyOrAccount).toJSON() === "XRP") {
|
|
75
|
+
return new Issue(currencyOrAccount);
|
|
70
76
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
// MPT
|
|
78
|
+
const issuerAccountId = new account_id_1.AccountID(parser.read(20));
|
|
79
|
+
if (NO_ACCOUNT.toHex() === issuerAccountId.toHex()) {
|
|
80
|
+
const sequence = parser.read(4);
|
|
81
|
+
return new Issue((0, utils_1.concat)([currencyOrAccount, NO_ACCOUNT.toBytes(), sequence]));
|
|
74
82
|
}
|
|
75
|
-
|
|
76
|
-
return new Issue((0, utils_1.concat)(
|
|
83
|
+
// IOU
|
|
84
|
+
return new Issue((0, utils_1.concat)([currencyOrAccount, issuerAccountId.toBytes()]));
|
|
77
85
|
}
|
|
78
86
|
/**
|
|
79
|
-
* Get the JSON representation of this
|
|
87
|
+
* Get the JSON representation of this IssueObject
|
|
80
88
|
*
|
|
81
89
|
* @returns the JSON interpretation of this.bytes
|
|
82
90
|
*/
|
|
83
91
|
toJSON() {
|
|
84
|
-
// If the buffer is exactly
|
|
85
|
-
if (this.toBytes().length ===
|
|
92
|
+
// If the buffer is exactly 44 bytes, treat it as an MPTIssue.
|
|
93
|
+
if (this.toBytes().length === MPT_WIDTH) {
|
|
94
|
+
const issuerAccount = this.toBytes().slice(0, 20);
|
|
95
|
+
const sequence = new DataView(this.toBytes().slice(40).buffer).getUint32(0, true);
|
|
96
|
+
// sequence part of mpt_issuance_id should be in Big-endian
|
|
97
|
+
const sequenceBuffer = new Uint8Array(4);
|
|
98
|
+
(0, utils_2.writeUInt32BE)(sequenceBuffer, sequence, 0);
|
|
86
99
|
return {
|
|
87
|
-
mpt_issuance_id:
|
|
100
|
+
mpt_issuance_id: (0, utils_1.bytesToHex)((0, utils_1.concat)([sequenceBuffer, issuerAccount])),
|
|
88
101
|
};
|
|
89
102
|
}
|
|
90
103
|
const parser = new binary_parser_1.BinaryParser(this.toString());
|
|
91
104
|
const currency = currency_1.Currency.fromParser(parser);
|
|
92
|
-
if (currency.toJSON() ===
|
|
105
|
+
if (currency.toJSON() === "XRP") {
|
|
93
106
|
return { currency: currency.toJSON() };
|
|
94
107
|
}
|
|
95
108
|
const issuer = account_id_1.AccountID.fromParser(parser);
|
|
@@ -103,5 +116,5 @@ class Issue extends serialized_type_1.SerializedType {
|
|
|
103
116
|
}
|
|
104
117
|
}
|
|
105
118
|
exports.Issue = Issue;
|
|
106
|
-
Issue.
|
|
119
|
+
Issue.XRP_ISSUE = new Issue(new Uint8Array(20));
|
|
107
120
|
//# sourceMappingURL=issue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../../src/types/issue.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../../src/types/issue.ts"],"names":[],"mappings":";;;AAAA,qDAA+D;AAC/D,2DAAuD;AAEvD,6CAAyC;AACzC,yCAAsC;AACtC,uDAI2B;AAC3B,yCAAqC;AACrC,oCAAuD;AAkBvD;;GAEG;AACH,SAAS,aAAa,CAAC,GAAG;IACxB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC;IAC1D,MAAM,KAAK,GACT,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CA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