@apibara/indexer 2.0.0-beta.29 → 2.0.0-beta.30
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.
|
@@ -14,6 +14,7 @@ require('@opentelemetry/api');
|
|
|
14
14
|
|
|
15
15
|
function generateMockMessages(count = 10, options) {
|
|
16
16
|
const invalidateAt = options?.invalidate;
|
|
17
|
+
const finalizeAt = options?.finalize;
|
|
17
18
|
const messages = [];
|
|
18
19
|
for (let i = 0; i < count; i++) {
|
|
19
20
|
if (invalidateAt && i === invalidateAt.invalidateTriggerIndex) {
|
|
@@ -25,6 +26,15 @@ function generateMockMessages(count = 10, options) {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
});
|
|
29
|
+
} else if (finalizeAt && i === finalizeAt.finalizeTriggerIndex) {
|
|
30
|
+
messages.push({
|
|
31
|
+
_tag: "finalize",
|
|
32
|
+
finalize: {
|
|
33
|
+
cursor: {
|
|
34
|
+
orderKey: BigInt(5e6 + finalizeAt.finalizeToIndex)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
28
38
|
} else {
|
|
29
39
|
messages.push({
|
|
30
40
|
_tag: "data",
|
|
@@ -8,6 +8,10 @@ type MockMessagesOptions = {
|
|
|
8
8
|
invalidateFromIndex: number;
|
|
9
9
|
invalidateTriggerIndex: number;
|
|
10
10
|
};
|
|
11
|
+
finalize?: {
|
|
12
|
+
finalizeToIndex: number;
|
|
13
|
+
finalizeTriggerIndex: number;
|
|
14
|
+
};
|
|
11
15
|
};
|
|
12
16
|
declare function generateMockMessages(count?: number, options?: MockMessagesOptions): MockStreamResponse[];
|
|
13
17
|
declare function getMockIndexer({ plugins, override, }?: {
|
|
@@ -8,6 +8,10 @@ type MockMessagesOptions = {
|
|
|
8
8
|
invalidateFromIndex: number;
|
|
9
9
|
invalidateTriggerIndex: number;
|
|
10
10
|
};
|
|
11
|
+
finalize?: {
|
|
12
|
+
finalizeToIndex: number;
|
|
13
|
+
finalizeTriggerIndex: number;
|
|
14
|
+
};
|
|
11
15
|
};
|
|
12
16
|
declare function generateMockMessages(count?: number, options?: MockMessagesOptions): MockStreamResponse[];
|
|
13
17
|
declare function getMockIndexer({ plugins, override, }?: {
|
|
@@ -8,6 +8,10 @@ type MockMessagesOptions = {
|
|
|
8
8
|
invalidateFromIndex: number;
|
|
9
9
|
invalidateTriggerIndex: number;
|
|
10
10
|
};
|
|
11
|
+
finalize?: {
|
|
12
|
+
finalizeToIndex: number;
|
|
13
|
+
finalizeTriggerIndex: number;
|
|
14
|
+
};
|
|
11
15
|
};
|
|
12
16
|
declare function generateMockMessages(count?: number, options?: MockMessagesOptions): MockStreamResponse[];
|
|
13
17
|
declare function getMockIndexer({ plugins, override, }?: {
|
|
@@ -12,6 +12,7 @@ import '@opentelemetry/api';
|
|
|
12
12
|
|
|
13
13
|
function generateMockMessages(count = 10, options) {
|
|
14
14
|
const invalidateAt = options?.invalidate;
|
|
15
|
+
const finalizeAt = options?.finalize;
|
|
15
16
|
const messages = [];
|
|
16
17
|
for (let i = 0; i < count; i++) {
|
|
17
18
|
if (invalidateAt && i === invalidateAt.invalidateTriggerIndex) {
|
|
@@ -23,6 +24,15 @@ function generateMockMessages(count = 10, options) {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
});
|
|
27
|
+
} else if (finalizeAt && i === finalizeAt.finalizeTriggerIndex) {
|
|
28
|
+
messages.push({
|
|
29
|
+
_tag: "finalize",
|
|
30
|
+
finalize: {
|
|
31
|
+
cursor: {
|
|
32
|
+
orderKey: BigInt(5e6 + finalizeAt.finalizeToIndex)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
26
36
|
} else {
|
|
27
37
|
messages.push({
|
|
28
38
|
_tag: "data",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apibara/indexer",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.30",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"vitest": "^1.6.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@apibara/protocol": "2.0.0-beta.
|
|
61
|
+
"@apibara/protocol": "2.0.0-beta.30",
|
|
62
62
|
"@opentelemetry/api": "^1.9.0",
|
|
63
63
|
"ci-info": "^4.1.0",
|
|
64
64
|
"consola": "^3.2.3",
|
package/src/internal/testing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isCursor } from "@apibara/protocol";
|
|
1
|
+
import { type Finalize, type Invalidate, isCursor } from "@apibara/protocol";
|
|
2
2
|
import {
|
|
3
3
|
type MockBlock,
|
|
4
4
|
type MockFilter,
|
|
@@ -15,6 +15,10 @@ export type MockMessagesOptions = {
|
|
|
15
15
|
invalidateFromIndex: number;
|
|
16
16
|
invalidateTriggerIndex: number;
|
|
17
17
|
};
|
|
18
|
+
finalize?: {
|
|
19
|
+
finalizeToIndex: number;
|
|
20
|
+
finalizeTriggerIndex: number;
|
|
21
|
+
};
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
export function generateMockMessages(
|
|
@@ -22,7 +26,7 @@ export function generateMockMessages(
|
|
|
22
26
|
options?: MockMessagesOptions,
|
|
23
27
|
): MockStreamResponse[] {
|
|
24
28
|
const invalidateAt = options?.invalidate;
|
|
25
|
-
|
|
29
|
+
const finalizeAt = options?.finalize;
|
|
26
30
|
const messages: MockStreamResponse[] = [];
|
|
27
31
|
|
|
28
32
|
for (let i = 0; i < count; i++) {
|
|
@@ -34,7 +38,16 @@ export function generateMockMessages(
|
|
|
34
38
|
orderKey: BigInt(5_000_000 + invalidateAt.invalidateFromIndex),
|
|
35
39
|
},
|
|
36
40
|
},
|
|
37
|
-
});
|
|
41
|
+
} as Invalidate);
|
|
42
|
+
} else if (finalizeAt && i === finalizeAt.finalizeTriggerIndex) {
|
|
43
|
+
messages.push({
|
|
44
|
+
_tag: "finalize",
|
|
45
|
+
finalize: {
|
|
46
|
+
cursor: {
|
|
47
|
+
orderKey: BigInt(5_000_000 + finalizeAt.finalizeToIndex),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
} as Finalize);
|
|
38
51
|
} else {
|
|
39
52
|
messages.push({
|
|
40
53
|
_tag: "data",
|