From 2f0f8ccb47f15470a434d5e7a2091b858e12b290 Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 9 Apr 2024 09:38:28 +0200 Subject: [PATCH] Prevent failure when executed with a project not using `Vm` --- slither/printers/summary/cheatcodes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/slither/printers/summary/cheatcodes.py b/slither/printers/summary/cheatcodes.py index 50dcdc158..24315a7e2 100644 --- a/slither/printers/summary/cheatcodes.py +++ b/slither/printers/summary/cheatcodes.py @@ -23,7 +23,10 @@ class CheatcodePrinter(AbstractPrinter): info: str = "" - vm = self.slither.get_contract_from_name("Vm").pop() + try: + vm = self.slither.get_contract_from_name("Vm").pop() + except IndexError: + return output.Output("No contract named VM found") for contract in self.slither.contracts_derived: # Check that the IS_TEST variable is set. (Only works for Foundry)