diff --git a/src/block.ts b/src/block.ts index cc947a2..2d1f780 100644 --- a/src/block.ts +++ b/src/block.ts @@ -48,11 +48,7 @@ function blockMapToObject(object: Map): BlockData { for (const [key, value] of object) { if (key === 'r' && value instanceof Map && Array.from(value.keys()).every((k) => typeof k === 'number')) { // State proof transactions have a property `r` with a map with numeric keys that must stay intact - const rMap = new Map() - for (const [k, v] of value) { - rMap.set(k, v instanceof Map ? blockMapToObject(v) : v) - } - result[key] = rMap + result[key] = value } else if (value instanceof Map) { result[key] = blockMapToObject(value) } else if (value instanceof Uint8Array) { diff --git a/src/transform.ts b/src/transform.ts index 26db98e..867256a 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -168,23 +168,16 @@ function concatArrays(...arrs: ArrayLike[]) { return c } -// TODO: PD - review this again -const keysHaveAddressType = ['snd', 'close', 'aclose', 'rekey', 'rcv', 'arcv', 'fadd', 'asnd', 'm', 'r', 'f', 'c'] - // eslint-disable-next-line @typescript-eslint/no-explicit-any const objectToMap = (object: Record): Map => { return new Map( Object.entries(object).map(([key, value]) => { - if (key === 'r' && value instanceof Map) { - // State proof transactions have a property `r` with a map with numeric keys that must stay intact - const rMap = new Map() - for (const [k, v] of value) { - rMap.set(k, objectToMap(v)) - } - return [key, rMap] + if (key === 'r' && value instanceof Map && Array.from(value.keys()).every((k) => typeof k === 'number')) { + return [key, value] } if (value instanceof Uint8Array) { - if (keysHaveAddressType.includes(key) && value.length === 32) { + if (['snd', 'close', 'aclose', 'rekey', 'rcv', 'arcv', 'fadd', 'asnd', 'm', 'r', 'f', 'c'].includes(key) && value.length === 32) { + // fromEncodingData expects Address type return [key, new algosdk.Address(value)] } return [key, value]