@apibara/evm 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +17 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE.txt +202 -0
- package/README.md +27 -0
- package/buf.gen.yaml +14 -0
- package/build.config.ts +11 -0
- package/dist/index.cjs +2994 -0
- package/dist/index.d.cts +1900 -0
- package/dist/index.d.mts +1900 -0
- package/dist/index.d.ts +1900 -0
- package/dist/index.mjs +2953 -0
- package/package.json +49 -0
- package/proto/common.proto +37 -0
- package/proto/data.proto +192 -0
- package/proto/filter.proto +61 -0
- package/src/block.ts +167 -0
- package/src/common.test.ts +79 -0
- package/src/common.ts +117 -0
- package/src/filter.test.ts +191 -0
- package/src/filter.ts +117 -0
- package/src/index.ts +15 -0
- package/src/proto/common.ts +561 -0
- package/src/proto/data.ts +2111 -0
- package/src/proto/filter.ts +658 -0
- package/src/proto/google/protobuf/timestamp.ts +220 -0
- package/src/proto/index.ts +3 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v1.176.0
|
|
4
|
+
// protoc unknown
|
|
5
|
+
// source: common.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import Long from "long";
|
|
9
|
+
import _m0 from "protobufjs/minimal";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "evm.v2";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* An address of 160 bits.
|
|
15
|
+
*
|
|
16
|
+
* As a separate type so that the API is clearer.
|
|
17
|
+
*/
|
|
18
|
+
export interface Address {
|
|
19
|
+
readonly x0?: bigint | undefined;
|
|
20
|
+
readonly x1?: bigint | undefined;
|
|
21
|
+
readonly x2?: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A bloom filter of 256 bytes. */
|
|
25
|
+
export interface Bloom {
|
|
26
|
+
readonly value?: Uint8Array | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Unsigned integer of 128 bits. */
|
|
30
|
+
export interface U128 {
|
|
31
|
+
readonly x0?: bigint | undefined;
|
|
32
|
+
readonly x1?: bigint | undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Unsigned integer of 256 bits. */
|
|
36
|
+
export interface U256 {
|
|
37
|
+
readonly x0?: bigint | undefined;
|
|
38
|
+
readonly x1?: bigint | undefined;
|
|
39
|
+
readonly x2?: bigint | undefined;
|
|
40
|
+
readonly x3?: bigint | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Byte array of 256 bits. */
|
|
44
|
+
export interface B256 {
|
|
45
|
+
readonly x0?: bigint | undefined;
|
|
46
|
+
readonly x1?: bigint | undefined;
|
|
47
|
+
readonly x2?: bigint | undefined;
|
|
48
|
+
readonly x3?: bigint | undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function createBaseAddress(): Address {
|
|
52
|
+
return { x0: BigInt("0"), x1: BigInt("0"), x2: 0 };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const Address = {
|
|
56
|
+
encode(message: Address, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
57
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
58
|
+
if (BigInt.asUintN(64, message.x0) !== message.x0) {
|
|
59
|
+
throw new globalThis.Error("value provided for field message.x0 of type fixed64 too large");
|
|
60
|
+
}
|
|
61
|
+
writer.uint32(9).fixed64(message.x0.toString());
|
|
62
|
+
}
|
|
63
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
64
|
+
if (BigInt.asUintN(64, message.x1) !== message.x1) {
|
|
65
|
+
throw new globalThis.Error("value provided for field message.x1 of type fixed64 too large");
|
|
66
|
+
}
|
|
67
|
+
writer.uint32(17).fixed64(message.x1.toString());
|
|
68
|
+
}
|
|
69
|
+
if (message.x2 !== undefined && message.x2 !== 0) {
|
|
70
|
+
writer.uint32(29).fixed32(message.x2);
|
|
71
|
+
}
|
|
72
|
+
return writer;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Address {
|
|
76
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
77
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
78
|
+
const message = createBaseAddress() as any;
|
|
79
|
+
while (reader.pos < end) {
|
|
80
|
+
const tag = reader.uint32();
|
|
81
|
+
switch (tag >>> 3) {
|
|
82
|
+
case 1:
|
|
83
|
+
if (tag !== 9) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
message.x0 = longToBigint(reader.fixed64() as Long);
|
|
88
|
+
continue;
|
|
89
|
+
case 2:
|
|
90
|
+
if (tag !== 17) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
message.x1 = longToBigint(reader.fixed64() as Long);
|
|
95
|
+
continue;
|
|
96
|
+
case 3:
|
|
97
|
+
if (tag !== 29) {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
message.x2 = reader.fixed32();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
reader.skipType(tag & 7);
|
|
108
|
+
}
|
|
109
|
+
return message;
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
fromJSON(object: any): Address {
|
|
113
|
+
return {
|
|
114
|
+
x0: isSet(object.x0) ? BigInt(object.x0) : BigInt("0"),
|
|
115
|
+
x1: isSet(object.x1) ? BigInt(object.x1) : BigInt("0"),
|
|
116
|
+
x2: isSet(object.x2) ? globalThis.Number(object.x2) : 0,
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
toJSON(message: Address): unknown {
|
|
121
|
+
const obj: any = {};
|
|
122
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
123
|
+
obj.x0 = message.x0.toString();
|
|
124
|
+
}
|
|
125
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
126
|
+
obj.x1 = message.x1.toString();
|
|
127
|
+
}
|
|
128
|
+
if (message.x2 !== undefined && message.x2 !== 0) {
|
|
129
|
+
obj.x2 = Math.round(message.x2);
|
|
130
|
+
}
|
|
131
|
+
return obj;
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
create(base?: DeepPartial<Address>): Address {
|
|
135
|
+
return Address.fromPartial(base ?? {});
|
|
136
|
+
},
|
|
137
|
+
fromPartial(object: DeepPartial<Address>): Address {
|
|
138
|
+
const message = createBaseAddress() as any;
|
|
139
|
+
message.x0 = object.x0 ?? BigInt("0");
|
|
140
|
+
message.x1 = object.x1 ?? BigInt("0");
|
|
141
|
+
message.x2 = object.x2 ?? 0;
|
|
142
|
+
return message;
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
function createBaseBloom(): Bloom {
|
|
147
|
+
return { value: new Uint8Array(0) };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const Bloom = {
|
|
151
|
+
encode(message: Bloom, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
152
|
+
if (message.value !== undefined && message.value.length !== 0) {
|
|
153
|
+
writer.uint32(10).bytes(message.value);
|
|
154
|
+
}
|
|
155
|
+
return writer;
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Bloom {
|
|
159
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
160
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
161
|
+
const message = createBaseBloom() as any;
|
|
162
|
+
while (reader.pos < end) {
|
|
163
|
+
const tag = reader.uint32();
|
|
164
|
+
switch (tag >>> 3) {
|
|
165
|
+
case 1:
|
|
166
|
+
if (tag !== 10) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
message.value = reader.bytes();
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
reader.skipType(tag & 7);
|
|
177
|
+
}
|
|
178
|
+
return message;
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
fromJSON(object: any): Bloom {
|
|
182
|
+
return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0) };
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
toJSON(message: Bloom): unknown {
|
|
186
|
+
const obj: any = {};
|
|
187
|
+
if (message.value !== undefined && message.value.length !== 0) {
|
|
188
|
+
obj.value = base64FromBytes(message.value);
|
|
189
|
+
}
|
|
190
|
+
return obj;
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
create(base?: DeepPartial<Bloom>): Bloom {
|
|
194
|
+
return Bloom.fromPartial(base ?? {});
|
|
195
|
+
},
|
|
196
|
+
fromPartial(object: DeepPartial<Bloom>): Bloom {
|
|
197
|
+
const message = createBaseBloom() as any;
|
|
198
|
+
message.value = object.value ?? new Uint8Array(0);
|
|
199
|
+
return message;
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
function createBaseU128(): U128 {
|
|
204
|
+
return { x0: BigInt("0"), x1: BigInt("0") };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export const U128 = {
|
|
208
|
+
encode(message: U128, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
209
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
210
|
+
if (BigInt.asUintN(64, message.x0) !== message.x0) {
|
|
211
|
+
throw new globalThis.Error("value provided for field message.x0 of type fixed64 too large");
|
|
212
|
+
}
|
|
213
|
+
writer.uint32(9).fixed64(message.x0.toString());
|
|
214
|
+
}
|
|
215
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
216
|
+
if (BigInt.asUintN(64, message.x1) !== message.x1) {
|
|
217
|
+
throw new globalThis.Error("value provided for field message.x1 of type fixed64 too large");
|
|
218
|
+
}
|
|
219
|
+
writer.uint32(17).fixed64(message.x1.toString());
|
|
220
|
+
}
|
|
221
|
+
return writer;
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): U128 {
|
|
225
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
226
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
227
|
+
const message = createBaseU128() as any;
|
|
228
|
+
while (reader.pos < end) {
|
|
229
|
+
const tag = reader.uint32();
|
|
230
|
+
switch (tag >>> 3) {
|
|
231
|
+
case 1:
|
|
232
|
+
if (tag !== 9) {
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
message.x0 = longToBigint(reader.fixed64() as Long);
|
|
237
|
+
continue;
|
|
238
|
+
case 2:
|
|
239
|
+
if (tag !== 17) {
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
message.x1 = longToBigint(reader.fixed64() as Long);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
reader.skipType(tag & 7);
|
|
250
|
+
}
|
|
251
|
+
return message;
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
fromJSON(object: any): U128 {
|
|
255
|
+
return {
|
|
256
|
+
x0: isSet(object.x0) ? BigInt(object.x0) : BigInt("0"),
|
|
257
|
+
x1: isSet(object.x1) ? BigInt(object.x1) : BigInt("0"),
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
toJSON(message: U128): unknown {
|
|
262
|
+
const obj: any = {};
|
|
263
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
264
|
+
obj.x0 = message.x0.toString();
|
|
265
|
+
}
|
|
266
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
267
|
+
obj.x1 = message.x1.toString();
|
|
268
|
+
}
|
|
269
|
+
return obj;
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
create(base?: DeepPartial<U128>): U128 {
|
|
273
|
+
return U128.fromPartial(base ?? {});
|
|
274
|
+
},
|
|
275
|
+
fromPartial(object: DeepPartial<U128>): U128 {
|
|
276
|
+
const message = createBaseU128() as any;
|
|
277
|
+
message.x0 = object.x0 ?? BigInt("0");
|
|
278
|
+
message.x1 = object.x1 ?? BigInt("0");
|
|
279
|
+
return message;
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
function createBaseU256(): U256 {
|
|
284
|
+
return { x0: BigInt("0"), x1: BigInt("0"), x2: BigInt("0"), x3: BigInt("0") };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export const U256 = {
|
|
288
|
+
encode(message: U256, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
289
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
290
|
+
if (BigInt.asUintN(64, message.x0) !== message.x0) {
|
|
291
|
+
throw new globalThis.Error("value provided for field message.x0 of type fixed64 too large");
|
|
292
|
+
}
|
|
293
|
+
writer.uint32(9).fixed64(message.x0.toString());
|
|
294
|
+
}
|
|
295
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
296
|
+
if (BigInt.asUintN(64, message.x1) !== message.x1) {
|
|
297
|
+
throw new globalThis.Error("value provided for field message.x1 of type fixed64 too large");
|
|
298
|
+
}
|
|
299
|
+
writer.uint32(17).fixed64(message.x1.toString());
|
|
300
|
+
}
|
|
301
|
+
if (message.x2 !== undefined && message.x2 !== BigInt("0")) {
|
|
302
|
+
if (BigInt.asUintN(64, message.x2) !== message.x2) {
|
|
303
|
+
throw new globalThis.Error("value provided for field message.x2 of type fixed64 too large");
|
|
304
|
+
}
|
|
305
|
+
writer.uint32(25).fixed64(message.x2.toString());
|
|
306
|
+
}
|
|
307
|
+
if (message.x3 !== undefined && message.x3 !== BigInt("0")) {
|
|
308
|
+
if (BigInt.asUintN(64, message.x3) !== message.x3) {
|
|
309
|
+
throw new globalThis.Error("value provided for field message.x3 of type fixed64 too large");
|
|
310
|
+
}
|
|
311
|
+
writer.uint32(33).fixed64(message.x3.toString());
|
|
312
|
+
}
|
|
313
|
+
return writer;
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): U256 {
|
|
317
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
318
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
319
|
+
const message = createBaseU256() as any;
|
|
320
|
+
while (reader.pos < end) {
|
|
321
|
+
const tag = reader.uint32();
|
|
322
|
+
switch (tag >>> 3) {
|
|
323
|
+
case 1:
|
|
324
|
+
if (tag !== 9) {
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
message.x0 = longToBigint(reader.fixed64() as Long);
|
|
329
|
+
continue;
|
|
330
|
+
case 2:
|
|
331
|
+
if (tag !== 17) {
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
message.x1 = longToBigint(reader.fixed64() as Long);
|
|
336
|
+
continue;
|
|
337
|
+
case 3:
|
|
338
|
+
if (tag !== 25) {
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
message.x2 = longToBigint(reader.fixed64() as Long);
|
|
343
|
+
continue;
|
|
344
|
+
case 4:
|
|
345
|
+
if (tag !== 33) {
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
message.x3 = longToBigint(reader.fixed64() as Long);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
reader.skipType(tag & 7);
|
|
356
|
+
}
|
|
357
|
+
return message;
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
fromJSON(object: any): U256 {
|
|
361
|
+
return {
|
|
362
|
+
x0: isSet(object.x0) ? BigInt(object.x0) : BigInt("0"),
|
|
363
|
+
x1: isSet(object.x1) ? BigInt(object.x1) : BigInt("0"),
|
|
364
|
+
x2: isSet(object.x2) ? BigInt(object.x2) : BigInt("0"),
|
|
365
|
+
x3: isSet(object.x3) ? BigInt(object.x3) : BigInt("0"),
|
|
366
|
+
};
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
toJSON(message: U256): unknown {
|
|
370
|
+
const obj: any = {};
|
|
371
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
372
|
+
obj.x0 = message.x0.toString();
|
|
373
|
+
}
|
|
374
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
375
|
+
obj.x1 = message.x1.toString();
|
|
376
|
+
}
|
|
377
|
+
if (message.x2 !== undefined && message.x2 !== BigInt("0")) {
|
|
378
|
+
obj.x2 = message.x2.toString();
|
|
379
|
+
}
|
|
380
|
+
if (message.x3 !== undefined && message.x3 !== BigInt("0")) {
|
|
381
|
+
obj.x3 = message.x3.toString();
|
|
382
|
+
}
|
|
383
|
+
return obj;
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
create(base?: DeepPartial<U256>): U256 {
|
|
387
|
+
return U256.fromPartial(base ?? {});
|
|
388
|
+
},
|
|
389
|
+
fromPartial(object: DeepPartial<U256>): U256 {
|
|
390
|
+
const message = createBaseU256() as any;
|
|
391
|
+
message.x0 = object.x0 ?? BigInt("0");
|
|
392
|
+
message.x1 = object.x1 ?? BigInt("0");
|
|
393
|
+
message.x2 = object.x2 ?? BigInt("0");
|
|
394
|
+
message.x3 = object.x3 ?? BigInt("0");
|
|
395
|
+
return message;
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
function createBaseB256(): B256 {
|
|
400
|
+
return { x0: BigInt("0"), x1: BigInt("0"), x2: BigInt("0"), x3: BigInt("0") };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export const B256 = {
|
|
404
|
+
encode(message: B256, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
405
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
406
|
+
if (BigInt.asUintN(64, message.x0) !== message.x0) {
|
|
407
|
+
throw new globalThis.Error("value provided for field message.x0 of type fixed64 too large");
|
|
408
|
+
}
|
|
409
|
+
writer.uint32(9).fixed64(message.x0.toString());
|
|
410
|
+
}
|
|
411
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
412
|
+
if (BigInt.asUintN(64, message.x1) !== message.x1) {
|
|
413
|
+
throw new globalThis.Error("value provided for field message.x1 of type fixed64 too large");
|
|
414
|
+
}
|
|
415
|
+
writer.uint32(17).fixed64(message.x1.toString());
|
|
416
|
+
}
|
|
417
|
+
if (message.x2 !== undefined && message.x2 !== BigInt("0")) {
|
|
418
|
+
if (BigInt.asUintN(64, message.x2) !== message.x2) {
|
|
419
|
+
throw new globalThis.Error("value provided for field message.x2 of type fixed64 too large");
|
|
420
|
+
}
|
|
421
|
+
writer.uint32(25).fixed64(message.x2.toString());
|
|
422
|
+
}
|
|
423
|
+
if (message.x3 !== undefined && message.x3 !== BigInt("0")) {
|
|
424
|
+
if (BigInt.asUintN(64, message.x3) !== message.x3) {
|
|
425
|
+
throw new globalThis.Error("value provided for field message.x3 of type fixed64 too large");
|
|
426
|
+
}
|
|
427
|
+
writer.uint32(33).fixed64(message.x3.toString());
|
|
428
|
+
}
|
|
429
|
+
return writer;
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): B256 {
|
|
433
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
434
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
435
|
+
const message = createBaseB256() as any;
|
|
436
|
+
while (reader.pos < end) {
|
|
437
|
+
const tag = reader.uint32();
|
|
438
|
+
switch (tag >>> 3) {
|
|
439
|
+
case 1:
|
|
440
|
+
if (tag !== 9) {
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
message.x0 = longToBigint(reader.fixed64() as Long);
|
|
445
|
+
continue;
|
|
446
|
+
case 2:
|
|
447
|
+
if (tag !== 17) {
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
message.x1 = longToBigint(reader.fixed64() as Long);
|
|
452
|
+
continue;
|
|
453
|
+
case 3:
|
|
454
|
+
if (tag !== 25) {
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
message.x2 = longToBigint(reader.fixed64() as Long);
|
|
459
|
+
continue;
|
|
460
|
+
case 4:
|
|
461
|
+
if (tag !== 33) {
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
message.x3 = longToBigint(reader.fixed64() as Long);
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
reader.skipType(tag & 7);
|
|
472
|
+
}
|
|
473
|
+
return message;
|
|
474
|
+
},
|
|
475
|
+
|
|
476
|
+
fromJSON(object: any): B256 {
|
|
477
|
+
return {
|
|
478
|
+
x0: isSet(object.x0) ? BigInt(object.x0) : BigInt("0"),
|
|
479
|
+
x1: isSet(object.x1) ? BigInt(object.x1) : BigInt("0"),
|
|
480
|
+
x2: isSet(object.x2) ? BigInt(object.x2) : BigInt("0"),
|
|
481
|
+
x3: isSet(object.x3) ? BigInt(object.x3) : BigInt("0"),
|
|
482
|
+
};
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
toJSON(message: B256): unknown {
|
|
486
|
+
const obj: any = {};
|
|
487
|
+
if (message.x0 !== undefined && message.x0 !== BigInt("0")) {
|
|
488
|
+
obj.x0 = message.x0.toString();
|
|
489
|
+
}
|
|
490
|
+
if (message.x1 !== undefined && message.x1 !== BigInt("0")) {
|
|
491
|
+
obj.x1 = message.x1.toString();
|
|
492
|
+
}
|
|
493
|
+
if (message.x2 !== undefined && message.x2 !== BigInt("0")) {
|
|
494
|
+
obj.x2 = message.x2.toString();
|
|
495
|
+
}
|
|
496
|
+
if (message.x3 !== undefined && message.x3 !== BigInt("0")) {
|
|
497
|
+
obj.x3 = message.x3.toString();
|
|
498
|
+
}
|
|
499
|
+
return obj;
|
|
500
|
+
},
|
|
501
|
+
|
|
502
|
+
create(base?: DeepPartial<B256>): B256 {
|
|
503
|
+
return B256.fromPartial(base ?? {});
|
|
504
|
+
},
|
|
505
|
+
fromPartial(object: DeepPartial<B256>): B256 {
|
|
506
|
+
const message = createBaseB256() as any;
|
|
507
|
+
message.x0 = object.x0 ?? BigInt("0");
|
|
508
|
+
message.x1 = object.x1 ?? BigInt("0");
|
|
509
|
+
message.x2 = object.x2 ?? BigInt("0");
|
|
510
|
+
message.x3 = object.x3 ?? BigInt("0");
|
|
511
|
+
return message;
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
function bytesFromBase64(b64: string): Uint8Array {
|
|
516
|
+
if ((globalThis as any).Buffer) {
|
|
517
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
518
|
+
} else {
|
|
519
|
+
const bin = globalThis.atob(b64);
|
|
520
|
+
const arr = new Uint8Array(bin.length);
|
|
521
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
522
|
+
arr[i] = bin.charCodeAt(i);
|
|
523
|
+
}
|
|
524
|
+
return arr;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function base64FromBytes(arr: Uint8Array): string {
|
|
529
|
+
if ((globalThis as any).Buffer) {
|
|
530
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
531
|
+
} else {
|
|
532
|
+
const bin: string[] = [];
|
|
533
|
+
arr.forEach((byte) => {
|
|
534
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
535
|
+
});
|
|
536
|
+
return globalThis.btoa(bin.join(""));
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
|
541
|
+
|
|
542
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
543
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
544
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
545
|
+
: T extends { readonly $case: string }
|
|
546
|
+
? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { readonly $case: T["$case"] }
|
|
547
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
548
|
+
: Partial<T>;
|
|
549
|
+
|
|
550
|
+
function longToBigint(long: Long) {
|
|
551
|
+
return BigInt(long.toString());
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (_m0.util.Long !== Long) {
|
|
555
|
+
_m0.util.Long = Long as any;
|
|
556
|
+
_m0.configure();
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function isSet(value: any): boolean {
|
|
560
|
+
return value !== null && value !== undefined;
|
|
561
|
+
}
|