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

Commit 94efcbd

Browse files
committed
fixes for linking and compiling
1 parent fe539a3 commit 94efcbd

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ethereum/_solidity.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ def solidity_resolve_address(hex_code, library_symbol, library_address):
177177
bin: The bytecode encoded in hexadecimal with the library references
178178
resolved.
179179
"""
180+
if library_address.startswith('0x'):
181+
raise ValueError('Address should not contain the 0x prefix')
182+
183+
try:
184+
_ = library_address.decode('hex')
185+
except TypeError:
186+
raise ValueError('library_address contains invalid characters, it must be hex encoded.')
187+
188+
if len(library_symbol) != 40 or len(library_address) != 40:
189+
raise ValueError('Address with wrong length')
190+
180191
return hex_code.replace(library_symbol, library_address)
181192

182193

@@ -307,8 +318,7 @@ def _code_or_path(sourcecode, path, contract_name, libraries, combined):
307318
all_names = solidity_names(sourcecode)
308319
all_contract_names = [
309320
name
310-
for kind, name in all_names
311-
if kind == 'contract'
321+
for _, name in all_names
312322
]
313323
last_contract = all_contract_names[-1]
314324

0 commit comments

Comments
 (0)