ripple-binary-codec 1.5.0-beta.3 → 1.5.0-beta.4
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 +21 -6
- package/dist/binary.js +28 -9
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +2 -2
- package/dist/coretypes.js +2 -1
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/bytes.d.ts +1 -1
- package/dist/enums/bytes.js +24 -28
- package/dist/enums/bytes.js.map +1 -1
- package/dist/enums/definitions.json +78 -37
- package/dist/enums/field.d.ts +0 -1
- package/dist/enums/field.js +16 -22
- package/dist/enums/field.js.map +1 -1
- package/dist/enums/index.d.ts +12 -48
- package/dist/enums/index.js +18 -109
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +78 -37
- package/dist/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/enums/xrpl-definitions-base.js +59 -0
- package/dist/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/enums/xrpl-definitions.d.ts +7 -30
- package/dist/enums/xrpl-definitions.js +12 -52
- package/dist/enums/xrpl-definitions.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.js +24 -9
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +4 -1
- package/dist/ledger-hashes.js +4 -2
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +6 -3
- package/dist/serdes/binary-parser.js +5 -2
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +1 -1
- package/dist/shamap.js +3 -1
- package/dist/shamap.js.map +1 -1
- package/dist/types/index.d.ts +3 -22
- package/dist/types/index.js +21 -8
- package/dist/types/index.js.map +1 -1
- package/dist/types/st-object.d.ts +6 -3
- package/dist/types/st-object.js +7 -5
- package/dist/types/st-object.js.map +1 -1
- package/package.json +6 -5
- package/test/definitions.test.js +100 -0
- package/test/fixtures/codec-fixtures.json +78 -78
- package/test/signing-data-encoding.test.js +103 -1
- package/dist/serdes/bytes-list.d.ts +0 -29
- package/dist/serdes/bytes-list.js +0 -48
- package/dist/serdes/bytes-list.js.map +0 -1
- package/dist/types/issued-currency.d.ts +0 -46
- package/dist/types/issued-currency.js +0 -108
- package/dist/types/issued-currency.js.map +0 -1
- package/dist/types/xchain-attestation-batch.d.ts +0 -44
- package/dist/types/xchain-attestation-batch.js +0 -90
- package/dist/types/xchain-attestation-batch.js.map +0 -1
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'buffer/';
|
|
2
|
-
/**
|
|
3
|
-
* Bytes list is a collection of buffer objects
|
|
4
|
-
*/
|
|
5
|
-
declare class BytesList {
|
|
6
|
-
private bytesArray;
|
|
7
|
-
/**
|
|
8
|
-
* Get the total number of bytes in the BytesList
|
|
9
|
-
*
|
|
10
|
-
* @return the number of bytes
|
|
11
|
-
*/
|
|
12
|
-
getLength(): number;
|
|
13
|
-
/**
|
|
14
|
-
* Put bytes in the BytesList
|
|
15
|
-
*
|
|
16
|
-
* @param bytesArg A Buffer
|
|
17
|
-
* @return this BytesList
|
|
18
|
-
*/
|
|
19
|
-
put(bytesArg: Buffer): BytesList;
|
|
20
|
-
/**
|
|
21
|
-
* Write this BytesList to the back of another bytes list
|
|
22
|
-
*
|
|
23
|
-
* @param list The BytesList to write to
|
|
24
|
-
*/
|
|
25
|
-
toBytesSink(list: BytesList): void;
|
|
26
|
-
toBytes(): Buffer;
|
|
27
|
-
toHex(): string;
|
|
28
|
-
}
|
|
29
|
-
export { BytesList };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BytesList = void 0;
|
|
4
|
-
var buffer_1 = require("buffer/");
|
|
5
|
-
/**
|
|
6
|
-
* Bytes list is a collection of buffer objects
|
|
7
|
-
*/
|
|
8
|
-
var BytesList = /** @class */ (function () {
|
|
9
|
-
function BytesList() {
|
|
10
|
-
this.bytesArray = [];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Get the total number of bytes in the BytesList
|
|
14
|
-
*
|
|
15
|
-
* @return the number of bytes
|
|
16
|
-
*/
|
|
17
|
-
BytesList.prototype.getLength = function () {
|
|
18
|
-
return buffer_1.Buffer.concat(this.bytesArray).byteLength;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Put bytes in the BytesList
|
|
22
|
-
*
|
|
23
|
-
* @param bytesArg A Buffer
|
|
24
|
-
* @return this BytesList
|
|
25
|
-
*/
|
|
26
|
-
BytesList.prototype.put = function (bytesArg) {
|
|
27
|
-
var bytes = buffer_1.Buffer.from(bytesArg); // Temporary, to catch instances of Uint8Array being passed in
|
|
28
|
-
this.bytesArray.push(bytes);
|
|
29
|
-
return this;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Write this BytesList to the back of another bytes list
|
|
33
|
-
*
|
|
34
|
-
* @param list The BytesList to write to
|
|
35
|
-
*/
|
|
36
|
-
BytesList.prototype.toBytesSink = function (list) {
|
|
37
|
-
list.put(this.toBytes());
|
|
38
|
-
};
|
|
39
|
-
BytesList.prototype.toBytes = function () {
|
|
40
|
-
return buffer_1.Buffer.concat(this.bytesArray);
|
|
41
|
-
};
|
|
42
|
-
BytesList.prototype.toHex = function () {
|
|
43
|
-
return this.toBytes().toString('hex').toUpperCase();
|
|
44
|
-
};
|
|
45
|
-
return BytesList;
|
|
46
|
-
}());
|
|
47
|
-
exports.BytesList = BytesList;
|
|
48
|
-
//# sourceMappingURL=bytes-list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bytes-list.js","sourceRoot":"","sources":["../../src/serdes/bytes-list.ts"],"names":[],"mappings":";;;AAAA,kCAAgC;AAEhC;;GAEG;AACH;IAAA;QACU,eAAU,GAAkB,EAAE,CAAA;IAuCxC,CAAC;IArCC;;;;OAIG;IACI,6BAAS,GAAhB;QACE,OAAO,eAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,UAAU,CAAA;IAClD,CAAC;IAED;;;;;OAKG;IACI,uBAAG,GAAV,UAAW,QAAgB;QACzB,IAAM,KAAK,GAAG,eAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA,CAAC,8DAA8D;QAClG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC3B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACI,+BAAW,GAAlB,UAAmB,IAAe;QAChC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1B,CAAC;IAEM,2BAAO,GAAd;QACE,OAAO,eAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACvC,CAAC;IAED,yBAAK,GAAL;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IACrD,CAAC;IACH,gBAAC;AAAD,CAAC,AAxCD,IAwCC;AAEQ,8BAAS"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { BinaryParser } from '../serdes/binary-parser';
|
|
2
|
-
import { JsonObject, SerializedType } from './serialized-type';
|
|
3
|
-
import { Buffer } from 'buffer/';
|
|
4
|
-
/**
|
|
5
|
-
* Interface for JSON objects that represent amounts
|
|
6
|
-
*/
|
|
7
|
-
interface IssuedCurrencyObject extends JsonObject {
|
|
8
|
-
currency: string;
|
|
9
|
-
issuer: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Class for serializing/Deserializing Amounts
|
|
13
|
-
*/
|
|
14
|
-
declare class IssuedCurrency extends SerializedType {
|
|
15
|
-
static readonly ZERO_ISSUED_CURRENCY: IssuedCurrency;
|
|
16
|
-
constructor(bytes: Buffer);
|
|
17
|
-
/**
|
|
18
|
-
* Construct an amount from an IOU or string amount
|
|
19
|
-
*
|
|
20
|
-
* @param value An Amount, object representing an IOU, or a string
|
|
21
|
-
* representing an integer amount
|
|
22
|
-
* @returns An Amount object
|
|
23
|
-
*/
|
|
24
|
-
static from<T extends IssuedCurrency | IssuedCurrencyObject | string>(value: T): IssuedCurrency;
|
|
25
|
-
/**
|
|
26
|
-
* Read an amount from a BinaryParser
|
|
27
|
-
*
|
|
28
|
-
* @param parser BinaryParser to read the Amount from
|
|
29
|
-
* @returns An Amount object
|
|
30
|
-
*/
|
|
31
|
-
static fromParser(parser: BinaryParser): IssuedCurrency;
|
|
32
|
-
/**
|
|
33
|
-
* Get the JSON representation of this Amount
|
|
34
|
-
*
|
|
35
|
-
* @returns the JSON interpretation of this.bytes
|
|
36
|
-
*/
|
|
37
|
-
toJSON(): IssuedCurrencyObject | string;
|
|
38
|
-
/**
|
|
39
|
-
* Validate XRP amount
|
|
40
|
-
*
|
|
41
|
-
* @param value String representing XRP amount
|
|
42
|
-
* @returns void, but will throw if invalid amount
|
|
43
|
-
*/
|
|
44
|
-
private static assertXrpIsValid;
|
|
45
|
-
}
|
|
46
|
-
export { IssuedCurrency, IssuedCurrencyObject };
|
|
@@ -1,108 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.IssuedCurrency = void 0;
|
|
19
|
-
var binary_parser_1 = require("../serdes/binary-parser");
|
|
20
|
-
var account_id_1 = require("./account-id");
|
|
21
|
-
var currency_1 = require("./currency");
|
|
22
|
-
var serialized_type_1 = require("./serialized-type");
|
|
23
|
-
var buffer_1 = require("buffer/");
|
|
24
|
-
/**
|
|
25
|
-
* Type guard for AmountObject
|
|
26
|
-
*/
|
|
27
|
-
function isIssuedCurrencyObject(arg) {
|
|
28
|
-
var keys = Object.keys(arg).sort();
|
|
29
|
-
return keys.length === 2 && keys[0] === 'currency' && keys[1] === 'issuer';
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Class for serializing/Deserializing Amounts
|
|
33
|
-
*/
|
|
34
|
-
var IssuedCurrency = /** @class */ (function (_super) {
|
|
35
|
-
__extends(IssuedCurrency, _super);
|
|
36
|
-
function IssuedCurrency(bytes) {
|
|
37
|
-
return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : IssuedCurrency.ZERO_ISSUED_CURRENCY.bytes) || this;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Construct an amount from an IOU or string amount
|
|
41
|
-
*
|
|
42
|
-
* @param value An Amount, object representing an IOU, or a string
|
|
43
|
-
* representing an integer amount
|
|
44
|
-
* @returns An Amount object
|
|
45
|
-
*/
|
|
46
|
-
IssuedCurrency.from = function (value) {
|
|
47
|
-
if (value instanceof IssuedCurrency) {
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
50
|
-
if (typeof value === 'string') {
|
|
51
|
-
IssuedCurrency.assertXrpIsValid(value);
|
|
52
|
-
var currency = currency_1.Currency.from(value).toBytes();
|
|
53
|
-
return new IssuedCurrency(currency);
|
|
54
|
-
}
|
|
55
|
-
if (isIssuedCurrencyObject(value)) {
|
|
56
|
-
var currency = currency_1.Currency.from(value.currency).toBytes();
|
|
57
|
-
var issuer = account_id_1.AccountID.from(value.issuer).toBytes();
|
|
58
|
-
return new IssuedCurrency(buffer_1.Buffer.concat([currency, issuer]));
|
|
59
|
-
}
|
|
60
|
-
throw new Error('Invalid type to construct an Amount');
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Read an amount from a BinaryParser
|
|
64
|
-
*
|
|
65
|
-
* @param parser BinaryParser to read the Amount from
|
|
66
|
-
* @returns An Amount object
|
|
67
|
-
*/
|
|
68
|
-
IssuedCurrency.fromParser = function (parser) {
|
|
69
|
-
var currency = parser.read(20);
|
|
70
|
-
if (new currency_1.Currency(currency).toJSON() === 'XRP') {
|
|
71
|
-
return new IssuedCurrency(currency);
|
|
72
|
-
}
|
|
73
|
-
var currencyAndIssuer = [currency, parser.read(20)];
|
|
74
|
-
return new IssuedCurrency(buffer_1.Buffer.concat(currencyAndIssuer));
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Get the JSON representation of this Amount
|
|
78
|
-
*
|
|
79
|
-
* @returns the JSON interpretation of this.bytes
|
|
80
|
-
*/
|
|
81
|
-
IssuedCurrency.prototype.toJSON = function () {
|
|
82
|
-
var parser = new binary_parser_1.BinaryParser(this.toString());
|
|
83
|
-
var currency = currency_1.Currency.fromParser(parser);
|
|
84
|
-
if (currency.toJSON() === 'XRP') {
|
|
85
|
-
return currency.toJSON();
|
|
86
|
-
}
|
|
87
|
-
var issuer = account_id_1.AccountID.fromParser(parser);
|
|
88
|
-
return {
|
|
89
|
-
currency: currency.toJSON(),
|
|
90
|
-
issuer: issuer.toJSON(),
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Validate XRP amount
|
|
95
|
-
*
|
|
96
|
-
* @param value String representing XRP amount
|
|
97
|
-
* @returns void, but will throw if invalid amount
|
|
98
|
-
*/
|
|
99
|
-
IssuedCurrency.assertXrpIsValid = function (value) {
|
|
100
|
-
if (value !== 'XRP') {
|
|
101
|
-
throw new Error("".concat(value, " is an illegal amount"));
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
IssuedCurrency.ZERO_ISSUED_CURRENCY = new IssuedCurrency(buffer_1.Buffer.alloc(20));
|
|
105
|
-
return IssuedCurrency;
|
|
106
|
-
}(serialized_type_1.SerializedType));
|
|
107
|
-
exports.IssuedCurrency = IssuedCurrency;
|
|
108
|
-
//# sourceMappingURL=issued-currency.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"issued-currency.js","sourceRoot":"","sources":["../../src/types/issued-currency.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yDAAsD;AAEtD,2CAAwC;AACxC,uCAAqC;AACrC,qDAA8D;AAC9D,kCAAgC;AAUhC;;GAEG;AACH,SAAS,sBAAsB,CAAC,GAAG;IACjC,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAA;AAC5E,CAAC;AAED;;GAEG;AACH;IAA6B,kCAAc;IAKzC,wBAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,cAAc,CAAC,oBAAoB,CAAC,KAAK,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACI,mBAAI,GAAX,UACE,KAAQ;QAER,IAAI,KAAK,YAAY,cAAc,EAAE;YACnC,OAAO,KAAK,CAAA;SACb;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;YAEtC,IAAM,QAAQ,GAAG,mBAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;YAE/C,OAAO,IA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MAAM,CAAc,CAAA;QAExD,OAAO;YACL,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;SACxB,CAAA;IACH,CAAC;IAED;;;;;OAKG;IACY,+BAAgB,GAA/B,UAAgC,KAAa;QAC3C,IAAI,KAAK,KAAK,KAAK,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,UAAG,KAAK,0BAAuB,CAAC,CAAA;SACjD;IACH,CAAC;IAnFe,mCAAoB,GAAmB,IAAI,cAAc,CACvE,eAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CACjB,CAAA;IAkFH,qBAAC;CAAA,AArFD,CAA6B,gCAAc,GAqF1C;AAEQ,wCAAc"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { BinaryParser } from '../serdes/binary-parser';
|
|
2
|
-
import { JsonObject, SerializedType } from './serialized-type';
|
|
3
|
-
import { Buffer } from 'buffer/';
|
|
4
|
-
import { XChainBridgeObject } from './xchain-bridge';
|
|
5
|
-
/**
|
|
6
|
-
* Interface for JSON objects that represent cross-chain attestations
|
|
7
|
-
*/
|
|
8
|
-
interface XChainAttestationBatchObject extends JsonObject {
|
|
9
|
-
XChainBridge: XChainBridgeObject;
|
|
10
|
-
XChainClaimAttestationBatch: JsonObject[];
|
|
11
|
-
XChainCreateAccountAttestationBatch: JsonObject[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Class for serializing/deserializing XChainAttestationBatchs
|
|
15
|
-
*/
|
|
16
|
-
declare class XChainAttestationBatch extends SerializedType {
|
|
17
|
-
static readonly ZERO_XCHAIN_ATTESTATION_BATCH: XChainAttestationBatch;
|
|
18
|
-
static readonly TYPE_ORDER: {
|
|
19
|
-
name: string;
|
|
20
|
-
type: typeof SerializedType;
|
|
21
|
-
}[];
|
|
22
|
-
constructor(bytes: Buffer);
|
|
23
|
-
/**
|
|
24
|
-
* Construct a cross-chain bridge from a JSON
|
|
25
|
-
*
|
|
26
|
-
* @param value XChainAttestationBatch or JSON to parse into a XChainAttestationBatch
|
|
27
|
-
* @returns A XChainAttestationBatch object
|
|
28
|
-
*/
|
|
29
|
-
static from<T extends XChainAttestationBatch | XChainAttestationBatchObject>(value: T): XChainAttestationBatch;
|
|
30
|
-
/**
|
|
31
|
-
* Read a XChainAttestationBatch from a BinaryParser
|
|
32
|
-
*
|
|
33
|
-
* @param parser BinaryParser to read the XChainAttestationBatch from
|
|
34
|
-
* @returns A XChainAttestationBatch object
|
|
35
|
-
*/
|
|
36
|
-
static fromParser(parser: BinaryParser): XChainAttestationBatch;
|
|
37
|
-
/**
|
|
38
|
-
* Get the JSON representation of this XChainAttestationBatch
|
|
39
|
-
*
|
|
40
|
-
* @returns the JSON interpretation of this.bytes
|
|
41
|
-
*/
|
|
42
|
-
toJSON(): XChainAttestationBatchObject;
|
|
43
|
-
}
|
|
44
|
-
export { XChainAttestationBatch, XChainAttestationBatchObject };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XChainAttestationBatch = void 0;
|
|
4
|
-
const binary_parser_1 = require("../serdes/binary-parser");
|
|
5
|
-
const serialized_type_1 = require("./serialized-type");
|
|
6
|
-
const buffer_1 = require("buffer/");
|
|
7
|
-
const xchain_bridge_1 = require("./xchain-bridge");
|
|
8
|
-
const st_array_1 = require("./st-array");
|
|
9
|
-
/**
|
|
10
|
-
* Type guard for XChainAttestationBatchObject
|
|
11
|
-
*/
|
|
12
|
-
function isXChainAttestationBatchObject(arg) {
|
|
13
|
-
const keys = Object.keys(arg).sort();
|
|
14
|
-
return (keys.length === 3 &&
|
|
15
|
-
keys[0] === 'XChainBridge' &&
|
|
16
|
-
keys[1] === 'XChainClaimAttestationBatch' &&
|
|
17
|
-
keys[2] === 'XChainCreateAccountAttestationBatch');
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Class for serializing/deserializing XChainAttestationBatchs
|
|
21
|
-
*/
|
|
22
|
-
class XChainAttestationBatch extends serialized_type_1.SerializedType {
|
|
23
|
-
constructor(bytes) {
|
|
24
|
-
super(bytes !== null && bytes !== void 0 ? bytes : XChainAttestationBatch.ZERO_XCHAIN_ATTESTATION_BATCH.bytes);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Construct a cross-chain bridge from a JSON
|
|
28
|
-
*
|
|
29
|
-
* @param value XChainAttestationBatch or JSON to parse into a XChainAttestationBatch
|
|
30
|
-
* @returns A XChainAttestationBatch object
|
|
31
|
-
*/
|
|
32
|
-
static from(value) {
|
|
33
|
-
if (value instanceof XChainAttestationBatch) {
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
if (isXChainAttestationBatchObject(value)) {
|
|
37
|
-
const bytes = [];
|
|
38
|
-
this.TYPE_ORDER.forEach((item) => {
|
|
39
|
-
const { name, type } = item;
|
|
40
|
-
const object = type.from(value[name]);
|
|
41
|
-
bytes.push(object.toBytes());
|
|
42
|
-
});
|
|
43
|
-
return new XChainAttestationBatch(buffer_1.Buffer.concat(bytes));
|
|
44
|
-
}
|
|
45
|
-
throw new Error('Invalid type to construct a XChainAttestationBatch');
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Read a XChainAttestationBatch from a BinaryParser
|
|
49
|
-
*
|
|
50
|
-
* @param parser BinaryParser to read the XChainAttestationBatch from
|
|
51
|
-
* @returns A XChainAttestationBatch object
|
|
52
|
-
*/
|
|
53
|
-
static fromParser(parser) {
|
|
54
|
-
const bytes = [];
|
|
55
|
-
this.TYPE_ORDER.forEach((item) => {
|
|
56
|
-
const { type } = item;
|
|
57
|
-
const object = type.fromParser(parser);
|
|
58
|
-
bytes.push(object.toBytes());
|
|
59
|
-
});
|
|
60
|
-
return new XChainAttestationBatch(buffer_1.Buffer.concat(bytes));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get the JSON representation of this XChainAttestationBatch
|
|
64
|
-
*
|
|
65
|
-
* @returns the JSON interpretation of this.bytes
|
|
66
|
-
*/
|
|
67
|
-
toJSON() {
|
|
68
|
-
const parser = new binary_parser_1.BinaryParser(this.toString());
|
|
69
|
-
const json = {};
|
|
70
|
-
XChainAttestationBatch.TYPE_ORDER.forEach((item) => {
|
|
71
|
-
const { name, type } = item;
|
|
72
|
-
const object = type.fromParser(parser).toJSON();
|
|
73
|
-
json[name] = object;
|
|
74
|
-
});
|
|
75
|
-
return json;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.XChainAttestationBatch = XChainAttestationBatch;
|
|
79
|
-
XChainAttestationBatch.ZERO_XCHAIN_ATTESTATION_BATCH = new XChainAttestationBatch(buffer_1.Buffer.concat([
|
|
80
|
-
buffer_1.Buffer.from([0x14]),
|
|
81
|
-
buffer_1.Buffer.alloc(40),
|
|
82
|
-
buffer_1.Buffer.from([0x14]),
|
|
83
|
-
buffer_1.Buffer.alloc(40),
|
|
84
|
-
]));
|
|
85
|
-
XChainAttestationBatch.TYPE_ORDER = [
|
|
86
|
-
{ name: 'XChainBridge', type: xchain_bridge_1.XChainBridge },
|
|
87
|
-
{ name: 'XChainClaimAttestationBatch', type: st_array_1.STArray },
|
|
88
|
-
{ name: 'XChainCreateAccountAttestationBatch', type: st_array_1.STArray },
|
|
89
|
-
];
|
|
90
|
-
//# sourceMappingURL=xchain-attestation-batch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xchain-attestation-batch.js","sourceRoot":"","sources":["../../src/types/xchain-attestation-batch.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AAEtD,uDAA8D;AAC9D,oCAAgC;AAChC,mDAAkE;AAClE,yCAAoC;AAWpC;;GAEG;AACH,SAAS,8BAA8B,CACrC,GAAG;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,OAAO,CACL,IAAI,CAAC,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