ripple-binary-codec 2.7.0-smartescrow.0 → 2.8.0-smartcontract.0
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 +173 -270
- package/dist/enums/src/enums/definitions.json +173 -270
- package/dist/quality.js +15 -3
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.js +8 -2
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +1 -1
- package/dist/serdes/binary-serializer.js +2 -2
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/src/enums/definitions.json +173 -270
- package/dist/src/quality.js +15 -3
- package/dist/src/quality.js.map +1 -1
- package/dist/src/serdes/binary-parser.js +8 -2
- package/dist/src/serdes/binary-parser.js.map +1 -1
- package/dist/src/serdes/binary-serializer.d.ts +1 -1
- package/dist/src/serdes/binary-serializer.js +2 -2
- package/dist/src/serdes/binary-serializer.js.map +1 -1
- package/dist/src/types/account-id.d.ts +2 -0
- package/dist/src/types/account-id.js +4 -0
- package/dist/src/types/account-id.js.map +1 -1
- package/dist/src/types/amount.d.ts +2 -1
- package/dist/src/types/amount.js +25 -4
- package/dist/src/types/amount.js.map +1 -1
- package/dist/src/types/blob.d.ts +2 -1
- package/dist/src/types/blob.js +3 -0
- package/dist/src/types/blob.js.map +1 -1
- package/dist/src/types/currency.d.ts +2 -0
- package/dist/src/types/currency.js +4 -0
- package/dist/src/types/currency.js.map +1 -1
- package/dist/src/types/data.d.ts +86 -0
- package/dist/src/types/data.js +252 -0
- package/dist/src/types/data.js.map +1 -0
- package/dist/src/types/dataType.d.ts +94 -0
- package/dist/src/types/dataType.js +145 -0
- package/dist/src/types/dataType.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +2 -0
- package/dist/src/types/hash-128.js +4 -0
- package/dist/src/types/hash-128.js.map +1 -1
- package/dist/src/types/hash-160.d.ts +2 -0
- package/dist/src/types/hash-160.js +4 -0
- package/dist/src/types/hash-160.js.map +1 -1
- package/dist/src/types/hash-192.d.ts +2 -0
- package/dist/src/types/hash-192.js +4 -0
- package/dist/src/types/hash-192.js.map +1 -1
- package/dist/src/types/hash-256.d.ts +2 -0
- package/dist/src/types/hash-256.js +4 -0
- package/dist/src/types/hash-256.js.map +1 -1
- package/dist/src/types/index.d.ts +3 -1
- package/dist/src/types/index.js +7 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/int-32.d.ts +17 -8
- package/dist/src/types/int-32.js +25 -11
- package/dist/src/types/int-32.js.map +1 -1
- 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 +2 -1
- package/dist/src/types/issue.js +3 -0
- package/dist/src/types/issue.js.map +1 -1
- package/dist/src/types/json.d.ts +173 -0
- package/dist/src/types/json.js +531 -0
- package/dist/src/types/json.js.map +1 -0
- package/dist/src/types/path-set.d.ts +2 -1
- package/dist/src/types/path-set.js +3 -0
- package/dist/src/types/path-set.js.map +1 -1
- package/dist/src/types/serialized-type.d.ts +43 -0
- package/dist/src/types/serialized-type.js +63 -1
- package/dist/src/types/serialized-type.js.map +1 -1
- package/dist/src/types/st-array.d.ts +2 -1
- package/dist/src/types/st-array.js +3 -0
- package/dist/src/types/st-array.js.map +1 -1
- package/dist/src/types/st-number.d.ts +2 -1
- package/dist/src/types/st-number.js +3 -0
- package/dist/src/types/st-number.js.map +1 -1
- package/dist/src/types/st-object.d.ts +2 -1
- package/dist/src/types/st-object.js +9 -1
- package/dist/src/types/st-object.js.map +1 -1
- package/dist/src/types/uint-16.d.ts +2 -0
- package/dist/src/types/uint-16.js +4 -0
- package/dist/src/types/uint-16.js.map +1 -1
- package/dist/src/types/uint-32.d.ts +2 -0
- package/dist/src/types/uint-32.js +4 -0
- package/dist/src/types/uint-32.js.map +1 -1
- package/dist/src/types/uint-64.d.ts +2 -0
- package/dist/src/types/uint-64.js +4 -0
- package/dist/src/types/uint-64.js.map +1 -1
- package/dist/src/types/uint-8.d.ts +2 -0
- package/dist/src/types/uint-8.js +4 -0
- package/dist/src/types/uint-8.js.map +1 -1
- package/dist/src/types/vector-256.d.ts +2 -1
- package/dist/src/types/vector-256.js +3 -0
- package/dist/src/types/vector-256.js.map +1 -1
- package/dist/src/types/xchain-bridge.d.ts +2 -1
- package/dist/src/types/xchain-bridge.js +3 -0
- package/dist/src/types/xchain-bridge.js.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/account-id.d.ts +2 -0
- package/dist/types/account-id.js +4 -0
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +2 -1
- package/dist/types/amount.js +25 -4
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +2 -1
- package/dist/types/blob.js +3 -0
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +2 -0
- package/dist/types/currency.js +4 -0
- package/dist/types/currency.js.map +1 -1
- package/dist/types/data.d.ts +86 -0
- package/dist/types/data.js +252 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/dataType.d.ts +94 -0
- package/dist/types/dataType.js +145 -0
- package/dist/types/dataType.js.map +1 -0
- package/dist/types/hash-128.d.ts +2 -0
- package/dist/types/hash-128.js +4 -0
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +2 -0
- package/dist/types/hash-160.js +4 -0
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +2 -0
- package/dist/types/hash-192.js +4 -0
- package/dist/types/hash-192.js.map +1 -1
- package/dist/types/hash-256.d.ts +2 -0
- package/dist/types/hash-256.js +4 -0
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +7 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/int-32.d.ts +17 -8
- package/dist/types/int-32.js +25 -11
- package/dist/types/int-32.js.map +1 -1
- 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 +2 -1
- package/dist/types/issue.js +3 -0
- package/dist/types/issue.js.map +1 -1
- package/dist/types/json.d.ts +173 -0
- package/dist/types/json.js +531 -0
- package/dist/types/json.js.map +1 -0
- package/dist/types/path-set.d.ts +2 -1
- package/dist/types/path-set.js +3 -0
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +43 -0
- package/dist/types/serialized-type.js +63 -1
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +2 -1
- package/dist/types/st-array.js +3 -0
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-number.d.ts +2 -1
- package/dist/types/st-number.js +3 -0
- package/dist/types/st-number.js.map +1 -1
- package/dist/types/st-object.d.ts +2 -1
- package/dist/types/st-object.js +9 -1
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +2 -0
- package/dist/types/uint-16.js +4 -0
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +2 -0
- package/dist/types/uint-32.js +4 -0
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +2 -0
- package/dist/types/uint-64.js +4 -0
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +2 -0
- package/dist/types/uint-8.js +4 -0
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/vector-256.d.ts +2 -1
- package/dist/types/vector-256.js +3 -0
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +2 -1
- package/dist/types/xchain-bridge.js +3 -0
- package/dist/types/xchain-bridge.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/enums/definitions.json +173 -270
- package/src/quality.ts +13 -3
- package/src/serdes/binary-parser.ts +12 -2
- package/src/serdes/binary-serializer.ts +2 -2
- package/src/types/account-id.ts +5 -0
- package/src/types/amount.ts +25 -6
- package/src/types/blob.ts +5 -1
- package/src/types/currency.ts +5 -0
- package/src/types/data.ts +294 -0
- package/src/types/dataType.ts +178 -0
- package/src/types/hash-128.ts +5 -0
- package/src/types/hash-160.ts +5 -0
- package/src/types/hash-192.ts +5 -0
- package/src/types/hash-256.ts +5 -0
- package/src/types/index.ts +6 -0
- package/src/types/int-32.ts +27 -12
- package/src/types/int.ts +75 -0
- package/src/types/issue.ts +5 -1
- package/src/types/json.ts +650 -0
- package/src/types/path-set.ts +5 -1
- package/src/types/serialized-type.ts +67 -0
- package/src/types/st-array.ts +5 -1
- package/src/types/st-number.ts +5 -1
- package/src/types/st-object.ts +12 -2
- package/src/types/uint-16.ts +5 -0
- package/src/types/uint-32.ts +5 -0
- package/src/types/uint-64.ts +6 -1
- package/src/types/uint-8.ts +5 -0
- package/src/types/vector-256.ts +5 -1
- package/src/types/xchain-bridge.ts +5 -1
- package/src/utils.ts +1 -1
package/dist/types/hash-160.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hash160 = void 0;
|
|
4
4
|
const hash_1 = require("./hash");
|
|
5
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
6
|
/**
|
|
6
7
|
* Hash with a width of 160 bits
|
|
7
8
|
*/
|
|
@@ -12,6 +13,9 @@ class Hash160 extends hash_1.Hash {
|
|
|
12
13
|
}
|
|
13
14
|
super(bytes !== null && bytes !== void 0 ? bytes : Hash160.ZERO_160.bytes);
|
|
14
15
|
}
|
|
16
|
+
getSType() {
|
|
17
|
+
return serialized_type_1.SerializedTypeID.STI_UINT160;
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
exports.Hash160 = Hash160;
|
|
17
21
|
Hash160.width = 20;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-160.js","sourceRoot":"","sources":["../../src/types/hash-160.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;
|
|
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"}
|
package/dist/types/hash-192.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hash } from './hash';
|
|
2
|
+
import { SerializedTypeID } from './serialized-type';
|
|
2
3
|
/**
|
|
3
4
|
* Hash with a width of 192 bits
|
|
4
5
|
*/
|
|
@@ -6,5 +7,6 @@ declare class Hash192 extends Hash {
|
|
|
6
7
|
static readonly width = 24;
|
|
7
8
|
static readonly ZERO_192: Hash192;
|
|
8
9
|
constructor(bytes?: Uint8Array);
|
|
10
|
+
getSType(): SerializedTypeID;
|
|
9
11
|
}
|
|
10
12
|
export { Hash192 };
|
package/dist/types/hash-192.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hash192 = void 0;
|
|
4
4
|
const hash_1 = require("./hash");
|
|
5
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
6
|
/**
|
|
6
7
|
* Hash with a width of 192 bits
|
|
7
8
|
*/
|
|
@@ -12,6 +13,9 @@ class Hash192 extends hash_1.Hash {
|
|
|
12
13
|
}
|
|
13
14
|
super(bytes !== null && bytes !== void 0 ? bytes : Hash192.ZERO_192.bytes);
|
|
14
15
|
}
|
|
16
|
+
getSType() {
|
|
17
|
+
return serialized_type_1.SerializedTypeID.STI_UINT192;
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
exports.Hash192 = Hash192;
|
|
17
21
|
Hash192.width = 24;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-192.js","sourceRoot":"","sources":["../../src/types/hash-192.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;
|
|
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"}
|
package/dist/types/hash-256.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hash } from './hash';
|
|
2
|
+
import { SerializedTypeID } from './serialized-type';
|
|
2
3
|
/**
|
|
3
4
|
* Hash with a width of 256 bits
|
|
4
5
|
*/
|
|
@@ -6,5 +7,6 @@ declare class Hash256 extends Hash {
|
|
|
6
7
|
static readonly width = 32;
|
|
7
8
|
static readonly ZERO_256: Hash256;
|
|
8
9
|
constructor(bytes: Uint8Array);
|
|
10
|
+
getSType(): SerializedTypeID;
|
|
9
11
|
}
|
|
10
12
|
export { Hash256 };
|
package/dist/types/hash-256.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hash256 = void 0;
|
|
4
4
|
const hash_1 = require("./hash");
|
|
5
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
6
|
/**
|
|
6
7
|
* Hash with a width of 256 bits
|
|
7
8
|
*/
|
|
@@ -9,6 +10,9 @@ class Hash256 extends hash_1.Hash {
|
|
|
9
10
|
constructor(bytes) {
|
|
10
11
|
super(bytes !== null && bytes !== void 0 ? bytes : Hash256.ZERO_256.bytes);
|
|
11
12
|
}
|
|
13
|
+
getSType() {
|
|
14
|
+
return serialized_type_1.SerializedTypeID.STI_UINT256;
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
exports.Hash256 = Hash256;
|
|
14
18
|
Hash256.width = 32;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-256.js","sourceRoot":"","sources":["../../src/types/hash-256.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;
|
|
1
|
+
{"version":3,"file":"hash-256.js","sourceRoot":"","sources":["../../src/types/hash-256.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,uDAAoD;AAEpD;;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;IAED,QAAQ;QACN,OAAO,kCAAgB,CAAC,WAAW,CAAA;IACrC,CAAC;;AAGM,0BAAO;AAZE,aAAK,GAAG,EAAE,CAAA;AACV,gBAAQ,GAAG,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { AccountID } from './account-id';
|
|
|
2
2
|
import { Amount } from './amount';
|
|
3
3
|
import { Blob } from './blob';
|
|
4
4
|
import { Currency } from './currency';
|
|
5
|
+
import { Data } from './data';
|
|
6
|
+
import { DataType } from './dataType';
|
|
5
7
|
import { Hash128 } from './hash-128';
|
|
6
8
|
import { Hash160 } from './hash-160';
|
|
7
9
|
import { Hash192 } from './hash-192';
|
|
@@ -17,4 +19,4 @@ import { UInt8 } from './uint-8';
|
|
|
17
19
|
import { Vector256 } from './vector-256';
|
|
18
20
|
import { type SerializedType } from './serialized-type';
|
|
19
21
|
declare const coreTypes: Record<string, typeof SerializedType>;
|
|
20
|
-
export { coreTypes, AccountID, Amount, Blob, Currency, Hash128, Hash160, Hash192, Hash256, Int32, 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/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.Int32 = exports.Hash256 = exports.Hash192 = exports.Hash160 = exports.Hash128 = 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");
|
|
@@ -9,6 +9,10 @@ const blob_1 = require("./blob");
|
|
|
9
9
|
Object.defineProperty(exports, "Blob", { enumerable: true, get: function () { return blob_1.Blob; } });
|
|
10
10
|
const currency_1 = require("./currency");
|
|
11
11
|
Object.defineProperty(exports, "Currency", { enumerable: true, get: function () { return currency_1.Currency; } });
|
|
12
|
+
const data_1 = require("./data");
|
|
13
|
+
Object.defineProperty(exports, "Data", { enumerable: true, get: function () { return data_1.Data; } });
|
|
14
|
+
const dataType_1 = require("./dataType");
|
|
15
|
+
Object.defineProperty(exports, "DataType", { enumerable: true, get: function () { return dataType_1.DataType; } });
|
|
12
16
|
const hash_128_1 = require("./hash-128");
|
|
13
17
|
Object.defineProperty(exports, "Hash128", { enumerable: true, get: function () { return hash_128_1.Hash128; } });
|
|
14
18
|
const hash_160_1 = require("./hash-160");
|
|
@@ -44,6 +48,8 @@ const coreTypes = {
|
|
|
44
48
|
Amount: amount_1.Amount,
|
|
45
49
|
Blob: blob_1.Blob,
|
|
46
50
|
Currency: currency_1.Currency,
|
|
51
|
+
Data: data_1.Data,
|
|
52
|
+
DataType: dataType_1.DataType,
|
|
47
53
|
Hash128: hash_128_1.Hash128,
|
|
48
54
|
Hash160: hash_160_1.Hash160,
|
|
49
55
|
Hash192: hash_192_1.Hash192,
|
package/dist/types/index.js.map
CHANGED
|
@@ -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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AAO;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"}
|
package/dist/types/int-32.d.ts
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Int } from './int';
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
3
|
/**
|
|
4
|
-
* Derived Int class for serializing/deserializing 32
|
|
4
|
+
* Derived Int class for serializing/deserializing signed 32-bit integers.
|
|
5
5
|
*/
|
|
6
|
-
declare class Int32 extends
|
|
6
|
+
declare class Int32 extends Int {
|
|
7
7
|
protected static readonly width: number;
|
|
8
8
|
static readonly defaultInt32: Int32;
|
|
9
|
+
static readonly MIN_VALUE: number;
|
|
10
|
+
static readonly MAX_VALUE: number;
|
|
9
11
|
constructor(bytes: Uint8Array);
|
|
10
|
-
static fromParser(parser: BinaryParser): UInt;
|
|
11
12
|
/**
|
|
12
|
-
* Construct
|
|
13
|
+
* Construct an Int32 from a BinaryParser
|
|
13
14
|
*
|
|
14
|
-
* @param
|
|
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
|
|
15
24
|
*/
|
|
16
25
|
static from<T extends Int32 | number | string>(val: T): Int32;
|
|
17
26
|
/**
|
|
18
|
-
*
|
|
27
|
+
* Get the value of the Int32 object
|
|
19
28
|
*
|
|
20
|
-
* @returns the
|
|
29
|
+
* @returns the signed 32-bit integer represented by this.bytes
|
|
21
30
|
*/
|
|
22
31
|
valueOf(): number;
|
|
23
32
|
}
|
package/dist/types/int-32.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Int32 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const int_1 = require("./int");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
/**
|
|
7
|
-
* Derived Int class for serializing/deserializing 32
|
|
7
|
+
* Derived Int class for serializing/deserializing signed 32-bit integers.
|
|
8
8
|
*/
|
|
9
|
-
class Int32 extends
|
|
9
|
+
class Int32 extends int_1.Int {
|
|
10
10
|
constructor(bytes) {
|
|
11
11
|
super(bytes !== null && bytes !== void 0 ? bytes : Int32.defaultInt32.bytes);
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Construct an Int32 from a BinaryParser
|
|
15
|
+
*
|
|
16
|
+
* @param parser BinaryParser to read Int32 from
|
|
17
|
+
* @returns An Int32 object
|
|
18
|
+
*/
|
|
13
19
|
static fromParser(parser) {
|
|
14
20
|
return new Int32(parser.read(Int32.width));
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
|
-
* Construct
|
|
23
|
+
* Construct an Int32 object from a number or string
|
|
18
24
|
*
|
|
19
|
-
* @param val Int32 object or
|
|
25
|
+
* @param val Int32 object, number, or string
|
|
26
|
+
* @returns An Int32 object
|
|
20
27
|
*/
|
|
21
28
|
static from(val) {
|
|
22
29
|
if (val instanceof Int32) {
|
|
@@ -24,27 +31,34 @@ class Int32 extends uint_1.UInt {
|
|
|
24
31
|
}
|
|
25
32
|
const buf = new Uint8Array(Int32.width);
|
|
26
33
|
if (typeof val === 'string') {
|
|
27
|
-
const num = Number
|
|
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);
|
|
28
39
|
(0, utils_1.writeInt32BE)(buf, num, 0);
|
|
29
40
|
return new Int32(buf);
|
|
30
41
|
}
|
|
31
|
-
if (typeof val === 'number') {
|
|
32
|
-
Int32.
|
|
42
|
+
if (typeof val === 'number' && Number.isInteger(val)) {
|
|
43
|
+
Int32.checkIntRange('Int32', val, Int32.MIN_VALUE, Int32.MAX_VALUE);
|
|
33
44
|
(0, utils_1.writeInt32BE)(buf, val, 0);
|
|
34
45
|
return new Int32(buf);
|
|
35
46
|
}
|
|
36
47
|
throw new Error('Cannot construct Int32 from given value');
|
|
37
48
|
}
|
|
38
49
|
/**
|
|
39
|
-
*
|
|
50
|
+
* Get the value of the Int32 object
|
|
40
51
|
*
|
|
41
|
-
* @returns the
|
|
52
|
+
* @returns the signed 32-bit integer represented by this.bytes
|
|
42
53
|
*/
|
|
43
54
|
valueOf() {
|
|
44
55
|
return (0, utils_1.readInt32BE)(this.bytes, 0);
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
exports.Int32 = Int32;
|
|
48
|
-
Int32.width = 32 / 8; // 4
|
|
59
|
+
Int32.width = 32 / 8; // 4 bytes
|
|
49
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
|
|
50
64
|
//# sourceMappingURL=int-32.js.map
|
package/dist/types/int-32.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int-32.js","sourceRoot":"","sources":["../../src/types/int-32.ts"],"names":[],"mappings":";;;AAAA
|
|
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,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAoC,GAAM;QACnD,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,OAAO,GAAG,CAAA;SACX;QAED,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAEvC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YACvB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;gBACnD,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,EAAE,CAAC,CAAA;aAC9D;YACD,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;YACnE,IAAA,oBAAY,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;SACtB;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YACpD,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;YACnE,IAAA,oBAAY,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;SACtB;QAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAC5D,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAA,mBAAW,EAAC,IAAI,CAAC,KAAK,EAAE,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"}
|
package/dist/types/issue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
2
|
-
import { JsonObject, SerializedType } from './serialized-type';
|
|
2
|
+
import { JsonObject, SerializedType, SerializedTypeID } from './serialized-type';
|
|
3
3
|
interface XRPIssue extends JsonObject {
|
|
4
4
|
currency: string;
|
|
5
5
|
}
|
|
@@ -41,5 +41,6 @@ declare class Issue extends SerializedType {
|
|
|
41
41
|
* @returns the JSON interpretation of this.bytes
|
|
42
42
|
*/
|
|
43
43
|
toJSON(): IssueObject;
|
|
44
|
+
getSType(): SerializedTypeID;
|
|
44
45
|
}
|
|
45
46
|
export { Issue, IssueObject };
|
package/dist/types/issue.js
CHANGED
|
@@ -111,6 +111,9 @@ class Issue extends serialized_type_1.SerializedType {
|
|
|
111
111
|
issuer: issuer.toJSON(),
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
+
getSType() {
|
|
115
|
+
return serialized_type_1.SerializedTypeID.STI_ISSUE;
|
|
116
|
+
}
|
|
114
117
|
}
|
|
115
118
|
exports.Issue = Issue;
|
|
116
119
|
Issue.XRP_ISSUE = new Issue(new Uint8Array(20));
|
package/dist/types/issue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../src/types/issue.ts"],"names":[],"mappings":";;;AAAA,mDAA4D;AAC5D,2DAAsD;AAEtD,6CAAwC;AACxC,yCAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../src/types/issue.ts"],"names":[],"mappings":";;;AAAA,mDAA4D;AAC5D,2DAAsD;AAEtD,6CAAwC;AACxC,yCAAqC;AACrC,uDAAgF;AAChF,yCAAoC;AACpC,oCAAsD;AAkBtD;;GAEG;AACH,SAAS,aAAa,CAAC,GAAG;IACxB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAA;IACzD,MAAM,KAAK,GACT,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAA;IACrE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAA;IAEhE,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,CAAA;AAChC,CAAC;AAED,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,MAAM,UAAU,GAAG,sBAAS,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAA;AAE7E;;GAEG;AACH,MAAM,KAAM,SAAQ,gCAAc;IAGhC,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,aAAL,K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+
import { BinarySerializer } from '../serdes/binary-serializer';
|
|
4
|
+
/**
|
|
5
|
+
* STJson: Serialized Type for JSON-like structures (objects or arrays).
|
|
6
|
+
*
|
|
7
|
+
* Supports two modes:
|
|
8
|
+
* - Object: Key-value pairs where keys are VL-encoded strings
|
|
9
|
+
* - Array: Ordered list of values
|
|
10
|
+
*
|
|
11
|
+
* Values are [SType marker][VL-encoded SType serialization].
|
|
12
|
+
* Values can be any SType, including nested STJson.
|
|
13
|
+
*
|
|
14
|
+
* Serialization format: [type_byte][VL_length][data...]
|
|
15
|
+
* - type_byte: 0x00 = Object, 0x01 = Array
|
|
16
|
+
*
|
|
17
|
+
* Depth constraint: Maximum nesting depth of 1 level
|
|
18
|
+
*/
|
|
19
|
+
declare class STJson extends SerializedType {
|
|
20
|
+
private static readonly JsonType;
|
|
21
|
+
private data;
|
|
22
|
+
private jsonType;
|
|
23
|
+
private default_;
|
|
24
|
+
/**
|
|
25
|
+
* Construct STJson from bytes
|
|
26
|
+
* @param bytes - Uint8Array containing serialized JSON
|
|
27
|
+
*/
|
|
28
|
+
constructor(bytes: Uint8Array);
|
|
29
|
+
/**
|
|
30
|
+
* Create an empty STJson with the given type
|
|
31
|
+
*/
|
|
32
|
+
private static createEmpty;
|
|
33
|
+
/**
|
|
34
|
+
* Parse STJson from BinaryParser
|
|
35
|
+
*
|
|
36
|
+
* @param parser - BinaryParser positioned at the start of STJson
|
|
37
|
+
* @returns STJson instance
|
|
38
|
+
*/
|
|
39
|
+
static fromParser(parser: BinaryParser): STJson;
|
|
40
|
+
/**
|
|
41
|
+
* Parse a single key-value pair from the parser
|
|
42
|
+
*/
|
|
43
|
+
private static parsePair;
|
|
44
|
+
/**
|
|
45
|
+
* Factory for SType value from VL blob (with SType marker)
|
|
46
|
+
*/
|
|
47
|
+
private static makeValueFromVLWithType;
|
|
48
|
+
/**
|
|
49
|
+
* Check if this is an array type
|
|
50
|
+
*/
|
|
51
|
+
isArray(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if this is an object type
|
|
54
|
+
*/
|
|
55
|
+
isObject(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get the JSON type
|
|
58
|
+
*/
|
|
59
|
+
getType(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Get nesting depth (0 = no nesting, 1 = one level of nesting)
|
|
62
|
+
*/
|
|
63
|
+
getDepth(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Validate nesting depth (max 1 level)
|
|
66
|
+
*/
|
|
67
|
+
private validateDepth;
|
|
68
|
+
/**
|
|
69
|
+
* Set a field in an object
|
|
70
|
+
*/
|
|
71
|
+
setObjectField(key: string, value: SerializedType | null): void;
|
|
72
|
+
/**
|
|
73
|
+
* Get a field from an object
|
|
74
|
+
*/
|
|
75
|
+
getObjectField(key: string): SerializedType | null | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Set a nested object field (one level deep)
|
|
78
|
+
*/
|
|
79
|
+
setNestedObjectField(key: string, nestedKey: string, value: SerializedType | null): void;
|
|
80
|
+
/**
|
|
81
|
+
* Get a nested object field
|
|
82
|
+
*/
|
|
83
|
+
getNestedObjectField(key: string, nestedKey: string): SerializedType | null | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Get the inner data as a Map (for objects)
|
|
86
|
+
*/
|
|
87
|
+
getMap(): Map<string, SerializedType | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Get the inner data as an array
|
|
90
|
+
*/
|
|
91
|
+
getArray(): (SerializedType | null)[];
|
|
92
|
+
/**
|
|
93
|
+
* Push an element to an array
|
|
94
|
+
*/
|
|
95
|
+
pushArrayElement(value: SerializedType | null): void;
|
|
96
|
+
/**
|
|
97
|
+
* Get an array element by index
|
|
98
|
+
*/
|
|
99
|
+
getArrayElement(index: number): SerializedType | null | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Set an array element by index
|
|
102
|
+
*/
|
|
103
|
+
setArrayElement(index: number, value: SerializedType | null): void;
|
|
104
|
+
/**
|
|
105
|
+
* Set a field within an array element (element must be an object)
|
|
106
|
+
*/
|
|
107
|
+
setArrayElementField(index: number, key: string, value: SerializedType | null): void;
|
|
108
|
+
/**
|
|
109
|
+
* Get a field within an array element
|
|
110
|
+
*/
|
|
111
|
+
getArrayElementField(index: number, key: string): SerializedType | null | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Get the size of the array
|
|
114
|
+
*/
|
|
115
|
+
arraySize(): number;
|
|
116
|
+
/**
|
|
117
|
+
* Set a nested array element (array stored in object field)
|
|
118
|
+
*/
|
|
119
|
+
setNestedArrayElement(key: string, index: number, value: SerializedType | null): void;
|
|
120
|
+
/**
|
|
121
|
+
* Set a field within a nested array element
|
|
122
|
+
*/
|
|
123
|
+
setNestedArrayElementField(key: string, index: number, nestedKey: string, value: SerializedType | null): void;
|
|
124
|
+
/**
|
|
125
|
+
* Get a nested array element
|
|
126
|
+
*/
|
|
127
|
+
getNestedArrayElement(key: string, index: number): SerializedType | null | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Get a field within a nested array element
|
|
130
|
+
*/
|
|
131
|
+
getNestedArrayElementField(key: string, index: number, nestedKey: string): SerializedType | null | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Serialize to binary
|
|
134
|
+
*/
|
|
135
|
+
add(s: BinarySerializer): void;
|
|
136
|
+
/**
|
|
137
|
+
* Encode a key as VL
|
|
138
|
+
*/
|
|
139
|
+
private static addVLKey;
|
|
140
|
+
/**
|
|
141
|
+
* Encode a value as [SType marker][VL]
|
|
142
|
+
*/
|
|
143
|
+
private static addVLValue;
|
|
144
|
+
/**
|
|
145
|
+
* Convert to JSON representation
|
|
146
|
+
*/
|
|
147
|
+
toJSON(): JsonObject | JsonObject[];
|
|
148
|
+
/**
|
|
149
|
+
* Compare with another STJson for equivalence
|
|
150
|
+
*/
|
|
151
|
+
isEquivalent(t: SerializedType): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Check if this is the default value
|
|
154
|
+
*/
|
|
155
|
+
isDefault(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Get blob representation
|
|
158
|
+
*/
|
|
159
|
+
toBlob(): Uint8Array;
|
|
160
|
+
/**
|
|
161
|
+
* Get the size (number of bytes in serialized form)
|
|
162
|
+
*/
|
|
163
|
+
size(): number;
|
|
164
|
+
/**
|
|
165
|
+
* Set the value from another STJson
|
|
166
|
+
*/
|
|
167
|
+
setValue(v: STJson): void;
|
|
168
|
+
/**
|
|
169
|
+
* Get serialized type ID
|
|
170
|
+
*/
|
|
171
|
+
getSType(): SerializedTypeID;
|
|
172
|
+
}
|
|
173
|
+
export { STJson };
|