diff --git a/packages/server/src/common/util.ts b/packages/server/src/common/util.ts index 426d4df8..850d6e85 100644 --- a/packages/server/src/common/util.ts +++ b/packages/server/src/common/util.ts @@ -11,8 +11,8 @@ export function asJSON(o: unknown) { typeof v === 'bigint' ? v.toString() : v instanceof Binary ? v.asHex() : v, ) } -export function asSerializable(o: unknown) { - return typeof o === 'string' ? o : safeDestr(asJSON(o)) +export function asSerializable(o: T) { + return typeof o === 'string' ? o : safeDestr(asJSON(o)) } export function getEventValue(module: string, name: string | string[], events: Event[]) { return events.find((e) => diff --git a/packages/server/src/services/agents/steward/agent.ts b/packages/server/src/services/agents/steward/agent.ts index 5d04747a..64f697cd 100644 --- a/packages/server/src/services/agents/steward/agent.ts +++ b/packages/server/src/services/agents/steward/agent.ts @@ -9,7 +9,7 @@ import { IngressConsumer, NetworkInfo } from '@/services/ingress/index.js' import { Scheduled, Scheduler } from '@/services/persistence/level/scheduler.js' import { LevelDB, Logger, NetworkURN } from '@/services/types.js' -import { stringToUa8 } from '@/common/util.js' +import { asSerializable, stringToUa8 } from '@/common/util.js' import { HexString } from '@/lib.js' import { Agent, @@ -263,7 +263,7 @@ export class DataSteward implements Agent, Queryable { .pipe( mergeMap((keys) => { return keys.map((key) => - this.#ingress.getStorage(chainId, key).pipe(mapEntry(key, this.#ingress)), + this.#ingress.getStorage(chainId, key).pipe(asSerializable(mapEntry(key, this.#ingress))), ) }), mergeAll(),