This commit is contained in:
nitowa
2023-08-15 22:28:03 +02:00
commit 1dae68b1c7
5529 changed files with 1659171 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import { BytesList, BinaryParser } from '../binary';
import { Buffer } from 'buffer/';
export declare class Bytes {
readonly name: string;
readonly ordinal: number;
readonly ordinalWidth: number;
readonly bytes: Buffer;
constructor(name: string, ordinal: number, ordinalWidth: number);
toJSON(): string;
toBytesSink(sink: BytesList): void;
toBytes(): Uint8Array;
}
export declare class BytesLookup {
readonly ordinalWidth: number;
constructor(types: Record<string, number>, ordinalWidth: number);
/**
* Add a new name value pair to the BytesLookup.
*
* @param name - A human readable name for the field.
* @param value - The numeric value for the field.
* @throws if the name or value already exist in the lookup because it's unclear how to decode.
*/
add(name: string, value: number): void;
from(value: Bytes | string): Bytes;
fromParser(parser: BinaryParser): Bytes;
}
+64
View File
@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BytesLookup = exports.Bytes = void 0;
const buffer_1 = require("buffer/");
/*
* @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result
*/
class Bytes {
constructor(name, ordinal, ordinalWidth) {
this.name = name;
this.ordinal = ordinal;
this.ordinalWidth = ordinalWidth;
this.bytes = buffer_1.Buffer.alloc(ordinalWidth);
for (let i = 0; i < ordinalWidth; i++) {
this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff;
}
}
toJSON() {
return this.name;
}
toBytesSink(sink) {
sink.put(this.bytes);
}
toBytes() {
return this.bytes;
}
}
exports.Bytes = Bytes;
/*
* @brief: Collection of Bytes objects, mapping bidirectionally
*/
class BytesLookup {
constructor(types, ordinalWidth) {
this.ordinalWidth = ordinalWidth;
Object.entries(types).forEach(([k, v]) => {
this.add(k, v);
});
}
/**
* Add a new name value pair to the BytesLookup.
*
* @param name - A human readable name for the field.
* @param value - The numeric value for the field.
* @throws if the name or value already exist in the lookup because it's unclear how to decode.
*/
add(name, value) {
if (this[name]) {
throw new SyntaxError(`Attempted to add a value with a duplicate name "${name}". This is not allowed because it is unclear how to decode.`);
}
if (this[value.toString()]) {
throw new SyntaxError(`Attempted to add a duplicate value under a different name (Given name: "${name}" and previous name: "${this[value.toString()]}. This is not allowed because it is unclear how to decode.\nGiven value: ${value.toString()}`);
}
this[name] = new Bytes(name, value, this.ordinalWidth);
this[value.toString()] = this[name];
}
from(value) {
return value instanceof Bytes ? value : this[value];
}
fromParser(parser) {
return this.from(parser.readUIntN(this.ordinalWidth).toString());
}
}
exports.BytesLookup = BytesLookup;
//# sourceMappingURL=bytes.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/enums/bytes.ts"],"names":[],"mappings":";;;AACA,oCAAgC;AAEhC;;GAEG;AACH,MAAa,KAAK;IAGhB,YACW,IAAY,EACZ,OAAe,EACf,YAAoB;QAFpB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,iBAAY,GAAZ,YAAY,CAAQ;QAE7B,IAAI,CAAC,KAAK,GAAG,eAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,EAAE,CAAC,EAAE,EAAE;YACrC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;SAChE;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,WAAW,CAAC,IAAe;QACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF;AAzBD,sBAyBC;AAED;;GAEG;AACH,MAAa,WAAW;IACtB,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IDTH = 2;
export declare const TRANSACTION_TYPE_WIDTH = 2;
export declare const TRANSACTION_RESULT_WIDTH = 1;
+8
View File
@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRANSACTION_RESULT_WIDTH = exports.TRANSACTION_TYPE_WIDTH = exports.LEDGER_ENTRY_WIDTH = exports.TYPE_WIDTH = void 0;
exports.TYPE_WIDTH = 2;
exports.LEDGER_ENTRY_WIDTH = 2;
exports.TRANSACTION_TYPE_WIDTH = 2;
exports.TRANSACTION_RESULT_WIDTH = 1;
//# sourceMappingURL=constants.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/enums/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,CAAC,CAAA;AACd,QAAA,kBAAkB,GAAG,CAAC,CAAA;AACtB,QAAA,sBAAsB,GAAG,CAAC,CAAA;AAC1B,QAAA,wBAAwB,GAAG,CAAC,CAAA"}
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
import { Bytes } from './bytes';
import { SerializedType } from '../types/serialized-type';
import { Buffer } from 'buffer/';
/**
* Encoding information for a rippled field, often used in transactions.
* See the enums [README.md](https://github.com/XRPLF/xrpl.js/tree/main/packages/ripple-binary-codec/src/enums) for more details on what each means.
*/
export interface FieldInfo {
nth: number;
isVLEncoded: boolean;
isSerialized: boolean;
isSigningField: boolean;
type: string;
}
export 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;
}
export declare class FieldLookup {
constructor(fields: Array<[string, FieldInfo]>, types: Record<string, number>);
fromString(value: string): FieldInstance;
}
+59
View File
@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldLookup = void 0;
const bytes_1 = require("./bytes");
const serialized_type_1 = require("../types/serialized-type");
const constants_1 = require("./constants");
const buffer_1 = require("buffer/");
/*
* @brief: Serialize a field based on type_code and Field.nth
*/
function fieldHeader(type, nth) {
const 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);
}
function buildField([name, info], typeOrdinal) {
const 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_1.Bytes(info.type, typeOrdinal, constants_1.TYPE_WIDTH),
header: field,
associatedType: serialized_type_1.SerializedType, // For later assignment in ./types/index.js or Definitions.updateAll(...)
};
}
/*
* @brief: The collection of all fields as defined in definitions.json
*/
class FieldLookup {
constructor(fields, types) {
fields.forEach(([name, field_info]) => {
const typeOrdinal = types[field_info.type];
this[name] = buildField([name, field_info], typeOrdinal);
this[this[name].ordinal.toString()] = this[name];
});
}
fromString(value) {
return this[value];
}
}
exports.FieldLookup = FieldLookup;
//# sourceMappingURL=field.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/enums/field.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,8DAAyD;AACzD,2CAAwC;AACxC,oCAAgC;AA0BhC;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY,EAAE,GAAW;IAC5C,MAAM,MAAM,GAAkB,EAAE,CAAA;IAChC,IAAI,IAAI,GAAG,EAAE,EAAE;QACb,IAAI,GAAG,GAAG,EAAE,EAAE;YACZ,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;SAC/B;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,EAA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,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAkB,CAAA;IACrC,CAAC;CACF;AAfD,kCAeC"}
+48
View File
@@ -0,0 +1,48 @@
import { SerializedType } from '../types/serialized-type';
import { Buffer } from 'buffer/';
import { BytesList } from '../binary';
export declare const TRANSACTION_TYPES: string[];
export declare class Bytes {
readonly name: string;
readonly ordinal: number;
readonly ordinalWidth: number;
readonly bytes: Buffer;
constructor(name: string, ordinal: number, ordinalWidth: number);
toJSON(): string;
toBytesSink(sink: BytesList): void;
toBytes(): Uint8Array;
}
declare class BytesLookup {
readonly ordinalWidth: number;
constructor(types: Record<string, number>, 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, };
+142
View File
@@ -0,0 +1,142 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionType = exports.TransactionResult = exports.LedgerEntryType = exports.Type = exports.Field = exports.Bytes = exports.TRANSACTION_TYPES = void 0;
const enums = __importStar(require("./definitions.json"));
const serialized_type_1 = require("../types/serialized-type");
const buffer_1 = require("buffer/");
/*
* @brief: All valid transaction types
*/
exports.TRANSACTION_TYPES = Object.entries(enums.TRANSACTION_TYPES)
.filter(([_key, value]) => value >= 0)
.map(([key, _value]) => key);
const TYPE_WIDTH = 2;
const LEDGER_ENTRY_WIDTH = 2;
const TRANSACTION_TYPE_WIDTH = 2;
const TRANSACTION_RESULT_WIDTH = 1;
/*
* @brief: Serialize a field based on type_code and Field.nth
*/
function fieldHeader(type, nth) {
const 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
*/
class Bytes {
constructor(name, ordinal, ordinalWidth) {
this.name = name;
this.ordinal = ordinal;
this.ordinalWidth = ordinalWidth;
this.bytes = buffer_1.Buffer.alloc(ordinalWidth);
for (let i = 0; i < ordinalWidth; i++) {
this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff;
}
}
toJSON() {
return this.name;
}
toBytesSink(sink) {
sink.put(this.bytes);
}
toBytes() {
return this.bytes;
}
}
exports.Bytes = Bytes;
/*
* @brief: Collection of Bytes objects, mapping bidirectionally
*/
class BytesLookup {
constructor(types, ordinalWidth) {
this.ordinalWidth = ordinalWidth;
Object.entries(types).forEach(([k, v]) => {
this[k] = new Bytes(k, v, ordinalWidth);
this[v.toString()] = this[k];
});
}
from(value) {
return value instanceof Bytes ? value : this[value];
}
fromParser(parser) {
return this.from(parser.readUIntN(this.ordinalWidth).toString());
}
}
function buildField([name, info]) {
const typeOrdinal = enums.TYPES[info.type];
const 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, // For later assignment in ./types/index.js
};
}
/*
* @brief: The collection of all fields as defined in definitions.json
*/
class FieldLookup {
constructor(fields) {
fields.forEach(([k, v]) => {
this[k] = buildField([k, v]);
this[this[k].ordinal.toString()] = this[k];
});
}
fromString(value) {
return this[value];
}
}
const Type = new BytesLookup(enums.TYPES, TYPE_WIDTH);
exports.Type = Type;
const LedgerEntryType = new BytesLookup(enums.LEDGER_ENTRY_TYPES, LEDGER_ENTRY_WIDTH);
exports.LedgerEntryType = LedgerEntryType;
const TransactionType = new BytesLookup(enums.TRANSACTION_TYPES, TRANSACTION_TYPE_WIDTH);
exports.TransactionType = TransactionType;
const TransactionResult = new BytesLookup(enums.TRANSACTION_RESULTS, TRANSACTION_RESULT_WIDTH);
exports.TransactionResult = TransactionResult;
const Field = new FieldLookup(enums.FIELDS);
exports.Field = Field;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA2C;AAC3C,8DAAyD;AACzD,oCAAgC;AAGhC;;GAEG;AACU,QA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B,kBAAkB,CACnB,CAAA;AAeC,0CAAe;AAdjB,MAAM,eAAe,GAAG,IAAI,WAAW,CACrC,KAAK,CAAC,iBAAiB,EACvB,sBAAsB,CACvB,CAAA;AAaC,0CAAe;AAZjB,MAAM,iBAAiB,GAAG,IAAI,WAAW,CACvC,KAAK,CAAC,mBAAmB,EACzB,wBAAwB,CACzB,CAAA;AAQC,8CAAiB;AAPnB,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,MAAoC,CAAC,CAAA;AAGvE,sBAAK"}
File diff suppressed because it is too large Load Diff
+101
View File
@@ -0,0 +1,101 @@
/**
* 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;
+127
View File
@@ -0,0 +1,127 @@
"use strict";
/**
* Quick script to re-number values
*/
const 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,
};
let startingFromTemBADSENDXRPPATHS = -284;
let startingFromTefFAILURE = -199;
let startingFromTerRETRY = -99;
const tesSUCCESS = 0;
let startingFromTecCLAIM = 100;
const startingFromTecDIRFULL = 121;
let previousKey = 'tem';
Object.keys(input).forEach((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
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"utils-renumber.js","sourceRoot":"","sources":["../../src/enums/utils-renumber.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,MAAM,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,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AC,QAAQ,GAAG,MAAM,oBAAoB,EAAE,GAAG,CAAC,CAAA;KACxD;AACH,CAAC,CAAC,CAAA"}
+44
View File
@@ -0,0 +1,44 @@
import { SerializedType } from '../types/serialized-type';
import { Bytes, BytesLookup } from './bytes';
import { FieldInfo, FieldLookup, FieldInstance } from './field';
interface DefinitionsData {
TYPES: Record<string, number>;
LEDGER_ENTRY_TYPES: Record<string, number>;
FIELDS: (string | FieldInfo)[][];
TRANSACTION_RESULTS: Record<string, number>;
TRANSACTION_TYPES: Record<string, number>;
}
/**
* Stores the various types and fields for rippled to be used to encode/decode information later on.
* XrplDefinitions should be instantiated instead of this class.
*/
declare class XrplDefinitionsBase {
field: FieldLookup;
ledgerEntryType: BytesLookup;
type: BytesLookup;
transactionResult: BytesLookup;
transactionType: BytesLookup;
transactionNames: string[];
dataTypes: Record<string, typeof SerializedType>;
/**
* Present rippled types in a typed and updatable format.
* For an example of the input format see `definitions.json`
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
*
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
*
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
* @param types - A list of type objects with the same name as the fields defined.
* You can use the coreTypes object if you are not adding new types.
*/
constructor(enums: DefinitionsData, types: Record<string, typeof SerializedType>);
/**
* Associates each Field to a corresponding class that TypeScript can recognize.
*
* @param types a list of type objects with the same name as the fields defined.
* Defaults to xrpl.js's core type definitions.
*/
associateTypes(types: Record<string, typeof SerializedType>): void;
getAssociatedTypes(): Record<string, typeof SerializedType>;
}
export { DefinitionsData, XrplDefinitionsBase, FieldLookup, FieldInfo, FieldInstance, Bytes, BytesLookup, };
+64
View File
@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BytesLookup = exports.Bytes = exports.FieldLookup = exports.XrplDefinitionsBase = void 0;
const bytes_1 = require("./bytes");
Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return bytes_1.Bytes; } });
Object.defineProperty(exports, "BytesLookup", { enumerable: true, get: function () { return bytes_1.BytesLookup; } });
const field_1 = require("./field");
Object.defineProperty(exports, "FieldLookup", { enumerable: true, get: function () { return field_1.FieldLookup; } });
const constants_1 = require("./constants");
/**
* Stores the various types and fields for rippled to be used to encode/decode information later on.
* XrplDefinitions should be instantiated instead of this class.
*/
class XrplDefinitionsBase {
/**
* Present rippled types in a typed and updatable format.
* For an example of the input format see `definitions.json`
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
*
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
*
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
* @param types - A list of type objects with the same name as the fields defined.
* You can use the coreTypes object if you are not adding new types.
*/
constructor(enums, types) {
// Helps catch errors early in JavaScript code.
if (types == undefined) {
throw new TypeError('You passed in an undefined `types` parameter, but `types` must be defined since it contains logic for encoding/decoding transaction data. ' +
'If you have NOT added/modified any data types, you can import and use `coreTypes` from the types folder.');
}
this.type = new bytes_1.BytesLookup(enums.TYPES, constants_1.TYPE_WIDTH);
this.ledgerEntryType = new bytes_1.BytesLookup(enums.LEDGER_ENTRY_TYPES, constants_1.LEDGER_ENTRY_WIDTH);
this.transactionType = new bytes_1.BytesLookup(enums.TRANSACTION_TYPES, constants_1.TRANSACTION_TYPE_WIDTH);
this.transactionResult = new bytes_1.BytesLookup(enums.TRANSACTION_RESULTS, constants_1.TRANSACTION_RESULT_WIDTH);
this.field = new field_1.FieldLookup(enums.FIELDS, enums.TYPES);
this.transactionNames = Object.entries(enums.TRANSACTION_TYPES)
.filter(([_key, value]) => value >= 0)
.map(([key, _value]) => key);
this.dataTypes = {}; // Filled in via associateTypes
this.associateTypes(types);
}
/**
* Associates each Field to a corresponding class that TypeScript can recognize.
*
* @param types a list of type objects with the same name as the fields defined.
* Defaults to xrpl.js's core type definitions.
*/
associateTypes(types) {
// Overwrite any existing type definitions with the given types
this.dataTypes = Object.assign({}, this.dataTypes, types);
Object.values(this.field).forEach((field) => {
field.associatedType = this.dataTypes[field.type.name];
});
this.field['TransactionType'].associatedType = this.transactionType;
this.field['TransactionResult'].associatedType = this.transactionResult;
this.field['LedgerEntryType'].associatedType = this.ledgerEntryType;
}
getAssociatedTypes() {
return this.dataTypes;
}
}
exports.XrplDefinitionsBase = XrplDefinitionsBase;
//# sourceMappingURL=xrpl-definitions-base.js.map
@@ -0,0 +1 @@
{"version":3,"file":"xrpl-definitions-base.js","sourceRoot":"","sources":["../../src/enums/xrpl-definitions-base.ts"],"names":[],"mappings":";;;AACA,mCAA4C;AAmH1C,sFAnHO,aAAK,OAmHP;AACL,4FApHc,mBAAW,OAoHd;AAnHb,mCAA+D;AA+G7D,4FA/GkB,mBAAW,OA+GlB;AA9Gb,2CAKoB;AAUpB;;;GAGG;AACH,MAAM,mBAAmB;IAgBvB;;;;;;;;;;OAUG;IACH,YACE,KAAsB,EACtB,KAA4C;QAE5C,+CAA+C;QAC/C,IAAI,KAAK,IAAI,SAAS,EAAE;YACtB,MAAM,IAAI,SAAS,CACjB,4IAA4I;gBAC1I,0GAA0G,CAC7G,CAAA;SACF;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAW,CAAC,KAAK,CAAC,KAAK,EAAE,sBAAU,CAAC,CAAA;QACpD,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAW,CACpC,KAAK,CAAC,kBAAkB,EACxB,8BAAkB,CACnB,CAAA;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAW,CACpC,KAAK,CAAC,iBAAiB,EACvB,kCAAsB,CACvB,CAAA;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,mBAAW,CACtC,KAAK,CAAC,mBAAmB,EACzB,oCAAwB,CACzB,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAW,CAC1B,KAAK,CAAC,MAAoC,EAC1C,KAAK,CAAC,KAAK,CACZ,CAAA;QACD,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;aAC5D,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAA;QAE9B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA,CAAC,+BAA+B;QACnD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,KAA4C;QAChE,+DAA+D;QAC/D,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAEzD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1C,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAA;QACnE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAA;QACvE,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAA;IACrE,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF;AAIC,kDAAmB"}
+21
View File
@@ -0,0 +1,21 @@
import { type DefinitionsData, XrplDefinitionsBase } from './xrpl-definitions-base';
import { SerializedType } from '../types/serialized-type';
/**
* Stores the various types and fields for rippled to be used to encode/decode information later on.
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
* ledger data.
*/
export declare class XrplDefinitions extends XrplDefinitionsBase {
/**
* Present rippled types in a typed and updatable format.
* For an example of the input format see `definitions.json`
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
*
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
*
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
* @param types - A list of type objects with the same name as the fields defined.
* You can use the coreTypes object if you are not adding new types.
*/
constructor(enums: DefinitionsData, types?: Record<string, typeof SerializedType>);
}
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XrplDefinitions = void 0;
const xrpl_definitions_base_1 = require("./xrpl-definitions-base");
const types_1 = require("../types");
/**
* Stores the various types and fields for rippled to be used to encode/decode information later on.
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
* ledger data.
*/
class XrplDefinitions extends xrpl_definitions_base_1.XrplDefinitionsBase {
/**
* Present rippled types in a typed and updatable format.
* For an example of the input format see `definitions.json`
* To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
*
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
*
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
* @param types - A list of type objects with the same name as the fields defined.
* You can use the coreTypes object if you are not adding new types.
*/
constructor(enums, types = types_1.coreTypes) {
super(enums, types);
}
}
exports.XrplDefinitions = XrplDefinitions;
//# sourceMappingURL=xrpl-definitions.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"xrpl-definitions.js","sourceRoot":"","sources":["../../src/enums/xrpl-definitions.ts"],"names":[],"mappings":";;;AAAA,mEAGgC;AAChC,oCAAoC;AAGpC;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,2CAAmB;IACtD;;;;;;;;;;OAUG;IACH,YACE,KAAsB,EACtB,QAA+C,iBAAS;QAExD,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACrB,CAAC;CACF;AAlBD,0CAkBC"}