From 7d51a28a8b42ab32fb27df24b81597fdf2d7f07f Mon Sep 17 00:00:00 2001 From: SidestreamColdMelon <132689270+SidestreamColdMelon@users.noreply.github.com> Date: Tue, 21 May 2024 10:30:16 +0200 Subject: [PATCH] Refactor: replace dapp-tools with foundry for spell flattening (#391) --- Makefile | 2 +- scripts/verify.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 18d2ebd4e..9adc617eb 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ estimate :; ./scripts/estimate-deploy-gas.sh deploy :; ./scripts/deploy.sh deploy-info :; ./scripts/get-deploy-info.sh tx=$(tx) verify :; ./scripts/verify.py DssSpell $(addr) -flatten :; hevm flatten --source-file "src/DssSpell.sol" > out/flat.sol +flatten :; forge flatten src/DssSpell.sol --output out/flat.sol diff-deployed-spell :; ./scripts/diff-deployed-dssspell.sh $(spell) check-deployed-spell :; ./scripts/check-deployed-dssspell.sh cast-on-tenderly :; cd ./scripts/cast-on-tenderly/ && npm i && npm start -- $(spell); cd - diff --git a/scripts/verify.py b/scripts/verify.py index c799e7eee..2340a594f 100755 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -53,8 +53,8 @@ exit('contract name not found.') print('Obtaining chain... ') -seth_chain = subprocess.run(['seth', 'chain'], capture_output=True) -chain = seth_chain.stdout.decode('ascii').replace('\n', '') +cast_chain = subprocess.run(['cast', 'chain'], capture_output=True) +chain = cast_chain.stdout.decode('ascii').replace('\n', '') print(chain) text_metadata = content['contracts'][contract_path][contract_name]['metadata'] @@ -74,13 +74,16 @@ action = 'verifysourcecode' code_format = 'solidity-single-file' -flatten = subprocess.run([ - 'hevm', +flatten_output_path = 'out/flat.sol' +subprocess.run([ + 'forge', 'flatten', - '--source-file', - contract_path -], capture_output=True) -code = flatten.stdout.decode('utf-8') + contract_path, + '--output', + flatten_output_path +]) +with open(flatten_output_path, 'r', encoding='utf-8') as code_file: + code = code_file.read() def get_block(signature, code, with_frame=False): block_and_tail = code[code.find(signature) :]