ponder 0.18.0 → 0.18.2
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/CHANGELOG.md +16 -0
- package/dist/esm/indexing-store/index.js +8 -4
- package/dist/esm/indexing-store/index.js.map +1 -1
- package/dist/esm/indexing-store/utils.js +3 -1
- package/dist/esm/indexing-store/utils.js.map +1 -1
- package/dist/esm/rpc/actions.js +2 -16
- package/dist/esm/rpc/actions.js.map +1 -1
- package/dist/esm/runtime/filter.js +80 -32
- package/dist/esm/runtime/filter.js.map +1 -1
- package/dist/esm/sync-historical/in-memory.js +1 -2
- package/dist/esm/sync-historical/in-memory.js.map +1 -1
- package/dist/esm/sync-historical/index.js +1 -2
- package/dist/esm/sync-historical/index.js.map +1 -1
- package/dist/esm/sync-realtime/bloom.js +72 -64
- package/dist/esm/sync-realtime/bloom.js.map +1 -1
- package/dist/esm/sync-realtime/index.js +79 -50
- package/dist/esm/sync-realtime/index.js.map +1 -1
- package/dist/esm/utils/copy.js +77 -56
- package/dist/esm/utils/copy.js.map +1 -1
- package/dist/esm/utils/decodeEventLog.js +20 -6
- package/dist/esm/utils/decodeEventLog.js.map +1 -1
- package/dist/types/indexing-store/index.d.ts.map +1 -1
- package/dist/types/indexing-store/utils.d.ts.map +1 -1
- package/dist/types/rpc/actions.d.ts +2 -3
- package/dist/types/rpc/actions.d.ts.map +1 -1
- package/dist/types/runtime/filter.d.ts +24 -1
- package/dist/types/runtime/filter.d.ts.map +1 -1
- package/dist/types/sync-historical/in-memory.d.ts.map +1 -1
- package/dist/types/sync-historical/index.d.ts.map +1 -1
- package/dist/types/sync-realtime/bloom.d.ts +52 -8
- package/dist/types/sync-realtime/bloom.d.ts.map +1 -1
- package/dist/types/sync-realtime/index.d.ts.map +1 -1
- package/dist/types/utils/copy.d.ts +10 -2
- package/dist/types/utils/copy.d.ts.map +1 -1
- package/dist/types/utils/decodeEventLog.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/indexing-store/index.ts +8 -4
- package/src/indexing-store/utils.ts +3 -1
- package/src/rpc/actions.ts +1 -21
- package/src/runtime/filter.ts +116 -52
- package/src/sync-historical/in-memory.ts +0 -2
- package/src/sync-historical/index.ts +0 -2
- package/src/sync-realtime/bloom.ts +129 -79
- package/src/sync-realtime/index.ts +114 -72
- package/src/utils/copy.ts +83 -64
- package/src/utils/decodeEventLog.ts +28 -6
|
@@ -12,6 +12,31 @@ import {
|
|
|
12
12
|
} from "./decodeAbiParameters.js";
|
|
13
13
|
import { toLowerCase } from "./lowercase.js";
|
|
14
14
|
|
|
15
|
+
type DecodeEventLogInputs = {
|
|
16
|
+
isUnnamed: boolean;
|
|
17
|
+
indexedInputs: (readonly [AbiParameter, number])[];
|
|
18
|
+
nonIndexedInputs: AbiParameter[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Inputs of each `abiItem`, so that they aren't recomputed for every log. */
|
|
22
|
+
const inputsCache = new WeakMap<AbiEvent, DecodeEventLogInputs>();
|
|
23
|
+
|
|
24
|
+
const getInputs = (abiItem: AbiEvent): DecodeEventLogInputs => {
|
|
25
|
+
let result = inputsCache.get(abiItem);
|
|
26
|
+
if (result === undefined) {
|
|
27
|
+
const { inputs } = abiItem;
|
|
28
|
+
result = {
|
|
29
|
+
isUnnamed: inputs?.some((x) => !("name" in x && x.name)),
|
|
30
|
+
indexedInputs: inputs
|
|
31
|
+
.map((x, i) => [x, i] as const)
|
|
32
|
+
.filter(([x]) => "indexed" in x && x.indexed),
|
|
33
|
+
nonIndexedInputs: inputs.filter((x) => !("indexed" in x && x.indexed)),
|
|
34
|
+
};
|
|
35
|
+
inputsCache.set(abiItem, result);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
|
|
15
40
|
/**
|
|
16
41
|
* Decode an event log.
|
|
17
42
|
*
|
|
@@ -27,14 +52,11 @@ export function decodeEventLog({
|
|
|
27
52
|
data: Hex;
|
|
28
53
|
}): any {
|
|
29
54
|
const { inputs } = abiItem;
|
|
30
|
-
const isUnnamed
|
|
55
|
+
const { isUnnamed, indexedInputs, nonIndexedInputs } = getInputs(abiItem);
|
|
31
56
|
|
|
32
57
|
const args: any = isUnnamed ? [] : {};
|
|
33
58
|
|
|
34
59
|
// Decode topics (indexed args).
|
|
35
|
-
const indexedInputs = inputs
|
|
36
|
-
.map((x, i) => [x, i] as const)
|
|
37
|
-
.filter(([x]) => "indexed" in x && x.indexed);
|
|
38
60
|
for (let i = 0; i < indexedInputs.length; i++) {
|
|
39
61
|
const [param, argIndex] = indexedInputs[i]!;
|
|
40
62
|
const topic = topics[i + 1];
|
|
@@ -52,7 +74,6 @@ export function decodeEventLog({
|
|
|
52
74
|
}
|
|
53
75
|
|
|
54
76
|
// Decode data (non-indexed args).
|
|
55
|
-
const nonIndexedInputs = inputs.filter((x) => !("indexed" in x && x.indexed));
|
|
56
77
|
if (nonIndexedInputs.length > 0) {
|
|
57
78
|
if (data && data !== "0x") {
|
|
58
79
|
const out = [] as DecodeAbiParametersReturnType<typeof nonIndexedInputs>;
|
|
@@ -82,7 +103,8 @@ export function decodeEventLog({
|
|
|
82
103
|
}
|
|
83
104
|
}
|
|
84
105
|
|
|
85
|
-
|
|
106
|
+
// Note: Every input sets a value in `args`.
|
|
107
|
+
return inputs.length > 0 ? args : undefined;
|
|
86
108
|
}
|
|
87
109
|
|
|
88
110
|
const ARRAY_REGEX = /^(.*)\[(\d+)?\]$/;
|