From 2256a1b0269a038c389ca6e95fb48a1dd2a33ea7 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Tue, 19 Jul 2022 10:56:48 +0200 Subject: [PATCH] fix: use defineProperty to avoid webpack calling getter --- src/utils/type.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/type.ts b/src/utils/type.ts index e65c5669..4ab44469 100644 --- a/src/utils/type.ts +++ b/src/utils/type.ts @@ -200,12 +200,13 @@ export function makeReferenceOrEns(value: unknown, expectedCidType: ReferenceTyp * @param cidType Type as described in the @ethersphere/swarm-cids-js -> ReferenceType */ export function addCidConversionFunction(result: UploadResult, cidType: ReferenceType): UploadResultWithCid { - return { - ...result, - get cid() { + Object.defineProperty(result, 'cid', { + get: () => { return encodeReference(result.reference, cidType).toString() }, - } + }) + + return result as UploadResultWithCid } export function assertAddress(value: unknown): asserts value is Address {