diff --git a/src/soroban/parsers.ts b/src/soroban/parsers.ts index e07d8f672..c600cb679 100644 --- a/src/soroban/parsers.ts +++ b/src/soroban/parsers.ts @@ -23,17 +23,16 @@ export function parseRawEvents( return { latestLedger: r.latestLedger, events: (r.events ?? []).map((evt) => { + const clone: Omit = { ...evt }; + delete (clone as any).contractId; // `as any` hack because contractId field isn't optional + // the contractId may be empty so we omit the field in that case - const cid = evt.contractId; - delete (evt as any).contractId; - const rv = { - ...evt as Omit, - ...(cid !== '' && { contractId: new Contract(cid) }), + return { + ...clone, + ...(evt.contractId !== '' && { contractId: new Contract(evt.contractId) }), topic: evt.topic.map((topic) => xdr.ScVal.fromXDR(topic, 'base64')), value: xdr.ScVal.fromXDR(evt.value.xdr, 'base64') }; - evt.contractId = cid; // put value back after parsing - return rv; }) }; }