Skip to content

Commit

Permalink
fix: diff unequal mappings (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Jan 21, 2025
1 parent 85bc659 commit 5f17d87
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/govv3/checks/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ function getContractChanges(diffs: StateDiff[]) {
// This is a complex type like a mapping, which may have multiple changes. The diff.original
// and diff.dirty fields can be strings or objects, and for complex types they are objects,
// so we cast them as such
const keys = Object.keys(diff.original);
const original = diff.original as Record<string, any>;
const dirty = diff.dirty as Record<string, any>;
const keys = Array.from(
new Set([...Object.keys(diff.original || {}), ...Object.keys(diff.dirty || {})]),
);
const original = (diff.original || {}) as Record<string, any>;
const dirty = (diff.dirty || {}) as Record<string, any>;
for (const k of keys as Hex[]) {
changes.push({before: original[k], after: dirty[k], name: k, type: diff.soltype?.name});
if (original[k] || dirty[k])
changes.push({before: original[k], after: dirty[k], name: k, type: diff.soltype?.name});
}
} else {
// TODO arrays and nested mapping are currently not well supported -- find a transaction
Expand Down

0 comments on commit 5f17d87

Please sign in to comment.