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

Commit 29ce3a9

Browse files
LefterisJPkonradkonrad
authored andcommitted
Add method to get all_contracts key in solidity
1 parent 8c32ae4 commit 29ce3a9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ethereum/_solidity.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,17 @@ def solidity_get_contract_data(all_contracts, filepath, contract_name):
272272
return contract_data
273273

274274

275+
def solidity_get_contract_key(all_contracts, filepath, contract_name):
276+
""" A backwards compatible method of getting the key to the all_contracts
277+
dictionary for a particular contract"""
278+
if contract_name in all_contracts:
279+
return contract_name
280+
else:
281+
_, filename = os.path.split(filepath)
282+
contract_key = filename + ":" + contract_name
283+
return contract_key if contract_key in all_contracts else None
284+
285+
275286
def compile_contract(filepath, contract_name, libraries=None, combined='bin,abi', optimize=True, extra_args=None):
276287
all_contracts = compile_file(
277288
filepath,

0 commit comments

Comments
 (0)