Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 3131642

Browse files
committed
add condition checking for 1 source to determine whether to filter artifact
1 parent 8ebc466 commit 3131642

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/core/lib/console.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,17 @@ class Console extends EventEmitter {
263263
"utf8"
264264
);
265265
const json = JSON.parse(body);
266-
// hack to prevent a warning about the console.sol contract which we
267-
// don't load into the environment - we only want to do this when it is
268-
// Truffle's console.sol, that is why we check the sources keys
266+
const metadata = JSON.parse(json.metadata);
267+
// filter out Truffle's console.log. We don't want users to interact with in the REPL.
268+
// user contracts named console.log will be imported, and a warning will be issued.
269269
if (
270-
!Object.keys(JSON.parse(json.metadata).sources).some(source => {
270+
!Object.keys(metadata.sources).some(source => {
271271
return (
272272
source === "truffle/console.sol" ||
273273
source === "truffle/Console.sol"
274274
);
275-
})
275+
}) &&
276+
Object.keys(metadata.sources).length === 1
276277
) {
277278
jsonBlobs.push(json);
278279
}

0 commit comments

Comments
 (0)