xrpl-binary-codec-prerelease
Version:
XRP Ledger Protocol Binary Codec - For XRPL, Xahau and other networks (with dynamic definitions)
61 lines (60 loc) • 2.57 kB
TypeScript
import { SerializedType } from '../types/serialized-type';
import { Bytes, BytesLookup } from './bytes';
import { FieldInfo, FieldLookup, FieldInstance } from './field';
interface TxFlags {
[TransactionType: string]: {
[Flag: string]: number;
};
}
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>;
TRANSACTION_FLAGS_INDICES?: TxFlags;
TRANSACTION_FLAGS?: TxFlags;
native_currency_code?: string;
hash?: string;
}
/**
* 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>;
transactionFlagsIndices?: TxFlags;
transactionFlags?: TxFlags;
nativeAsset?: string;
hash?: string;
/**
* 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>;
getNativeAsset(): string;
getHash(): string | null;
}
export { DefinitionsData, XrplDefinitionsBase, FieldLookup, FieldInfo, FieldInstance, Bytes, BytesLookup, };
export type { TxFlags };