From 5c5e4bd35c0af82c861582d720360584507cdca6 Mon Sep 17 00:00:00 2001 From: Tadej Golobic Date: Tue, 26 Jan 2021 22:56:51 +0100 Subject: [PATCH] fix(dist): remove dist folder --- .gitignore | 2 +- dist/binary.d.ts | 76 -- dist/binary.js | 113 -- dist/binary.js.map | 1 - dist/coretypes.d.ts | 9 - dist/coretypes.js | 24 - dist/coretypes.js.map | 1 - dist/enums/definitions.json | 1772 -------------------------- dist/enums/index.d.ts | 46 - dist/enums/index.js | 120 -- dist/enums/index.js.map | 1 - dist/enums/utils-renumber.d.ts | 101 -- dist/enums/utils-renumber.js | 127 -- dist/enums/utils-renumber.js.map | 1 - dist/hash-prefixes.d.ts | 6 - dist/hash-prefixes.js | 41 - dist/hash-prefixes.js.map | 1 - dist/hashes.d.ts | 51 - dist/hashes.js | 97 -- dist/hashes.js.map | 1 - dist/index.d.ts | 65 - dist/index.js | 98 -- dist/index.js.map | 1 - dist/ledger-hashes.d.ts | 46 - dist/ledger-hashes.js | 135 -- dist/ledger-hashes.js.map | 1 - dist/quality.d.ts | 22 - dist/quality.js | 43 - dist/quality.js.map | 1 - dist/serdes/binary-parser.d.ts | 98 -- dist/serdes/binary-parser.js | 185 --- dist/serdes/binary-parser.js.map | 1 - dist/serdes/binary-serializer.d.ts | 82 -- dist/serdes/binary-serializer.js | 148 --- dist/serdes/binary-serializer.js.map | 1 - dist/shamap.d.ts | 103 -- dist/shamap.js | 196 --- dist/shamap.js.map | 1 - dist/types/account-id.d.ts | 36 - dist/types/account-id.js | 80 -- dist/types/account-id.js.map | 1 - dist/types/amount.d.ts | 68 - dist/types/amount.js | 222 ---- dist/types/amount.js.map | 1 - dist/types/blob.d.ts | 25 - dist/types/blob.js | 55 - dist/types/blob.js.map | 1 - dist/types/currency.d.ts | 36 - dist/types/currency.js | 141 -- dist/types/currency.js.map | 1 - dist/types/hash-128.d.ts | 11 - dist/types/hash-128.js | 32 - dist/types/hash-128.js.map | 1 - dist/types/hash-160.d.ts | 11 - dist/types/hash-160.js | 37 - dist/types/hash-160.js.map | 1 - dist/types/hash-256.d.ts | 11 - dist/types/hash-256.js | 32 - dist/types/hash-256.js.map | 1 - dist/types/hash.d.ts | 41 - dist/types/hash.js | 88 -- dist/types/hash.js.map | 1 - dist/types/index.d.ts | 33 - dist/types/index.js | 44 - dist/types/index.js.map | 1 - dist/types/path-set.d.ts | 36 - dist/types/path-set.js | 251 ---- dist/types/path-set.js.map | 1 - dist/types/serialized-type.d.ts | 63 - dist/types/serialized-type.js | 116 -- dist/types/serialized-type.js.map | 1 - dist/types/st-array.d.ts | 28 - dist/types/st-array.js | 98 -- dist/types/st-array.js.map | 1 - dist/types/st-object.d.ts | 29 - dist/types/st-object.js | 157 --- dist/types/st-object.js.map | 1 - dist/types/uint-16.d.ts | 25 - dist/types/uint-16.js | 59 - dist/types/uint-16.js.map | 1 - dist/types/uint-32.d.ts | 25 - dist/types/uint-32.js | 64 - dist/types/uint-32.js.map | 1 - dist/types/uint-64.d.ts | 39 - dist/types/uint-64.js | 101 -- dist/types/uint-64.js.map | 1 - dist/types/uint-8.d.ts | 25 - dist/types/uint-8.js | 59 - dist/types/uint-8.js.map | 1 - dist/types/uint.d.ts | 30 - dist/types/uint.js | 57 - dist/types/uint.js.map | 1 - dist/types/vector-256.d.ts | 31 - dist/types/vector-256.js | 90 -- dist/types/vector-256.js.map | 1 - 95 files changed, 1 insertion(+), 6222 deletions(-) delete mode 100644 dist/binary.d.ts delete mode 100644 dist/binary.js delete mode 100644 dist/binary.js.map delete mode 100644 dist/coretypes.d.ts delete mode 100644 dist/coretypes.js delete mode 100644 dist/coretypes.js.map delete mode 100644 dist/enums/definitions.json delete mode 100644 dist/enums/index.d.ts delete mode 100644 dist/enums/index.js delete mode 100644 dist/enums/index.js.map delete mode 100644 dist/enums/utils-renumber.d.ts delete mode 100644 dist/enums/utils-renumber.js delete mode 100644 dist/enums/utils-renumber.js.map delete mode 100644 dist/hash-prefixes.d.ts delete mode 100644 dist/hash-prefixes.js delete mode 100644 dist/hash-prefixes.js.map delete mode 100644 dist/hashes.d.ts delete mode 100644 dist/hashes.js delete mode 100644 dist/hashes.js.map delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 dist/ledger-hashes.d.ts delete mode 100644 dist/ledger-hashes.js delete mode 100644 dist/ledger-hashes.js.map delete mode 100644 dist/quality.d.ts delete mode 100644 dist/quality.js delete mode 100644 dist/quality.js.map delete mode 100644 dist/serdes/binary-parser.d.ts delete mode 100644 dist/serdes/binary-parser.js delete mode 100644 dist/serdes/binary-parser.js.map delete mode 100644 dist/serdes/binary-serializer.d.ts delete mode 100644 dist/serdes/binary-serializer.js delete mode 100644 dist/serdes/binary-serializer.js.map delete mode 100644 dist/shamap.d.ts delete mode 100644 dist/shamap.js delete mode 100644 dist/shamap.js.map delete mode 100644 dist/types/account-id.d.ts delete mode 100644 dist/types/account-id.js delete mode 100644 dist/types/account-id.js.map delete mode 100644 dist/types/amount.d.ts delete mode 100644 dist/types/amount.js delete mode 100644 dist/types/amount.js.map delete mode 100644 dist/types/blob.d.ts delete mode 100644 dist/types/blob.js delete mode 100644 dist/types/blob.js.map delete mode 100644 dist/types/currency.d.ts delete mode 100644 dist/types/currency.js delete mode 100644 dist/types/currency.js.map delete mode 100644 dist/types/hash-128.d.ts delete mode 100644 dist/types/hash-128.js delete mode 100644 dist/types/hash-128.js.map delete mode 100644 dist/types/hash-160.d.ts delete mode 100644 dist/types/hash-160.js delete mode 100644 dist/types/hash-160.js.map delete mode 100644 dist/types/hash-256.d.ts delete mode 100644 dist/types/hash-256.js delete mode 100644 dist/types/hash-256.js.map delete mode 100644 dist/types/hash.d.ts delete mode 100644 dist/types/hash.js delete mode 100644 dist/types/hash.js.map delete mode 100644 dist/types/index.d.ts delete mode 100644 dist/types/index.js delete mode 100644 dist/types/index.js.map delete mode 100644 dist/types/path-set.d.ts delete mode 100644 dist/types/path-set.js delete mode 100644 dist/types/path-set.js.map delete mode 100644 dist/types/serialized-type.d.ts delete mode 100644 dist/types/serialized-type.js delete mode 100644 dist/types/serialized-type.js.map delete mode 100644 dist/types/st-array.d.ts delete mode 100644 dist/types/st-array.js delete mode 100644 dist/types/st-array.js.map delete mode 100644 dist/types/st-object.d.ts delete mode 100644 dist/types/st-object.js delete mode 100644 dist/types/st-object.js.map delete mode 100644 dist/types/uint-16.d.ts delete mode 100644 dist/types/uint-16.js delete mode 100644 dist/types/uint-16.js.map delete mode 100644 dist/types/uint-32.d.ts delete mode 100644 dist/types/uint-32.js delete mode 100644 dist/types/uint-32.js.map delete mode 100644 dist/types/uint-64.d.ts delete mode 100644 dist/types/uint-64.js delete mode 100644 dist/types/uint-64.js.map delete mode 100644 dist/types/uint-8.d.ts delete mode 100644 dist/types/uint-8.js delete mode 100644 dist/types/uint-8.js.map delete mode 100644 dist/types/uint.d.ts delete mode 100644 dist/types/uint.js delete mode 100644 dist/types/uint.js.map delete mode 100644 dist/types/vector-256.d.ts delete mode 100644 dist/types/vector-256.js delete mode 100644 dist/types/vector-256.js.map diff --git a/.gitignore b/.gitignore index c86d9aa..7c31fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,7 @@ test/config.js npm-debug.log # Ignore dist folder, build for bower -#dist/ +dist/ # Ignore flow output directory out/ diff --git a/dist/binary.d.ts b/dist/binary.d.ts deleted file mode 100644 index 91f7174..0000000 --- a/dist/binary.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { BinaryParser } from "./serdes/binary-parser"; -import { AccountID } from "./types/account-id"; -import { BinarySerializer, BytesList } from "./serdes/binary-serializer"; -import { sha512Half, transactionID } from "./hashes"; -import { JsonObject } from "./types/serialized-type"; -import { Buffer } from "buffer/"; -/** - * Construct a BinaryParser - * - * @param bytes hex-string to construct BinaryParser from - * @returns A BinaryParser - */ -declare const makeParser: (bytes: string) => BinaryParser; -/** - * Parse BinaryParser into JSON - * - * @param parser BinaryParser object - * @returns JSON for the bytes in the BinaryParser - */ -declare const readJSON: (parser: BinaryParser) => JsonObject; -/** - * Parse a hex-string into its JSON interpretation - * - * @param bytes hex-string to parse into JSON - * @returns JSON - */ -declare const binaryToJSON: (bytes: string) => JsonObject; -/** - * Interface for passing parameters to SerializeObject - * - * @field set signingFieldOnly to true if you want to serialize only signing fields - */ -interface OptionObject { - prefix?: Buffer; - suffix?: Buffer; - signingFieldsOnly?: boolean; -} -/** - * Function to serialize JSON object representing a transaction - * - * @param object JSON object to serialize - * @param opts options for serializing, including optional prefix, suffix, and signingFieldOnly - * @returns A Buffer containing the serialized object - */ -declare function serializeObject(object: JsonObject, opts?: OptionObject): Buffer; -/** - * Serialize an object for signing - * - * @param transaction Transaction to serialize - * @param prefix Prefix bytes to put before the serialized object - * @returns A Buffer with the serialized object - */ -declare function signingData(transaction: JsonObject, prefix?: Buffer): Buffer; -/** - * Interface describing fields required for a Claim - */ -interface ClaimObject extends JsonObject { - channel: string; - amount: string | number; -} -/** - * Serialize a signingClaim - * - * @param claim A claim object to serialize - * @returns the serialized object with appropriate prefix - */ -declare function signingClaimData(claim: ClaimObject): Buffer; -/** - * Serialize a transaction object for multiSigning - * - * @param transaction transaction to serialize - * @param signingAccount Account to sign the transaction with - * @returns serialized transaction with appropriate prefix and suffix - */ -declare function multiSigningData(transaction: JsonObject, signingAccount: string | AccountID): Buffer; -export { BinaryParser, BinarySerializer, BytesList, ClaimObject, makeParser, serializeObject, readJSON, multiSigningData, signingData, signingClaimData, binaryToJSON, sha512Half, transactionID, }; diff --git a/dist/binary.js b/dist/binary.js deleted file mode 100644 index 9f9118c..0000000 --- a/dist/binary.js +++ /dev/null @@ -1,113 +0,0 @@ -"use strict"; -/* eslint-disable func-style */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.transactionID = exports.sha512Half = exports.binaryToJSON = exports.signingClaimData = exports.signingData = exports.multiSigningData = exports.readJSON = exports.serializeObject = exports.makeParser = exports.BytesList = exports.BinarySerializer = exports.BinaryParser = void 0; -var types_1 = require("./types"); -var binary_parser_1 = require("./serdes/binary-parser"); -Object.defineProperty(exports, "BinaryParser", { enumerable: true, get: function () { return binary_parser_1.BinaryParser; } }); -var hash_prefixes_1 = require("./hash-prefixes"); -var binary_serializer_1 = require("./serdes/binary-serializer"); -Object.defineProperty(exports, "BinarySerializer", { enumerable: true, get: function () { return binary_serializer_1.BinarySerializer; } }); -Object.defineProperty(exports, "BytesList", { enumerable: true, get: function () { return binary_serializer_1.BytesList; } }); -var hashes_1 = require("./hashes"); -Object.defineProperty(exports, "sha512Half", { enumerable: true, get: function () { return hashes_1.sha512Half; } }); -Object.defineProperty(exports, "transactionID", { enumerable: true, get: function () { return hashes_1.transactionID; } }); -var bigInt = require("big-integer"); -/** - * Construct a BinaryParser - * - * @param bytes hex-string to construct BinaryParser from - * @returns A BinaryParser - */ -var makeParser = function (bytes) { return new binary_parser_1.BinaryParser(bytes); }; -exports.makeParser = makeParser; -/** - * Parse BinaryParser into JSON - * - * @param parser BinaryParser object - * @returns JSON for the bytes in the BinaryParser - */ -var readJSON = function (parser) { - return parser.readType(types_1.coreTypes.STObject).toJSON(); -}; -exports.readJSON = readJSON; -/** - * Parse a hex-string into its JSON interpretation - * - * @param bytes hex-string to parse into JSON - * @returns JSON - */ -var binaryToJSON = function (bytes) { return readJSON(makeParser(bytes)); }; -exports.binaryToJSON = binaryToJSON; -/** - * Function to serialize JSON object representing a transaction - * - * @param object JSON object to serialize - * @param opts options for serializing, including optional prefix, suffix, and signingFieldOnly - * @returns A Buffer containing the serialized object - */ -function serializeObject(object, opts) { - if (opts === void 0) { opts = {}; } - var prefix = opts.prefix, suffix = opts.suffix, _a = opts.signingFieldsOnly, signingFieldsOnly = _a === void 0 ? false : _a; - var bytesList = new binary_serializer_1.BytesList(); - if (prefix) { - bytesList.put(prefix); - } - var filter = signingFieldsOnly - ? function (f) { return f.isSigningField; } - : undefined; - types_1.coreTypes.STObject.from(object, filter).toBytesSink(bytesList); - if (suffix) { - bytesList.put(suffix); - } - return bytesList.toBytes(); -} -exports.serializeObject = serializeObject; -/** - * Serialize an object for signing - * - * @param transaction Transaction to serialize - * @param prefix Prefix bytes to put before the serialized object - * @returns A Buffer with the serialized object - */ -function signingData(transaction, prefix) { - if (prefix === void 0) { prefix = hash_prefixes_1.HashPrefix.transactionSig; } - return serializeObject(transaction, { prefix: prefix, signingFieldsOnly: true }); -} -exports.signingData = signingData; -/** - * Serialize a signingClaim - * - * @param claim A claim object to serialize - * @returns the serialized object with appropriate prefix - */ -function signingClaimData(claim) { - var num = bigInt(String(claim.amount)); - var prefix = hash_prefixes_1.HashPrefix.paymentChannelClaim; - var channel = types_1.coreTypes.Hash256.from(claim.channel).toBytes(); - var amount = types_1.coreTypes.UInt64.from(num).toBytes(); - var bytesList = new binary_serializer_1.BytesList(); - bytesList.put(prefix); - bytesList.put(channel); - bytesList.put(amount); - return bytesList.toBytes(); -} -exports.signingClaimData = signingClaimData; -/** - * Serialize a transaction object for multiSigning - * - * @param transaction transaction to serialize - * @param signingAccount Account to sign the transaction with - * @returns serialized transaction with appropriate prefix and suffix - */ -function multiSigningData(transaction, signingAccount) { - var prefix = hash_prefixes_1.HashPrefix.transactionMultiSig; - var suffix = types_1.coreTypes.AccountID.from(signingAccount).toBytes(); - return serializeObject(transaction, { - prefix: prefix, - suffix: suffix, - signingFieldsOnly: true, - }); -} -exports.multiSigningData = multiSigningData; -//# sourceMappingURL=binary.js.map \ No newline at end of file diff --git a/dist/binary.js.map b/dist/binary.js.map deleted file mode 100644 index 316ebed..0000000 --- a/dist/binary.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"binary.js","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;AAE/B,iCAAoC;AACpC,wDAAsD;AAyIpD,6FAzIO,4BAAY,OAyIP;AAvId,iDAA6C;AAC7C,gEAAyE;AAuIvE,iGAvIO,oCAAgB,OAuIP;AAChB,0FAxIyB,6BAAS,OAwIzB;AAvIX,mCAAqD;AAgJnD,2FAhJO,mBAA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KACxB,CAAC,CAAC;AACL,CAAC;AAUC,4CAAgB"} \ No newline at end of file diff --git a/dist/coretypes.d.ts b/dist/coretypes.d.ts deleted file mode 100644 index 0030fed..0000000 --- a/dist/coretypes.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Field, TransactionType, LedgerEntryType, Type, TransactionResult } from "./enums"; -import * as types from "./types"; -import * as binary from "./binary"; -import { ShaMap } from "./shamap"; -import * as ledgerHashes from "./ledger-hashes"; -import * as hashes from "./hashes"; -import { quality } from "./quality"; -import { HashPrefix } from "./hash-prefixes"; -export { hashes, binary, ledgerHashes, Field, TransactionType, LedgerEntryType, Type, TransactionResult, quality, HashPrefix, ShaMap, types, }; diff --git a/dist/coretypes.js b/dist/coretypes.js deleted file mode 100644 index 3cd0a03..0000000 --- a/dist/coretypes.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.types = exports.ShaMap = exports.HashPrefix = exports.quality = exports.TransactionResult = exports.Type = exports.LedgerEntryType = exports.TransactionType = exports.Field = exports.ledgerHashes = exports.binary = exports.hashes = void 0; -var enums_1 = require("./enums"); -Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return enums_1.Field; } }); -Object.defineProperty(exports, "TransactionType", { enumerable: true, get: function () { return enums_1.TransactionType; } }); -Object.defineProperty(exports, "LedgerEntryType", { enumerable: true, get: function () { return enums_1.LedgerEntryType; } }); -Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return enums_1.Type; } }); -Object.defineProperty(exports, "TransactionResult", { enumerable: true, get: function () { return enums_1.TransactionResult; } }); -var types = require("./types"); -exports.types = types; -var binary = require("./binary"); -exports.binary = binary; -var shamap_1 = require("./shamap"); -Object.defineProperty(exports, "ShaMap", { enumerable: true, get: function () { return shamap_1.ShaMap; } }); -var ledgerHashes = require("./ledger-hashes"); -exports.ledgerHashes = ledgerHashes; -var hashes = require("./hashes"); -exports.hashes = hashes; -var quality_1 = require("./quality"); -Object.defineProperty(exports, "quality", { enumerable: true, get: function () { return quality_1.quality; } }); -var hash_prefixes_1 = require("./hash-prefixes"); -Object.defineProperty(exports, "HashPrefix", { enumerable: true, get: function () { return hash_prefixes_1.HashPrefix; } }); -//# sourceMappingURL=coretypes.js.map \ No newline at end of file diff --git a/dist/coretypes.js.map b/dist/coretypes.js.map deleted file mode 100644 index da6c723..0000000 --- a/dist/coretypes.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"coretypes.js","sourceRoot":"","sources":["../src/coretypes.ts"],"names":[],"mappings":";;;AAAA,iCAMiB;AAaf,sFAlBA,aAAK,OAkBA;AACL,gGAlBA,uBAAe,OAkBA;AACf,gGAlBA,uBAAe,OAkBA;AACf,qFAlBA,YAAI,OAkBA;AACJ,kGAlBA,yBAAiB,OAkBA;AAhBnB,+BAAiC;AAoB/B,sBAAK;AAnBP,iCAAmC;AASjC,wBAAM;AARR,mCAAkC;AAiBhC,uFAjBO,eAAM,OAiBP;AAhBR,8CAAgD;AAQ9C,oCAAY;AAPd,iCAAmC;AAKjC,wBAAM;AAJR,qCAAoC;AAYlC,wFAZO,iBAAO,OAYP;AAXT,iDAA6C;AAY3C,2FAZO,0BAAU,OAYP"} \ No newline at end of file diff --git a/dist/enums/definitions.json b/dist/enums/definitions.json deleted file mode 100644 index b9efb96..0000000 --- a/dist/enums/definitions.json +++ /dev/null @@ -1,1772 +0,0 @@ -{ - "TYPES": { - "Validation": 10003, - "Done": -1, - "Hash128": 4, - "Blob": 7, - "AccountID": 8, - "Amount": 6, - "Hash256": 5, - "UInt8": 16, - "Vector256": 19, - "STObject": 14, - "Unknown": -2, - "Transaction": 10001, - "Hash160": 17, - "PathSet": 18, - "LedgerEntry": 10002, - "UInt16": 1, - "NotPresent": 0, - "UInt64": 3, - "UInt32": 2, - "STArray": 15 - }, - "LEDGER_ENTRY_TYPES": { - "Any": -3, - "Child": -2, - "Invalid": -1, - "AccountRoot": 97, - "DirectoryNode": 100, - "RippleState": 114, - "Ticket": 84, - "SignerList": 83, - "Offer": 111, - "LedgerHashes": 104, - "Amendments": 102, - "FeeSettings": 115, - "Escrow": 117, - "PayChannel": 120, - "DepositPreauth": 112, - "Check": 67, - "Nickname": 110, - "Contract": 99, - "GeneratorMap": 103, - "NegativeUNL": 78 - }, - "FIELDS": [ - [ - "Generic", - { - "nth": 0, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Unknown" - } - ], - [ - "Invalid", - { - "nth": -1, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Unknown" - } - ], - [ - "LedgerEntryType", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt16" - } - ], - [ - "TransactionType", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt16" - } - ], - [ - "SignerWeight", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt16" - } - ], - [ - "Flags", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "SourceTag", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "Sequence", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "PreviousTxnLgrSeq", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "LedgerSequence", - { - "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "CloseTime", - { - "nth": 7, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "ParentCloseTime", - { - "nth": 8, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "SigningTime", - { - "nth": 9, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "Expiration", - { - "nth": 10, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "TransferRate", - { - "nth": 11, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "WalletSize", - { - "nth": 12, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "OwnerCount", - { - "nth": 13, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "DestinationTag", - { - "nth": 14, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "HighQualityIn", - { - "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "HighQualityOut", - { - "nth": 17, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "LowQualityIn", - { - "nth": 18, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "LowQualityOut", - { - "nth": 19, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "QualityIn", - { - "nth": 20, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "QualityOut", - { - "nth": 21, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "StampEscrow", - { - "nth": 22, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "BondAmount", - { - "nth": 23, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "LoadFee", - { - "nth": 24, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "OfferSequence", - { - "nth": 25, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "FirstLedgerSequence", - { - "nth": 26, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "LastLedgerSequence", - { - "nth": 27, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "TransactionIndex", - { - "nth": 28, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "OperationLimit", - { - "nth": 29, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "ReferenceFeeUnits", - { - "nth": 30, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "ReserveBase", - { - "nth": 31, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "ReserveIncrement", - { - "nth": 32, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "SetFlag", - { - "nth": 33, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "ClearFlag", - { - "nth": 34, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "SignerQuorum", - { - "nth": 35, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "CancelAfter", - { - "nth": 36, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "FinishAfter", - { - "nth": 37, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "IndexNext", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "IndexPrevious", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "BookNode", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "OwnerNode", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "BaseFee", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "ExchangeRate", - { - "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "LowNode", - { - "nth": 7, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "HighNode", - { - "nth": 8, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ], - [ - "EmailHash", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash128" - } - ], - [ - "LedgerHash", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "ParentHash", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "TransactionHash", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "AccountHash", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "PreviousTxnID", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "LedgerIndex", - { - "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "WalletLocator", - { - "nth": 7, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "RootIndex", - { - "nth": 8, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "AccountTxnID", - { - "nth": 9, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "BookDirectory", - { - "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "InvoiceID", - { - "nth": 17, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "Nickname", - { - "nth": 18, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "Amendment", - { - "nth": 19, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "TicketID", - { - "nth": 20, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "Digest", - { - "nth": 21, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "hash", - { - "nth": 257, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Hash256" - } - ], - [ - "index", - { - "nth": 258, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Hash256" - } - ], - [ - "Amount", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "Balance", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "LimitAmount", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "TakerPays", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "TakerGets", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "LowLimit", - { - "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "HighLimit", - { - "nth": 7, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "Fee", - { - "nth": 8, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "SendMax", - { - "nth": 9, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "DeliverMin", - { - "nth": 10, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "MinimumOffer", - { - "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "RippleEscrow", - { - "nth": 17, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "DeliveredAmount", - { - "nth": 18, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], - [ - "taker_gets_funded", - { - "nth": 258, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Amount" - } - ], - [ - "taker_pays_funded", - { - "nth": 259, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Amount" - } - ], - [ - "PublicKey", - { - "nth": 1, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "MessageKey", - { - "nth": 2, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "SigningPubKey", - { - "nth": 3, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "TxnSignature", - { - "nth": 4, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": false, - "type": "Blob" - } - ], - [ - "Generator", - { - "nth": 5, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "Signature", - { - "nth": 6, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": false, - "type": "Blob" - } - ], - [ - "Domain", - { - "nth": 7, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "FundCode", - { - "nth": 8, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "RemoveCode", - { - "nth": 9, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "ExpireCode", - { - "nth": 10, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "CreateCode", - { - "nth": 11, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "MemoType", - { - "nth": 12, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "MemoData", - { - "nth": 13, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "MemoFormat", - { - "nth": 14, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "Fulfillment", - { - "nth": 16, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "Condition", - { - "nth": 17, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "MasterSignature", - { - "nth": 18, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": false, - "type": "Blob" - } - ], - [ - "UNLModifyValidator", - { - "nth": 19, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "ValidatorToDisable", - { - "nth": 20, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "ValidatorToReEnable", - { - "nth": 20, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Blob" - } - ], - [ - "Account", - { - "nth": 1, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "Owner", - { - "nth": 2, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "Destination", - { - "nth": 3, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "Issuer", - { - "nth": 4, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "Authorize", - { - "nth": 5, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "Unauthorize", - { - "nth": 6, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "Target", - { - "nth": 7, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "RegularKey", - { - "nth": 8, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], - [ - "ObjectEndMarker", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "TransactionMetaData", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "CreatedNode", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "DeletedNode", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "ModifiedNode", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "PreviousFields", - { - "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "FinalFields", - { - "nth": 7, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "NewFields", - { - "nth": 8, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "TemplateEntry", - { - "nth": 9, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "Memo", - { - "nth": 10, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "SignerEntry", - { - "nth": 11, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "Signer", - { - "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "Majority", - { - "nth": 18, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "DisabledValidator", - { - "nth": 19, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "ArrayEndMarker", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "Signers", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": false, - "type": "STArray" - } - ], - [ - "SignerEntries", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "Template", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "Necessary", - { - "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "Sufficient", - { - "nth": 7, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "AffectedNodes", - { - "nth": 8, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "Memos", - { - "nth": 9, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "Majorities", - { - "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "DisabledValidators", - { - "nth": 17, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], - [ - "CloseResolution", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt8" - } - ], - [ - "Method", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt8" - } - ], - [ - "TransactionResult", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt8" - } - ], - [ - "TakerPaysCurrency", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash160" - } - ], - [ - "TakerPaysIssuer", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash160" - } - ], - [ - "TakerGetsCurrency", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash160" - } - ], - [ - "TakerGetsIssuer", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash160" - } - ], - [ - "Paths", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "PathSet" - } - ], - [ - "Indexes", - { - "nth": 1, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Vector256" - } - ], - [ - "Hashes", - { - "nth": 2, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Vector256" - } - ], - [ - "Amendments", - { - "nth": 3, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "Vector256" - } - ], - [ - "Transaction", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Transaction" - } - ], - [ - "LedgerEntry", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "LedgerEntry" - } - ], - [ - "Validation", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Validation" - } - ], - [ - "SignerListID", - { - "nth": 38, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "SettleDelay", - { - "nth": 39, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "TicketCount", - { - "nth": 40, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "TicketSequence", - { - "nth": 41, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" - } - ], - [ - "Channel", - { - "nth": 22, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "ConsensusHash", - { - "nth": 23, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "CheckID", - { - "nth": 24, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Hash256" - } - ], - [ - "TickSize", - { - "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt8" - } - ], - [ - "UNLModifyDisabling", - { - "nth": 17, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt8" - } - ], - [ - "DestinationNode", - { - "nth": 9, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt64" - } - ] - ], - "TRANSACTION_RESULTS": { - "telLOCAL_ERROR": -399, - "telBAD_DOMAIN": -398, - "telBAD_PATH_COUNT": -397, - "telBAD_PUBLIC_KEY": -396, - "telFAILED_PROCESSING": -395, - "telINSUF_FEE_P": -394, - "telNO_DST_PARTIAL": -393, - "telCAN_NOT_QUEUE": -392, - "telCAN_NOT_QUEUE_BALANCE": -391, - "telCAN_NOT_QUEUE_BLOCKS": -390, - "telCAN_NOT_QUEUE_BLOCKED": -389, - "telCAN_NOT_QUEUE_FEE": -388, - "telCAN_NOT_QUEUE_FULL": -387, - - "temMALFORMED": -299, - "temBAD_AMOUNT": -298, - "temBAD_CURRENCY": -297, - "temBAD_EXPIRATION": -296, - "temBAD_FEE": -295, - "temBAD_ISSUER": -294, - "temBAD_LIMIT": -293, - "temBAD_OFFER": -292, - "temBAD_PATH": -291, - "temBAD_PATH_LOOP": -290, - "temBAD_REGKEY": -289, - "temBAD_SEND_XRP_LIMIT": -288, - "temBAD_SEND_XRP_MAX": -287, - "temBAD_SEND_XRP_NO_DIRECT": -286, - "temBAD_SEND_XRP_PARTIAL": -285, - "temBAD_SEND_XRP_PATHS": -284, - "temBAD_SEQUENCE": -283, - "temBAD_SIGNATURE": -282, - "temBAD_SRC_ACCOUNT": -281, - "temBAD_TRANSFER_RATE": -280, - "temDST_IS_SRC": -279, - "temDST_NEEDED": -278, - "temINVALID": -277, - "temINVALID_FLAG": -276, - "temREDUNDANT": -275, - "temRIPPLE_EMPTY": -274, - "temDISABLED": -273, - "temBAD_SIGNER": -272, - "temBAD_QUORUM": -271, - "temBAD_WEIGHT": -270, - "temBAD_TICK_SIZE": -269, - "temINVALID_ACCOUNT_ID": -268, - "temCANNOT_PREAUTH_SELF": -267, - "temUNCERTAIN": -266, - "temUNKNOWN": -265, - - "tefFAILURE": -199, - "tefALREADY": -198, - "tefBAD_ADD_AUTH": -197, - "tefBAD_AUTH": -196, - "tefBAD_LEDGER": -195, - "tefCREATED": -194, - "tefEXCEPTION": -193, - "tefINTERNAL": -192, - "tefNO_AUTH_REQUIRED": -191, - "tefPAST_SEQ": -190, - "tefWRONG_PRIOR": -189, - "tefMASTER_DISABLED": -188, - "tefMAX_LEDGER": -187, - "tefBAD_SIGNATURE": -186, - "tefBAD_QUORUM": -185, - "tefNOT_MULTI_SIGNING": -184, - "tefBAD_AUTH_MASTER": -183, - "tefINVARIANT_FAILED": -182, - "tefTOO_BIG": -181, - - "terRETRY": -99, - "terFUNDS_SPENT": -98, - "terINSUF_FEE_B": -97, - "terNO_ACCOUNT": -96, - "terNO_AUTH": -95, - "terNO_LINE": -94, - "terOWNERS": -93, - "terPRE_SEQ": -92, - "terLAST": -91, - "terNO_RIPPLE": -90, - "terQUEUED": -89, - - "tesSUCCESS": 0, - - "tecCLAIM": 100, - "tecPATH_PARTIAL": 101, - "tecUNFUNDED_ADD": 102, - "tecUNFUNDED_OFFER": 103, - "tecUNFUNDED_PAYMENT": 104, - "tecFAILED_PROCESSING": 105, - "tecDIR_FULL": 121, - "tecINSUF_RESERVE_LINE": 122, - "tecINSUF_RESERVE_OFFER": 123, - "tecNO_DST": 124, - "tecNO_DST_INSUF_XRP": 125, - "tecNO_LINE_INSUF_RESERVE": 126, - "tecNO_LINE_REDUNDANT": 127, - "tecPATH_DRY": 128, - "tecUNFUNDED": 129, - "tecNO_ALTERNATIVE_KEY": 130, - "tecNO_REGULAR_KEY": 131, - "tecOWNERS": 132, - "tecNO_ISSUER": 133, - "tecNO_AUTH": 134, - "tecNO_LINE": 135, - "tecINSUFF_FEE": 136, - "tecFROZEN": 137, - "tecNO_TARGET": 138, - "tecNO_PERMISSION": 139, - "tecNO_ENTRY": 140, - "tecINSUFFICIENT_RESERVE": 141, - "tecNEED_MASTER_KEY": 142, - "tecDST_TAG_NEEDED": 143, - "tecINTERNAL": 144, - "tecOVERSIZE": 145, - "tecCRYPTOCONDITION_ERROR": 146, - "tecINVARIANT_FAILED": 147, - "tecEXPIRED": 148, - "tecDUPLICATE": 149, - "tecKILLED": 150, - "tecHAS_OBLIGATIONS": 151, - "tecTOO_SOON": 152 - }, - "TRANSACTION_TYPES": { - "Invalid": -1, - - "Payment": 0, - "EscrowCreate": 1, - "EscrowFinish": 2, - "AccountSet": 3, - "EscrowCancel": 4, - "SetRegularKey": 5, - "NickNameSet": 6, - "OfferCreate": 7, - "OfferCancel": 8, - "Contract": 9, - "TicketCreate": 10, - "TicketCancel": 11, - "SignerListSet": 12, - "PaymentChannelCreate": 13, - "PaymentChannelFund": 14, - "PaymentChannelClaim": 15, - "CheckCreate": 16, - "CheckCash": 17, - "CheckCancel": 18, - "DepositPreauth": 19, - "TrustSet": 20, - "AccountDelete": 21, - - "EnableAmendment": 100, - "SetFee": 101, - "UNLModify": 102 - } -} diff --git a/dist/enums/index.d.ts b/dist/enums/index.d.ts deleted file mode 100644 index 344c7da..0000000 --- a/dist/enums/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { SerializedType } from "../types/serialized-type"; -import { Buffer } from "buffer/"; -declare class Bytes { - readonly name: string; - readonly ordinal: number; - readonly ordinalWidth: number; - readonly bytes: Uint8Array; - constructor(name: string, ordinal: number, ordinalWidth: number); - toJSON(): string; - toBytesSink(sink: any): void; - toBytes(): Uint8Array; -} -declare class BytesLookup { - readonly ordinalWidth: number; - constructor(types: Record, ordinalWidth: number); - from(value: Bytes | string): Bytes; - fromParser(parser: any): Bytes; -} -interface FieldInfo { - nth: number; - isVLEncoded: boolean; - isSerialized: boolean; - isSigningField: boolean; - type: string; -} -interface FieldInstance { - readonly nth: number; - readonly isVariableLengthEncoded: boolean; - readonly isSerialized: boolean; - readonly isSigningField: boolean; - readonly type: Bytes; - readonly ordinal: number; - readonly name: string; - readonly header: Buffer; - readonly associatedType: typeof SerializedType; -} -declare class FieldLookup { - constructor(fields: Array<[string, FieldInfo]>); - fromString(value: string): FieldInstance; -} -declare const Type: BytesLookup; -declare const LedgerEntryType: BytesLookup; -declare const TransactionType: BytesLookup; -declare const TransactionResult: BytesLookup; -declare const Field: FieldLookup; -export { Field, FieldInstance, Type, LedgerEntryType, TransactionResult, TransactionType, }; diff --git a/dist/enums/index.js b/dist/enums/index.js deleted file mode 100644 index 67e80df..0000000 --- a/dist/enums/index.js +++ /dev/null @@ -1,120 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TransactionType = exports.TransactionResult = exports.LedgerEntryType = exports.Type = exports.Field = void 0; -var enums = require("./definitions.json"); -var serialized_type_1 = require("../types/serialized-type"); -var buffer_1 = require("buffer/"); -var TYPE_WIDTH = 2; -var LEDGER_ENTRY_WIDTH = 2; -var TRANSACTION_TYPE_WIDTH = 2; -var TRANSACTION_RESULT_WIDTH = 1; -/* - * @brief: Serialize a field based on type_code and Field.nth - */ -function fieldHeader(type, nth) { - var header = []; - if (type < 16) { - if (nth < 16) { - header.push((type << 4) | nth); - } - else { - header.push(type << 4, nth); - } - } - else if (nth < 16) { - header.push(nth, type); - } - else { - header.push(0, type, nth); - } - return buffer_1.Buffer.from(header); -} -/* - * @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result - */ -var Bytes = /** @class */ (function () { - function Bytes(name, ordinal, ordinalWidth) { - this.name = name; - this.ordinal = ordinal; - this.ordinalWidth = ordinalWidth; - this.bytes = buffer_1.Buffer.alloc(ordinalWidth); - for (var i = 0; i < ordinalWidth; i++) { - this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff; - } - } - Bytes.prototype.toJSON = function () { - return this.name; - }; - Bytes.prototype.toBytesSink = function (sink) { - sink.put(this.bytes); - }; - Bytes.prototype.toBytes = function () { - return this.bytes; - }; - return Bytes; -}()); -/* - * @brief: Collection of Bytes objects, mapping bidirectionally - */ -var BytesLookup = /** @class */ (function () { - function BytesLookup(types, ordinalWidth) { - var _this = this; - this.ordinalWidth = ordinalWidth; - Object.entries(types).forEach(function (_a) { - var k = _a[0], v = _a[1]; - _this[k] = new Bytes(k, v, ordinalWidth); - _this[v.toString()] = _this[k]; - }); - } - BytesLookup.prototype.from = function (value) { - return value instanceof Bytes ? value : this[value]; - }; - BytesLookup.prototype.fromParser = function (parser) { - return this.from(parser.readUIntN(this.ordinalWidth).toString()); - }; - return BytesLookup; -}()); -function buildField(_a) { - var name = _a[0], info = _a[1]; - var typeOrdinal = enums.TYPES[info.type]; - var field = fieldHeader(typeOrdinal, info.nth); - return { - name: name, - nth: info.nth, - isVariableLengthEncoded: info.isVLEncoded, - isSerialized: info.isSerialized, - isSigningField: info.isSigningField, - ordinal: (typeOrdinal << 16) | info.nth, - type: new Bytes(info.type, typeOrdinal, TYPE_WIDTH), - header: field, - associatedType: serialized_type_1.SerializedType, - }; -} -/* - * @brief: The collection of all fields as defined in definitions.json - */ -var FieldLookup = /** @class */ (function () { - function FieldLookup(fields) { - var _this = this; - fields.forEach(function (_a) { - var k = _a[0], v = _a[1]; - _this[k] = buildField([k, v]); - _this[_this[k].ordinal.toString()] = _this[k]; - }); - } - FieldLookup.prototype.fromString = function (value) { - return this[value]; - }; - return FieldLookup; -}()); -var Type = new BytesLookup(enums.TYPES, TYPE_WIDTH); -exports.Type = Type; -var LedgerEntryType = new BytesLookup(enums.LEDGER_ENTRY_TYPES, LEDGER_ENTRY_WIDTH); -exports.LedgerEntryType = LedgerEntryType; -var TransactionType = new BytesLookup(enums.TRANSACTION_TYPES, TRANSACTION_TYPE_WIDTH); -exports.TransactionType = TransactionType; -var TransactionResult = new BytesLookup(enums.TRANSACTION_RESULTS, TRANSACTION_RESULT_WIDTH); -exports.TransactionResult = TransactionResult; -var Field = new FieldLookup(enums.FIELDS); -exports.Field = Field; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/enums/index.js.map b/dist/enums/index.js.map deleted file mode 100644 index 3fc68ab..0000000 --- a/dist/enums/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAC5C,4DAA0D;AAC1D,kCAAiC;AAEjC,IAAM,UAAU,GAAG,CAAC,CAAC;AACrB,IAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,IAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,IAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY,EAAE,GAAW;IAC5C,IAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,IAAI,GAAG,EAAE,EAAE;QACb,IAAI,GAAG,GAAG,EAAE,EAAE;YACZ,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;SAChC;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,GAAG,CAA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AKC;QAJC,MAAM,CAAC,OAAO,CAAC,UAAC,EAAM;gBAAL,CAAC,QAAA,EAAE,CAAC,QAAA;YACnB,KAAI,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7B,KAAI,CAAC,KAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAI,CAAC,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,gCAAU,GAAV,UAAW,KAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAkB,CAAC;IACtC,CAAC;IACH,kBAAC;AAAD,CAAC,AAXD,IAWC;AAED,IAAM,IAAI,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AAkBpD,oBAAI;AAjBN,IAAM,eAAe,GAAG,IAAI,WAAW,CACrC,KAAK,CAAC,kBAAkB,EACxB,kBAAkB,CACnB,CAAC;AAeA,0CAAe;AAdjB,IAAM,eAAe,GAAG,IAAI,WAAW,CACrC,KAAK,CAAC,iBAAiB,EACvB,sBAAsB,CACvB,CAAC;AAaA,0CAAe;AAZjB,IAAM,iBAAiB,GAAG,IAAI,WAAW,CACvC,KAAK,CAAC,mBAAmB,EACzB,wBAAwB,CACzB,CAAC;AAQA,8CAAiB;AAPnB,IAAM,KAAK,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,MAAoC,CAAC,CAAC;AAGxE,sBAAK"} \ No newline at end of file diff --git a/dist/enums/utils-renumber.d.ts b/dist/enums/utils-renumber.d.ts deleted file mode 100644 index 8174ca1..0000000 --- a/dist/enums/utils-renumber.d.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Quick script to re-number values - */ -declare const input: { - temBAD_SEND_XRP_PATHS: number; - temBAD_SEQUENCE: number; - temBAD_SIGNATURE: number; - temBAD_SRC_ACCOUNT: number; - temBAD_TRANSFER_RATE: number; - temDST_IS_SRC: number; - temDST_NEEDED: number; - temINVALID: number; - temINVALID_FLAG: number; - temREDUNDANT: number; - temRIPPLE_EMPTY: number; - temDISABLED: number; - temBAD_SIGNER: number; - temBAD_QUORUM: number; - temBAD_WEIGHT: number; - temBAD_TICK_SIZE: number; - temINVALID_ACCOUNT_ID: number; - temCANNOT_PREAUTH_SELF: number; - temUNCERTAIN: number; - temUNKNOWN: number; - tefFAILURE: number; - tefALREADY: number; - tefBAD_ADD_AUTH: number; - tefBAD_AUTH: number; - tefBAD_LEDGER: number; - tefCREATED: number; - tefEXCEPTION: number; - tefINTERNAL: number; - tefNO_AUTH_REQUIRED: number; - tefPAST_SEQ: number; - tefWRONG_PRIOR: number; - tefMASTER_DISABLED: number; - tefMAX_LEDGER: number; - tefBAD_SIGNATURE: number; - tefBAD_QUORUM: number; - tefNOT_MULTI_SIGNING: number; - tefBAD_AUTH_MASTER: number; - tefINVARIANT_FAILED: number; - tefTOO_BIG: number; - terRETRY: number; - terFUNDS_SPENT: number; - terINSUF_FEE_B: number; - terNO_ACCOUNT: number; - terNO_AUTH: number; - terNO_LINE: number; - terOWNERS: number; - terPRE_SEQ: number; - terLAST: number; - terNO_RIPPLE: number; - terQUEUED: number; - tesSUCCESS: number; - tecCLAIM: number; - tecPATH_PARTIAL: number; - tecUNFUNDED_ADD: number; - tecUNFUNDED_OFFER: number; - tecUNFUNDED_PAYMENT: number; - tecFAILED_PROCESSING: number; - tecDIR_FULL: number; - tecINSUF_RESERVE_LINE: number; - tecINSUF_RESERVE_OFFER: number; - tecNO_DST: number; - tecNO_DST_INSUF_XRP: number; - tecNO_LINE_INSUF_RESERVE: number; - tecNO_LINE_REDUNDANT: number; - tecPATH_DRY: number; - tecUNFUNDED: number; - tecNO_ALTERNATIVE_KEY: number; - tecNO_REGULAR_KEY: number; - tecOWNERS: number; - tecNO_ISSUER: number; - tecNO_AUTH: number; - tecNO_LINE: number; - tecINSUFF_FEE: number; - tecFROZEN: number; - tecNO_TARGET: number; - tecNO_PERMISSION: number; - tecNO_ENTRY: number; - tecINSUFFICIENT_RESERVE: number; - tecNEED_MASTER_KEY: number; - tecDST_TAG_NEEDED: number; - tecINTERNAL: number; - tecOVERSIZE: number; - tecCRYPTOCONDITION_ERROR: number; - tecINVARIANT_FAILED: number; - tecEXPIRED: number; - tecDUPLICATE: number; - tecKILLED: number; - tecHAS_OBLIGATIONS: number; - tecTOO_SOON: number; -}; -declare let startingFromTemBADSENDXRPPATHS: number; -declare let startingFromTefFAILURE: number; -declare let startingFromTerRETRY: number; -declare const tesSUCCESS = 0; -declare let startingFromTecCLAIM: number; -declare const startingFromTecDIRFULL = 121; -declare let previousKey: string; diff --git a/dist/enums/utils-renumber.js b/dist/enums/utils-renumber.js deleted file mode 100644 index 609f1c0..0000000 --- a/dist/enums/utils-renumber.js +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; -/** - * Quick script to re-number values - */ -var input = { - temBAD_SEND_XRP_PATHS: -283, - temBAD_SEQUENCE: -282, - temBAD_SIGNATURE: -281, - temBAD_SRC_ACCOUNT: -280, - temBAD_TRANSFER_RATE: -279, - temDST_IS_SRC: -278, - temDST_NEEDED: -277, - temINVALID: -276, - temINVALID_FLAG: -275, - temREDUNDANT: -274, - temRIPPLE_EMPTY: -273, - temDISABLED: -272, - temBAD_SIGNER: -271, - temBAD_QUORUM: -270, - temBAD_WEIGHT: -269, - temBAD_TICK_SIZE: -268, - temINVALID_ACCOUNT_ID: -267, - temCANNOT_PREAUTH_SELF: -266, - temUNCERTAIN: -265, - temUNKNOWN: -264, - tefFAILURE: -199, - tefALREADY: -198, - tefBAD_ADD_AUTH: -197, - tefBAD_AUTH: -196, - tefBAD_LEDGER: -195, - tefCREATED: -194, - tefEXCEPTION: -193, - tefINTERNAL: -192, - tefNO_AUTH_REQUIRED: -191, - tefPAST_SEQ: -190, - tefWRONG_PRIOR: -189, - tefMASTER_DISABLED: -188, - tefMAX_LEDGER: -187, - tefBAD_SIGNATURE: -186, - tefBAD_QUORUM: -185, - tefNOT_MULTI_SIGNING: -184, - tefBAD_AUTH_MASTER: -183, - tefINVARIANT_FAILED: -182, - tefTOO_BIG: -181, - terRETRY: -99, - terFUNDS_SPENT: -98, - terINSUF_FEE_B: -97, - terNO_ACCOUNT: -96, - terNO_AUTH: -95, - terNO_LINE: -94, - terOWNERS: -93, - terPRE_SEQ: -92, - terLAST: -91, - terNO_RIPPLE: -90, - terQUEUED: -89, - tesSUCCESS: 0, - tecCLAIM: 100, - tecPATH_PARTIAL: 101, - tecUNFUNDED_ADD: 102, - tecUNFUNDED_OFFER: 103, - tecUNFUNDED_PAYMENT: 104, - tecFAILED_PROCESSING: 105, - tecDIR_FULL: 121, - tecINSUF_RESERVE_LINE: 122, - tecINSUF_RESERVE_OFFER: 123, - tecNO_DST: 124, - tecNO_DST_INSUF_XRP: 125, - tecNO_LINE_INSUF_RESERVE: 126, - tecNO_LINE_REDUNDANT: 127, - tecPATH_DRY: 128, - tecUNFUNDED: 129, - tecNO_ALTERNATIVE_KEY: 130, - tecNO_REGULAR_KEY: 131, - tecOWNERS: 132, - tecNO_ISSUER: 133, - tecNO_AUTH: 134, - tecNO_LINE: 135, - tecINSUFF_FEE: 136, - tecFROZEN: 137, - tecNO_TARGET: 138, - tecNO_PERMISSION: 139, - tecNO_ENTRY: 140, - tecINSUFFICIENT_RESERVE: 141, - tecNEED_MASTER_KEY: 142, - tecDST_TAG_NEEDED: 143, - tecINTERNAL: 144, - tecOVERSIZE: 145, - tecCRYPTOCONDITION_ERROR: 146, - tecINVARIANT_FAILED: 147, - tecEXPIRED: 148, - tecDUPLICATE: 149, - tecKILLED: 150, - tecHAS_OBLIGATIONS: 151, - tecTOO_SOON: 152, -}; -var startingFromTemBADSENDXRPPATHS = -284; -var startingFromTefFAILURE = -199; -var startingFromTerRETRY = -99; -var tesSUCCESS = 0; -var startingFromTecCLAIM = 100; -var startingFromTecDIRFULL = 121; -var previousKey = "tem"; -Object.keys(input).forEach(function (key) { - if (key.substring(0, 3) !== previousKey.substring(0, 3)) { - console.log(); - previousKey = key; - } - if (key.substring(0, 3) === "tem") { - console.log(" \"" + key + "\": " + startingFromTemBADSENDXRPPATHS++ + ","); - } - else if (key.substring(0, 3) === "tef") { - console.log(" \"" + key + "\": " + startingFromTefFAILURE++ + ","); - } - else if (key.substring(0, 3) === "ter") { - console.log(" \"" + key + "\": " + startingFromTerRETRY++ + ","); - } - else if (key.substring(0, 3) === "tes") { - console.log(" \"" + key + "\": " + tesSUCCESS + ","); - } - else if (key.substring(0, 3) === "tec") { - if (key === "tecDIR_FULL") { - startingFromTecCLAIM = startingFromTecDIRFULL; - } - console.log(" \"" + key + "\": " + startingFromTecCLAIM++ + ","); - } -}); -//# sourceMappingURL=utils-renumber.js.map \ No newline at end of file diff --git a/dist/enums/utils-renumber.js.map b/dist/enums/utils-renumber.js.map deleted file mode 100644 index 348bab2..0000000 --- a/dist/enums/utils-renumber.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils-renumber.js","sourceRoot":"","sources":["../../src/enums/utils-renumber.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,IAAM,KAAK,GAAG;IACZ,qBAAqB,EAAE,CAAC,GAAG;IAC3B,eAAe,EAAE,CAAC,GAAG;IACrB,gBAAgB,EAAE,CAAC,GAAG;IACtB,kBAAkB,EAAE,CAAC,GAAG;IACxB,oBAAoB,EAAE,CAAC,GAAG;IAC1B,aAAa,EAAE,CAAC,GAAG;IACnB,aAAa,EAAE,CAAC,GAAG;IACnB,UAAU,EAAE,CAAC,GAAG;IAChB,eAAe,EAAE,CAAC,GAAG;IACrB,YAAY,EAAE,CAAC,GAAG;IAClB,eAAe,EAAE,CAAC,GAAG;IACrB,WAAW,EAAE,CAAC,GAAG;IACjB,aAAa,EAAE,CAAC,GAAG;IACnB,aAAa,EAAE,CAAC,GAAG;IACnB,aAAa,EAAE,CAAC,GAAG;IACnB,gBAAgB,EAAE,CAAC,GAAG;IACtB,qBAAqB,EAAE,CA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AC,EAAE,CAAC,CAAC,EAAE;QACvD,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,WAAW,GAAG,GAAG,CAAC;KACnB;IACD,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACjC,OAAO,CAAC,GAAG,CAAC,WAAQ,GAAG,YAAM,8BAA8B,EAAE,MAAG,CAAC,CAAC;KACnE;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,WAAQ,GAAG,YAAM,sBAAsB,EAAE,MAAG,CAAC,CAAC;KAC3D;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,WAAQ,GAAG,YAAM,oBAAoB,EAAE,MAAG,CAAC,CAAC;KACzD;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,WAAQ,GAAG,YAAM,UAAU,MAAG,CAAC,CAAC;KAC7C;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,IAAI,GAAG,KAAK,aAAa,EAAE;YACzB,oBAAoB,GAAG,sBAAsB,CAAC;SAC/C;QACD,OAAO,CAAC,GAAG,CAAC,WAAQ,GAAG,YAAM,oBAAoB,EAAE,MAAG,CAAC,CAAC;KACzD;AACH,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/hash-prefixes.d.ts b/dist/hash-prefixes.d.ts deleted file mode 100644 index e295f7b..0000000 --- a/dist/hash-prefixes.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Buffer } from "buffer/"; -/** - * Maps HashPrefix names to their byte representation - */ -declare const HashPrefix: Record; -export { HashPrefix }; diff --git a/dist/hash-prefixes.js b/dist/hash-prefixes.js deleted file mode 100644 index 35bf062..0000000 --- a/dist/hash-prefixes.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.HashPrefix = void 0; -var buffer_1 = require("buffer/"); -/** - * Write a 32 bit integer to a Buffer - * - * @param uint32 32 bit integer to write to buffer - * @returns a buffer with the bytes representation of uint32 - */ -function bytes(uint32) { - var result = buffer_1.Buffer.alloc(4); - result.writeUInt32BE(uint32, 0); - return result; -} -/** - * Maps HashPrefix names to their byte representation - */ -var HashPrefix = { - transactionID: bytes(0x54584e00), - // transaction plus metadata - transaction: bytes(0x534e4400), - // account state - accountStateEntry: bytes(0x4d4c4e00), - // inner node in tree - innerNode: bytes(0x4d494e00), - // ledger master data for signing - ledgerHeader: bytes(0x4c575200), - // inner transaction to sign - transactionSig: bytes(0x53545800), - // inner transaction to sign - transactionMultiSig: bytes(0x534d5400), - // validation for signing - validation: bytes(0x56414c00), - // proposal for signing - proposal: bytes(0x50525000), - // payment channel claim - paymentChannelClaim: bytes(0x434c4d00), -}; -exports.HashPrefix = HashPrefix; -//# sourceMappingURL=hash-prefixes.js.map \ No newline at end of file diff --git a/dist/hash-prefixes.js.map b/dist/hash-prefixes.js.map deleted file mode 100644 index 50f0ef9..0000000 --- a/dist/hash-prefixes.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash-prefixes.js","sourceRoot":"","sources":["../src/hash-prefixes.ts"],"names":[],"mappings":";;;AAAA,kCAAiC;AAEjC;;;;;GAKG;AACH,SAAS,KAAK,CAAC,MAAc;IAC3B,IAAM,MAAM,GAAG,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,IAAM,UAAU,GAA2B;IACzC,aAAa,EAAE,KAAK,CAAC,UAAU,CAAC;IAChC,4BAA4B;IAC5B,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC;IAC9B,gBAAgB;IAChB,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC;IACpC,qBAAqB;IACrB,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC;IAC5B,iCAAiC;IACjC,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC;IAC/B,4BAA4B;IAC5B,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC;IACjC,4BAA4B;IAC5B,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC;IACtC,yBAAyB;IACzB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC;IAC7B,uBAAuB;IACvB,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC;IAC3B,wBAAwB;IACxB,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC;CACvC,CAAC;AAEO,gCAAU"} \ No newline at end of file diff --git a/dist/hashes.d.ts b/dist/hashes.d.ts deleted file mode 100644 index 63cd8e3..0000000 --- a/dist/hashes.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Hash256 } from "./types/hash-256"; -import { BytesList } from "./serdes/binary-serializer"; -import { Buffer } from "buffer/"; -/** - * Class for hashing with SHA512 - * @extends BytesList So SerializedTypes can write bytes to a Sha512Half - */ -declare class Sha512Half extends BytesList { - private hash; - /** - * Construct a new Sha512Hash and write bytes this.hash - * - * @param bytes bytes to write to this.hash - * @returns the new Sha512Hash object - */ - static put(bytes: Buffer): Sha512Half; - /** - * Write bytes to an existing Sha512Hash - * - * @param bytes bytes to write to object - * @returns the Sha512 object - */ - put(bytes: Buffer): Sha512Half; - /** - * Compute SHA512 hash and slice in half - * - * @returns half of a SHA512 hash - */ - finish256(): Buffer; - /** - * Constructs a Hash256 from the Sha512Half object - * - * @returns a Hash256 object - */ - finish(): Hash256; -} -/** - * compute SHA512 hash of a list of bytes - * - * @param args zero or more arguments to hash - * @returns the sha512half hash of the arguments. - */ -declare function sha512Half(...args: Buffer[]): Buffer; -/** - * Construct a transactionID from a Serialized Transaction - * - * @param serialized bytes to hash - * @returns a Hash256 object - */ -declare function transactionID(serialized: Buffer): Hash256; -export { Sha512Half, sha512Half, transactionID }; diff --git a/dist/hashes.js b/dist/hashes.js deleted file mode 100644 index 786e86c..0000000 --- a/dist/hashes.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.transactionID = exports.sha512Half = exports.Sha512Half = void 0; -var hash_prefixes_1 = require("./hash-prefixes"); -var createHash = require("create-hash"); -var hash_256_1 = require("./types/hash-256"); -var binary_serializer_1 = require("./serdes/binary-serializer"); -/** - * Class for hashing with SHA512 - * @extends BytesList So SerializedTypes can write bytes to a Sha512Half - */ -var Sha512Half = /** @class */ (function (_super) { - __extends(Sha512Half, _super); - function Sha512Half() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.hash = createHash("sha512"); - return _this; - } - /** - * Construct a new Sha512Hash and write bytes this.hash - * - * @param bytes bytes to write to this.hash - * @returns the new Sha512Hash object - */ - Sha512Half.put = function (bytes) { - return new Sha512Half().put(bytes); - }; - /** - * Write bytes to an existing Sha512Hash - * - * @param bytes bytes to write to object - * @returns the Sha512 object - */ - Sha512Half.prototype.put = function (bytes) { - this.hash.update(bytes); - return this; - }; - /** - * Compute SHA512 hash and slice in half - * - * @returns half of a SHA512 hash - */ - Sha512Half.prototype.finish256 = function () { - var bytes = this.hash.digest(); - return bytes.slice(0, 32); - }; - /** - * Constructs a Hash256 from the Sha512Half object - * - * @returns a Hash256 object - */ - Sha512Half.prototype.finish = function () { - return new hash_256_1.Hash256(this.finish256()); - }; - return Sha512Half; -}(binary_serializer_1.BytesList)); -exports.Sha512Half = Sha512Half; -/** - * compute SHA512 hash of a list of bytes - * - * @param args zero or more arguments to hash - * @returns the sha512half hash of the arguments. - */ -function sha512Half() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var hash = new Sha512Half(); - args.forEach(function (a) { return hash.put(a); }); - return hash.finish256(); -} -exports.sha512Half = sha512Half; -/** - * Construct a transactionID from a Serialized Transaction - * - * @param serialized bytes to hash - * @returns a Hash256 object - */ -function transactionID(serialized) { - return new hash_256_1.Hash256(sha512Half(hash_prefixes_1.HashPrefix.transactionID, serialized)); -} -exports.transactionID = transactionID; -//# sourceMappingURL=hashes.js.map \ No newline at end of file diff --git a/dist/hashes.js.map b/dist/hashes.js.map deleted file mode 100644 index c3e719e..0000000 --- a/dist/hashes.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hashes.js","sourceRoot":"","sources":["../src/hashes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA6C;AAC7C,wCAA0C;AAC1C,6CAA2C;AAC3C,gEAAuD;AAGvD;;;GAGG;AACH;IAAyB,8BAAS;IAAlC;QAAA,qEA0CC;QAzCS,UAAI,GAAe,UAAU,CAAC,QAAQ,CAAC,CAAC;;IAyClD,CAAC;IAvCC;;;;;OAKG;IACI,cAAG,GAAV,UAAW,KAAa;QACtB,OAAO,IAAI,UAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACH,wBAAG,GAAH,UAAI,KAAa;QACf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,8BAAS,GAAT;QACE,IAAM,KAAK,GAAW,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,2BAAM,GAAN;QACE,OAAO,IAAI,kBAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACvC,CAAC;IACH,iBAAC;AAAD,CAAC,AA1CD,CAAyB,6BAAS,GA0CjC;AAwBQ,gCAAU;AAtBnB;;;;;GAKG;AACH,SAAS,UAAU;IAAC,cAAiB;SAAjB,UAAiB,EAAjB,qBAAiB,EAAjB,IAAiB;QAAjB,yBAAiB;;IACnC,IAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAX,CAAW,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;AAC1B,CAAC;AAYoB,gCAAU;AAV/B;;;;;GAKG;AACH,SAAS,aAAa,CAAC,UAAkB;IACvC,OAAO,IAAI,kBAAO,CAAC,UAAU,CAAC,0BAAU,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;AACvE,CAAC;AAEgC,sCAAa"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 42c83f9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { decodeLedgerData } from "./ledger-hashes"; -import { JsonObject } from "./types/serialized-type"; -/** - * Decode a transaction - * - * @param binary hex-string of the encoded transaction - * @returns the JSON representation of the transaction - */ -declare function decode(binary: string): JsonObject; -/** - * Encode a transaction - * - * @param json The JSON representation of a transaction - * @returns A hex-string of the encoded transaction - */ -declare function encode(json: object): string; -/** - * Encode a transaction and prepare for signing - * - * @param json JSON object representing the transaction - * @param signer string representing the account to sign the transaction with - * @returns a hex string of the encoded transaction - */ -declare function encodeForSigning(json: object): string; -/** - * Encode a transaction and prepare for signing with a claim - * - * @param json JSON object representing the transaction - * @param signer string representing the account to sign the transaction with - * @returns a hex string of the encoded transaction - */ -declare function encodeForSigningClaim(json: object): string; -/** - * Encode a transaction and prepare for multi-signing - * - * @param json JSON object representing the transaction - * @param signer string representing the account to sign the transaction with - * @returns a hex string of the encoded transaction - */ -declare function encodeForMultisigning(json: object, signer: string): string; -/** - * Encode a quality value - * - * @param value string representation of a number - * @returns a hex-string representing the quality - */ -declare function encodeQuality(value: string): string; -/** - * Decode a quality value - * - * @param value hex-string of a quality - * @returns a string representing the quality - */ -declare function decodeQuality(value: string): string; -declare const _default: { - decode: typeof decode; - encode: typeof encode; - encodeForSigning: typeof encodeForSigning; - encodeForSigningClaim: typeof encodeForSigningClaim; - encodeForMultisigning: typeof encodeForMultisigning; - encodeQuality: typeof encodeQuality; - decodeQuality: typeof decodeQuality; - decodeLedgerData: typeof decodeLedgerData; -}; -export = _default; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16020e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,98 +0,0 @@ -"use strict"; -var assert = require("assert"); -var coretypes_1 = require("./coretypes"); -var ledger_hashes_1 = require("./ledger-hashes"); -var signingData = coretypes_1.binary.signingData, signingClaimData = coretypes_1.binary.signingClaimData, multiSigningData = coretypes_1.binary.multiSigningData, binaryToJSON = coretypes_1.binary.binaryToJSON, serializeObject = coretypes_1.binary.serializeObject; -/** - * Decode a transaction - * - * @param binary hex-string of the encoded transaction - * @returns the JSON representation of the transaction - */ -function decode(binary) { - assert(typeof binary === "string", "binary must be a hex string"); - return binaryToJSON(binary); -} -/** - * Encode a transaction - * - * @param json The JSON representation of a transaction - * @returns A hex-string of the encoded transaction - */ -function encode(json) { - assert(typeof json === "object"); - return serializeObject(json) - .toString("hex") - .toUpperCase(); -} -/** - * Encode a transaction and prepare for signing - * - * @param json JSON object representing the transaction - * @param signer string representing the account to sign the transaction with - * @returns a hex string of the encoded transaction - */ -function encodeForSigning(json) { - assert(typeof json === "object"); - return signingData(json) - .toString("hex") - .toUpperCase(); -} -/** - * Encode a transaction and prepare for signing with a claim - * - * @param json JSON object representing the transaction - * @param signer string representing the account to sign the transaction with - * @returns a hex string of the encoded transaction - */ -function encodeForSigningClaim(json) { - assert(typeof json === "object"); - return signingClaimData(json) - .toString("hex") - .toUpperCase(); -} -/** - * Encode a transaction and prepare for multi-signing - * - * @param json JSON object representing the transaction - * @param signer string representing the account to sign the transaction with - * @returns a hex string of the encoded transaction - */ -function encodeForMultisigning(json, signer) { - assert(typeof json === "object"); - assert.equal(json["SigningPubKey"], ""); - return multiSigningData(json, signer) - .toString("hex") - .toUpperCase(); -} -/** - * Encode a quality value - * - * @param value string representation of a number - * @returns a hex-string representing the quality - */ -function encodeQuality(value) { - assert(typeof value === "string"); - return coretypes_1.quality.encode(value).toString("hex").toUpperCase(); -} -/** - * Decode a quality value - * - * @param value hex-string of a quality - * @returns a string representing the quality - */ -function decodeQuality(value) { - assert(typeof value === "string"); - return coretypes_1.quality.decode(value).toString(); -} -module.exports = { - decode: decode, - encode: encode, - encodeForSigning: encodeForSigning, - encodeForSigningClaim: encodeForSigningClaim, - encodeForMultisigning: encodeForMultisigning, - encodeQuality: encodeQuality, - decodeQuality: decodeQuality, - decodeLedgerData: ledger_hashes_1.decodeLedgerData, -}; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 7e29d97..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+BAAiC;AACjC,yCAA8C;AAC9C,iDAAmD;AAIjD,IAAA,WAAW,GAKT,kBAAM,YALG,EACX,gBAAgB,GAId,kBAAM,iBAJQ,EAChB,gBAAgB,GAGd,kBAAM,iBAHQ,EAChB,YAAY,GAEV,kBAAM,aAFI,EACZ,eAAe,G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OAAO,mBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;IAClC,OAAO,mBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC1C,CAAC;AAED,iBAAS;IACP,MAAM,QAAA;IACN,MAAM,QAAA;IACN,gBAAgB,kBAAA;IAChB,qBAAqB,uBAAA;IACrB,qBAAqB,uBAAA;IACrB,aAAa,eAAA;IACb,aAAa,eAAA;IACb,gBAAgB,kCAAA;CACjB,CAAC"} \ No newline at end of file diff --git a/dist/ledger-hashes.d.ts b/dist/ledger-hashes.d.ts deleted file mode 100644 index ee3e7a2..0000000 --- a/dist/ledger-hashes.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Hash256 } from "./types/hash-256"; -import { JsonObject } from "./types/serialized-type"; -import * as bigInt from "big-integer"; -/** - * Function computing the hash of a transaction tree - * - * @param param An array of transaction objects to hash - * @returns A Hash256 object - */ -declare function transactionTreeHash(param: Array): Hash256; -/** - * Function computing the hash of accountState - * - * @param param A list of accountStates hash - * @returns A Hash256 object - */ -declare function accountStateHash(param: Array): Hash256; -/** - * Interface describing a ledger header - */ -interface ledgerObject { - ledger_index: number; - total_coins: string | number | bigInt.BigInteger; - parent_hash: string; - transaction_hash: string; - account_hash: string; - parent_close_time: number; - close_time: number; - close_time_resolution: number; - close_flags: number; -} -/** - * Serialize and hash a ledger header - * - * @param header a ledger header - * @returns the hash of header - */ -declare function ledgerHash(header: ledgerObject): Hash256; -/** - * Decodes a serialized ledger header - * - * @param binary A serialized ledger header - * @returns A JSON object describing a ledger header - */ -declare function decodeLedgerData(binary: string): object; -export { accountStateHash, transactionTreeHash, ledgerHash, decodeLedgerData }; diff --git a/dist/ledger-hashes.js b/dist/ledger-hashes.js deleted file mode 100644 index b5f5615..0000000 --- a/dist/ledger-hashes.js +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.decodeLedgerData = exports.ledgerHash = exports.transactionTreeHash = exports.accountStateHash = void 0; -var assert = require("assert"); -var shamap_1 = require("./shamap"); -var hash_prefixes_1 = require("./hash-prefixes"); -var hashes_1 = require("./hashes"); -var binary_1 = require("./binary"); -var hash_256_1 = require("./types/hash-256"); -var st_object_1 = require("./types/st-object"); -var uint_64_1 = require("./types/uint-64"); -var uint_32_1 = require("./types/uint-32"); -var uint_8_1 = require("./types/uint-8"); -var binary_parser_1 = require("./serdes/binary-parser"); -var bigInt = require("big-integer"); -/** - * Computes the hash of a list of objects - * - * @param itemizer Converts an item into a format that can be added to SHAMap - * @param itemsJson Array of items to add to a SHAMap - * @returns the hash of the SHAMap - */ -function computeHash(itemizer, itemsJson) { - var map = new shamap_1.ShaMap(); - itemsJson.forEach(function (item) { return map.addItem.apply(map, itemizer(item)); }); - return map.hash(); -} -/** - * Convert a transaction into an index and an item - * - * @param json transaction with metadata - * @returns a tuple of index and item to be added to SHAMap - */ -function transactionItemizer(json) { - assert(json.hash); - var index = hash_256_1.Hash256.from(json.hash); - var item = { - hashPrefix: function () { - return hash_prefixes_1.HashPrefix.transaction; - }, - toBytesSink: function (sink) { - var serializer = new binary_1.BinarySerializer(sink); - serializer.writeLengthEncoded(st_object_1.STObject.from(json)); - serializer.writeLengthEncoded(st_object_1.STObject.from(json.metaData)); - }, - }; - return [index, item, undefined]; -} -/** - * Convert an entry to a pair Hash256 and ShaMapNode - * - * @param json JSON describing a ledger entry item - * @returns a tuple of index and item to be added to SHAMap - */ -function entryItemizer(json) { - var index = hash_256_1.Hash256.from(json.index); - var bytes = binary_1.serializeObject(json); - var item = { - hashPrefix: function () { - return hash_prefixes_1.HashPrefix.accountStateEntry; - }, - toBytesSink: function (sink) { - sink.put(bytes); - }, - }; - return [index, item, undefined]; -} -/** - * Function computing the hash of a transaction tree - * - * @param param An array of transaction objects to hash - * @returns A Hash256 object - */ -function transactionTreeHash(param) { - var itemizer = transactionItemizer; - return computeHash(itemizer, param); -} -exports.transactionTreeHash = transactionTreeHash; -/** - * Function computing the hash of accountState - * - * @param param A list of accountStates hash - * @returns A Hash256 object - */ -function accountStateHash(param) { - var itemizer = entryItemizer; - return computeHash(itemizer, param); -} -exports.accountStateHash = accountStateHash; -/** - * Serialize and hash a ledger header - * - * @param header a ledger header - * @returns the hash of header - */ -function ledgerHash(header) { - var hash = new hashes_1.Sha512Half(); - hash.put(hash_prefixes_1.HashPrefix.ledgerHeader); - assert(header.parent_close_time !== undefined); - assert(header.close_flags !== undefined); - uint_32_1.UInt32.from(header.ledger_index).toBytesSink(hash); - uint_64_1.UInt64.from(bigInt(String(header.total_coins))).toBytesSink(hash); - hash_256_1.Hash256.from(header.parent_hash).toBytesSink(hash); - hash_256_1.Hash256.from(header.transaction_hash).toBytesSink(hash); - hash_256_1.Hash256.from(header.account_hash).toBytesSink(hash); - uint_32_1.UInt32.from(header.parent_close_time).toBytesSink(hash); - uint_32_1.UInt32.from(header.close_time).toBytesSink(hash); - uint_8_1.UInt8.from(header.close_time_resolution).toBytesSink(hash); - uint_8_1.UInt8.from(header.close_flags).toBytesSink(hash); - return hash.finish(); -} -exports.ledgerHash = ledgerHash; -/** - * Decodes a serialized ledger header - * - * @param binary A serialized ledger header - * @returns A JSON object describing a ledger header - */ -function decodeLedgerData(binary) { - assert(typeof binary === "string", "binary must be a hex string"); - var parser = new binary_parser_1.BinaryParser(binary); - return { - ledger_index: parser.readUInt32(), - total_coins: parser.readType(uint_64_1.UInt64).valueOf().toString(), - parent_hash: parser.readType(hash_256_1.Hash256).toHex(), - transaction_hash: parser.readType(hash_256_1.Hash256).toHex(), - account_hash: parser.readType(hash_256_1.Hash256).toHex(), - parent_close_time: parser.readUInt32(), - close_time: parser.readUInt32(), - close_time_resolution: parser.readUInt8(), - close_flags: parser.readUInt8(), - }; -} -exports.decodeLedgerData = decodeLedgerData; -//# sourceMappingURL=ledger-hashes.js.map \ No newline at end of file diff --git a/dist/ledger-hashes.js.map b/dist/ledger-hashes.js.map deleted file mode 100644 index f0e724f..0000000 --- a/dist/ledger-hashes.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ledger-hashes.js","sourceRoot":"","sources":["../src/ledger-hashes.ts"],"names":[],"mappings":";;;AAAA,+BAAiC;AACjC,mCAA0D;AAC1D,iDAA6C;AAC7C,mCAAsC;AACtC,mCAA6D;AAC7D,6CAA2C;AAC3C,+CAA6C;AAC7C,2CAAyC;AACzC,2CAAyC;AACzC,yCAAuC;AACvC,wDAAsD;AAEtD,oCAAsC;AAEtC;;;;;;GAMG;AACH,SAAS,WAAW,CAClB,QAAoE,EACpE,SAA4B;IAE5B,IAAM,GAAG,GAAG,IAAI,eAAM,EAAE,CAAC;IACzB,SAAS,CAAC,OAAO,CAAC,UAAC,IAAI,IAAK,OAAA,GAAG,CAAC,OAAO,OAAX,GAAG,EAAY,QAAQ,CAAC,IAAI,CAAC,GAA7B,CAA8B,CAAC,CAAC;IAC5D,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC;AAUD;;;;;GAKG;AACH,SAAS,mBAAmB,CAC1B,IAA2B;IAE3B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,IAAM,KAAK,GAAG,kBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,IAAI,GAAG;QACX,UAAU;YACR,OAAO,0BAAU,CAAC,WAAW,CAAC;QAChC,CAAC;QACD,WAAW,YAAC,IAAI;YACd,IAAM,UAAU,GAAG,IAAI,yBAAgB,CAAC,IAAI,CAAC,CAAC;YAC9C,UAAU,CAAC,kBAAkB,CAAC,oBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACnD,UAAU,CAAC,kBAAkB,CAAC,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AAE,CAAC,QAAQ,EAAE;QACzD,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,kBAAO,CAAC,CAAC,KAAK,EAAE;QAC7C,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,kBAAO,CAAC,CAAC,KAAK,EAAE;QAClD,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,kBAAO,CAAC,CAAC,KAAK,EAAE;QAC9C,iBAAiB,EAAE,MAAM,CAAC,UAAU,EAAE;QACtC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;QAC/B,qBAAqB,EAAE,MAAM,CAAC,SAAS,EAAE;QACzC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE;KAChC,CAAC;AACJ,CAAC;AAE2D,4CAAgB"} \ No newline at end of file diff --git a/dist/quality.d.ts b/dist/quality.d.ts deleted file mode 100644 index 646b4db..0000000 --- a/dist/quality.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Decimal } from "decimal.js"; -import { Buffer } from "buffer/"; -/** - * class for encoding and decoding quality - */ -declare class quality { - /** - * Encode quality amount - * - * @param arg string representation of an amount - * @returns Serialized quality - */ - static encode(quality: string): Buffer; - /** - * Decode quality amount - * - * @param arg hex-string denoting serialized quality - * @returns deserialized quality - */ - static decode(quality: string): Decimal; -} -export { quality }; diff --git a/dist/quality.js b/dist/quality.js deleted file mode 100644 index 2c9d743..0000000 --- a/dist/quality.js +++ /dev/null @@ -1,43 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.quality = void 0; -var types_1 = require("./types"); -var decimal_js_1 = require("decimal.js"); -var bigInt = require("big-integer"); -var buffer_1 = require("buffer/"); -/** - * class for encoding and decoding quality - */ -var quality = /** @class */ (function () { - function quality() { - } - /** - * Encode quality amount - * - * @param arg string representation of an amount - * @returns Serialized quality - */ - quality.encode = function (quality) { - var decimal = new decimal_js_1.Decimal(quality); - var exponent = decimal.e - 15; - var qualityString = decimal.times("1e" + -exponent).abs().toString(); - var bytes = types_1.coreTypes.UInt64.from(bigInt(qualityString)).toBytes(); - bytes[0] = exponent + 100; - return bytes; - }; - /** - * Decode quality amount - * - * @param arg hex-string denoting serialized quality - * @returns deserialized quality - */ - quality.decode = function (quality) { - var bytes = buffer_1.Buffer.from(quality, "hex").slice(-8); - var exponent = bytes[0] - 100; - var mantissa = new decimal_js_1.Decimal("0x" + bytes.slice(1).toString("hex")); - return mantissa.times("1e" + exponent); - }; - return quality; -}()); -exports.quality = quality; -//# sourceMappingURL=quality.js.map \ No newline at end of file diff --git a/dist/quality.js.map b/dist/quality.js.map deleted file mode 100644 index 2a62161..0000000 --- a/dist/quality.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"quality.js","sourceRoot":"","sources":["../src/quality.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,yCAAqC;AACrC,oCAAsC;AACtC,kCAAiC;AAEjC;;GAEG;AACH;IAAA;IA4BA,CAAC;IA3BC;;;;;OAKG;IACI,cAAM,GAAb,UAAc,OAAe;QAC3B,IAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;QAChC,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,OAAK,CAAC,QAAU,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QACvE,IAAM,KAAK,GAAG,iBAAS,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACrE,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,GAAG,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,cAAM,GAAb,UAAc,OAAe;QAC3B,IAAM,KAAK,GAAG,eAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,IAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAChC,IAAM,QAAQ,GAAG,IAAI,oBAAO,CAAC,OAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAG,CAAC,CAAC;QACpE,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAK,QAAU,CAAC,CAAC;IACzC,CAAC;IACH,cAAC;AAAD,CAAC,AA5BD,IA4BC;AAEQ,0BAAO"} \ No newline at end of file diff --git a/dist/serdes/binary-parser.d.ts b/dist/serdes/binary-parser.d.ts deleted file mode 100644 index dbc50e1..0000000 --- a/dist/serdes/binary-parser.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { FieldInstance } from "../enums"; -import { SerializedType } from "../types/serialized-type"; -import { Buffer } from "buffer/"; -/** - * BinaryParser is used to compute fields and values from a HexString - */ -declare class BinaryParser { - private bytes; - /** - * Initialize bytes to a hex string - * - * @param hexBytes a hex string - */ - constructor(hexBytes: string); - /** - * Peek the first byte of the BinaryParser - * - * @returns The first byte of the BinaryParser - */ - peek(): number; - /** - * Consume the first n bytes of the BinaryParser - * - * @param n the number of bytes to skip - */ - skip(n: number): void; - /** - * read the first n bytes from the BinaryParser - * - * @param n The number of bytes to read - * @return The bytes - */ - read(n: number): Buffer; - /** - * Read an integer of given size - * - * @param n The number of bytes to read - * @return The number represented by those bytes - */ - readUIntN(n: number): number; - readUInt8(): number; - readUInt16(): number; - readUInt32(): number; - size(): number; - end(customEnd?: number): boolean; - /** - * Reads variable length encoded bytes - * - * @return The variable length bytes - */ - readVariableLength(): Buffer; - /** - * Reads the length of the variable length encoded bytes - * - * @return The length of the variable length encoded bytes - */ - readVariableLengthLength(): number; - /** - * Reads the field ordinal from the BinaryParser - * - * @return Field ordinal - */ - readFieldOrdinal(): number; - /** - * Read the field from the BinaryParser - * - * @return The field represented by the bytes at the head of the BinaryParser - */ - readField(): FieldInstance; - /** - * Read a given type from the BinaryParser - * - * @param type The type that you want to read from the BinaryParser - * @return The instance of that type read from the BinaryParser - */ - readType(type: typeof SerializedType): SerializedType; - /** - * Get the type associated with a given field - * - * @param field The field that you wan to get the type of - * @return The type associated with the given field - */ - typeForField(field: FieldInstance): typeof SerializedType; - /** - * Read value of the type specified by field from the BinaryParser - * - * @param field The field that you want to get the associated value for - * @return The value associated with the given field - */ - readFieldValue(field: FieldInstance): SerializedType; - /** - * Get the next field and value from the BinaryParser - * - * @return The field and value - */ - readFieldAndValue(): [FieldInstance, SerializedType]; -} -export { BinaryParser }; diff --git a/dist/serdes/binary-parser.js b/dist/serdes/binary-parser.js deleted file mode 100644 index a2b6a5c..0000000 --- a/dist/serdes/binary-parser.js +++ /dev/null @@ -1,185 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BinaryParser = void 0; -var assert = require("assert"); -var enums_1 = require("../enums"); -var buffer_1 = require("buffer/"); -/** - * BinaryParser is used to compute fields and values from a HexString - */ -var BinaryParser = /** @class */ (function () { - /** - * Initialize bytes to a hex string - * - * @param hexBytes a hex string - */ - function BinaryParser(hexBytes) { - this.bytes = buffer_1.Buffer.from(hexBytes, "hex"); - } - /** - * Peek the first byte of the BinaryParser - * - * @returns The first byte of the BinaryParser - */ - BinaryParser.prototype.peek = function () { - assert(this.bytes.byteLength !== 0); - return this.bytes[0]; - }; - /** - * Consume the first n bytes of the BinaryParser - * - * @param n the number of bytes to skip - */ - BinaryParser.prototype.skip = function (n) { - assert(n <= this.bytes.byteLength); - this.bytes = this.bytes.slice(n); - }; - /** - * read the first n bytes from the BinaryParser - * - * @param n The number of bytes to read - * @return The bytes - */ - BinaryParser.prototype.read = function (n) { - assert(n <= this.bytes.byteLength); - var slice = this.bytes.slice(0, n); - this.skip(n); - return slice; - }; - /** - * Read an integer of given size - * - * @param n The number of bytes to read - * @return The number represented by those bytes - */ - BinaryParser.prototype.readUIntN = function (n) { - assert(0 < n && n <= 4, "invalid n"); - return this.read(n).reduce(function (a, b) { return (a << 8) | b; }) >>> 0; - }; - BinaryParser.prototype.readUInt8 = function () { - return this.readUIntN(1); - }; - BinaryParser.prototype.readUInt16 = function () { - return this.readUIntN(2); - }; - BinaryParser.prototype.readUInt32 = function () { - return this.readUIntN(4); - }; - BinaryParser.prototype.size = function () { - return this.bytes.byteLength; - }; - BinaryParser.prototype.end = function (customEnd) { - var length = this.bytes.byteLength; - return length === 0 || (customEnd !== undefined && length <= customEnd); - }; - /** - * Reads variable length encoded bytes - * - * @return The variable length bytes - */ - BinaryParser.prototype.readVariableLength = function () { - return this.read(this.readVariableLengthLength()); - }; - /** - * Reads the length of the variable length encoded bytes - * - * @return The length of the variable length encoded bytes - */ - BinaryParser.prototype.readVariableLengthLength = function () { - var b1 = this.readUInt8(); - if (b1 <= 192) { - return b1; - } - else if (b1 <= 240) { - var b2 = this.readUInt8(); - return 193 + (b1 - 193) * 256 + b2; - } - else if (b1 <= 254) { - var b2 = this.readUInt8(); - var b3 = this.readUInt8(); - return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3; - } - throw new Error("Invalid variable length indicator"); - }; - /** - * Reads the field ordinal from the BinaryParser - * - * @return Field ordinal - */ - BinaryParser.prototype.readFieldOrdinal = function () { - var type = this.readUInt8(); - var nth = type & 15; - type >>= 4; - if (type === 0) { - type = this.readUInt8(); - if (type === 0 || type < 16) { - throw new Error("Cannot read FieldOrdinal, type_code out of range"); - } - } - if (nth === 0) { - nth = this.readUInt8(); - if (nth === 0 || nth < 16) { - throw new Error("Cannot read FieldOrdinal, field_code out of range"); - } - } - return (type << 16) | nth; - }; - /** - * Read the field from the BinaryParser - * - * @return The field represented by the bytes at the head of the BinaryParser - */ - BinaryParser.prototype.readField = function () { - return enums_1.Field.fromString(this.readFieldOrdinal().toString()); - }; - /** - * Read a given type from the BinaryParser - * - * @param type The type that you want to read from the BinaryParser - * @return The instance of that type read from the BinaryParser - */ - BinaryParser.prototype.readType = function (type) { - return type.fromParser(this); - }; - /** - * Get the type associated with a given field - * - * @param field The field that you wan to get the type of - * @return The type associated with the given field - */ - BinaryParser.prototype.typeForField = function (field) { - return field.associatedType; - }; - /** - * Read value of the type specified by field from the BinaryParser - * - * @param field The field that you want to get the associated value for - * @return The value associated with the given field - */ - BinaryParser.prototype.readFieldValue = function (field) { - var type = this.typeForField(field); - if (!type) { - throw new Error("unsupported: (" + field.name + ", " + field.type.name + ")"); - } - var sizeHint = field.isVariableLengthEncoded - ? this.readVariableLengthLength() - : undefined; - var value = type.fromParser(this, sizeHint); - if (value === undefined) { - throw new Error("fromParser for (" + field.name + ", " + field.type.name + ") -> undefined "); - } - return value; - }; - /** - * Get the next field and value from the BinaryParser - * - * @return The field and value - */ - BinaryParser.prototype.readFieldAndValue = function () { - var field = this.readField(); - return [field, this.readFieldValue(field)]; - }; - return BinaryParser; -}()); -exports.BinaryParser = BinaryParser; -//# sourceMappingURL=binary-parser.js.map \ No newline at end of file diff --git a/dist/serdes/binary-parser.js.map b/dist/serdes/binary-parser.js.map deleted file mode 100644 index 3a52168..0000000 --- a/dist/serdes/binary-parser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"binary-parser.js","sourceRoot":"","sources":["../../src/serdes/binary-parser.ts"],"names":[],"mappings":";;;AAAA,+BAAiC;AACjC,kCAAgD;AAEhD,kCAAiC;AAEjC;;GAEG;AACH;IAGE;;;;OAIG;IACH,sBAAY,QAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,eAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,2BAAI,GAAJ;QACE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,2BAAI,GAAJ,UAAK,CAAS;QACZ,MAAM,CAAC,CAAC,IAA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AK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,wCAAiB,GAAjB;QACE,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;IACH,mBAAC;AAAD,CAAC,AAnMD,IAmMC;AAEQ,oCAAY"} \ No newline at end of file diff --git a/dist/serdes/binary-serializer.d.ts b/dist/serdes/binary-serializer.d.ts deleted file mode 100644 index 5e7a4d2..0000000 --- a/dist/serdes/binary-serializer.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { FieldInstance } from "../enums"; -import { SerializedType } from "../types/serialized-type"; -import { Buffer } from "buffer/"; -/** - * Bytes list is a collection of buffer objects - */ -declare class BytesList { - private bytesArray; - /** - * Get the total number of bytes in the BytesList - * - * @return the number of bytes - */ - getLength(): number; - /** - * Put bytes in the BytesList - * - * @param bytesArg A Buffer - * @return this BytesList - */ - put(bytesArg: Buffer): BytesList; - /** - * Write this BytesList to the back of another bytes list - * - * @param list The BytesList to write to - */ - toBytesSink(list: BytesList): void; - toBytes(): Buffer; - toHex(): string; -} -/** - * BinarySerializer is used to write fields and values to buffers - */ -declare class BinarySerializer { - private sink; - constructor(sink: BytesList); - /** - * Write a value to this BinarySerializer - * - * @param value a SerializedType value - */ - write(value: SerializedType): void; - /** - * Write bytes to this BinarySerializer - * - * @param bytes the bytes to write - */ - put(bytes: Buffer): void; - /** - * Write a value of a given type to this BinarySerializer - * - * @param type the type to write - * @param value a value of that type - */ - writeType(type: typeof SerializedType, value: SerializedType): void; - /** - * Write BytesList to this BinarySerializer - * - * @param bl BytesList to write to BinarySerializer - */ - writeBytesList(bl: BytesList): void; - /** - * Calculate the header of Variable Length encoded bytes - * - * @param length the length of the bytes - */ - private encodeVariableLength; - /** - * Write field and value to BinarySerializer - * - * @param field field to write to BinarySerializer - * @param value value to write to BinarySerializer - */ - writeFieldAndValue(field: FieldInstance, value: SerializedType): void; - /** - * Write a variable length encoded value to the BinarySerializer - * - * @param value length encoded value to write to BytesList - */ - writeLengthEncoded(value: SerializedType): void; -} -export { BytesList, BinarySerializer }; diff --git a/dist/serdes/binary-serializer.js b/dist/serdes/binary-serializer.js deleted file mode 100644 index e57285c..0000000 --- a/dist/serdes/binary-serializer.js +++ /dev/null @@ -1,148 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BinarySerializer = exports.BytesList = void 0; -var assert = require("assert"); -var buffer_1 = require("buffer/"); -/** - * Bytes list is a collection of buffer objects - */ -var BytesList = /** @class */ (function () { - function BytesList() { - this.bytesArray = []; - } - /** - * Get the total number of bytes in the BytesList - * - * @return the number of bytes - */ - BytesList.prototype.getLength = function () { - return buffer_1.Buffer.concat(this.bytesArray).byteLength; - }; - /** - * Put bytes in the BytesList - * - * @param bytesArg A Buffer - * @return this BytesList - */ - BytesList.prototype.put = function (bytesArg) { - var bytes = buffer_1.Buffer.from(bytesArg); // Temporary, to catch instances of Uint8Array being passed in - this.bytesArray.push(bytes); - return this; - }; - /** - * Write this BytesList to the back of another bytes list - * - * @param list The BytesList to write to - */ - BytesList.prototype.toBytesSink = function (list) { - list.put(this.toBytes()); - }; - BytesList.prototype.toBytes = function () { - return buffer_1.Buffer.concat(this.bytesArray); - }; - BytesList.prototype.toHex = function () { - return this.toBytes().toString("hex").toUpperCase(); - }; - return BytesList; -}()); -exports.BytesList = BytesList; -/** - * BinarySerializer is used to write fields and values to buffers - */ -var BinarySerializer = /** @class */ (function () { - function BinarySerializer(sink) { - this.sink = new BytesList(); - this.sink = sink; - } - /** - * Write a value to this BinarySerializer - * - * @param value a SerializedType value - */ - BinarySerializer.prototype.write = function (value) { - value.toBytesSink(this.sink); - }; - /** - * Write bytes to this BinarySerializer - * - * @param bytes the bytes to write - */ - BinarySerializer.prototype.put = function (bytes) { - this.sink.put(bytes); - }; - /** - * Write a value of a given type to this BinarySerializer - * - * @param type the type to write - * @param value a value of that type - */ - BinarySerializer.prototype.writeType = function (type, value) { - this.write(type.from(value)); - }; - /** - * Write BytesList to this BinarySerializer - * - * @param bl BytesList to write to BinarySerializer - */ - BinarySerializer.prototype.writeBytesList = function (bl) { - bl.toBytesSink(this.sink); - }; - /** - * Calculate the header of Variable Length encoded bytes - * - * @param length the length of the bytes - */ - BinarySerializer.prototype.encodeVariableLength = function (length) { - var lenBytes = buffer_1.Buffer.alloc(3); - if (length <= 192) { - lenBytes[0] = length; - return lenBytes.slice(0, 1); - } - else if (length <= 12480) { - length -= 193; - lenBytes[0] = 193 + (length >>> 8); - lenBytes[1] = length & 0xff; - return lenBytes.slice(0, 2); - } - else if (length <= 918744) { - length -= 12481; - lenBytes[0] = 241 + (length >>> 16); - lenBytes[1] = (length >> 8) & 0xff; - lenBytes[2] = length & 0xff; - return lenBytes.slice(0, 3); - } - throw new Error("Overflow error"); - }; - /** - * Write field and value to BinarySerializer - * - * @param field field to write to BinarySerializer - * @param value value to write to BinarySerializer - */ - BinarySerializer.prototype.writeFieldAndValue = function (field, value) { - var associatedValue = field.associatedType.from(value); - assert(associatedValue.toBytesSink !== undefined); - assert(field.name !== undefined); - this.sink.put(field.header); - if (field.isVariableLengthEncoded) { - this.writeLengthEncoded(associatedValue); - } - else { - associatedValue.toBytesSink(this.sink); - } - }; - /** - * Write a variable length encoded value to the BinarySerializer - * - * @param value length encoded value to write to BytesList - */ - BinarySerializer.prototype.writeLengthEncoded = function (value) { - var bytes = new BytesList(); - value.toBytesSink(bytes); - this.put(this.encodeVariableLength(bytes.getLength())); - this.writeBytesList(bytes); - }; - return BinarySerializer; -}()); -exports.BinarySerializer = BinarySerializer; -//# sourceMappingURL=binary-serializer.js.map \ No newline at end of file diff --git a/dist/serdes/binary-serializer.js.map b/dist/serdes/binary-serializer.js.map deleted file mode 100644 index 25da349..0000000 --- a/dist/serdes/binary-serializer.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"binary-serializer.js","sourceRoot":"","s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;SAC7B;QACD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,6CAAkB,GAAlB,UAAmB,KAAoB,EAAE,KAAqB;QAC5D,IAAM,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,CAAC,eAAe,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC;QAClD,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAEjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,KAAK,CAAC,uBAAuB,EAAE;YACjC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;SAC1C;aAAM;YACL,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;IAED;;;;OAIG;IACI,6CAAkB,GAAzB,UAA0B,KAAqB;QAC7C,IAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;QAC9B,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACH,uBAAC;AAAD,CAAC,AApGD,IAoGC;AAEmB,4CAAgB"} \ No newline at end of file diff --git a/dist/shamap.d.ts b/dist/shamap.d.ts deleted file mode 100644 index 6a0310f..0000000 --- a/dist/shamap.d.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { Hash256 } from "./types/hash-256"; -import { BytesList } from "./serdes/binary-serializer"; -import { Buffer } from "buffer/"; -/** - * Abstract class describing a SHAMapNode - */ -declare abstract class ShaMapNode { - abstract hashPrefix(): Buffer; - abstract isLeaf(): boolean; - abstract isInner(): boolean; - abstract toBytesSink(list: BytesList): void; - abstract hash(): Hash256; -} -/** - * Class describing a Leaf of SHAMap - */ -declare class ShaMapLeaf extends ShaMapNode { - index: Hash256; - item?: ShaMapNode | undefined; - constructor(index: Hash256, item?: ShaMapNode | undefined); - /** - * @returns true as ShaMapLeaf is a leaf node - */ - isLeaf(): boolean; - /** - * @returns false as ShaMapLeaf is not an inner node - */ - isInner(): boolean; - /** - * Get the prefix of the this.item - * - * @returns The hash prefix, unless this.item is undefined, then it returns an empty Buffer - */ - hashPrefix(): Buffer; - /** - * Hash the bytes representation of this - * - * @returns hash of this.item concatenated with this.index - */ - hash(): Hash256; - /** - * Write the bytes representation of this to a BytesList - * @param list BytesList to write bytes to - */ - toBytesSink(list: BytesList): void; -} -/** - * Class defining an Inner Node of a SHAMap - */ -declare class ShaMapInner extends ShaMapNode { - private depth; - private slotBits; - private branches; - constructor(depth?: number); - /** - * @returns true as ShaMapInner is an inner node - */ - isInner(): boolean; - /** - * @returns false as ShaMapInner is not a leaf node - */ - isLeaf(): boolean; - /** - * Get the hash prefix for this node - * - * @returns hash prefix describing an inner node - */ - hashPrefix(): Buffer; - /** - * Set a branch of this node to be another node - * - * @param slot Slot to add branch to this.branches - * @param branch Branch to add - */ - setBranch(slot: number, branch: ShaMapNode): void; - /** - * @returns true if node is empty - */ - empty(): boolean; - /** - * Compute the hash of this node - * - * @returns The hash of this node - */ - hash(): Hash256; - /** - * Writes the bytes representation of this node to a BytesList - * - * @param list BytesList to write bytes to - */ - toBytesSink(list: BytesList): void; - /** - * Add item to the SHAMap - * - * @param index Hash of the index of the item being inserted - * @param item Item to insert in the map - * @param leaf Leaf node to insert when branch doesn't exist - */ - addItem(index?: Hash256, item?: ShaMapNode, leaf?: ShaMapLeaf): void; -} -declare class ShaMap extends ShaMapInner { -} -export { ShaMap, ShaMapNode, ShaMapLeaf }; diff --git a/dist/shamap.js b/dist/shamap.js deleted file mode 100644 index 0d184a7..0000000 --- a/dist/shamap.js +++ /dev/null @@ -1,196 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ShaMapLeaf = exports.ShaMapNode = exports.ShaMap = void 0; -var assert_1 = require("assert"); -var types_1 = require("./types"); -var hash_prefixes_1 = require("./hash-prefixes"); -var hashes_1 = require("./hashes"); -var buffer_1 = require("buffer/"); -/** - * Abstract class describing a SHAMapNode - */ -var ShaMapNode = /** @class */ (function () { - function ShaMapNode() { - } - return ShaMapNode; -}()); -exports.ShaMapNode = ShaMapNode; -/** - * Class describing a Leaf of SHAMap - */ -var ShaMapLeaf = /** @class */ (function (_super) { - __extends(ShaMapLeaf, _super); - function ShaMapLeaf(index, item) { - var _this = _super.call(this) || this; - _this.index = index; - _this.item = item; - return _this; - } - /** - * @returns true as ShaMapLeaf is a leaf node - */ - ShaMapLeaf.prototype.isLeaf = function () { - return true; - }; - /** - * @returns false as ShaMapLeaf is not an inner node - */ - ShaMapLeaf.prototype.isInner = function () { - return false; - }; - /** - * Get the prefix of the this.item - * - * @returns The hash prefix, unless this.item is undefined, then it returns an empty Buffer - */ - ShaMapLeaf.prototype.hashPrefix = function () { - return this.item === undefined ? buffer_1.Buffer.alloc(0) : this.item.hashPrefix(); - }; - /** - * Hash the bytes representation of this - * - * @returns hash of this.item concatenated with this.index - */ - ShaMapLeaf.prototype.hash = function () { - var hash = hashes_1.Sha512Half.put(this.hashPrefix()); - this.toBytesSink(hash); - return hash.finish(); - }; - /** - * Write the bytes representation of this to a BytesList - * @param list BytesList to write bytes to - */ - ShaMapLeaf.prototype.toBytesSink = function (list) { - if (this.item !== undefined) { - this.item.toBytesSink(list); - } - this.index.toBytesSink(list); - }; - return ShaMapLeaf; -}(ShaMapNode)); -exports.ShaMapLeaf = ShaMapLeaf; -/** - * Class defining an Inner Node of a SHAMap - */ -var ShaMapInner = /** @class */ (function (_super) { - __extends(ShaMapInner, _super); - function ShaMapInner(depth) { - if (depth === void 0) { depth = 0; } - var _this = _super.call(this) || this; - _this.depth = depth; - _this.slotBits = 0; - _this.branches = Array(16); - return _this; - } - /** - * @returns true as ShaMapInner is an inner node - */ - ShaMapInner.prototype.isInner = function () { - return true; - }; - /** - * @returns false as ShaMapInner is not a leaf node - */ - ShaMapInner.prototype.isLeaf = function () { - return false; - }; - /** - * Get the hash prefix for this node - * - * @returns hash prefix describing an inner node - */ - ShaMapInner.prototype.hashPrefix = function () { - return hash_prefixes_1.HashPrefix.innerNode; - }; - /** - * Set a branch of this node to be another node - * - * @param slot Slot to add branch to this.branches - * @param branch Branch to add - */ - ShaMapInner.prototype.setBranch = function (slot, branch) { - this.slotBits = this.slotBits | (1 << slot); - this.branches[slot] = branch; - }; - /** - * @returns true if node is empty - */ - ShaMapInner.prototype.empty = function () { - return this.slotBits === 0; - }; - /** - * Compute the hash of this node - * - * @returns The hash of this node - */ - ShaMapInner.prototype.hash = function () { - if (this.empty()) { - return types_1.coreTypes.Hash256.ZERO_256; - } - var hash = hashes_1.Sha512Half.put(this.hashPrefix()); - this.toBytesSink(hash); - return hash.finish(); - }; - /** - * Writes the bytes representation of this node to a BytesList - * - * @param list BytesList to write bytes to - */ - ShaMapInner.prototype.toBytesSink = function (list) { - for (var i = 0; i < this.branches.length; i++) { - var branch = this.branches[i]; - var hash = branch ? branch.hash() : types_1.coreTypes.Hash256.ZERO_256; - hash.toBytesSink(list); - } - }; - /** - * Add item to the SHAMap - * - * @param index Hash of the index of the item being inserted - * @param item Item to insert in the map - * @param leaf Leaf node to insert when branch doesn't exist - */ - ShaMapInner.prototype.addItem = function (index, item, leaf) { - assert_1.strict(index !== undefined); - var nibble = index.nibblet(this.depth); - var existing = this.branches[nibble]; - if (existing === undefined) { - this.setBranch(nibble, leaf || new ShaMapLeaf(index, item)); - } - else if (existing instanceof ShaMapLeaf) { - var newInner = new ShaMapInner(this.depth + 1); - newInner.addItem(existing.index, undefined, existing); - newInner.addItem(index, item, leaf); - this.setBranch(nibble, newInner); - } - else if (existing instanceof ShaMapInner) { - existing.addItem(index, item, leaf); - } - else { - throw new Error("invalid ShaMap.addItem call"); - } - }; - return ShaMapInner; -}(ShaMapNode)); -var ShaMap = /** @class */ (function (_super) { - __extends(ShaMap, _super); - function ShaMap() { - return _super !== null && _super.apply(this, arguments) || this; - } - return ShaMap; -}(ShaMapInner)); -exports.ShaMap = ShaMap; -//# sourceMappingURL=shamap.js.map \ No newline at end of file diff --git a/dist/shamap.js.map b/dist/shamap.js.map deleted file mode 100644 index b6bdc81..0000000 --- a/dist/shamap.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"shamap.js","sourceRoot":"","sources":["../src/shamap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAA0C;AAC1C,iCAAoC;AACpC,iDAA6C;AAC7C,mCAAsC;AAGtC,kCAAiC;AAEjC;;GAEG;AACH;IAAA;IAMA,CAAC;IAAD,iBAAC;AAAD,CAAC,AAND,IAMC;AAoKgB,gCAAU;AAlK3B;;GAEG;AACH;IAAyB,8BAAU;IACjC,oBAAmB,KAAc,EAAS,IAAiB;QAA3D,YACE,iBAAO,SACR;QAFkB,WAAK,GAAL,KAAK,CAAS;QAAS,UAAI,GAAJ,IAAI,CAAa;;IAE3D,CAAC;IAED;;OAEG;IACH,2BAAM,GAAN;QACE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,4BAAO,GAAP;QACE,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,+BAAU,GAAV;QACE,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC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AS,CAAC,MAAM,EAAE,IAAI,IAAI,IAAI,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;SAC7D;aAAM,IAAI,QAAQ,YAAY,UAAU,EAAE;YACzC,IAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YACjD,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YACtD,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YACpC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SAClC;aAAM,IAAI,QAAQ,YAAY,WAAW,EAAE;YAC1C,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;SACrC;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AArGD,CAA0B,UAAU,GAqGnC;AAED;IAAqB,0BAAW;IAAhC;;IAAkC,CAAC;IAAD,aAAC;AAAD,CAAC,AAAnC,CAAqB,WAAW,GAAG;AAE1B,wBAAM"} \ No newline at end of file diff --git a/dist/types/account-id.d.ts b/dist/types/account-id.d.ts deleted file mode 100644 index 0ef89bc..0000000 --- a/dist/types/account-id.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Hash160 } from "./hash-160"; -import { Buffer } from "buffer/"; -/** - * Class defining how to encode and decode an AccountID - */ -declare class AccountID extends Hash160 { - static readonly defaultAccountID: AccountID; - constructor(bytes?: Buffer); - /** - * Defines how to construct an AccountID - * - * @param value either an existing AccountID, a hex-string, or a base58 r-Address - * @returns an AccountID object - */ - static from(value: T): AccountID; - /** - * Defines how to build an AccountID from a base58 r-Address - * - * @param value a base58 r-Address - * @returns an AccountID object - */ - static fromBase58(value: string): AccountID; - /** - * Overload of toJSON - * - * @returns the base58 string for this AccountID - */ - toJSON(): string; - /** - * Defines how to encode AccountID into a base58 address - * - * @returns the base58 string defined by this.bytes - */ - toBase58(): string; -} -export { AccountID }; diff --git a/dist/types/account-id.js b/dist/types/account-id.js deleted file mode 100644 index e678ff0..0000000 --- a/dist/types/account-id.js +++ /dev/null @@ -1,80 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AccountID = void 0; -var ripple_address_codec_1 = require("ripple-address-codec"); -var hash_160_1 = require("./hash-160"); -var buffer_1 = require("buffer/"); -var HEX_REGEX = /^[A-F0-9]{40}$/; -/** - * Class defining how to encode and decode an AccountID - */ -var AccountID = /** @class */ (function (_super) { - __extends(AccountID, _super); - function AccountID(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : AccountID.defaultAccountID.bytes) || this; - } - /** - * Defines how to construct an AccountID - * - * @param value either an existing AccountID, a hex-string, or a base58 r-Address - * @returns an AccountID object - */ - AccountID.from = function (value) { - if (value instanceof AccountID) { - return value; - } - if (typeof value === "string") { - if (value === "") { - return new AccountID(); - } - return HEX_REGEX.test(value) - ? new AccountID(buffer_1.Buffer.from(value, "hex")) - : this.fromBase58(value); - } - throw new Error("Cannot construct AccountID from value given"); - }; - /** - * Defines how to build an AccountID from a base58 r-Address - * - * @param value a base58 r-Address - * @returns an AccountID object - */ - AccountID.fromBase58 = function (value) { - return new AccountID(buffer_1.Buffer.from(ripple_address_codec_1.decodeAccountID(value))); - }; - /** - * Overload of toJSON - * - * @returns the base58 string for this AccountID - */ - AccountID.prototype.toJSON = function () { - return this.toBase58(); - }; - /** - * Defines how to encode AccountID into a base58 address - * - * @returns the base58 string defined by this.bytes - */ - AccountID.prototype.toBase58 = function () { - /* eslint-disable @typescript-eslint/no-explicit-any */ - return ripple_address_codec_1.encodeAccountID(this.bytes); - /* eslint-enable @typescript-eslint/no-explicit-any */ - }; - AccountID.defaultAccountID = new AccountID(buffer_1.Buffer.alloc(20)); - return AccountID; -}(hash_160_1.Hash160)); -exports.AccountID = AccountID; -//# sourceMappingURL=account-id.js.map \ No newline at end of file diff --git a/dist/types/account-id.js.map b/dist/types/account-id.js.map deleted file mode 100644 index f247587..0000000 --- a/dist/types/account-id.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"account-id.js","sourceRoot":"","sources":["../../src/types/account-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAAwE;AACxE,uCAAqC;AACrC,kCAAiC;AAEjC,IAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC;;GAEG;AACH;IAAwB,6BAAO;IAG7B,mBAAY,KAAc;eACxB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,cAAI,GAAX,UAAwC,KAAQ;QAC9C,IAAI,KAAK,YAAY,SAAS,EAAE;YAC9B,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,KAAK,KAAK,EAAE,EAAE;gBAChB,OAAO,IAAI,SAAS,EAAE,CAAC;aACxB;YAED,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC1B,CAAC,CAAC,IAAI,SAAS,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAC1C,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SAC5B;QAED,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED;;;;;OAKG;IACI,oBAAU,GAAjB,UAAkB,KAAa;QAC7B,OAAO,IAAI,SAAS,CAAC,eAAM,CAAC,IAAI,CAAC,sCAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACH,0BAAM,GAAN;QACE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,4BAAQ,GAAR;QACE,uDAAuD;QACvD,OAAO,sCAAe,CAAC,IAAI,CAAC,KAAY,CAAC,CAAC;QAC1C,sDAAsD;IACxD,CAAC;IA1De,0BAAgB,GAAc,IAAI,SAAS,CAAC,eAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IA2DhF,gBAAC;CAAA,AA5DD,CAAwB,kBAAO,GA4D9B;AAEQ,8BAAS"} \ No newline at end of file diff --git a/dist/types/amount.d.ts b/dist/types/amount.d.ts deleted file mode 100644 index bf8fdd0..0000000 --- a/dist/types/amount.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { BinaryParser } from "../serdes/binary-parser"; -import { JsonObject, SerializedType } from "./serialized-type"; -import { Buffer } from "buffer/"; -/** - * Interface for JSON objects that represent amounts - */ -interface AmountObject extends JsonObject { - value: string; - currency: string; - issuer: string; -} -/** - * Class for serializing/Deserializing Amounts - */ -declare class Amount extends SerializedType { - static defaultAmount: Amount; - constructor(bytes: Buffer); - /** - * Construct an amount from an IOU or string amount - * - * @param value An Amount, object representing an IOU, or a string - * representing an integer amount - * @returns An Amount object - */ - static from(value: T): Amount; - /** - * Read an amount from a BinaryParser - * - * @param parser BinaryParser to read the Amount from - * @returns An Amount object - */ - static fromParser(parser: BinaryParser): Amount; - /** - * Get the JSON representation of this Amount - * - * @returns the JSON interpretation of this.bytes - */ - toJSON(): AmountObject | string; - /** - * Validate XRP amount - * - * @param amount String representing XRP amount - * @returns void, but will throw if invalid amount - */ - private static assertXrpIsValid; - /** - * Validate IOU.value amount - * - * @param decimal Decimal.js object representing IOU.value - * @returns void, but will throw if invalid amount - */ - private static assertIouIsValid; - /** - * Ensure that the value after being multiplied by the exponent does not - * contain a decimal. - * - * @param decimal a Decimal object - * @returns a string of the object without a decimal - */ - private static verifyNoDecimal; - /** - * Test if this amount is in units of Native Currency(XRP) - * - * @returns true if Native (XRP) - */ - private isNative; -} -export { Amount, AmountObject }; diff --git a/dist/types/amount.js b/dist/types/amount.js deleted file mode 100644 index 1e2fef2..0000000 --- a/dist/types/amount.js +++ /dev/null @@ -1,222 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Amount = void 0; -var decimal_js_1 = require("decimal.js"); -var binary_parser_1 = require("../serdes/binary-parser"); -var account_id_1 = require("./account-id"); -var currency_1 = require("./currency"); -var serialized_type_1 = require("./serialized-type"); -var bigInt = require("big-integer"); -var buffer_1 = require("buffer/"); -/** - * Constants for validating amounts - */ -var MIN_IOU_EXPONENT = -96; -var MAX_IOU_EXPONENT = 80; -var MAX_IOU_PRECISION = 16; -var MAX_DROPS = new decimal_js_1.Decimal("1e17"); -var MIN_XRP = new decimal_js_1.Decimal("1e-6"); -var mask = bigInt(0x00000000ffffffff); -/** - * decimal.js configuration for Amount IOUs - */ -decimal_js_1.Decimal.config({ - toExpPos: MAX_IOU_EXPONENT + MAX_IOU_PRECISION, - toExpNeg: MIN_IOU_EXPONENT - MAX_IOU_PRECISION, -}); -/** - * Type guard for AmountObject - */ -function isAmountObject(arg) { - var keys = Object.keys(arg).sort(); - return (keys.length === 3 && - keys[0] === "currency" && - keys[1] === "issuer" && - keys[2] === "value"); -} -/** - * Class for serializing/Deserializing Amounts - */ -var Amount = /** @class */ (function (_super) { - __extends(Amount, _super); - function Amount(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : Amount.defaultAmount.bytes) || this; - } - /** - * Construct an amount from an IOU or string amount - * - * @param value An Amount, object representing an IOU, or a string - * representing an integer amount - * @returns An Amount object - */ - Amount.from = function (value) { - if (value instanceof Amount) { - return value; - } - var amount = buffer_1.Buffer.alloc(8); - if (typeof value === "string") { - Amount.assertXrpIsValid(value); - var number = bigInt(value); - var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)]; - intBuf[0].writeUInt32BE(Number(number.shiftRight(32)), 0); - intBuf[1].writeUInt32BE(Number(number.and(mask)), 0); - amount = buffer_1.Buffer.concat(intBuf); - amount[0] |= 0x40; - return new Amount(amount); - } - if (isAmountObject(value)) { - var number = new decimal_js_1.Decimal(value.value); - Amount.assertIouIsValid(number); - if (number.isZero()) { - amount[0] |= 0x80; - } - else { - var integerNumberString = number - .times("1e" + -(number.e - 15)) - .abs() - .toString(); - var num = bigInt(integerNumberString); - var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)]; - intBuf[0].writeUInt32BE(Number(num.shiftRight(32)), 0); - intBuf[1].writeUInt32BE(Number(num.and(mask)), 0); - amount = buffer_1.Buffer.concat(intBuf); - amount[0] |= 0x80; - if (number.gt(new decimal_js_1.Decimal(0))) { - amount[0] |= 0x40; - } - var exponent = number.e - 15; - var exponentByte = 97 + exponent; - amount[0] |= exponentByte >>> 2; - amount[1] |= (exponentByte & 0x03) << 6; - } - var currency = currency_1.Currency.from(value.currency).toBytes(); - var issuer = account_id_1.AccountID.from(value.issuer).toBytes(); - return new Amount(buffer_1.Buffer.concat([amount, currency, issuer])); - } - throw new Error("Invalid type to construct an Amount"); - }; - /** - * Read an amount from a BinaryParser - * - * @param parser BinaryParser to read the Amount from - * @returns An Amount object - */ - Amount.fromParser = function (parser) { - var isXRP = parser.peek() & 0x80; - var numBytes = isXRP ? 48 : 8; - return new Amount(parser.read(numBytes)); - }; - /** - * Get the JSON representation of this Amount - * - * @returns the JSON interpretation of this.bytes - */ - Amount.prototype.toJSON = function () { - if (this.isNative()) { - var bytes = this.bytes; - var isPositive = bytes[0] & 0x40; - var sign = isPositive ? "" : "-"; - bytes[0] &= 0x3f; - var msb = bigInt(bytes.slice(0, 4).readUInt32BE(0)); - var lsb = bigInt(bytes.slice(4).readUInt32BE(0)); - var num = msb.shiftLeft(32).or(lsb); - return "" + sign + num.toString(); - } - else { - var parser = new binary_parser_1.BinaryParser(this.toString()); - var mantissa = parser.read(8); - var currency = currency_1.Currency.fromParser(parser); - var issuer = account_id_1.AccountID.fromParser(parser); - var b1 = mantissa[0]; - var b2 = mantissa[1]; - var isPositive = b1 & 0x40; - var sign = isPositive ? "" : "-"; - var exponent = ((b1 & 0x3f) << 2) + ((b2 & 0xff) >> 6) - 97; - mantissa[0] = 0; - mantissa[1] &= 0x3f; - var value = new decimal_js_1.Decimal(sign + "0x" + mantissa.toString("hex")).times("1e" + exponent); - Amount.assertIouIsValid(value); - return { - value: value.toString(), - currency: currency.toJSON(), - issuer: issuer.toJSON(), - }; - } - }; - /** - * Validate XRP amount - * - * @param amount String representing XRP amount - * @returns void, but will throw if invalid amount - */ - Amount.assertXrpIsValid = function (amount) { - if (amount.indexOf(".") !== -1) { - throw new Error(amount.toString() + " is an illegal amount"); - } - var decimal = new decimal_js_1.Decimal(amount); - if (!decimal.isZero()) { - if (decimal.lt(MIN_XRP) || decimal.gt(MAX_DROPS)) { - throw new Error(amount.toString() + " is an illegal amount"); - } - } - }; - /** - * Validate IOU.value amount - * - * @param decimal Decimal.js object representing IOU.value - * @returns void, but will throw if invalid amount - */ - Amount.assertIouIsValid = function (decimal) { - if (!decimal.isZero()) { - var p = decimal.precision(); - var e = decimal.e - 15; - if (p > MAX_IOU_PRECISION || - e > MAX_IOU_EXPONENT || - e < MIN_IOU_EXPONENT) { - throw new Error("Decimal precision out of range"); - } - this.verifyNoDecimal(decimal); - } - }; - /** - * Ensure that the value after being multiplied by the exponent does not - * contain a decimal. - * - * @param decimal a Decimal object - * @returns a string of the object without a decimal - */ - Amount.verifyNoDecimal = function (decimal) { - var integerNumberString = decimal - .times("1e" + -(decimal.e - 15)) - .abs() - .toString(); - if (integerNumberString.indexOf(".") !== -1) { - throw new Error("Decimal place found in integerNumberString"); - } - }; - /** - * Test if this amount is in units of Native Currency(XRP) - * - * @returns true if Native (XRP) - */ - Amount.prototype.isNative = function () { - return (this.bytes[0] & 0x80) === 0; - }; - Amount.defaultAmount = new Amount(buffer_1.Buffer.from("4000000000000000", "hex")); - return Amount; -}(serialized_type_1.SerializedType)); -exports.Amount = Amount; -//# sourceMappingURL=amount.js.map \ No newline at end of file diff --git a/dist/types/amount.js.map b/dist/types/amount.js.map deleted file mode 100644 index 1986afb..0000000 --- a/dist/types/amount.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/types/amount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAqC;AAErC,yDAAuD;AAEvD,2CAAyC;AACzC,uCAAsC;AACtC,qDAA+D;AAC/D,oCAAsC;AACtC,kCAAiC;AAEjC;;GAEG;AACH,IAAM,gBAAgB,GAAG,CAAC,EAAE,CAAC;AAC7B,IAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,IAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,IAAM,SAAS,GAAG,IAAI,oBAAO,CAAC,MAAM,CAAC,CAAC;AACtC,IAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,MAAM,CAAC,CAAC;AACpC,IAAM,IAAI,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAExC;;GAEG;AACH,oBAAO,CAAC,MAAM,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ACrB,CAAC,GAAG,gBAAgB;gBACpB,CAAC,GAAG,gBAAgB,EACpB;gBACA,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;aACnD;YACD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SAC/B;IACH,CAAC;IAED;;;;;;OAMG;IACY,sBAAe,GAA9B,UAA+B,OAAgB;QAC7C,IAAM,mBAAmB,GAAG,OAAO;aAChC,KAAK,CAAC,OAAK,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAG,CAAC;aAC/B,GAAG,EAAE;aACL,QAAQ,EAAE,CAAC;QAEd,IAAI,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;SAC/D;IACH,CAAC;IAED;;;;OAIG;IACK,yBAAQ,GAAhB;QACE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAtMM,oBAAa,GAAW,IAAI,MAAM,CACvC,eAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CACvC,CAAC;IAqMJ,aAAC;CAAA,AAxMD,CAAqB,gCAAc,GAwMlC;AAEQ,wBAAM"} \ No newline at end of file diff --git a/dist/types/blob.d.ts b/dist/types/blob.d.ts deleted file mode 100644 index a261295..0000000 --- a/dist/types/blob.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { SerializedType } from "./serialized-type"; -import { BinaryParser } from "../serdes/binary-parser"; -import { Buffer } from "buffer/"; -/** - * Variable length encoded type - */ -declare class Blob extends SerializedType { - constructor(bytes: Buffer); - /** - * Defines how to read a Blob from a BinaryParser - * - * @param parser The binary parser to read the Blob from - * @param hint The length of the blob, computed by readVariableLengthLength() and passed in - * @returns A Blob object - */ - static fromParser(parser: BinaryParser, hint: number): Blob; - /** - * Create a Blob object from a hex-string - * - * @param value existing Blob object or a hex-string - * @returns A Blob object - */ - static from(value: T): Blob; -} -export { Blob }; diff --git a/dist/types/blob.js b/dist/types/blob.js deleted file mode 100644 index 843d43d..0000000 --- a/dist/types/blob.js +++ /dev/null @@ -1,55 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Blob = void 0; -var serialized_type_1 = require("./serialized-type"); -var buffer_1 = require("buffer/"); -/** - * Variable length encoded type - */ -var Blob = /** @class */ (function (_super) { - __extends(Blob, _super); - function Blob(bytes) { - return _super.call(this, bytes) || this; - } - /** - * Defines how to read a Blob from a BinaryParser - * - * @param parser The binary parser to read the Blob from - * @param hint The length of the blob, computed by readVariableLengthLength() and passed in - * @returns A Blob object - */ - Blob.fromParser = function (parser, hint) { - return new Blob(parser.read(hint)); - }; - /** - * Create a Blob object from a hex-string - * - * @param value existing Blob object or a hex-string - * @returns A Blob object - */ - Blob.from = function (value) { - if (value instanceof Blob) { - return value; - } - if (typeof value === "string") { - return new Blob(buffer_1.Buffer.from(value, "hex")); - } - throw new Error("Cannot construct Blob from value given"); - }; - return Blob; -}(serialized_type_1.SerializedType)); -exports.Blob = Blob; -//# sourceMappingURL=blob.js.map \ No newline at end of file diff --git a/dist/types/blob.js.map b/dist/types/blob.js.map deleted file mode 100644 index cc91f2e..0000000 --- a/dist/types/blob.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/types/blob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmD;AAEnD,kCAAiC;AAEjC;;GAEG;AACH;IAAmB,wBAAc;IAC/B,cAAY,KAAa;eACvB,kBAAM,KAAK,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,eAAU,GAAjB,UAAkB,MAAoB,EAAE,IAAY;QAClD,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACI,SAAI,GAAX,UAAqC,KAAQ;QAC3C,IAAI,KAAK,YAAY,IAAI,EAAE;YACzB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,IAAI,IAAI,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;SAC5C;QAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACH,WAAC;AAAD,CAAC,AAjCD,CAAmB,gCAAc,GAiChC;AAEQ,oBAAI"} \ No newline at end of file diff --git a/dist/types/currency.d.ts b/dist/types/currency.d.ts deleted file mode 100644 index f4f97c7..0000000 --- a/dist/types/currency.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Hash160 } from "./hash-160"; -import { Buffer } from "buffer/"; -/** - * Class defining how to encode and decode Currencies - */ -declare class Currency extends Hash160 { - static readonly XRP: Currency; - private readonly _iso?; - private readonly _isNative; - constructor(byteBuf: Buffer); - /** - * Tells if this currency is native - * - * @returns true if native, false if not - */ - isNative(): boolean; - /** - * Return the ISO code of this currency - * - * @returns ISO code if it exists, else undefined - */ - iso(): string | undefined; - /** - * Constructs a Currency object - * - * @param val Currency object or a string representation of a currency - */ - static from(value: T): Currency; - /** - * Gets the JSON representation of a currency - * - * @returns JSON representation - */ - toJSON(): string; -} -export { Currency }; diff --git a/dist/types/currency.js b/dist/types/currency.js deleted file mode 100644 index b63ccb2..0000000 --- a/dist/types/currency.js +++ /dev/null @@ -1,141 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Currency = void 0; -var hash_160_1 = require("./hash-160"); -var buffer_1 = require("buffer/"); -var ISO_REGEX = /^[A-Z0-9]{3}$/; -var HEX_REGEX = /^[A-F0-9]{40}$/; -/** - * Convert an ISO code to a currency bytes representation - */ -function isoToBytes(iso) { - var bytes = buffer_1.Buffer.alloc(20); - if (iso !== "XRP") { - var isoBytes = iso.split("").map(function (c) { return c.charCodeAt(0); }); - bytes.set(isoBytes, 12); - } - return bytes; -} -/** - * Tests if ISO is a valid iso code - */ -function isIsoCode(iso) { - return iso.length === 3; -} -/** - * Tests if hex is a valid hex-string - */ -function isHex(hex) { - return HEX_REGEX.test(hex); -} -/** - * Tests if a string is a valid representation of a currency - */ -function isStringRepresentation(input) { - return isIsoCode(input) || isHex(input); -} -/** - * Tests if a Buffer is a valid representation of a currency - */ -function isBytesArray(bytes) { - return bytes.byteLength === 20; -} -/** - * Ensures that a value is a valid representation of a currency - */ -function isValidRepresentation(input) { - return input instanceof buffer_1.Buffer - ? isBytesArray(input) - : isStringRepresentation(input); -} -/** - * Generate bytes from a string or buffer representation of a currency - */ -function bytesFromRepresentation(input) { - if (!isValidRepresentation(input)) { - throw new Error("Unsupported Currency representation: " + input); - } - return input.length === 3 ? isoToBytes(input) : buffer_1.Buffer.from(input, "hex"); -} -/** - * Class defining how to encode and decode Currencies - */ -var Currency = /** @class */ (function (_super) { - __extends(Currency, _super); - function Currency(byteBuf) { - var _this = _super.call(this, byteBuf !== null && byteBuf !== void 0 ? byteBuf : Currency.XRP.bytes) || this; - var onlyISO = true; - var bytes = _this.bytes; - var code = _this.bytes.slice(12, 15); - var iso = code.toString(); - for (var i = bytes.length - 1; i >= 0; i--) { - if (bytes[i] !== 0 && !(i === 12 || i === 13 || i === 14)) { - onlyISO = false; - break; - } - } - var lossLessISO = onlyISO && iso !== "XRP" && ISO_REGEX.test(iso); - _this._isNative = onlyISO && code.toString("hex") === "000000"; - _this._iso = _this._isNative ? "XRP" : lossLessISO ? iso : undefined; - return _this; - } - /** - * Tells if this currency is native - * - * @returns true if native, false if not - */ - Currency.prototype.isNative = function () { - return this._isNative; - }; - /** - * Return the ISO code of this currency - * - * @returns ISO code if it exists, else undefined - */ - Currency.prototype.iso = function () { - return this._iso; - }; - /** - * Constructs a Currency object - * - * @param val Currency object or a string representation of a currency - */ - Currency.from = function (value) { - if (value instanceof Currency) { - return value; - } - if (typeof value === "string") { - return new Currency(bytesFromRepresentation(value)); - } - throw new Error("Cannot construct Currency from value given"); - }; - /** - * Gets the JSON representation of a currency - * - * @returns JSON representation - */ - Currency.prototype.toJSON = function () { - var iso = this.iso(); - if (iso !== undefined) { - return iso; - } - return this.bytes.toString("hex").toUpperCase(); - }; - Currency.XRP = new Currency(buffer_1.Buffer.alloc(20)); - return Currency; -}(hash_160_1.Hash160)); -exports.Currency = Currency; -//# sourceMappingURL=currency.js.map \ No newline at end of file diff --git a/dist/types/currency.js.map b/dist/types/currency.js.map deleted file mode 100644 index 6f2df4e..0000000 --- a/dist/types/currency.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../src/types/currency.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqC;AACrC,kCAAiC;AAEjC,IAAM,SAAS,GAAG,eAAe,CAAC;AAClC,IAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC;;GAEG;AACH,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAM,KAAK,GAAG,e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;QACE,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACI,aAAI,GAAX,UAAwC,KAAQ;QAC9C,IAAI,KAAK,YAAY,QAAQ,EAAE;YAC7B,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,IAAI,QAAQ,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC;SACrD;QAED,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACH,yBAAM,GAAN;QACE,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,OAAO,GAAG,CAAC;SACZ;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAClD,CAAC;IAvEe,YAAG,GAAG,IAAI,QAAQ,CAAC,eAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAwEvD,eAAC;CAAA,AAzED,CAAuB,kBAAO,GAyE7B;AAEQ,4BAAQ"} \ No newline at end of file diff --git a/dist/types/hash-128.d.ts b/dist/types/hash-128.d.ts deleted file mode 100644 index 5c61e99..0000000 --- a/dist/types/hash-128.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Hash } from "./hash"; -import { Buffer } from "buffer/"; -/** - * Hash with a width of 128 bits - */ -declare class Hash128 extends Hash { - static readonly width = 16; - static readonly ZERO_128: Hash128; - constructor(bytes: Buffer); -} -export { Hash128 }; diff --git a/dist/types/hash-128.js b/dist/types/hash-128.js deleted file mode 100644 index f258f63..0000000 --- a/dist/types/hash-128.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash128 = void 0; -var hash_1 = require("./hash"); -var buffer_1 = require("buffer/"); -/** - * Hash with a width of 128 bits - */ -var Hash128 = /** @class */ (function (_super) { - __extends(Hash128, _super); - function Hash128(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : Hash128.ZERO_128.bytes) || this; - } - Hash128.width = 16; - Hash128.ZERO_128 = new Hash128(buffer_1.Buffer.alloc(Hash128.width)); - return Hash128; -}(hash_1.Hash)); -exports.Hash128 = Hash128; -//# sourceMappingURL=hash-128.js.map \ No newline at end of file diff --git a/dist/types/hash-128.js.map b/dist/types/hash-128.js.map deleted file mode 100644 index 3bebb88..0000000 --- a/dist/types/hash-128.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash-128.js","sourceRoot":"","sources":["../../src/types/hash-128.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,kCAAiC;AAEjC;;GAEG;AACH;IAAsB,2BAAI;IAIxB,iBAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IACxC,CAAC;IALe,aAAK,GAAG,EAAE,CAAC;IACX,gBAAQ,GAAY,IAAI,OAAO,CAAC,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAK/E,cAAC;CAAA,AAPD,CAAsB,WAAI,GAOzB;AAEQ,0BAAO"} \ No newline at end of file diff --git a/dist/types/hash-160.d.ts b/dist/types/hash-160.d.ts deleted file mode 100644 index 905bf41..0000000 --- a/dist/types/hash-160.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Hash } from "./hash"; -import { Buffer } from "buffer/"; -/** - * Hash with a width of 160 bits - */ -declare class Hash160 extends Hash { - static readonly width = 20; - static readonly ZERO_160: Hash160; - constructor(bytes?: Buffer); -} -export { Hash160 }; diff --git a/dist/types/hash-160.js b/dist/types/hash-160.js deleted file mode 100644 index 0201de9..0000000 --- a/dist/types/hash-160.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash160 = void 0; -var hash_1 = require("./hash"); -var buffer_1 = require("buffer/"); -/** - * Hash with a width of 160 bits - */ -var Hash160 = /** @class */ (function (_super) { - __extends(Hash160, _super); - function Hash160(bytes) { - var _this = this; - if (bytes && bytes.byteLength === 0) { - bytes = Hash160.ZERO_160.bytes; - } - _this = _super.call(this, bytes !== null && bytes !== void 0 ? bytes : Hash160.ZERO_160.bytes) || this; - return _this; - } - Hash160.width = 20; - Hash160.ZERO_160 = new Hash160(buffer_1.Buffer.alloc(Hash160.width)); - return Hash160; -}(hash_1.Hash)); -exports.Hash160 = Hash160; -//# sourceMappingURL=hash-160.js.map \ No newline at end of file diff --git a/dist/types/hash-160.js.map b/dist/types/hash-160.js.map deleted file mode 100644 index 88c3b53..0000000 --- a/dist/types/hash-160.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash-160.js","sourceRoot":"","sources":["../../src/types/hash-160.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,kCAAiC;AAEjC;;GAEG;AACH;IAAsB,2BAAI;IAIxB,iBAAY,KAAc;QAA1B,iBAMC;QALC,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,EAAE;YACnC,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;SAChC;QAED,QAAA,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAC;;IACzC,CAAC;IATe,aAAK,GAAG,EAAE,CAAC;IACX,gBAAQ,GAAY,IAAI,OAAO,CAAC,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAS/E,cAAC;CAAA,AAXD,CAAsB,WAAI,GAWzB;AAEQ,0BAAO"} \ No newline at end of file diff --git a/dist/types/hash-256.d.ts b/dist/types/hash-256.d.ts deleted file mode 100644 index 7a68c90..0000000 --- a/dist/types/hash-256.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Hash } from "./hash"; -import { Buffer } from "buffer/"; -/** - * Hash with a width of 256 bits - */ -declare class Hash256 extends Hash { - static readonly width = 32; - static readonly ZERO_256: Hash256; - constructor(bytes: Buffer); -} -export { Hash256 }; diff --git a/dist/types/hash-256.js b/dist/types/hash-256.js deleted file mode 100644 index 9e31b4e..0000000 --- a/dist/types/hash-256.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash256 = void 0; -var hash_1 = require("./hash"); -var buffer_1 = require("buffer/"); -/** - * Hash with a width of 256 bits - */ -var Hash256 = /** @class */ (function (_super) { - __extends(Hash256, _super); - function Hash256(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : Hash256.ZERO_256.bytes) || this; - } - Hash256.width = 32; - Hash256.ZERO_256 = new Hash256(buffer_1.Buffer.alloc(Hash256.width)); - return Hash256; -}(hash_1.Hash)); -exports.Hash256 = Hash256; -//# sourceMappingURL=hash-256.js.map \ No newline at end of file diff --git a/dist/types/hash-256.js.map b/dist/types/hash-256.js.map deleted file mode 100644 index 556cf16..0000000 --- a/dist/types/hash-256.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash-256.js","sourceRoot":"","sources":["../../src/types/hash-256.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,kCAAiC;AAEjC;;GAEG;AACH;IAAsB,2BAAI;IAIxB,iBAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IACxC,CAAC;IALe,aAAK,GAAG,EAAE,CAAC;IACX,gBAAQ,GAAG,IAAI,OAAO,CAAC,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAKtE,cAAC;CAAA,AAPD,CAAsB,WAAI,GAOzB;AAEQ,0BAAO"} \ No newline at end of file diff --git a/dist/types/hash.d.ts b/dist/types/hash.d.ts deleted file mode 100644 index 805dd85..0000000 --- a/dist/types/hash.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Comparable } from "./serialized-type"; -import { BinaryParser } from "../serdes/binary-parser"; -import { Buffer } from "buffer/"; -/** - * Base class defining how to encode and decode hashes - */ -declare class Hash extends Comparable { - static readonly width: number; - constructor(bytes: Buffer); - /** - * Construct a Hash object from an existing Hash object or a hex-string - * - * @param value A hash object or hex-string of a hash - */ - static from(value: T): Hash; - /** - * Read a Hash object from a BinaryParser - * - * @param parser BinaryParser to read the hash from - * @param hint length of the bytes to read, optional - */ - static fromParser(parser: BinaryParser, hint?: number): Hash; - /** - * Overloaded operator for comparing two hash objects - * - * @param other The Hash to compare this to - */ - compareTo(other: Hash): number; - /** - * @returns the hex-string representation of this Hash - */ - toString(): string; - /** - * Returns four bits at the specified depth within a hash - * - * @param depth The depth of the four bits - * @returns The number represented by the four bits - */ - nibblet(depth: number): number; -} -export { Hash }; diff --git a/dist/types/hash.js b/dist/types/hash.js deleted file mode 100644 index 4d17b93..0000000 --- a/dist/types/hash.js +++ /dev/null @@ -1,88 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Hash = void 0; -var serialized_type_1 = require("./serialized-type"); -var buffer_1 = require("buffer/"); -/** - * Base class defining how to encode and decode hashes - */ -var Hash = /** @class */ (function (_super) { - __extends(Hash, _super); - function Hash(bytes) { - var _this = _super.call(this, bytes) || this; - if (_this.bytes.byteLength !== _this.constructor.width) { - throw new Error("Invalid Hash length " + _this.bytes.byteLength); - } - return _this; - } - /** - * Construct a Hash object from an existing Hash object or a hex-string - * - * @param value A hash object or hex-string of a hash - */ - Hash.from = function (value) { - if (value instanceof this) { - return value; - } - if (typeof value === "string") { - return new this(buffer_1.Buffer.from(value, "hex")); - } - throw new Error("Cannot construct Hash from given value"); - }; - /** - * Read a Hash object from a BinaryParser - * - * @param parser BinaryParser to read the hash from - * @param hint length of the bytes to read, optional - */ - Hash.fromParser = function (parser, hint) { - return new this(parser.read(hint !== null && hint !== void 0 ? hint : this.width)); - }; - /** - * Overloaded operator for comparing two hash objects - * - * @param other The Hash to compare this to - */ - Hash.prototype.compareTo = function (other) { - return this.bytes.compare(this.constructor.from(other).bytes); - }; - /** - * @returns the hex-string representation of this Hash - */ - Hash.prototype.toString = function () { - return this.toHex(); - }; - /** - * Returns four bits at the specified depth within a hash - * - * @param depth The depth of the four bits - * @returns The number represented by the four bits - */ - Hash.prototype.nibblet = function (depth) { - var byteIx = depth > 0 ? (depth / 2) | 0 : 0; - var b = this.bytes[byteIx]; - if (depth % 2 === 0) { - b = (b & 0xf0) >>> 4; - } - else { - b = b & 0x0f; - } - return b; - }; - return Hash; -}(serialized_type_1.Comparable)); -exports.Hash = Hash; -//# sourceMappingURL=hash.js.map \ No newline at end of file diff --git a/dist/types/hash.js.map b/dist/types/hash.js.map deleted file mode 100644 index c12e3a1..0000000 --- a/dist/types/hash.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/types/hash.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAA+C;AAE/C,kCAAiC;AAEjC;;GAEG;AACH;IAAmB,wBAAU;IAG3B,cAAY,KAAa;QAAzB,YACE,kBAAM,KAAK,CAAC,SAIb;QAHC,IAAI,KAAI,CAAC,KAAK,CAAC,UAAU,KAAM,KAAI,CAAC,WAA2B,CAAC,KAAK,EAAE;YACrE,MAAM,IAAI,KAAK,CAAC,yBAAuB,KAAI,CAAC,KAAK,CAAC,UAAY,CAAC,CAAC;SACjE;;IACH,CAAC;IAED;;;;OAIG;IACI,SAAI,GAAX,UAAqC,KAAQ;QAC3C,IAAI,KAAK,YAAY,IAAI,EAAE;YACzB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,IAAI,IAAI,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;SAC5C;QAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACI,eAAU,GAAjB,UAAkB,MAAoB,EAAE,IAAa;QACnD,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACH,wBAAS,GAAT,UAAU,KAAW;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACtB,IAAI,CAAC,WAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CACpD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,uBAAQ,GAAR;QACE,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,sBAAO,GAAP,UAAQ,KAAa;QACnB,IAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;YACnB,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SACtB;aAAM;YACL,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;SACd;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACH,WAAC;AAAD,CAAC,AAvED,CAAmB,4BAAU,GAuE5B;AAEQ,oBAAI"} \ No newline at end of file diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts deleted file mode 100644 index 72802f6..0000000 --- a/dist/types/index.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { AccountID } from "./account-id"; -import { Amount } from "./amount"; -import { Blob } from "./blob"; -import { Currency } from "./currency"; -import { Hash128 } from "./hash-128"; -import { Hash160 } from "./hash-160"; -import { Hash256 } from "./hash-256"; -import { PathSet } from "./path-set"; -import { STArray } from "./st-array"; -import { STObject } from "./st-object"; -import { UInt16 } from "./uint-16"; -import { UInt32 } from "./uint-32"; -import { UInt64 } from "./uint-64"; -import { UInt8 } from "./uint-8"; -import { Vector256 } from "./vector-256"; -declare const coreTypes: { - AccountID: typeof AccountID; - Amount: typeof Amount; - Blob: typeof Blob; - Currency: typeof Currency; - Hash128: typeof Hash128; - Hash160: typeof Hash160; - Hash256: typeof Hash256; - PathSet: typeof PathSet; - STArray: typeof STArray; - STObject: typeof STObject; - UInt8: typeof UInt8; - UInt16: typeof UInt16; - UInt32: typeof UInt32; - UInt64: typeof UInt64; - Vector256: typeof Vector256; -}; -export { coreTypes }; diff --git a/dist/types/index.js b/dist/types/index.js deleted file mode 100644 index e50b546..0000000 --- a/dist/types/index.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.coreTypes = void 0; -var enums_1 = require("../enums"); -var account_id_1 = require("./account-id"); -var amount_1 = require("./amount"); -var blob_1 = require("./blob"); -var currency_1 = require("./currency"); -var hash_128_1 = require("./hash-128"); -var hash_160_1 = require("./hash-160"); -var hash_256_1 = require("./hash-256"); -var path_set_1 = require("./path-set"); -var st_array_1 = require("./st-array"); -var st_object_1 = require("./st-object"); -var uint_16_1 = require("./uint-16"); -var uint_32_1 = require("./uint-32"); -var uint_64_1 = require("./uint-64"); -var uint_8_1 = require("./uint-8"); -var vector_256_1 = require("./vector-256"); -var coreTypes = { - AccountID: account_id_1.AccountID, - Amount: amount_1.Amount, - Blob: blob_1.Blob, - Currency: currency_1.Currency, - Hash128: hash_128_1.Hash128, - Hash160: hash_160_1.Hash160, - Hash256: hash_256_1.Hash256, - PathSet: path_set_1.PathSet, - STArray: st_array_1.STArray, - STObject: st_object_1.STObject, - UInt8: uint_8_1.UInt8, - UInt16: uint_16_1.UInt16, - UInt32: uint_32_1.UInt32, - UInt64: uint_64_1.UInt64, - Vector256: vector_256_1.Vector256, -}; -exports.coreTypes = coreTypes; -Object.values(enums_1.Field).forEach(function (field) { - field.associatedType = coreTypes[field.type.name]; -}); -enums_1.Field["TransactionType"].associatedType = enums_1.TransactionType; -enums_1.Field["TransactionResult"].associatedType = enums_1.TransactionResult; -enums_1.Field["LedgerEntryType"].associatedType = enums_1.LedgerEntryType; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/types/index.js.map b/dist/types/index.js.map deleted file mode 100644 index 80bc6e8..0000000 --- a/dist/types/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,kCAKkB;AAClB,2CAAyC;AACzC,mCAAkC;AAClC,+BAA8B;AAC9B,uCAAsC;AACtC,uCAAqC;AACrC,uCAAqC;AACrC,uCAAqC;AACrC,uCAAqC;AACrC,uCAAqC;AACrC,yCAAuC;AACvC,qCAAmC;AACnC,qCAAmC;AACnC,qCAAmC;AACnC,mCAAiC;AACjC,2CAAyC;AAEzC,IAAM,SAAS,GAAG;IAChB,SAAS,wBAAA;IACT,MAAM,iBAAA;IACN,IAAI,aAAA;IACJ,QAAQ,qBAAA;IACR,OAAO,oBAAA;IACP,OAAO,oBAAA;IACP,OAAO,oBAAA;IACP,OAAO,oBAAA;IACP,OAAO,oBAAA;IACP,QAAQ,sBAAA;IACR,KAAK,gBAAA;IACL,MAAM,kBAAA;IACN,MAAM,kBAAA;IACN,MAAM,kBAAA;IACN,SAAS,wBAAA;CACV,CAAC;AAUO,8BAAS;AARlB,MAAM,CAAC,MAAM,CAAC,aAAK,CAAC,CAAC,OAAO,CAAC,UAAC,KAAK;IACjC,KAAK,CAAC,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC;AAEH,aAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,uBAAe,CAAC;AAC1D,aAAK,CAAC,mBAAmB,CAAC,CAAC,cAAc,GAAG,yBAAiB,CAAC;AAC9D,aAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,uBAAe,CAAC"} \ No newline at end of file diff --git a/dist/types/path-set.d.ts b/dist/types/path-set.d.ts deleted file mode 100644 index f127f44..0000000 --- a/dist/types/path-set.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { BinaryParser } from "../serdes/binary-parser"; -import { SerializedType, JsonObject } from "./serialized-type"; -/** - * The object representation of a Hop, an issuer AccountID, an account AccountID, and a Currency - */ -interface HopObject extends JsonObject { - issuer?: string; - account?: string; - currency?: string; -} -/** - * Deserialize and Serialize the PathSet type - */ -declare class PathSet extends SerializedType { - /** - * Construct a PathSet from an Array of Arrays representing paths - * - * @param value A PathSet or Array of Array of HopObjects - * @returns the PathSet constructed from value - */ - static from>>(value: T): PathSet; - /** - * Construct a PathSet from a BinaryParser - * - * @param parser A BinaryParser to read PathSet from - * @returns the PathSet read from parser - */ - static fromParser(parser: BinaryParser): PathSet; - /** - * Get the JSON representation of this PathSet - * - * @returns an Array of Array of HopObjects, representing this PathSet - */ - toJSON(): Array>; -} -export { PathSet }; diff --git a/dist/types/path-set.js b/dist/types/path-set.js deleted file mode 100644 index 8a8e3fd..0000000 --- a/dist/types/path-set.js +++ /dev/null @@ -1,251 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PathSet = void 0; -var account_id_1 = require("./account-id"); -var currency_1 = require("./currency"); -var binary_parser_1 = require("../serdes/binary-parser"); -var serialized_type_1 = require("./serialized-type"); -var buffer_1 = require("buffer/"); -/** - * Constants for separating Paths in a PathSet - */ -var PATHSET_END_BYTE = 0x00; -var PATH_SEPARATOR_BYTE = 0xff; -/** - * Constant for masking types of a Hop - */ -var TYPE_ACCOUNT = 0x01; -var TYPE_CURRENCY = 0x10; -var TYPE_ISSUER = 0x20; -/** - * TypeGuard for HopObject - */ -function isHopObject(arg) { - return (arg.issuer !== undefined || - arg.account !== undefined || - arg.currency !== undefined); -} -/** - * TypeGuard for PathSet - */ -function isPathSet(arg) { - return ((Array.isArray(arg) && arg.length === 0) || - (Array.isArray(arg) && Array.isArray(arg[0]) && arg[0].length === 0) || - (Array.isArray(arg) && Array.isArray(arg[0]) && isHopObject(arg[0][0]))); -} -/** - * Serialize and Deserialize a Hop - */ -var Hop = /** @class */ (function (_super) { - __extends(Hop, _super); - function Hop() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Create a Hop from a HopObject - * - * @param value Either a hop or HopObject to create a hop with - * @returns a Hop - */ - Hop.from = function (value) { - if (value instanceof Hop) { - return value; - } - var bytes = [buffer_1.Buffer.from([0])]; - if (value.account) { - bytes.push(account_id_1.AccountID.from(value.account).toBytes()); - bytes[0][0] |= TYPE_ACCOUNT; - } - if (value.currency) { - bytes.push(currency_1.Currency.from(value.currency).toBytes()); - bytes[0][0] |= TYPE_CURRENCY; - } - if (value.issuer) { - bytes.push(account_id_1.AccountID.from(value.issuer).toBytes()); - bytes[0][0] |= TYPE_ISSUER; - } - return new Hop(buffer_1.Buffer.concat(bytes)); - }; - /** - * Construct a Hop from a BinaryParser - * - * @param parser BinaryParser to read the Hop from - * @returns a Hop - */ - Hop.fromParser = function (parser) { - var type = parser.readUInt8(); - var bytes = [buffer_1.Buffer.from([type])]; - if (type & TYPE_ACCOUNT) { - bytes.push(parser.read(account_id_1.AccountID.width)); - } - if (type & TYPE_CURRENCY) { - bytes.push(parser.read(currency_1.Currency.width)); - } - if (type & TYPE_ISSUER) { - bytes.push(parser.read(account_id_1.AccountID.width)); - } - return new Hop(buffer_1.Buffer.concat(bytes)); - }; - /** - * Get the JSON interpretation of this hop - * - * @returns a HopObject, an JS object with optional account, issuer, and currency - */ - Hop.prototype.toJSON = function () { - var hopParser = new binary_parser_1.BinaryParser(this.bytes.toString("hex")); - var type = hopParser.readUInt8(); - var result = {}; - if (type & TYPE_ACCOUNT) { - result.account = account_id_1.AccountID.fromParser(hopParser).toJSON(); - } - if (type & TYPE_CURRENCY) { - result.currency = currency_1.Currency.fromParser(hopParser).toJSON(); - } - if (type & TYPE_ISSUER) { - result.issuer = account_id_1.AccountID.fromParser(hopParser).toJSON(); - } - return result; - }; - /** - * get a number representing the type of this hop - * - * @returns a number to be bitwise and-ed with TYPE_ constants to describe the types in the hop - */ - Hop.prototype.type = function () { - return this.bytes[0]; - }; - return Hop; -}(serialized_type_1.SerializedType)); -/** - * Class for serializing/deserializing Paths - */ -var Path = /** @class */ (function (_super) { - __extends(Path, _super); - function Path() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * construct a Path from an array of Hops - * - * @param value Path or array of HopObjects to construct a Path - * @returns the Path - */ - Path.from = function (value) { - if (value instanceof Path) { - return value; - } - var bytes = []; - value.forEach(function (hop) { - bytes.push(Hop.from(hop).toBytes()); - }); - return new Path(buffer_1.Buffer.concat(bytes)); - }; - /** - * Read a Path from a BinaryParser - * - * @param parser BinaryParser to read Path from - * @returns the Path represented by the bytes read from the BinaryParser - */ - Path.fromParser = function (parser) { - var bytes = []; - while (!parser.end()) { - bytes.push(Hop.fromParser(parser).toBytes()); - if (parser.peek() === PATHSET_END_BYTE || - parser.peek() === PATH_SEPARATOR_BYTE) { - break; - } - } - return new Path(buffer_1.Buffer.concat(bytes)); - }; - /** - * Get the JSON representation of this Path - * - * @returns an Array of HopObject constructed from this.bytes - */ - Path.prototype.toJSON = function () { - var json = []; - var pathParser = new binary_parser_1.BinaryParser(this.toString()); - while (!pathParser.end()) { - json.push(Hop.fromParser(pathParser).toJSON()); - } - return json; - }; - return Path; -}(serialized_type_1.SerializedType)); -/** - * Deserialize and Serialize the PathSet type - */ -var PathSet = /** @class */ (function (_super) { - __extends(PathSet, _super); - function PathSet() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Construct a PathSet from an Array of Arrays representing paths - * - * @param value A PathSet or Array of Array of HopObjects - * @returns the PathSet constructed from value - */ - PathSet.from = function (value) { - if (value instanceof PathSet) { - return value; - } - if (isPathSet(value)) { - var bytes_1 = []; - value.forEach(function (path) { - bytes_1.push(Path.from(path).toBytes()); - bytes_1.push(buffer_1.Buffer.from([PATH_SEPARATOR_BYTE])); - }); - bytes_1[bytes_1.length - 1] = buffer_1.Buffer.from([PATHSET_END_BYTE]); - return new PathSet(buffer_1.Buffer.concat(bytes_1)); - } - throw new Error("Cannot construct PathSet from given value"); - }; - /** - * Construct a PathSet from a BinaryParser - * - * @param parser A BinaryParser to read PathSet from - * @returns the PathSet read from parser - */ - PathSet.fromParser = function (parser) { - var bytes = []; - while (!parser.end()) { - bytes.push(Path.fromParser(parser).toBytes()); - bytes.push(parser.read(1)); - if (bytes[bytes.length - 1][0] == PATHSET_END_BYTE) { - break; - } - } - return new PathSet(buffer_1.Buffer.concat(bytes)); - }; - /** - * Get the JSON representation of this PathSet - * - * @returns an Array of Array of HopObjects, representing this PathSet - */ - PathSet.prototype.toJSON = function () { - var json = []; - var pathParser = new binary_parser_1.BinaryParser(this.toString()); - while (!pathParser.end()) { - json.push(Path.fromParser(pathParser).toJSON()); - pathParser.skip(1); - } - return json; - }; - return PathSet; -}(serialized_type_1.SerializedType)); -exports.PathSet = PathSet; -//# sourceMappingURL=path-set.js.map \ No newline at end of file diff --git a/dist/types/path-set.js.map b/dist/types/path-set.js.map deleted file mode 100644 index 257e12f..0000000 --- a/dist/types/path-set.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"path-set.js","sourceRoot":"","sources":["../../src/types/path-set.ts"],"names":[],"mappings":";;;;;;;;;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QACzC,IAAM,UAAU,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAErD,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;YAChD,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACpB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IACH,cAAC;AAAD,CAAC,AAjED,CAAsB,gCAAc,GAiEnC;AAEQ,0BAAO"} \ No newline at end of file diff --git a/dist/types/serialized-type.d.ts b/dist/types/serialized-type.d.ts deleted file mode 100644 index 85b4197..0000000 --- a/dist/types/serialized-type.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { BytesList } from "../serdes/binary-serializer"; -import { BinaryParser } from "../serdes/binary-parser"; -import * as bigInt from "big-integer"; -import { Buffer } from "buffer/"; -declare type JSON = string | number | boolean | null | undefined | JSON[] | JsonObject; -declare type JsonObject = { - [key: string]: JSON; -}; -/** - * The base class for all binary-codec types - */ -declare class SerializedType { - protected readonly bytes: Buffer; - constructor(bytes: Buffer); - static fromParser(parser: BinaryParser, hint?: number): SerializedType; - static from(value: SerializedType | JSON | bigInt.BigInteger): SerializedType; - /** - * Write the bytes representation of a SerializedType to a BytesList - * - * @param list The BytesList to write SerializedType bytes to - */ - toBytesSink(list: BytesList): void; - /** - * Get the hex representation of a SerializedType's bytes - * - * @returns hex String of this.bytes - */ - toHex(): string; - /** - * Get the bytes representation of a SerializedType - * - * @returns A buffer of the bytes - */ - toBytes(): Buffer; - /** - * Return the JSON representation of a SerializedType - * - * @returns any type, if not overloaded returns hexString representation of bytes - */ - toJSON(): JSON; - /** - * @returns hexString representation of this.bytes - */ - toString(): string; -} -/** - * Base class for SerializedTypes that are comparable - */ -declare class Comparable extends SerializedType { - lt(other: Comparable): boolean; - eq(other: Comparable): boolean; - gt(other: Comparable): boolean; - gte(other: Comparable): boolean; - lte(other: Comparable): boolean; - /** - * Overload this method to define how two Comparable SerializedTypes are compared - * - * @param other The comparable object to compare this to - * @returns A number denoting the relationship of this and other - */ - compareTo(other: Comparable): number; -} -export { SerializedType, Comparable, JSON, JsonObject }; diff --git a/dist/types/serialized-type.js b/dist/types/serialized-type.js deleted file mode 100644 index 612f884..0000000 --- a/dist/types/serialized-type.js +++ /dev/null @@ -1,116 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Comparable = exports.SerializedType = void 0; -var binary_serializer_1 = require("../serdes/binary-serializer"); -var buffer_1 = require("buffer/"); -/** - * The base class for all binary-codec types - */ -var SerializedType = /** @class */ (function () { - function SerializedType(bytes) { - this.bytes = buffer_1.Buffer.alloc(0); - this.bytes = bytes !== null && bytes !== void 0 ? bytes : buffer_1.Buffer.alloc(0); - } - SerializedType.fromParser = function (parser, hint) { - throw new Error("fromParser not implemented"); - return this.fromParser(parser, hint); - }; - SerializedType.from = function (value) { - throw new Error("from not implemented"); - return this.from(value); - }; - /** - * Write the bytes representation of a SerializedType to a BytesList - * - * @param list The BytesList to write SerializedType bytes to - */ - SerializedType.prototype.toBytesSink = function (list) { - list.put(this.bytes); - }; - /** - * Get the hex representation of a SerializedType's bytes - * - * @returns hex String of this.bytes - */ - SerializedType.prototype.toHex = function () { - return this.toBytes().toString("hex").toUpperCase(); - }; - /** - * Get the bytes representation of a SerializedType - * - * @returns A buffer of the bytes - */ - SerializedType.prototype.toBytes = function () { - if (this.bytes) { - return this.bytes; - } - var bytes = new binary_serializer_1.BytesList(); - this.toBytesSink(bytes); - return bytes.toBytes(); - }; - /** - * Return the JSON representation of a SerializedType - * - * @returns any type, if not overloaded returns hexString representation of bytes - */ - SerializedType.prototype.toJSON = function () { - return this.toHex(); - }; - /** - * @returns hexString representation of this.bytes - */ - SerializedType.prototype.toString = function () { - return this.toHex(); - }; - return SerializedType; -}()); -exports.SerializedType = SerializedType; -/** - * Base class for SerializedTypes that are comparable - */ -var Comparable = /** @class */ (function (_super) { - __extends(Comparable, _super); - function Comparable() { - return _super !== null && _super.apply(this, arguments) || this; - } - Comparable.prototype.lt = function (other) { - return this.compareTo(other) < 0; - }; - Comparable.prototype.eq = function (other) { - return this.compareTo(other) === 0; - }; - Comparable.prototype.gt = function (other) { - return this.compareTo(other) > 0; - }; - Comparable.prototype.gte = function (other) { - return this.compareTo(other) > -1; - }; - Comparable.prototype.lte = function (other) { - return this.compareTo(other) < 1; - }; - /** - * Overload this method to define how two Comparable SerializedTypes are compared - * - * @param other The comparable object to compare this to - * @returns A number denoting the relationship of this and other - */ - Comparable.prototype.compareTo = function (other) { - throw new Error("cannot compare " + this.toString() + " and " + other.toString()); - }; - return Comparable; -}(SerializedType)); -exports.Comparable = Comparable; -//# sourceMappingURL=serialized-type.js.map \ No newline at end of file diff --git a/dist/types/serialized-type.js.map b/dist/types/serialized-type.js.map deleted file mode 100644 index 59d5e2e..0000000 --- a/dist/types/serialized-type.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"serialized-type.js","sourceRoot":"","sources":["../../src/types/serialized-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAAwD;AAGxD,kCAAiC;AAMjC;;GAEG;AACH;IAGE,wBAAY,KAAa;QAFN,UAAK,GAAW,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAGjD,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,eAAM,CAAC,KAAK,C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,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,uBAAE,GAAF,UAAG,KAAiB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,uBAAE,GAAF,UAAG,KAAiB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,wBAAG,GAAH,UAAI,KAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,wBAAG,GAAH,UAAI,KAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,8BAAS,GAAT,UAAU,KAAiB;QACzB,MAAM,IAAI,KAAK,CACb,oBAAkB,IAAI,CAAC,QAAQ,EAAE,aAAQ,KAAK,CAAC,QAAQ,EAAI,CAC5D,CAAC;IACJ,CAAC;IACH,iBAAC;AAAD,CAAC,AAhCD,CAAyB,cAAc,GAgCtC;AAEwB,gCAAU"} \ No newline at end of file diff --git a/dist/types/st-array.d.ts b/dist/types/st-array.d.ts deleted file mode 100644 index 7683a1d..0000000 --- a/dist/types/st-array.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { SerializedType, JsonObject } from "./serialized-type"; -import { BinaryParser } from "../serdes/binary-parser"; -/** - * Class for serializing and deserializing Arrays of Objects - */ -declare class STArray extends SerializedType { - /** - * Construct an STArray from a BinaryParser - * - * @param parser BinaryParser to parse an STArray from - * @returns An STArray Object - */ - static fromParser(parser: BinaryParser): STArray; - /** - * Construct an STArray from an Array of JSON Objects - * - * @param value STArray or Array of Objects to parse into an STArray - * @returns An STArray object - */ - static from>(value: T): STArray; - /** - * Return the JSON representation of this.bytes - * - * @returns An Array of JSON objects - */ - toJSON(): Array; -} -export { STArray }; diff --git a/dist/types/st-array.js b/dist/types/st-array.js deleted file mode 100644 index cca9d67..0000000 --- a/dist/types/st-array.js +++ /dev/null @@ -1,98 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.STArray = void 0; -var serialized_type_1 = require("./serialized-type"); -var st_object_1 = require("./st-object"); -var binary_parser_1 = require("../serdes/binary-parser"); -var buffer_1 = require("buffer/"); -var ARRAY_END_MARKER = buffer_1.Buffer.from([0xf1]); -var ARRAY_END_MARKER_NAME = "ArrayEndMarker"; -var OBJECT_END_MARKER = buffer_1.Buffer.from([0xe1]); -/** - * TypeGuard for Array - */ -function isObjects(args) { - return (Array.isArray(args) && (args.length === 0 || typeof args[0] === "object")); -} -/** - * Class for serializing and deserializing Arrays of Objects - */ -var STArray = /** @class */ (function (_super) { - __extends(STArray, _super); - function STArray() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Construct an STArray from a BinaryParser - * - * @param parser BinaryParser to parse an STArray from - * @returns An STArray Object - */ - STArray.fromParser = function (parser) { - var bytes = []; - while (!parser.end()) { - var field = parser.readField(); - if (field.name === ARRAY_END_MARKER_NAME) { - break; - } - bytes.push(field.header, parser.readFieldValue(field).toBytes(), OBJECT_END_MARKER); - } - bytes.push(ARRAY_END_MARKER); - return new STArray(buffer_1.Buffer.concat(bytes)); - }; - /** - * Construct an STArray from an Array of JSON Objects - * - * @param value STArray or Array of Objects to parse into an STArray - * @returns An STArray object - */ - STArray.from = function (value) { - if (value instanceof STArray) { - return value; - } - if (isObjects(value)) { - var bytes_1 = []; - value.forEach(function (obj) { - bytes_1.push(st_object_1.STObject.from(obj).toBytes()); - }); - bytes_1.push(ARRAY_END_MARKER); - return new STArray(buffer_1.Buffer.concat(bytes_1)); - } - throw new Error("Cannot construct STArray from value given"); - }; - /** - * Return the JSON representation of this.bytes - * - * @returns An Array of JSON objects - */ - STArray.prototype.toJSON = function () { - var result = []; - var arrayParser = new binary_parser_1.BinaryParser(this.toString()); - while (!arrayParser.end()) { - var field = arrayParser.readField(); - if (field.name === ARRAY_END_MARKER_NAME) { - break; - } - var outer = {}; - outer[field.name] = st_object_1.STObject.fromParser(arrayParser).toJSON(); - result.push(outer); - } - return result; - }; - return STArray; -}(serialized_type_1.SerializedType)); -exports.STArray = STArray; -//# sourceMappingURL=st-array.js.map \ No newline at end of file diff --git a/dist/types/st-array.js.map b/dist/types/st-array.js.map deleted file mode 100644 index 36c3d62..0000000 --- a/dist/types/st-array.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"st-array.js","sourceRoot":"","sources":["../../src/types/st-array.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAA+D;AAC/D,yCAAuC;AACvC,yDAAuD;AACvD,kCAAiC;AAEjC,IAAM,gBAAgB,GAAG,eAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7C,IAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,IAAM,iBAAiB,GAAG,eAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAE9C;;GAEG;AACH,SAAS,SAAS,CAAC,IAAI;IACrB,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAC1E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH;IAAsB,2BAAc;IAApC;;IA0EA,CAAC;IAzEC;;;;;OAKG;IACI,kBAAU,GAAjB,UAAkB,MAA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AAG,EAAE,EAAE;YACzB,IAAM,KAAK,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,EAAE;gBACxC,MAAM;aACP;YAED,IAAM,KAAK,GAAG,EAAE,CAAC;YACjB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,oBAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,cAAC;AAAD,CAAC,AA1ED,CAAsB,gCAAc,GA0EnC;AAEQ,0BAAO"} \ No newline at end of file diff --git a/dist/types/st-object.d.ts b/dist/types/st-object.d.ts deleted file mode 100644 index 11c8967..0000000 --- a/dist/types/st-object.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { SerializedType, JsonObject } from "./serialized-type"; -import { BinaryParser } from "../serdes/binary-parser"; -/** - * Class for Serializing/Deserializing objects - */ -declare class STObject extends SerializedType { - /** - * Construct a STObject from a BinaryParser - * - * @param parser BinaryParser to read STObject from - * @returns A STObject object - */ - static fromParser(parser: BinaryParser): STObject; - /** - * Construct a STObject from a JSON object - * - * @param value An object to include - * @param filter optional, denote which field to include in serialized object - * @returns a STObject object - */ - static from(value: T, filter?: (...any: any[]) => boolean): STObject; - /** - * Get the JSON interpretation of this.bytes - * - * @returns a JSON object - */ - toJSON(): JsonObject; -} -export { STObject }; diff --git a/dist/types/st-object.js b/dist/types/st-object.js deleted file mode 100644 index e737cbb..0000000 --- a/dist/types/st-object.js +++ /dev/null @@ -1,157 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.STObject = void 0; -var enums_1 = require("../enums"); -var serialized_type_1 = require("./serialized-type"); -var ripple_address_codec_1 = require("ripple-address-codec"); -var binary_parser_1 = require("../serdes/binary-parser"); -var binary_serializer_1 = require("../serdes/binary-serializer"); -var buffer_1 = require("buffer/"); -var OBJECT_END_MARKER_BYTE = buffer_1.Buffer.from([0xe1]); -var OBJECT_END_MARKER = "ObjectEndMarker"; -var ST_OBJECT = "STObject"; -var DESTINATION = "Destination"; -var ACCOUNT = "Account"; -var SOURCE_TAG = "SourceTag"; -var DEST_TAG = "DestinationTag"; -/** - * Break down an X-Address into an account and a tag - * - * @param field Name of field - * @param xAddress X-Address corresponding to the field - */ -function handleXAddress(field, xAddress) { - var _a, _b; - var decoded = ripple_address_codec_1.xAddressToClassicAddress(xAddress); - var tagName; - if (field === DESTINATION) - tagName = DEST_TAG; - else if (field === ACCOUNT) - tagName = SOURCE_TAG; - else if (decoded.tag !== false) - throw new Error(field + " cannot have an associated tag"); - return decoded.tag !== false - ? (_a = {}, _a[field] = decoded.classicAddress, _a[tagName] = decoded.tag, _a) : (_b = {}, _b[field] = decoded.classicAddress, _b); -} -/** - * Validate that two objects don't both have the same tag fields - * - * @param obj1 First object to check for tags - * @param obj2 Second object to check for tags - * @throws When both objects have SourceTag or DestinationTag - */ -function checkForDuplicateTags(obj1, obj2) { - if (!(obj1[SOURCE_TAG] === undefined || obj2[SOURCE_TAG] === undefined)) - throw new Error("Cannot have Account X-Address and SourceTag"); - if (!(obj1[DEST_TAG] === undefined || obj2[DEST_TAG] === undefined)) - throw new Error("Cannot have Destination X-Address and DestinationTag"); -} -/** - * Class for Serializing/Deserializing objects - */ -var STObject = /** @class */ (function (_super) { - __extends(STObject, _super); - function STObject() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Construct a STObject from a BinaryParser - * - * @param parser BinaryParser to read STObject from - * @returns A STObject object - */ - STObject.fromParser = function (parser) { - var list = new binary_serializer_1.BytesList(); - var bytes = new binary_serializer_1.BinarySerializer(list); - while (!parser.end()) { - var field = parser.readField(); - if (field.name === OBJECT_END_MARKER) { - break; - } - var associatedValue = parser.readFieldValue(field); - bytes.writeFieldAndValue(field, associatedValue); - if (field.type.name === ST_OBJECT) { - bytes.put(OBJECT_END_MARKER_BYTE); - } - } - return new STObject(list.toBytes()); - }; - /** - * Construct a STObject from a JSON object - * - * @param value An object to include - * @param filter optional, denote which field to include in serialized object - * @returns a STObject object - */ - STObject.from = function (value, filter) { - if (value instanceof STObject) { - return value; - } - var list = new binary_serializer_1.BytesList(); - var bytes = new binary_serializer_1.BinarySerializer(list); - var xAddressDecoded = Object.entries(value).reduce(function (acc, _a) { - var _b; - var key = _a[0], val = _a[1]; - var handled = undefined; - if (ripple_address_codec_1.isValidXAddress(val)) { - handled = handleXAddress(key, val); - checkForDuplicateTags(handled, value); - } - return Object.assign(acc, handled !== null && handled !== void 0 ? handled : (_b = {}, _b[key] = val, _b)); - }, {}); - var sorted = Object.keys(xAddressDecoded) - .map(function (f) { return enums_1.Field[f]; }) - .filter(function (f) { - return f !== undefined && - xAddressDecoded[f.name] !== undefined && - f.isSerialized; - }) - .sort(function (a, b) { - return a.ordinal - b.ordinal; - }); - if (filter !== undefined) { - sorted = sorted.filter(filter); - } - sorted.forEach(function (field) { - var associatedValue = field.associatedType.from(xAddressDecoded[field.name]); - bytes.writeFieldAndValue(field, associatedValue); - if (field.type.name === ST_OBJECT) { - bytes.put(OBJECT_END_MARKER_BYTE); - } - }); - return new STObject(list.toBytes()); - }; - /** - * Get the JSON interpretation of this.bytes - * - * @returns a JSON object - */ - STObject.prototype.toJSON = function () { - var objectParser = new binary_parser_1.BinaryParser(this.toString()); - var accumulator = {}; - while (!objectParser.end()) { - var field = objectParser.readField(); - if (field.name === OBJECT_END_MARKER) { - break; - } - accumulator[field.name] = objectParser.readFieldValue(field).toJSON(); - } - return accumulator; - }; - return STObject; -}(serialized_type_1.SerializedType)); -exports.STObject = STObject; -//# sourceMappingURL=st-object.js.map \ No newline at end of file diff --git a/dist/types/st-object.js.map b/dist/types/st-object.js.map deleted file mode 100644 index e187fa6..0000000 --- a/dist/types/st-object.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"st-object.js","sourceRoot":"","sources":["../../src/types/st-object.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kCAAgD;AAChD,qDAA+D;AAC/D,6DAG8B;AAC9B,yDAAuD;AACvD,iEAA0E;AAC1E,kCAAiC;AAEjC,IAAM,sBAAsB,GAAG,eAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACnD,IAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,IAAM,SAAS,GAAG,UAAU,CAAC;AAC7B,IAAM,WAAW,GAAG,aAAa,CAAC;AAClC,IAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,IAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,IAAM,QAAQ,GAAG,gBAAgB,CAAC;AAElC;;;;;GAKG;AACH,SAAS,cAAc,CAAC,KAAa,EAAE,QAAgB;;IACrD,IAAM,OAAO,GAAG,+CAAwB,CAAC,QAAQ,CAAC,CAAC;IAEnD,IAAI,OAAO,CAAC;IACZ,IAAI,KAAK,KAAK,WAAW;QAAE,OAAO,GAAG,QAAQ,CAAC;SACzC,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,GAAG,UAAU,CAAC;SAC5C,IAAI,OAAO,CAAC,GAAG,KAAK,KAAK;QAC5B,MAAM,IAAI,KAAK,CAAI,KAAK,mCAAgC,CAAC,CAAC;IAE5D,OAAO,OAAO,CAAC,GAAG,KAAK,KAAK;QAC1B,CAAC,WAAG,GAAC,KAAK,IAAG,OAAO,CAAC,cAAc,EAAE,GAAC,OAAO,IAAG,OAAO,CAAC,GAAG,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;QAED,MAAM,CAAC,OAAO,CAAC,UAAC,KAAK;YACnB,IAAM,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,CAC/C,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAC5B,CAAC;YAEF,KAAK,CAAC,kBAAkB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;YACjD,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;gBACjC,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;aACnC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,yBAAM,GAAN;QACE,IAAM,YAAY,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvD,IAAM,WAAW,GAAG,EAAE,CAAC;QAEvB,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE;YAC1B,IAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;YACvC,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;gBACpC,MAAM;aACP;YACD,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;SACvE;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IACH,eAAC;AAAD,CAAC,AAxGD,CAAuB,gCAAc,GAwGpC;AAEQ,4BAAQ"} \ No newline at end of file diff --git a/dist/types/uint-16.d.ts b/dist/types/uint-16.d.ts deleted file mode 100644 index b270c37..0000000 --- a/dist/types/uint-16.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { UInt } from "./uint"; -import { BinaryParser } from "../serdes/binary-parser"; -import { Buffer } from "buffer/"; -/** - * Derived UInt class for serializing/deserializing 16 bit UInt - */ -declare class UInt16 extends UInt { - protected static readonly width: number; - static readonly defaultUInt16: UInt16; - constructor(bytes: Buffer); - static fromParser(parser: BinaryParser): UInt; - /** - * Construct a UInt16 object from a number - * - * @param val UInt16 object or number - */ - static from(val: T): UInt16; - /** - * get the value of a UInt16 object - * - * @returns the number represented by this.bytes - */ - valueOf(): number; -} -export { UInt16 }; diff --git a/dist/types/uint-16.js b/dist/types/uint-16.js deleted file mode 100644 index 493c90d..0000000 --- a/dist/types/uint-16.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UInt16 = void 0; -var uint_1 = require("./uint"); -var buffer_1 = require("buffer/"); -/** - * Derived UInt class for serializing/deserializing 16 bit UInt - */ -var UInt16 = /** @class */ (function (_super) { - __extends(UInt16, _super); - function UInt16(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt16.defaultUInt16.bytes) || this; - } - UInt16.fromParser = function (parser) { - return new UInt16(parser.read(UInt16.width)); - }; - /** - * Construct a UInt16 object from a number - * - * @param val UInt16 object or number - */ - UInt16.from = function (val) { - if (val instanceof UInt16) { - return val; - } - if (typeof val === "number") { - var buf = buffer_1.Buffer.alloc(UInt16.width); - buf.writeUInt16BE(val, 0); - return new UInt16(buf); - } - throw new Error("Can not construct UInt16 with given value"); - }; - /** - * get the value of a UInt16 object - * - * @returns the number represented by this.bytes - */ - UInt16.prototype.valueOf = function () { - return this.bytes.readUInt16BE(0); - }; - UInt16.width = 16 / 8; // 2 - UInt16.defaultUInt16 = new UInt16(buffer_1.Buffer.alloc(UInt16.width)); - return UInt16; -}(uint_1.UInt)); -exports.UInt16 = UInt16; -//# sourceMappingURL=uint-16.js.map \ No newline at end of file diff --git a/dist/types/uint-16.js.map b/dist/types/uint-16.js.map deleted file mode 100644 index 932f8b9..0000000 --- a/dist/types/uint-16.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"uint-16.js","sourceRoot":"","sources":["../../src/types/uint-16.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAE9B,kCAAiC;AAEjC;;GAEG;AACH;IAAqB,0BAAI;IAMvB,gBAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;IAC5C,CAAC;IAEM,iBAAU,GAAjB,UAAkB,MAAoB;QACpC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACI,WAAI,GAAX,UAAuC,GAAM;QAC3C,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAC;SACZ;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC1B,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAvCyB,YAAK,GAAW,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI;IACtC,oBAAa,GAAW,IAAI,MAAM,CAChD,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B,CAAC;IAqCJ,aAAC;CAAA,AAzCD,CAAqB,WAAI,GAyCxB;AAEQ,wBAAM"} \ No newline at end of file diff --git a/dist/types/uint-32.d.ts b/dist/types/uint-32.d.ts deleted file mode 100644 index 97bb6c2..0000000 --- a/dist/types/uint-32.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { UInt } from "./uint"; -import { BinaryParser } from "../serdes/binary-parser"; -import { Buffer } from "buffer/"; -/** - * Derived UInt class for serializing/deserializing 32 bit UInt - */ -declare class UInt32 extends UInt { - protected static readonly width: number; - static readonly defaultUInt32: UInt32; - constructor(bytes: Buffer); - static fromParser(parser: BinaryParser): UInt; - /** - * Construct a UInt32 object from a number - * - * @param val UInt32 object or number - */ - static from(val: T): UInt32; - /** - * get the value of a UInt32 object - * - * @returns the number represented by this.bytes - */ - valueOf(): number; -} -export { UInt32 }; diff --git a/dist/types/uint-32.js b/dist/types/uint-32.js deleted file mode 100644 index f043a2f..0000000 --- a/dist/types/uint-32.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UInt32 = void 0; -var uint_1 = require("./uint"); -var buffer_1 = require("buffer/"); -/** - * Derived UInt class for serializing/deserializing 32 bit UInt - */ -var UInt32 = /** @class */ (function (_super) { - __extends(UInt32, _super); - function UInt32(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt32.defaultUInt32.bytes) || this; - } - UInt32.fromParser = function (parser) { - return new UInt32(parser.read(UInt32.width)); - }; - /** - * Construct a UInt32 object from a number - * - * @param val UInt32 object or number - */ - UInt32.from = function (val) { - if (val instanceof UInt32) { - return val; - } - var buf = buffer_1.Buffer.alloc(UInt32.width); - if (typeof val === "string") { - var num = Number.parseInt(val); - buf.writeUInt32BE(num, 0); - return new UInt32(buf); - } - if (typeof val === "number") { - buf.writeUInt32BE(val, 0); - return new UInt32(buf); - } - throw new Error("Cannot construct UInt32 from given value"); - }; - /** - * get the value of a UInt32 object - * - * @returns the number represented by this.bytes - */ - UInt32.prototype.valueOf = function () { - return this.bytes.readUInt32BE(0); - }; - UInt32.width = 32 / 8; // 4 - UInt32.defaultUInt32 = new UInt32(buffer_1.Buffer.alloc(UInt32.width)); - return UInt32; -}(uint_1.UInt)); -exports.UInt32 = UInt32; -//# sourceMappingURL=uint-32.js.map \ No newline at end of file diff --git a/dist/types/uint-32.js.map b/dist/types/uint-32.js.map deleted file mode 100644 index ba2ccd4..0000000 --- a/dist/types/uint-32.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"uint-32.js","sourceRoot":"","sources":["../../src/types/uint-32.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAE9B,kCAAiC;AAEjC;;GAEG;AACH;IAAqB,0BAAI;IAMvB,gBAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;IAC5C,CAAC;IAEM,iBAAU,GAAjB,UAAkB,MAAoB;QACpC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACI,WAAI,GAAX,UAAgD,GAAM;QACpD,IAAI,GAAG,YAAY,MAAM,EAAE;YACzB,OAAO,GAAG,CAAC;SACZ;QAED,IAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAEvC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACjC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC1B,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC1B,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IA9CyB,YAAK,GAAW,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI;IACtC,oBAAa,GAAW,IAAI,MAAM,CAChD,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B,CAAC;IA4CJ,aAAC;CAAA,AAhDD,CAAqB,WAAI,GAgDxB;AAEQ,wBAAM"} \ No newline at end of file diff --git a/dist/types/uint-64.d.ts b/dist/types/uint-64.d.ts deleted file mode 100644 index ac22612..0000000 --- a/dist/types/uint-64.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { UInt } from "./uint"; -import { BinaryParser } from "../serdes/binary-parser"; -import * as bigInt from "big-integer"; -import { Buffer } from "buffer/"; -/** - * Derived UInt class for serializing/deserializing 64 bit UInt - */ -declare class UInt64 extends UInt { - protected static readonly width: number; - static readonly defaultUInt64: UInt64; - constructor(bytes: Buffer); - static fromParser(parser: BinaryParser): UInt; - /** - * Construct a UInt64 object - * - * @param val A UInt64, hex-string, bigInt, or number - * @returns A UInt64 object - */ - static from(val: T): UInt64; - /** - * The JSON representation of a UInt64 object - * - * @returns a hex-string - */ - toJSON(): string; - /** - * Get the value of the UInt64 - * - * @returns the number represented buy this.bytes - */ - valueOf(): bigInt.BigInteger; - /** - * Get the bytes representation of the UInt64 object - * - * @returns 8 bytes representing the UInt64 - */ - toBytes(): Buffer; -} -export { UInt64 }; diff --git a/dist/types/uint-64.js b/dist/types/uint-64.js deleted file mode 100644 index 1ce15df..0000000 --- a/dist/types/uint-64.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UInt64 = void 0; -var uint_1 = require("./uint"); -var bigInt = require("big-integer"); -var big_integer_1 = require("big-integer"); -var buffer_1 = require("buffer/"); -var HEX_REGEX = /^[A-F0-9]{16}$/; -var mask = bigInt(0x00000000ffffffff); -/** - * Derived UInt class for serializing/deserializing 64 bit UInt - */ -var UInt64 = /** @class */ (function (_super) { - __extends(UInt64, _super); - function UInt64(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt64.defaultUInt64.bytes) || this; - } - UInt64.fromParser = function (parser) { - return new UInt64(parser.read(UInt64.width)); - }; - /** - * Construct a UInt64 object - * - * @param val A UInt64, hex-string, bigInt, or number - * @returns A UInt64 object - */ - UInt64.from = function (val) { - if (val instanceof UInt64) { - return val; - } - var buf = buffer_1.Buffer.alloc(UInt64.width); - if (typeof val === "number") { - if (val < 0) { - throw new Error("value must be an unsigned integer"); - } - var number = bigInt(val); - var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)]; - intBuf[0].writeUInt32BE(Number(number.shiftRight(32)), 0); - intBuf[1].writeUInt32BE(Number(number.and(mask)), 0); - return new UInt64(buffer_1.Buffer.concat(intBuf)); - } - if (typeof val === "string") { - if (!HEX_REGEX.test(val)) { - throw new Error(val + " is not a valid hex-string"); - } - buf = buffer_1.Buffer.from(val, "hex"); - return new UInt64(buf); - } - if (big_integer_1.isInstance(val)) { - var intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)]; - intBuf[0].writeUInt32BE(Number(val.shiftRight(bigInt(32))), 0); - intBuf[1].writeUInt32BE(Number(val.and(mask)), 0); - return new UInt64(buffer_1.Buffer.concat(intBuf)); - } - throw new Error("Cannot construct UInt64 from given value"); - }; - /** - * The JSON representation of a UInt64 object - * - * @returns a hex-string - */ - UInt64.prototype.toJSON = function () { - return this.bytes.toString("hex").toUpperCase(); - }; - /** - * Get the value of the UInt64 - * - * @returns the number represented buy this.bytes - */ - UInt64.prototype.valueOf = function () { - var msb = bigInt(this.bytes.slice(0, 4).readUInt32BE(0)); - var lsb = bigInt(this.bytes.slice(4).readUInt32BE(0)); - return msb.shiftLeft(bigInt(32)).or(lsb); - }; - /** - * Get the bytes representation of the UInt64 object - * - * @returns 8 bytes representing the UInt64 - */ - UInt64.prototype.toBytes = function () { - return this.bytes; - }; - UInt64.width = 64 / 8; // 8 - UInt64.defaultUInt64 = new UInt64(buffer_1.Buffer.alloc(UInt64.width)); - return UInt64; -}(uint_1.UInt)); -exports.UInt64 = UInt64; -//# sourceMappingURL=uint-64.js.map \ No newline at end of file diff --git a/dist/types/uint-64.js.map b/dist/types/uint-64.js.map deleted file mode 100644 index e949aa9..0000000 --- a/dist/types/uint-64.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"uint-64.js","sourceRoot":"","sources":["../../src/types/uint-64.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAE9B,oCAAsC;AACtC,2CAAyC;AACzC,kCAAiC;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,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,OAAO,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,wBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAxFyB,YAAK,GAAW,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI;IACtC,oBAAa,GAAW,IAAI,MAAM,CAChD,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B,CAAC;IAsFJ,aAAC;CAAA,AA1FD,CAAqB,WAAI,GA0FxB;AAEQ,wBAAM"} \ No newline at end of file diff --git a/dist/types/uint-8.d.ts b/dist/types/uint-8.d.ts deleted file mode 100644 index 99a49f8..0000000 --- a/dist/types/uint-8.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { UInt } from "./uint"; -import { BinaryParser } from "../serdes/binary-parser"; -import { Buffer } from "buffer/"; -/** - * Derived UInt class for serializing/deserializing 8 bit UInt - */ -declare class UInt8 extends UInt { - protected static readonly width: number; - static readonly defaultUInt8: UInt8; - constructor(bytes: Buffer); - static fromParser(parser: BinaryParser): UInt; - /** - * Construct a UInt8 object from a number - * - * @param val UInt8 object or number - */ - static from(val: T): UInt8; - /** - * get the value of a UInt8 object - * - * @returns the number represented by this.bytes - */ - valueOf(): number; -} -export { UInt8 }; diff --git a/dist/types/uint-8.js b/dist/types/uint-8.js deleted file mode 100644 index 50b0cd4..0000000 --- a/dist/types/uint-8.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UInt8 = void 0; -var uint_1 = require("./uint"); -var buffer_1 = require("buffer/"); -/** - * Derived UInt class for serializing/deserializing 8 bit UInt - */ -var UInt8 = /** @class */ (function (_super) { - __extends(UInt8, _super); - function UInt8(bytes) { - return _super.call(this, bytes !== null && bytes !== void 0 ? bytes : UInt8.defaultUInt8.bytes) || this; - } - UInt8.fromParser = function (parser) { - return new UInt8(parser.read(UInt8.width)); - }; - /** - * Construct a UInt8 object from a number - * - * @param val UInt8 object or number - */ - UInt8.from = function (val) { - if (val instanceof UInt8) { - return val; - } - if (typeof val === "number") { - var buf = buffer_1.Buffer.alloc(UInt8.width); - buf.writeUInt8(val, 0); - return new UInt8(buf); - } - throw new Error("Cannot construct UInt8 from given value"); - }; - /** - * get the value of a UInt8 object - * - * @returns the number represented by this.bytes - */ - UInt8.prototype.valueOf = function () { - return this.bytes.readUInt8(0); - }; - UInt8.width = 8 / 8; // 1 - UInt8.defaultUInt8 = new UInt8(buffer_1.Buffer.alloc(UInt8.width)); - return UInt8; -}(uint_1.UInt)); -exports.UInt8 = UInt8; -//# sourceMappingURL=uint-8.js.map \ No newline at end of file diff --git a/dist/types/uint-8.js.map b/dist/types/uint-8.js.map deleted file mode 100644 index fc78649..0000000 --- a/dist/types/uint-8.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"uint-8.js","sourceRoot":"","sources":["../../src/types/uint-8.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA8B;AAE9B,kCAAiC;AAEjC;;GAEG;AACH;IAAoB,yBAAI;IAItB,eAAY,KAAa;eACvB,kBAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC;IAC1C,CAAC;IAEM,gBAAU,GAAjB,UAAkB,MAAoB;QACpC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,UAAI,GAAX,UAAsC,GAAM;QAC1C,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,OAAO,GAAG,CAAC;SACZ;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,IAAM,GAAG,GAAG,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACvB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;SACvB;QAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACH,uBAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IArCyB,WAAK,GAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;IACrC,kBAAY,GAAU,IAAI,KAAK,CAAC,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAqC7E,YAAC;CAAA,AAvCD,CAAoB,WAAI,GAuCvB;AAEQ,sBAAK"} \ No newline at end of file diff --git a/dist/types/uint.d.ts b/dist/types/uint.d.ts deleted file mode 100644 index dffb0d9..0000000 --- a/dist/types/uint.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import * as bigInt from "big-integer"; -import { Comparable } from "./serialized-type"; -import { Buffer } from "buffer/"; -/** - * Base class for serializing and deserializing unsigned integers. - */ -declare abstract class UInt extends Comparable { - protected static width: number; - constructor(bytes: Buffer); - /** - * Overload of compareTo for Comparable - * - * @param other other UInt to compare this to - * @returns -1, 0, or 1 depending on how the objects relate to each other - */ - compareTo(other: UInt): number; - /** - * Convert a UInt object to JSON - * - * @returns number or string represented by this.bytes - */ - toJSON(): number | string; - /** - * Get the value of the UInt represented by this.bytes - * - * @returns the value - */ - abstract valueOf(): number | bigInt.BigInteger; -} -export { UInt }; diff --git a/dist/types/uint.js b/dist/types/uint.js deleted file mode 100644 index 41a5789..0000000 --- a/dist/types/uint.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UInt = void 0; -var serialized_type_1 = require("./serialized-type"); -/** - * Compare numbers and bigInts n1 and n2 - * - * @param n1 First object to compare - * @param n2 Second object to compare - * @returns -1, 0, or 1, depending on how the two objects compare - */ -function compare(n1, n2) { - return n1 < n2 ? -1 : n1 == n2 ? 0 : 1; -} -/** - * Base class for serializing and deserializing unsigned integers. - */ -var UInt = /** @class */ (function (_super) { - __extends(UInt, _super); - function UInt(bytes) { - return _super.call(this, bytes) || this; - } - /** - * Overload of compareTo for Comparable - * - * @param other other UInt to compare this to - * @returns -1, 0, or 1 depending on how the objects relate to each other - */ - UInt.prototype.compareTo = function (other) { - return compare(this.valueOf(), other.valueOf()); - }; - /** - * Convert a UInt object to JSON - * - * @returns number or string represented by this.bytes - */ - UInt.prototype.toJSON = function () { - var val = this.valueOf(); - return typeof val === "number" ? val : val.toString(); - }; - return UInt; -}(serialized_type_1.Comparable)); -exports.UInt = UInt; -//# sourceMappingURL=uint.js.map \ No newline at end of file diff --git a/dist/types/uint.js.map b/dist/types/uint.js.map deleted file mode 100644 index 59b7281..0000000 --- a/dist/types/uint.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"uint.js","sourceRoot":"","sources":["../../src/types/uint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,qDAA+C;AAG/C;;;;;;GAMG;AACH,SAAS,OAAO,CACd,EAA8B,EAC9B,EAA8B;IAE9B,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH;IAA4B,wBAAU;IAGpC,cAAY,KAAa;eACvB,kBAAM,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,wBAAS,GAAT,UAAU,KAAW;QACnB,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACH,qBAAM,GAAN;QACE,IAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxD,CAAC;IAQH,WAAC;AAAD,CAAC,AAjCD,CAA4B,4BAAU,GAiCrC;AAEQ,oBAAI"} \ No newline at end of file diff --git a/dist/types/vector-256.d.ts b/dist/types/vector-256.d.ts deleted file mode 100644 index f659412..0000000 --- a/dist/types/vector-256.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { SerializedType } from "./serialized-type"; -import { BinaryParser } from "../serdes/binary-parser"; -import { Buffer } from "buffer/"; -/** - * Class for serializing and deserializing vectors of Hash256 - */ -declare class Vector256 extends SerializedType { - constructor(bytes: Buffer); - /** - * Construct a Vector256 from a BinaryParser - * - * @param parser BinaryParser to - * @param hint length of the vector, in bytes, optional - * @returns a Vector256 object - */ - static fromParser(parser: BinaryParser, hint?: number): Vector256; - /** - * Construct a Vector256 object from an array of hashes - * - * @param value A Vector256 object or array of hex-strings representing Hash256's - * @returns a Vector256 object - */ - static from>(value: T): Vector256; - /** - * Return an Array of hex-strings represented by this.bytes - * - * @returns An Array of strings representing the Hash256 objects - */ - toJSON(): Array; -} -export { Vector256 }; diff --git a/dist/types/vector-256.js b/dist/types/vector-256.js deleted file mode 100644 index 7e7968b..0000000 --- a/dist/types/vector-256.js +++ /dev/null @@ -1,90 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Vector256 = void 0; -var serialized_type_1 = require("./serialized-type"); -var hash_256_1 = require("./hash-256"); -var binary_serializer_1 = require("../serdes/binary-serializer"); -/** - * TypeGuard for Array - */ -function isStrings(arg) { - return Array.isArray(arg) && (arg.length === 0 || typeof arg[0] === "string"); -} -/** - * Class for serializing and deserializing vectors of Hash256 - */ -var Vector256 = /** @class */ (function (_super) { - __extends(Vector256, _super); - function Vector256(bytes) { - return _super.call(this, bytes) || this; - } - /** - * Construct a Vector256 from a BinaryParser - * - * @param parser BinaryParser to - * @param hint length of the vector, in bytes, optional - * @returns a Vector256 object - */ - Vector256.fromParser = function (parser, hint) { - var bytesList = new binary_serializer_1.BytesList(); - var bytes = hint !== null && hint !== void 0 ? hint : parser.size(); - var hashes = bytes / 32; - for (var i = 0; i < hashes; i++) { - hash_256_1.Hash256.fromParser(parser).toBytesSink(bytesList); - } - return new Vector256(bytesList.toBytes()); - }; - /** - * Construct a Vector256 object from an array of hashes - * - * @param value A Vector256 object or array of hex-strings representing Hash256's - * @returns a Vector256 object - */ - Vector256.from = function (value) { - if (value instanceof Vector256) { - return value; - } - if (isStrings(value)) { - var bytesList_1 = new binary_serializer_1.BytesList(); - value.forEach(function (hash) { - hash_256_1.Hash256.from(hash).toBytesSink(bytesList_1); - }); - return new Vector256(bytesList_1.toBytes()); - } - throw new Error("Cannot construct Vector256 from given value"); - }; - /** - * Return an Array of hex-strings represented by this.bytes - * - * @returns An Array of strings representing the Hash256 objects - */ - Vector256.prototype.toJSON = function () { - if (this.bytes.byteLength % 32 !== 0) { - throw new Error("Invalid bytes for Vector256"); - } - var result = []; - for (var i = 0; i < this.bytes.byteLength; i += 32) { - result.push(this.bytes - .slice(i, i + 32) - .toString("hex") - .toUpperCase()); - } - return result; - }; - return Vector256; -}(serialized_type_1.SerializedType)); -exports.Vector256 = Vector256; -//# sourceMappingURL=vector-256.js.map \ No newline at end of file diff --git a/dist/types/vector-256.js.map b/dist/types/vector-256.js.map deleted file mode 100644 index 9ea0b53..0000000 --- a/dist/types/vector-256.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"vector-256.js","sourceRoot":"","sources":["../../src/types/vector-256.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmD;AAEnD,uCAAqC;AACrC,iEAAwD;AAGxD;;GAEG;AACH,SAAS,SAAS,CAAC,GAAG;IACpB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;AAChF,CAAC;AAED;;GAEG;AACH;IAAwB,6BAAc;IACpC,mBAAY,KAAa;eACvB,kBAAM,KAAK,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,oBAAU,GAAjB,UAAkB,MAAoB,EAAE,IAAa;QACnD,IAAM,SAAS,GAAG,IAAI,6BAAS,EAAE,CAAC;QAClC,IAAM,KAAK,GAAG,IAAI,aAAJ,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