Skip to content

Commit cbf0e4d

Browse files
authored
fix: stringify event log value arg (#560)
* fix: stringify value arg * recursive helper
1 parent 0c90424 commit cbf0e4d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/worker/tasks/processEventLogsWorker.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const formatDecodedLog = async (args: {
231231
if (name && name in logArgs) {
232232
res[name] = {
233233
type,
234-
value: (logArgs[name] as any).toString(),
234+
value: logArgToString(logArgs[name]),
235235
};
236236
}
237237
}
@@ -274,6 +274,19 @@ const getBlockTimestamps = async (
274274
return res;
275275
};
276276

277+
const logArgToString = (arg: any): string => {
278+
if (arg === null) {
279+
return "";
280+
}
281+
if (typeof arg === "object") {
282+
return Object.values(arg).map(logArgToString).join(",");
283+
}
284+
if (Array.isArray(arg)) {
285+
return arg.map(logArgToString).join(",");
286+
}
287+
return arg.toString();
288+
};
289+
277290
// Worker
278291
let _worker: Worker | null = null;
279292
if (redis) {

0 commit comments

Comments
 (0)