Skip to content

Commit

Permalink
Fix List and Map fromBytes parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Comp0te committed Dec 23, 2024
1 parent 9a301f2 commit b988b0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/types/clvalue/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export class CLValueList {
bytes: innerBytes
} = CLValueParser.fromBytesByType(remainder, clType.elementsType);

if (!inner) {
continue;
}

elements.push(inner);
remainder = innerBytes;
}
Expand Down
10 changes: 7 additions & 3 deletions src/types/clvalue/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class CLValueMap {

const { result: u32, bytes: u32Bytes } = CLValueUInt32.fromBytes(bytes);
const size = u32.getValue().toNumber();
let remainder = u32Bytes;
const remainder = u32Bytes;

if (size === 0) {
return { result: mapResult, bytes: remainder };
Expand All @@ -205,11 +205,15 @@ export class CLValueMap {
if (remainder.length) {
const keyVal = CLValueParser.fromBytesByType(remainder, mapType.key);

remainder = keyVal?.bytes;
if (!keyVal.result) {
continue;
}

const valVal = CLValueParser.fromBytesByType(remainder, mapType.val);

remainder = valVal.bytes;
if (!valVal.result) {
continue;
}

mapResult.append(keyVal?.result, valVal?.result);
}
Expand Down

0 comments on commit b988b0e

Please sign in to comment.