Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 8c32ae4

Browse files
LefterisJPkonradkonrad
authored andcommitted
Abstract away the extraction of the contract data
1 parent 6fc4a3d commit 8c32ae4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

ethereum/_solidity.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ def compile_file(filepath, libraries=None, combined='bin,abi', optimize=True, ex
261261
return solc_parse_output(output)
262262

263263

264+
def solidity_get_contract_data(all_contracts, filepath, contract_name):
265+
""" A backwards compatible method of getting the contract data out
266+
of a solc --combined-json output"""
267+
try:
268+
contract_data = all_contracts[contract_name]
269+
except:
270+
_, filename = os.path.split(filepath)
271+
contract_data = all_contracts[filename + ":" + contract_name]
272+
return contract_data
273+
274+
264275
def compile_contract(filepath, contract_name, libraries=None, combined='bin,abi', optimize=True, extra_args=None):
265276
all_contracts = compile_file(
266277
filepath,
@@ -269,12 +280,7 @@ def compile_contract(filepath, contract_name, libraries=None, combined='bin,abi'
269280
optimize=optimize,
270281
extra_args=extra_args
271282
)
272-
try:
273-
contract_data = all_contracts[contract_name]
274-
except:
275-
_, filename = os.path.split(filepath)
276-
contract_data = all_contracts[filename + ":" + contract_name]
277-
return contract_data
283+
return solidity_get_contract_data(all_contracts, filepath, contract_name)
278284

279285

280286
def compile_last_contract(filepath, libraries=None, combined='bin,abi', optimize=True, extra_args=None):

0 commit comments

Comments
 (0)