@apibara/protocol 2.0.0-beta.0 → 2.0.0-beta.10

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/dist/index.mjs CHANGED
@@ -1,1061 +1,47 @@
1
- import Long from 'long';
2
- import _m0 from 'protobufjs/minimal';
1
+ import { s as stream, t as testing, C as Cursor, D as DnaStreamDefinition, S as StreamDataResponse } from './shared/protocol.d9596779.mjs';
2
+ export { B as Bytes, a as BytesFromUint8Array, e as CursorFromBytes, n as Data, h as DataFinality, i as Duration, F as Finalize, H as Heartbeat, I as Invalidate, l as StdErr, k as StdOut, o as StreamConfig, j as StreamDataRequest, m as SystemMessage, _ as _Cursor, c as createCursor, g as cursorFromBytes, d as cursorFromProto, f as cursorToBytes, b as cursorToProto } from './shared/protocol.d9596779.mjs';
3
3
  import { Schema } from '@effect/schema';
4
- import { Option } from 'effect';
5
- import { toHex, hexToBytes } from 'viem';
6
4
  import { createChannel, createClient as createClient$1 } from 'nice-grpc';
5
+ import 'protobufjs/minimal.js';
7
6
  import assert from 'node:assert';
8
-
9
- const protobufPackage$2 = "dna.v2.common";
10
- function createBaseCursor() {
11
- return { orderKey: BigInt("0"), uniqueKey: new Uint8Array(0) };
12
- }
13
- const Cursor$1 = {
14
- encode(message, writer = _m0.Writer.create()) {
15
- if (message.orderKey !== BigInt("0")) {
16
- if (BigInt.asUintN(64, message.orderKey) !== message.orderKey) {
17
- throw new globalThis.Error("value provided for field message.orderKey of type uint64 too large");
18
- }
19
- writer.uint32(8).uint64(message.orderKey.toString());
20
- }
21
- if (message.uniqueKey.length !== 0) {
22
- writer.uint32(18).bytes(message.uniqueKey);
23
- }
24
- return writer;
25
- },
26
- decode(input, length) {
27
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
28
- let end = length === void 0 ? reader.len : reader.pos + length;
29
- const message = createBaseCursor();
30
- while (reader.pos < end) {
31
- const tag = reader.uint32();
32
- switch (tag >>> 3) {
33
- case 1:
34
- if (tag !== 8) {
35
- break;
36
- }
37
- message.orderKey = longToBigint(reader.uint64());
38
- continue;
39
- case 2:
40
- if (tag !== 18) {
41
- break;
42
- }
43
- message.uniqueKey = reader.bytes();
44
- continue;
45
- }
46
- if ((tag & 7) === 4 || tag === 0) {
47
- break;
48
- }
49
- reader.skipType(tag & 7);
50
- }
51
- return message;
52
- },
53
- fromJSON(object) {
54
- return {
55
- orderKey: isSet$2(object.orderKey) ? BigInt(object.orderKey) : BigInt("0"),
56
- uniqueKey: isSet$2(object.uniqueKey) ? bytesFromBase64$1(object.uniqueKey) : new Uint8Array(0)
57
- };
58
- },
59
- toJSON(message) {
60
- const obj = {};
61
- if (message.orderKey !== BigInt("0")) {
62
- obj.orderKey = message.orderKey.toString();
63
- }
64
- if (message.uniqueKey.length !== 0) {
65
- obj.uniqueKey = base64FromBytes$1(message.uniqueKey);
66
- }
67
- return obj;
68
- },
69
- create(base) {
70
- return Cursor$1.fromPartial(base ?? {});
71
- },
72
- fromPartial(object) {
73
- const message = createBaseCursor();
74
- message.orderKey = object.orderKey ?? BigInt("0");
75
- message.uniqueKey = object.uniqueKey ?? new Uint8Array(0);
76
- return message;
77
- }
78
- };
79
- function createBaseStatusRequest() {
80
- return {};
81
- }
82
- const StatusRequest$1 = {
83
- encode(_, writer = _m0.Writer.create()) {
84
- return writer;
85
- },
86
- decode(input, length) {
87
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
88
- let end = length === void 0 ? reader.len : reader.pos + length;
89
- const message = createBaseStatusRequest();
90
- while (reader.pos < end) {
91
- const tag = reader.uint32();
92
- if ((tag & 7) === 4 || tag === 0) {
93
- break;
94
- }
95
- reader.skipType(tag & 7);
96
- }
97
- return message;
98
- },
99
- fromJSON(_) {
100
- return {};
101
- },
102
- toJSON(_) {
103
- const obj = {};
104
- return obj;
105
- },
106
- create(base) {
107
- return StatusRequest$1.fromPartial(base ?? {});
108
- },
109
- fromPartial(_) {
110
- const message = createBaseStatusRequest();
111
- return message;
112
- }
113
- };
114
- function createBaseStatusResponse() {
115
- return { currentHead: void 0, lastIngested: void 0 };
116
- }
117
- const StatusResponse$1 = {
118
- encode(message, writer = _m0.Writer.create()) {
119
- if (message.currentHead !== void 0) {
120
- Cursor$1.encode(message.currentHead, writer.uint32(10).fork()).ldelim();
121
- }
122
- if (message.lastIngested !== void 0) {
123
- Cursor$1.encode(message.lastIngested, writer.uint32(18).fork()).ldelim();
124
- }
125
- return writer;
126
- },
127
- decode(input, length) {
128
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
129
- let end = length === void 0 ? reader.len : reader.pos + length;
130
- const message = createBaseStatusResponse();
131
- while (reader.pos < end) {
132
- const tag = reader.uint32();
133
- switch (tag >>> 3) {
134
- case 1:
135
- if (tag !== 10) {
136
- break;
137
- }
138
- message.currentHead = Cursor$1.decode(reader, reader.uint32());
139
- continue;
140
- case 2:
141
- if (tag !== 18) {
142
- break;
143
- }
144
- message.lastIngested = Cursor$1.decode(reader, reader.uint32());
145
- continue;
146
- }
147
- if ((tag & 7) === 4 || tag === 0) {
148
- break;
149
- }
150
- reader.skipType(tag & 7);
151
- }
152
- return message;
153
- },
154
- fromJSON(object) {
155
- return {
156
- currentHead: isSet$2(object.currentHead) ? Cursor$1.fromJSON(object.currentHead) : void 0,
157
- lastIngested: isSet$2(object.lastIngested) ? Cursor$1.fromJSON(object.lastIngested) : void 0
158
- };
159
- },
160
- toJSON(message) {
161
- const obj = {};
162
- if (message.currentHead !== void 0) {
163
- obj.currentHead = Cursor$1.toJSON(message.currentHead);
164
- }
165
- if (message.lastIngested !== void 0) {
166
- obj.lastIngested = Cursor$1.toJSON(message.lastIngested);
167
- }
168
- return obj;
169
- },
170
- create(base) {
171
- return StatusResponse$1.fromPartial(base ?? {});
172
- },
173
- fromPartial(object) {
174
- const message = createBaseStatusResponse();
175
- message.currentHead = object.currentHead !== void 0 && object.currentHead !== null ? Cursor$1.fromPartial(object.currentHead) : void 0;
176
- message.lastIngested = object.lastIngested !== void 0 && object.lastIngested !== null ? Cursor$1.fromPartial(object.lastIngested) : void 0;
177
- return message;
178
- }
179
- };
180
- function bytesFromBase64$1(b64) {
181
- if (globalThis.Buffer) {
182
- return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
183
- } else {
184
- const bin = globalThis.atob(b64);
185
- const arr = new Uint8Array(bin.length);
186
- for (let i = 0; i < bin.length; ++i) {
187
- arr[i] = bin.charCodeAt(i);
188
- }
189
- return arr;
190
- }
191
- }
192
- function base64FromBytes$1(arr) {
193
- if (globalThis.Buffer) {
194
- return globalThis.Buffer.from(arr).toString("base64");
195
- } else {
196
- const bin = [];
197
- arr.forEach((byte) => {
198
- bin.push(globalThis.String.fromCharCode(byte));
199
- });
200
- return globalThis.btoa(bin.join(""));
201
- }
202
- }
203
- function longToBigint(long) {
204
- return BigInt(long.toString());
205
- }
206
- if (_m0.util.Long !== Long) {
207
- _m0.util.Long = Long;
208
- _m0.configure();
209
- }
210
- function isSet$2(value) {
211
- return value !== null && value !== void 0;
212
- }
213
-
214
- const common = {
215
- __proto__: null,
216
- Cursor: Cursor$1,
217
- StatusRequest: StatusRequest$1,
218
- StatusResponse: StatusResponse$1,
219
- protobufPackage: protobufPackage$2
220
- };
221
-
222
- const protobufPackage$1 = "dna.v2.stream";
223
- var DataFinality$1 = /* @__PURE__ */ ((DataFinality2) => {
224
- DataFinality2[DataFinality2["UNKNOWN"] = 0] = "UNKNOWN";
225
- DataFinality2[DataFinality2["PENDING"] = 1] = "PENDING";
226
- DataFinality2[DataFinality2["ACCEPTED"] = 2] = "ACCEPTED";
227
- DataFinality2[DataFinality2["FINALIZED"] = 3] = "FINALIZED";
228
- DataFinality2[DataFinality2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
229
- return DataFinality2;
230
- })(DataFinality$1 || {});
231
- function dataFinalityFromJSON(object) {
232
- switch (object) {
233
- case 0:
234
- case "DATA_FINALITY_UNKNOWN":
235
- return 0 /* UNKNOWN */;
236
- case 1:
237
- case "DATA_FINALITY_PENDING":
238
- return 1 /* PENDING */;
239
- case 2:
240
- case "DATA_FINALITY_ACCEPTED":
241
- return 2 /* ACCEPTED */;
242
- case 3:
243
- case "DATA_FINALITY_FINALIZED":
244
- return 3 /* FINALIZED */;
245
- case -1:
246
- case "UNRECOGNIZED":
247
- default:
248
- return -1 /* UNRECOGNIZED */;
249
- }
250
- }
251
- function dataFinalityToJSON(object) {
252
- switch (object) {
253
- case 0 /* UNKNOWN */:
254
- return "DATA_FINALITY_UNKNOWN";
255
- case 1 /* PENDING */:
256
- return "DATA_FINALITY_PENDING";
257
- case 2 /* ACCEPTED */:
258
- return "DATA_FINALITY_ACCEPTED";
259
- case 3 /* FINALIZED */:
260
- return "DATA_FINALITY_FINALIZED";
261
- case -1 /* UNRECOGNIZED */:
262
- default:
263
- return "UNRECOGNIZED";
264
- }
265
- }
266
- function createBaseStreamDataRequest() {
267
- return { startingCursor: void 0, finality: void 0, filter: [] };
268
- }
269
- const StreamDataRequest$1 = {
270
- encode(message, writer = _m0.Writer.create()) {
271
- if (message.startingCursor !== void 0) {
272
- Cursor$1.encode(message.startingCursor, writer.uint32(10).fork()).ldelim();
273
- }
274
- if (message.finality !== void 0) {
275
- writer.uint32(16).int32(message.finality);
276
- }
277
- for (const v of message.filter) {
278
- writer.uint32(26).bytes(v);
279
- }
280
- return writer;
281
- },
282
- decode(input, length) {
283
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
284
- let end = length === void 0 ? reader.len : reader.pos + length;
285
- const message = createBaseStreamDataRequest();
286
- while (reader.pos < end) {
287
- const tag = reader.uint32();
288
- switch (tag >>> 3) {
289
- case 1:
290
- if (tag !== 10) {
291
- break;
292
- }
293
- message.startingCursor = Cursor$1.decode(reader, reader.uint32());
294
- continue;
295
- case 2:
296
- if (tag !== 16) {
297
- break;
298
- }
299
- message.finality = reader.int32();
300
- continue;
301
- case 3:
302
- if (tag !== 26) {
303
- break;
304
- }
305
- message.filter.push(reader.bytes());
306
- continue;
307
- }
308
- if ((tag & 7) === 4 || tag === 0) {
309
- break;
310
- }
311
- reader.skipType(tag & 7);
312
- }
313
- return message;
314
- },
315
- fromJSON(object) {
316
- return {
317
- startingCursor: isSet$1(object.startingCursor) ? Cursor$1.fromJSON(object.startingCursor) : void 0,
318
- finality: isSet$1(object.finality) ? dataFinalityFromJSON(object.finality) : void 0,
319
- filter: globalThis.Array.isArray(object?.filter) ? object.filter.map((e) => bytesFromBase64(e)) : []
320
- };
321
- },
322
- toJSON(message) {
323
- const obj = {};
324
- if (message.startingCursor !== void 0) {
325
- obj.startingCursor = Cursor$1.toJSON(message.startingCursor);
326
- }
327
- if (message.finality !== void 0) {
328
- obj.finality = dataFinalityToJSON(message.finality);
329
- }
330
- if (message.filter?.length) {
331
- obj.filter = message.filter.map((e) => base64FromBytes(e));
332
- }
333
- return obj;
334
- },
335
- create(base) {
336
- return StreamDataRequest$1.fromPartial(base ?? {});
337
- },
338
- fromPartial(object) {
339
- const message = createBaseStreamDataRequest();
340
- message.startingCursor = object.startingCursor !== void 0 && object.startingCursor !== null ? Cursor$1.fromPartial(object.startingCursor) : void 0;
341
- message.finality = object.finality ?? void 0;
342
- message.filter = object.filter?.map((e) => e) || [];
343
- return message;
344
- }
345
- };
346
- function createBaseStreamDataResponse() {
347
- return { message: void 0 };
348
- }
349
- const StreamDataResponse$1 = {
350
- encode(message, writer = _m0.Writer.create()) {
351
- switch (message.message?.$case) {
352
- case "data":
353
- Data$1.encode(message.message.data, writer.uint32(10).fork()).ldelim();
354
- break;
355
- case "invalidate":
356
- Invalidate$1.encode(message.message.invalidate, writer.uint32(18).fork()).ldelim();
357
- break;
358
- case "heartbeat":
359
- Heartbeat$1.encode(message.message.heartbeat, writer.uint32(26).fork()).ldelim();
360
- break;
361
- case "systemMessage":
362
- SystemMessage$1.encode(message.message.systemMessage, writer.uint32(34).fork()).ldelim();
363
- break;
364
- }
365
- return writer;
366
- },
367
- decode(input, length) {
368
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
369
- let end = length === void 0 ? reader.len : reader.pos + length;
370
- const message = createBaseStreamDataResponse();
371
- while (reader.pos < end) {
372
- const tag = reader.uint32();
373
- switch (tag >>> 3) {
374
- case 1:
375
- if (tag !== 10) {
376
- break;
377
- }
378
- message.message = { $case: "data", data: Data$1.decode(reader, reader.uint32()) };
379
- continue;
380
- case 2:
381
- if (tag !== 18) {
382
- break;
383
- }
384
- message.message = { $case: "invalidate", invalidate: Invalidate$1.decode(reader, reader.uint32()) };
385
- continue;
386
- case 3:
387
- if (tag !== 26) {
388
- break;
389
- }
390
- message.message = { $case: "heartbeat", heartbeat: Heartbeat$1.decode(reader, reader.uint32()) };
391
- continue;
392
- case 4:
393
- if (tag !== 34) {
394
- break;
395
- }
396
- message.message = { $case: "systemMessage", systemMessage: SystemMessage$1.decode(reader, reader.uint32()) };
397
- continue;
398
- }
399
- if ((tag & 7) === 4 || tag === 0) {
400
- break;
401
- }
402
- reader.skipType(tag & 7);
403
- }
404
- return message;
405
- },
406
- fromJSON(object) {
407
- return {
408
- message: isSet$1(object.data) ? { $case: "data", data: Data$1.fromJSON(object.data) } : isSet$1(object.invalidate) ? { $case: "invalidate", invalidate: Invalidate$1.fromJSON(object.invalidate) } : isSet$1(object.heartbeat) ? { $case: "heartbeat", heartbeat: Heartbeat$1.fromJSON(object.heartbeat) } : isSet$1(object.systemMessage) ? { $case: "systemMessage", systemMessage: SystemMessage$1.fromJSON(object.systemMessage) } : void 0
409
- };
410
- },
411
- toJSON(message) {
412
- const obj = {};
413
- if (message.message?.$case === "data") {
414
- obj.data = Data$1.toJSON(message.message.data);
415
- }
416
- if (message.message?.$case === "invalidate") {
417
- obj.invalidate = Invalidate$1.toJSON(message.message.invalidate);
418
- }
419
- if (message.message?.$case === "heartbeat") {
420
- obj.heartbeat = Heartbeat$1.toJSON(message.message.heartbeat);
421
- }
422
- if (message.message?.$case === "systemMessage") {
423
- obj.systemMessage = SystemMessage$1.toJSON(message.message.systemMessage);
424
- }
425
- return obj;
426
- },
427
- create(base) {
428
- return StreamDataResponse$1.fromPartial(base ?? {});
429
- },
430
- fromPartial(object) {
431
- const message = createBaseStreamDataResponse();
432
- if (object.message?.$case === "data" && object.message?.data !== void 0 && object.message?.data !== null) {
433
- message.message = { $case: "data", data: Data$1.fromPartial(object.message.data) };
434
- }
435
- if (object.message?.$case === "invalidate" && object.message?.invalidate !== void 0 && object.message?.invalidate !== null) {
436
- message.message = { $case: "invalidate", invalidate: Invalidate$1.fromPartial(object.message.invalidate) };
437
- }
438
- if (object.message?.$case === "heartbeat" && object.message?.heartbeat !== void 0 && object.message?.heartbeat !== null) {
439
- message.message = { $case: "heartbeat", heartbeat: Heartbeat$1.fromPartial(object.message.heartbeat) };
440
- }
441
- if (object.message?.$case === "systemMessage" && object.message?.systemMessage !== void 0 && object.message?.systemMessage !== null) {
442
- message.message = {
443
- $case: "systemMessage",
444
- systemMessage: SystemMessage$1.fromPartial(object.message.systemMessage)
445
- };
446
- }
447
- return message;
448
- }
449
- };
450
- function createBaseInvalidate() {
451
- return { cursor: void 0 };
452
- }
453
- const Invalidate$1 = {
454
- encode(message, writer = _m0.Writer.create()) {
455
- if (message.cursor !== void 0) {
456
- Cursor$1.encode(message.cursor, writer.uint32(10).fork()).ldelim();
457
- }
458
- return writer;
459
- },
460
- decode(input, length) {
461
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
462
- let end = length === void 0 ? reader.len : reader.pos + length;
463
- const message = createBaseInvalidate();
464
- while (reader.pos < end) {
465
- const tag = reader.uint32();
466
- switch (tag >>> 3) {
467
- case 1:
468
- if (tag !== 10) {
469
- break;
470
- }
471
- message.cursor = Cursor$1.decode(reader, reader.uint32());
472
- continue;
473
- }
474
- if ((tag & 7) === 4 || tag === 0) {
475
- break;
476
- }
477
- reader.skipType(tag & 7);
478
- }
479
- return message;
480
- },
481
- fromJSON(object) {
482
- return { cursor: isSet$1(object.cursor) ? Cursor$1.fromJSON(object.cursor) : void 0 };
483
- },
484
- toJSON(message) {
485
- const obj = {};
486
- if (message.cursor !== void 0) {
487
- obj.cursor = Cursor$1.toJSON(message.cursor);
488
- }
489
- return obj;
490
- },
491
- create(base) {
492
- return Invalidate$1.fromPartial(base ?? {});
493
- },
494
- fromPartial(object) {
495
- const message = createBaseInvalidate();
496
- message.cursor = object.cursor !== void 0 && object.cursor !== null ? Cursor$1.fromPartial(object.cursor) : void 0;
497
- return message;
498
- }
499
- };
500
- function createBaseData() {
501
- return { cursor: void 0, endCursor: void 0, finality: 0, data: [] };
502
- }
503
- const Data$1 = {
504
- encode(message, writer = _m0.Writer.create()) {
505
- if (message.cursor !== void 0) {
506
- Cursor$1.encode(message.cursor, writer.uint32(10).fork()).ldelim();
507
- }
508
- if (message.endCursor !== void 0) {
509
- Cursor$1.encode(message.endCursor, writer.uint32(18).fork()).ldelim();
510
- }
511
- if (message.finality !== 0) {
512
- writer.uint32(24).int32(message.finality);
513
- }
514
- for (const v of message.data) {
515
- writer.uint32(34).bytes(v);
516
- }
517
- return writer;
518
- },
519
- decode(input, length) {
520
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
521
- let end = length === void 0 ? reader.len : reader.pos + length;
522
- const message = createBaseData();
523
- while (reader.pos < end) {
524
- const tag = reader.uint32();
525
- switch (tag >>> 3) {
526
- case 1:
527
- if (tag !== 10) {
528
- break;
529
- }
530
- message.cursor = Cursor$1.decode(reader, reader.uint32());
531
- continue;
532
- case 2:
533
- if (tag !== 18) {
534
- break;
535
- }
536
- message.endCursor = Cursor$1.decode(reader, reader.uint32());
537
- continue;
538
- case 3:
539
- if (tag !== 24) {
540
- break;
541
- }
542
- message.finality = reader.int32();
543
- continue;
544
- case 4:
545
- if (tag !== 34) {
546
- break;
547
- }
548
- message.data.push(reader.bytes());
549
- continue;
550
- }
551
- if ((tag & 7) === 4 || tag === 0) {
552
- break;
553
- }
554
- reader.skipType(tag & 7);
555
- }
556
- return message;
557
- },
558
- fromJSON(object) {
559
- return {
560
- cursor: isSet$1(object.cursor) ? Cursor$1.fromJSON(object.cursor) : void 0,
561
- endCursor: isSet$1(object.endCursor) ? Cursor$1.fromJSON(object.endCursor) : void 0,
562
- finality: isSet$1(object.finality) ? dataFinalityFromJSON(object.finality) : 0,
563
- data: globalThis.Array.isArray(object?.data) ? object.data.map((e) => bytesFromBase64(e)) : []
564
- };
565
- },
566
- toJSON(message) {
567
- const obj = {};
568
- if (message.cursor !== void 0) {
569
- obj.cursor = Cursor$1.toJSON(message.cursor);
570
- }
571
- if (message.endCursor !== void 0) {
572
- obj.endCursor = Cursor$1.toJSON(message.endCursor);
573
- }
574
- if (message.finality !== 0) {
575
- obj.finality = dataFinalityToJSON(message.finality);
576
- }
577
- if (message.data?.length) {
578
- obj.data = message.data.map((e) => base64FromBytes(e));
579
- }
580
- return obj;
581
- },
582
- create(base) {
583
- return Data$1.fromPartial(base ?? {});
584
- },
585
- fromPartial(object) {
586
- const message = createBaseData();
587
- message.cursor = object.cursor !== void 0 && object.cursor !== null ? Cursor$1.fromPartial(object.cursor) : void 0;
588
- message.endCursor = object.endCursor !== void 0 && object.endCursor !== null ? Cursor$1.fromPartial(object.endCursor) : void 0;
589
- message.finality = object.finality ?? 0;
590
- message.data = object.data?.map((e) => e) || [];
591
- return message;
592
- }
593
- };
594
- function createBaseHeartbeat() {
595
- return {};
596
- }
597
- const Heartbeat$1 = {
598
- encode(_, writer = _m0.Writer.create()) {
599
- return writer;
600
- },
601
- decode(input, length) {
602
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
603
- let end = length === void 0 ? reader.len : reader.pos + length;
604
- const message = createBaseHeartbeat();
605
- while (reader.pos < end) {
606
- const tag = reader.uint32();
607
- if ((tag & 7) === 4 || tag === 0) {
608
- break;
609
- }
610
- reader.skipType(tag & 7);
611
- }
612
- return message;
613
- },
614
- fromJSON(_) {
615
- return {};
616
- },
617
- toJSON(_) {
618
- const obj = {};
619
- return obj;
620
- },
621
- create(base) {
622
- return Heartbeat$1.fromPartial(base ?? {});
623
- },
624
- fromPartial(_) {
625
- const message = createBaseHeartbeat();
626
- return message;
627
- }
628
- };
629
- function createBaseSystemMessage() {
630
- return { output: void 0 };
631
- }
632
- const SystemMessage$1 = {
633
- encode(message, writer = _m0.Writer.create()) {
634
- switch (message.output?.$case) {
635
- case "stdout":
636
- writer.uint32(10).string(message.output.stdout);
637
- break;
638
- case "stderr":
639
- writer.uint32(18).string(message.output.stderr);
640
- break;
641
- }
642
- return writer;
643
- },
644
- decode(input, length) {
645
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
646
- let end = length === void 0 ? reader.len : reader.pos + length;
647
- const message = createBaseSystemMessage();
648
- while (reader.pos < end) {
649
- const tag = reader.uint32();
650
- switch (tag >>> 3) {
651
- case 1:
652
- if (tag !== 10) {
653
- break;
654
- }
655
- message.output = { $case: "stdout", stdout: reader.string() };
656
- continue;
657
- case 2:
658
- if (tag !== 18) {
659
- break;
660
- }
661
- message.output = { $case: "stderr", stderr: reader.string() };
662
- continue;
663
- }
664
- if ((tag & 7) === 4 || tag === 0) {
665
- break;
666
- }
667
- reader.skipType(tag & 7);
668
- }
669
- return message;
670
- },
671
- fromJSON(object) {
672
- return {
673
- output: isSet$1(object.stdout) ? { $case: "stdout", stdout: globalThis.String(object.stdout) } : isSet$1(object.stderr) ? { $case: "stderr", stderr: globalThis.String(object.stderr) } : void 0
674
- };
675
- },
676
- toJSON(message) {
677
- const obj = {};
678
- if (message.output?.$case === "stdout") {
679
- obj.stdout = message.output.stdout;
680
- }
681
- if (message.output?.$case === "stderr") {
682
- obj.stderr = message.output.stderr;
683
- }
684
- return obj;
685
- },
686
- create(base) {
687
- return SystemMessage$1.fromPartial(base ?? {});
688
- },
689
- fromPartial(object) {
690
- const message = createBaseSystemMessage();
691
- if (object.output?.$case === "stdout" && object.output?.stdout !== void 0 && object.output?.stdout !== null) {
692
- message.output = { $case: "stdout", stdout: object.output.stdout };
693
- }
694
- if (object.output?.$case === "stderr" && object.output?.stderr !== void 0 && object.output?.stderr !== null) {
695
- message.output = { $case: "stderr", stderr: object.output.stderr };
696
- }
697
- return message;
698
- }
699
- };
700
- const DnaStreamDefinition = {
701
- name: "DnaStream",
702
- fullName: "dna.v2.stream.DnaStream",
703
- methods: {
704
- /** Stream data from the server. */
705
- streamData: {
706
- name: "StreamData",
707
- requestType: StreamDataRequest$1,
708
- requestStream: false,
709
- responseType: StreamDataResponse$1,
710
- responseStream: true,
711
- options: {}
712
- },
713
- /** Get DNA server status. */
714
- status: {
715
- name: "Status",
716
- requestType: StatusRequest$1,
717
- requestStream: false,
718
- responseType: StatusResponse$1,
719
- responseStream: false,
720
- options: {}
721
- }
722
- }
723
- };
724
- function bytesFromBase64(b64) {
725
- if (globalThis.Buffer) {
726
- return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
727
- } else {
728
- const bin = globalThis.atob(b64);
729
- const arr = new Uint8Array(bin.length);
730
- for (let i = 0; i < bin.length; ++i) {
731
- arr[i] = bin.charCodeAt(i);
732
- }
733
- return arr;
734
- }
735
- }
736
- function base64FromBytes(arr) {
737
- if (globalThis.Buffer) {
738
- return globalThis.Buffer.from(arr).toString("base64");
739
- } else {
740
- const bin = [];
741
- arr.forEach((byte) => {
742
- bin.push(globalThis.String.fromCharCode(byte));
743
- });
744
- return globalThis.btoa(bin.join(""));
745
- }
746
- }
747
- function isSet$1(value) {
748
- return value !== null && value !== void 0;
749
- }
750
-
751
- const stream = {
752
- __proto__: null,
753
- Data: Data$1,
754
- DataFinality: DataFinality$1,
755
- DnaStreamDefinition: DnaStreamDefinition,
756
- Heartbeat: Heartbeat$1,
757
- Invalidate: Invalidate$1,
758
- StreamDataRequest: StreamDataRequest$1,
759
- StreamDataResponse: StreamDataResponse$1,
760
- SystemMessage: SystemMessage$1,
761
- dataFinalityFromJSON: dataFinalityFromJSON,
762
- dataFinalityToJSON: dataFinalityToJSON,
763
- protobufPackage: protobufPackage$1
764
- };
765
-
766
- const protobufPackage = "dna.v2.testing";
767
- function createBaseMockFilter() {
768
- return { filter: void 0 };
769
- }
770
- const MockFilter = {
771
- encode(message, writer = _m0.Writer.create()) {
772
- if (message.filter !== void 0) {
773
- writer.uint32(10).string(message.filter);
774
- }
775
- return writer;
776
- },
777
- decode(input, length) {
778
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
779
- let end = length === void 0 ? reader.len : reader.pos + length;
780
- const message = createBaseMockFilter();
781
- while (reader.pos < end) {
782
- const tag = reader.uint32();
783
- switch (tag >>> 3) {
784
- case 1:
785
- if (tag !== 10) {
786
- break;
787
- }
788
- message.filter = reader.string();
789
- continue;
790
- }
791
- if ((tag & 7) === 4 || tag === 0) {
792
- break;
793
- }
794
- reader.skipType(tag & 7);
795
- }
796
- return message;
797
- },
798
- fromJSON(object) {
799
- return { filter: isSet(object.filter) ? globalThis.String(object.filter) : void 0 };
800
- },
801
- toJSON(message) {
802
- const obj = {};
803
- if (message.filter !== void 0) {
804
- obj.filter = message.filter;
805
- }
806
- return obj;
807
- },
808
- create(base) {
809
- return MockFilter.fromPartial(base ?? {});
810
- },
811
- fromPartial(object) {
812
- const message = createBaseMockFilter();
813
- message.filter = object.filter ?? void 0;
814
- return message;
815
- }
816
- };
817
- function createBaseMockBlock() {
818
- return { data: void 0 };
819
- }
820
- const MockBlock = {
821
- encode(message, writer = _m0.Writer.create()) {
822
- if (message.data !== void 0) {
823
- writer.uint32(10).string(message.data);
824
- }
825
- return writer;
826
- },
827
- decode(input, length) {
828
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
829
- let end = length === void 0 ? reader.len : reader.pos + length;
830
- const message = createBaseMockBlock();
831
- while (reader.pos < end) {
832
- const tag = reader.uint32();
833
- switch (tag >>> 3) {
834
- case 1:
835
- if (tag !== 10) {
836
- break;
837
- }
838
- message.data = reader.string();
839
- continue;
840
- }
841
- if ((tag & 7) === 4 || tag === 0) {
842
- break;
843
- }
844
- reader.skipType(tag & 7);
845
- }
846
- return message;
847
- },
848
- fromJSON(object) {
849
- return { data: isSet(object.data) ? globalThis.String(object.data) : void 0 };
850
- },
851
- toJSON(message) {
852
- const obj = {};
853
- if (message.data !== void 0) {
854
- obj.data = message.data;
855
- }
856
- return obj;
857
- },
858
- create(base) {
859
- return MockBlock.fromPartial(base ?? {});
860
- },
861
- fromPartial(object) {
862
- const message = createBaseMockBlock();
863
- message.data = object.data ?? void 0;
864
- return message;
865
- }
866
- };
867
- function isSet(value) {
868
- return value !== null && value !== void 0;
869
- }
870
-
871
- const testing = {
872
- __proto__: null,
873
- MockBlock: MockBlock,
874
- MockFilter: MockFilter,
875
- protobufPackage: protobufPackage
876
- };
7
+ import 'effect';
8
+ import 'viem';
9
+ import 'long';
877
10
 
878
11
  const index = {
879
12
  __proto__: null,
880
- common: common,
881
13
  stream: stream,
882
14
  testing: testing
883
15
  };
884
16
 
885
- const Bytes = Schema.TemplateLiteral(
886
- Schema.Literal("0x"),
887
- Schema.String
888
- );
889
- const BytesFromUint8Array = Schema.requiredToOptional(
890
- Schema.Uint8ArrayFromSelf,
891
- Bytes,
892
- {
893
- decode(value) {
894
- if (value.length === 0) {
895
- return Option.none();
896
- }
897
- return Option.some(toHex(value));
898
- },
899
- encode(value) {
900
- return value.pipe(
901
- Option.map(hexToBytes),
902
- Option.getOrElse(() => new Uint8Array(0))
903
- );
904
- }
905
- }
906
- );
907
- const _Cursor = Schema.Struct({
908
- /** The block number. */
909
- orderKey: Schema.BigIntFromSelf,
910
- /** The block hash, if any. */
911
- uniqueKey: BytesFromUint8Array
912
- });
913
- const Cursor = _Cursor;
914
- const createCursor = (props) => props;
915
- const cursorToProto = Schema.encodeSync(Cursor);
916
- const cursorFromProto = Schema.decodeSync(Cursor);
917
- const CursorFromBytes = Schema.transform(
918
- Schema.Uint8ArrayFromSelf,
919
- Cursor,
920
- {
921
- decode(value) {
922
- return Cursor$1.decode(value);
923
- },
924
- encode(value) {
925
- return Cursor$1.encode(value).finish();
926
- }
927
- }
928
- );
929
- const cursorToBytes = Schema.encodeSync(CursorFromBytes);
930
- const cursorFromBytes = Schema.decodeSync(CursorFromBytes);
931
-
932
17
  const StatusRequest = Schema.Struct({});
933
18
  const statusRequestToProto = Schema.encodeSync(StatusRequest);
934
19
  const statusRequestFromProto = Schema.decodeSync(StatusRequest);
935
20
  const StatusResponse = Schema.Struct({
936
21
  currentHead: Schema.optional(Cursor),
937
- lastIngested: Schema.optional(Cursor)
22
+ lastIngested: Schema.optional(Cursor),
23
+ finalized: Schema.optional(Cursor),
24
+ starting: Schema.optional(Cursor)
938
25
  });
939
26
  const statusResponseToProto = Schema.encodeSync(StatusResponse);
940
27
  const statusResponseFromProto = Schema.decodeSync(StatusResponse);
941
28
 
942
- const DataFinality = Schema.transform(
943
- Schema.Enums(DataFinality$1),
944
- Schema.Literal("finalized", "accepted", "pending", "unknown"),
945
- {
946
- decode(value) {
947
- const enumMap = {
948
- [DataFinality$1.FINALIZED]: "finalized",
949
- [DataFinality$1.ACCEPTED]: "accepted",
950
- [DataFinality$1.PENDING]: "pending",
951
- [DataFinality$1.UNKNOWN]: "unknown",
952
- [DataFinality$1.UNRECOGNIZED]: "unknown"
953
- };
954
- return enumMap[value] ?? "unknown";
955
- },
956
- encode(value) {
957
- const enumMap = {
958
- finalized: DataFinality$1.FINALIZED,
959
- accepted: DataFinality$1.ACCEPTED,
960
- pending: DataFinality$1.PENDING,
961
- unknown: DataFinality$1.UNKNOWN
962
- };
963
- return enumMap[value] ?? DataFinality$1.UNKNOWN;
964
- }
965
- }
966
- );
967
- const StreamDataRequest = (filter) => Schema.Struct({
968
- finality: Schema.optional(DataFinality),
969
- startingCursor: Schema.optional(Cursor),
970
- filter: Schema.mutable(Schema.Array(filter))
971
- });
972
- const Invalidate = Schema.Struct({
973
- _tag: tag("invalidate"),
974
- invalidate: Schema.Struct({
975
- cursor: Schema.optional(Cursor)
976
- })
977
- });
978
- const Heartbeat = Schema.Struct({
979
- _tag: tag("heartbeat")
980
- });
981
- const StdOut = Schema.Struct({
982
- _tag: tag("stdout"),
983
- stdout: Schema.String
984
- });
985
- const StdErr = Schema.Struct({
986
- _tag: tag("stderr"),
987
- stderr: Schema.String
988
- });
989
- const SystemMessage = Schema.Struct({
990
- _tag: tag("systemMessage"),
991
- systemMessage: Schema.Struct({
992
- output: Schema.optional(Schema.Union(StdOut, StdErr))
993
- })
994
- });
995
- const Data = (schema) => Schema.Struct({
996
- _tag: tag("data"),
997
- data: Schema.Struct({
998
- cursor: Schema.optional(Cursor),
999
- endCursor: Schema.optional(Cursor),
1000
- finality: DataFinality,
1001
- data: Schema.Array(schema)
1002
- })
1003
- });
1004
- const StreamDataResponse = (data) => Schema.Union(Data(data), Invalidate, Heartbeat, SystemMessage);
1005
- Schema.Union(Invalidate, Heartbeat, SystemMessage);
1006
- function tag(tag2) {
1007
- return Schema.Literal(tag2).pipe(
1008
- Schema.propertySignature,
1009
- Schema.fromKey("$case")
1010
- );
1011
- }
1012
-
1013
- var __defProp$2 = Object.defineProperty;
1014
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1015
- var __publicField$2 = (obj, key, value) => {
1016
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
1017
- return value;
1018
- };
1019
- class StreamConfig {
1020
- constructor(filter, block, mergeFilter) {
1021
- this.filter = filter;
1022
- this.block = block;
1023
- this.mergeFilter = mergeFilter;
1024
- __publicField$2(this, "request");
1025
- __publicField$2(this, "response");
1026
- this.request = StreamDataRequest(this.filter);
1027
- this.response = StreamDataResponse(this.block);
1028
- }
1029
- /** Filter schema. */
1030
- get Filter() {
1031
- return this.filter;
1032
- }
1033
- /** Block schema. */
1034
- get Block() {
1035
- return this.block;
1036
- }
1037
- /** Stream data request schema. */
1038
- get Request() {
1039
- return this.request;
1040
- }
1041
- /** Stream data response schema. */
1042
- get Response() {
1043
- return this.response;
1044
- }
1045
- }
1046
-
1047
29
  var __defProp$1 = Object.defineProperty;
1048
30
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1049
31
  var __publicField$1 = (obj, key, value) => {
1050
32
  __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1051
33
  return value;
1052
34
  };
1053
- function createClient(config, streamUrl, defaultCallOptions) {
1054
- const channel = createChannel(streamUrl);
35
+ function createClient(config, streamUrl, options = {}) {
36
+ const channel = createChannel(
37
+ streamUrl,
38
+ options?.credentials,
39
+ options?.channelOptions
40
+ );
1055
41
  const client = createClient$1(
1056
42
  DnaStreamDefinition,
1057
43
  channel,
1058
- defaultCallOptions
44
+ options?.defaultCallOptions
1059
45
  );
1060
46
  return new GrpcClient(config, client);
1061
47
  }
@@ -1169,4 +155,4 @@ class RateGauge {
1169
155
  }
1170
156
  }
1171
157
 
1172
- export { Bytes, BytesFromUint8Array, Cursor, CursorFromBytes, Data, DataFinality, DnaStreamDefinition, GrpcClient, Heartbeat, Invalidate, RateGauge, StatusRequest, StatusResponse, StdErr, StdOut, StreamConfig, StreamDataIterable, StreamDataRequest, StreamDataResponse, SystemMessage, _Cursor, createClient, createCursor, cursorFromBytes, cursorFromProto, cursorToBytes, cursorToProto, index as proto, statusRequestFromProto, statusRequestToProto, statusResponseFromProto, statusResponseToProto };
158
+ export { Cursor, DnaStreamDefinition, GrpcClient, RateGauge, StatusRequest, StatusResponse, StreamDataIterable, StreamDataResponse, createClient, index as proto, statusRequestFromProto, statusRequestToProto, statusResponseFromProto, statusResponseToProto };