Use `get_missing_vars` in MissingVariable detector

pull/1757/head
webthethird 2 years ago
parent 574afbe04b
commit f216817d21
  1. 16
      slither/tools/upgradeability/checks/variables_order.py

@ -2,6 +2,7 @@ from slither.tools.upgradeability.checks.abstract_checks import (
CheckClassification, CheckClassification,
AbstractCheck, AbstractCheck,
) )
from slither.utils.upgradeability import get_missing_vars
class MissingVariable(AbstractCheck): class MissingVariable(AbstractCheck):
@ -48,21 +49,10 @@ Do not change the order of the state variables in the updated contract.
def _check(self): def _check(self):
contract1 = self.contract contract1 = self.contract
contract2 = self.contract_v2 contract2 = self.contract_v2
order1 = [ missing = get_missing_vars(contract1, contract2)
variable
for variable in contract1.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
order2 = [
variable
for variable in contract2.state_variables_ordered
if not (variable.is_constant or variable.is_immutable)
]
results = [] results = []
for idx, _ in enumerate(order1): for variable1 in missing:
variable1 = order1[idx]
if len(order2) <= idx:
info = ["Variable missing in ", contract2, ": ", variable1, "\n"] info = ["Variable missing in ", contract2, ": ", variable1, "\n"]
json = self.generate_result(info) json = self.generate_result(info)
results.append(json) results.append(json)

Loading…
Cancel
Save