Skip to content

Commit

Permalink
feat!: Stop supporting console.log selectors with "(u)int" aliases
Browse files Browse the repository at this point in the history
Historically, Hardhat used selectors that computed signatures such as
"log(int)", "log(bool,int)", even though the canonical ABI spec defines
that the keccak256 should be calculated over the canonical type name, so
"int256" or "uint256".

This change removes this support as popular tools already support the
correct ABI encoding or patch the faulty one, instead.
  • Loading branch information
Xanewok committed Sep 19, 2024
1 parent f93c447 commit 3df95d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 233 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-spoons-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": minor
---

Remove support for `console.log` selectors that wrongly use "(u)int" type aliases in the selector calculation
12 changes: 0 additions & 12 deletions packages/hardhat-core/scripts/console-library-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ const CONSOLE_LOG_SIGNATURES: Map<string, string[]> =
const types = params.map((p) => p.type);
acc.set(signature, types);

// For backwards compatibility, we additionally support the (invalid)
// selectors that contain the `int`/`uint` aliases in the selector calculation.
if (params.some((p) => ["uint256", "int256"].includes(p.type))) {
const aliased = params.map((p) => ({
...p,
type: p.type.replace("int256", "int"),
}));

const signature = toHex(selector({ name: "log", params: aliased }));
acc.set(signature, types);
}

return acc;
}, new Map());

Expand Down
Loading

0 comments on commit 3df95d3

Please sign in to comment.