UNPKG

1.56 kBTypeScriptView Raw
1export declare type Input = string | number | bigint | Uint8Array | Array<Input> | null | undefined;
2export declare type NestedUint8Array = Array<Uint8Array | NestedUint8Array>;
3export interface Decoded {
4 data: Uint8Array | NestedUint8Array;
5 remainder: Uint8Array;
6}
7/**
8 * RLP Encoding based on https://eth.wiki/en/fundamentals/rlp
9 * This function takes in data, converts it to Uint8Array if not,
10 * and adds a length for recursion.
11 * @param input Will be converted to Uint8Array
12 * @returns Uint8Array of encoded data
13 **/
14export declare function encode(input: Input): Uint8Array;
15/**
16 * RLP Decoding based on https://eth.wiki/en/fundamentals/rlp
17 * @param input Will be converted to Uint8Array
18 * @param stream Is the input a stream (false by default)
19 * @returns decoded Array of Uint8Arrays containing the original message
20 **/
21export declare function decode(input: Input, stream?: false): Uint8Array | NestedUint8Array;
22export declare function decode(input: Input, stream?: true): Decoded;
23declare function bytesToHex(uint8a: Uint8Array): string;
24declare function hexToBytes(hex: string): Uint8Array;
25/** Concatenates two Uint8Arrays into one. */
26declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
27declare function utf8ToBytes(utf: string): Uint8Array;
28export declare const utils: {
29 bytesToHex: typeof bytesToHex;
30 concatBytes: typeof concatBytes;
31 hexToBytes: typeof hexToBytes;
32 utf8ToBytes: typeof utf8ToBytes;
33};
34declare const RLP: {
35 encode: typeof encode;
36 decode: typeof decode;
37};
38export default RLP;