1 |
|
2 |
|
3 |
|
4 | import { TransactionHeader } from './eosjs-api-interfaces';
|
5 | import { Abi, BlockTaposInfo } from './eosjs-rpc-interfaces';
|
6 | import { Query } from './eosjs-api-interfaces';
|
7 |
|
8 | export interface Field {
|
9 |
|
10 | name: string;
|
11 |
|
12 | typeName: string;
|
13 |
|
14 | type: Type;
|
15 | }
|
16 |
|
17 | export interface SerializerOptions {
|
18 | bytesAsUint8Array?: boolean;
|
19 | }
|
20 |
|
21 | export declare class SerializerState {
|
22 | options: SerializerOptions;
|
23 |
|
24 | skippedBinaryExtension: boolean;
|
25 | constructor(options?: SerializerOptions);
|
26 | }
|
27 | /**
|
28 | * An Anyvar (non-short form) may be any of the following:
|
29 | * * null
|
30 | * * string
|
31 | * * number
|
32 | * * Caution: assumes number is int32. Use {type, value} form for other numeric types
|
33 | * * an array of anyvar
|
34 | * * {type, value}
|
35 | * * type is a string matching one of the predefined types in anyvarDefs
|
36 | * * value:
|
37 | * * If type === 'any_object', then value is an object. The values within the object are anyvar.
|
38 | * * If type === 'any_array', then value is an array of anyvar.
|
39 | * * Else, value must be eosjs-compatible with the specified type (e.g. uint64 should be a string
|
40 | * containing the value in decimal).
|
41 | * * Other object. The values within the object are anyvar.
|
42 | *
|
43 | * The short form is more convenient, but it can't be converted back to binary (serialized).
|
44 | * Wherever the anyvar would have {type, value}, it has just the value instead.
|
45 | */
|
46 | export declare type Anyvar = null | string | number | Anyvar[] | {
|
47 | type: string;
|
48 | value: any;
|
49 | } | Record<string, unknown>;
|
50 |
|
51 | export interface Type {
|
52 |
|
53 | name: string;
|
54 |
|
55 | aliasOfName: string;
|
56 |
|
57 | arrayOf: Type;
|
58 |
|
59 | optionalOf: Type;
|
60 |
|
61 | extensionOf?: Type;
|
62 |
|
63 | baseName: string;
|
64 |
|
65 | base: Type;
|
66 |
|
67 | fields: Field[];
|
68 |
|
69 | serialize: (buffer: SerialBuffer, data: any, state?: SerializerState, allowExtensions?: boolean) => void;
|
70 |
|
71 | deserialize: (buffer: SerialBuffer, state?: SerializerState, allowExtensions?: boolean) => any;
|
72 | }
|
73 |
|
74 | export interface Symbol {
|
75 |
|
76 | name: string;
|
77 |
|
78 | precision: number;
|
79 | }
|
80 | export interface Contract {
|
81 | actions: Map<string, Type>;
|
82 | types: Map<string, Type>;
|
83 | }
|
84 | export interface Authorization {
|
85 | actor: string;
|
86 | permission: string;
|
87 | }
|
88 |
|
89 | export interface Action {
|
90 | account: string;
|
91 | name: string;
|
92 | authorization: Authorization[];
|
93 | data: any;
|
94 | hex_data?: string;
|
95 | }
|
96 |
|
97 | export interface SerializedAction {
|
98 | account: string;
|
99 | name: string;
|
100 | authorization: Authorization[];
|
101 | data: string;
|
102 | }
|
103 |
|
104 | export declare class SerialBuffer {
|
105 |
|
106 | length: number;
|
107 |
|
108 | array: Uint8Array;
|
109 |
|
110 | readPos: number;
|
111 | textEncoder: TextEncoder;
|
112 | textDecoder: TextDecoder;
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | constructor({ textEncoder, textDecoder, array }?: {
|
120 | textEncoder?: TextEncoder;
|
121 | textDecoder?: TextDecoder;
|
122 | array?: Uint8Array;
|
123 | });
|
124 | /** Resize `array` if needed to have at least `size` bytes free */
|
125 | reserve(size: number): void;
|
126 | /** Is there data available to read? */
|
127 | haveReadData(): boolean;
|
128 | /** Restart reading from the beginning */
|
129 | restartRead(): void;
|
130 | /** Return data with excess storage trimmed away */
|
131 | asUint8Array(): Uint8Array;
|
132 | /** Append bytes */
|
133 | pushArray(v: number[] | Uint8Array): void;
|
134 | /** Append bytes */
|
135 | push(...v: number[]): void;
|
136 | /** Get a single byte */
|
137 | get(): number;
|
138 | /** Append bytes in `v`. Throws if `len` doesn't match `v.length` */
|
139 | pushUint8ArrayChecked(v: Uint8Array, len: number): void;
|
140 | /** Get `len` bytes */
|
141 | getUint8Array(len: number): Uint8Array;
|
142 | /** Skip `len` bytes */
|
143 | skip(len: number): void;
|
144 | /** Append a `uint16` */
|
145 | pushUint16(v: number): void;
|
146 | /** Get a `uint16` */
|
147 | getUint16(): number;
|
148 | /** Append a `uint32` */
|
149 | pushUint32(v: number): void;
|
150 | /** Get a `uint32` */
|
151 | getUint32(): number;
|
152 | /** Append a `uint64`. *Caution*: `number` only has 53 bits of precision */
|
153 | pushNumberAsUint64(v: number): void;
|
154 | /**
|
155 | * Get a `uint64` as a `number`. *Caution*: `number` only has 53 bits of precision; some values will change.
|
156 | * `numeric.binaryToDecimal(serialBuffer.getUint8Array(8))` recommended instead
|
157 | */
|
158 | getUint64AsNumber(): number;
|
159 | /** Append a `varuint32` */
|
160 | pushVaruint32(v: number): void;
|
161 | /** Get a `varuint32` */
|
162 | getVaruint32(): number;
|
163 | /** Append a `varint32` */
|
164 | pushVarint32(v: number): void;
|
165 | /** Get a `varint32` */
|
166 | getVarint32(): number;
|
167 | /** Append a `float32` */
|
168 | pushFloat32(v: number): void;
|
169 | /** Get a `float32` */
|
170 | getFloat32(): number;
|
171 | /** Append a `float64` */
|
172 | pushFloat64(v: number): void;
|
173 | /** Get a `float64` */
|
174 | getFloat64(): number;
|
175 | /** Append a `name` */
|
176 | pushName(s: string): void;
|
177 | /** Get a `name` */
|
178 | getName(): string;
|
179 | /** Append length-prefixed binary data */
|
180 | pushBytes(v: number[] | Uint8Array): void;
|
181 | /** Get length-prefixed binary data */
|
182 | getBytes(): Uint8Array;
|
183 | /** Append a string */
|
184 | pushString(v: string): void;
|
185 | /** Get a string */
|
186 | getString(): string;
|
187 | /** Append a `symbol_code`. Unlike `symbol`, `symbol_code` doesn't include a precision. */
|
188 | pushSymbolCode(name: string): void;
|
189 | /** Get a `symbol_code`. Unlike `symbol`, `symbol_code` doesn't include a precision. */
|
190 | getSymbolCode(): string;
|
191 | /** Append a `symbol` */
|
192 | pushSymbol({ name, precision }: {
|
193 | name: string;
|
194 | precision: number;
|
195 | }): void;
|
196 | /** Get a `symbol` */
|
197 | getSymbol(): {
|
198 | name: string;
|
199 | precision: number;
|
200 | };
|
201 |
|
202 | pushAsset(s: string): void;
|
203 |
|
204 | getAsset(): string;
|
205 |
|
206 | pushPublicKey(s: string): void;
|
207 |
|
208 | getPublicKey(): string;
|
209 |
|
210 | pushPrivateKey(s: string): void;
|
211 |
|
212 | getPrivateKey(): string;
|
213 |
|
214 | pushSignature(s: string): void;
|
215 |
|
216 | getSignature(): string;
|
217 | }
|
218 |
|
219 | export declare const supportedAbiVersion: (version: string) => boolean;
|
220 |
|
221 | export declare const dateToTimePoint: (date: string) => number;
|
222 |
|
223 | export declare const timePointToDate: (us: number) => string;
|
224 |
|
225 | export declare const dateToTimePointSec: (date: string) => number;
|
226 |
|
227 | export declare const timePointSecToDate: (sec: number) => string;
|
228 |
|
229 | export declare const dateToBlockTimestamp: (date: string) => number;
|
230 |
|
231 | export declare const blockTimestampToDate: (slot: number) => string;
|
232 |
|
233 | export declare const stringToSymbol: (s: string) => {
|
234 | name: string;
|
235 | precision: number;
|
236 | };
|
237 |
|
238 | export declare const symbolToString: ({ name, precision }: {
|
239 | name: string;
|
240 | precision: number;
|
241 | }) => string;
|
242 |
|
243 | export declare const arrayToHex: (data: Uint8Array) => string;
|
244 |
|
245 | export declare const hexToUint8Array: (hex: string) => Uint8Array;
|
246 |
|
247 | export declare const createInitialTypes: () => Map<string, Type>;
|
248 | export declare const createAbiTypes: () => Map<string, Type>;
|
249 | export declare const createTransactionExtensionTypes: () => Map<string, Type>;
|
250 | export declare const createTransactionTypes: () => Map<string, Type>;
|
251 |
|
252 | export declare const getType: (types: Map<string, Type>, name: string) => Type;
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | export declare const getTypesFromAbi: (initialTypes: Map<string, Type>, abi?: Abi) => Map<string, Type>;
|
260 |
|
261 | export declare const transactionHeader: (refBlock: BlockTaposInfo, expireSeconds: number) => TransactionHeader;
|
262 |
|
263 | export declare const serializeActionData: (contract: Contract, account: string, name: string, data: any, textEncoder: TextEncoder, textDecoder: TextDecoder) => string;
|
264 |
|
265 | export declare const serializeAction: (contract: Contract, account: string, name: string, authorization: Authorization[], data: any, textEncoder: TextEncoder, textDecoder: TextDecoder) => SerializedAction;
|
266 |
|
267 | export declare const deserializeActionData: (contract: Contract, account: string, name: string, data: string | Uint8Array | number[], textEncoder: TextEncoder, textDecoder: TextDecoder) => any;
|
268 |
|
269 | export declare const deserializeAction: (contract: Contract, account: string, name: string, authorization: Authorization[], data: string | Uint8Array | number[], textEncoder: TextEncoder, textDecoder: TextDecoder) => Action;
|
270 | export declare const serializeAnyvar: (buffer: SerialBuffer, anyvar: Anyvar) => void;
|
271 | export declare const deserializeAnyvar: (buffer: SerialBuffer, state?: SerializerState) => any;
|
272 | export declare const deserializeAnyvarShort: (buffer: SerialBuffer) => any;
|
273 | export declare const serializeAnyObject: (buffer: SerialBuffer, obj: any) => void;
|
274 | export declare const deserializeAnyObject: (buffer: SerialBuffer, state?: SerializerState) => any;
|
275 | export declare const serializeAnyArray: (buffer: SerialBuffer, arr: Anyvar[]) => void;
|
276 | export declare const deserializeAnyArray: (buffer: SerialBuffer, state?: SerializerState) => any[];
|
277 | export declare const serializeQuery: (buffer: SerialBuffer, query: Query) => void;
|