Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_invalid_type_exception(bad_code):
with raises(InvalidTypeException):
compiler.compile(bad_code)
def test_block_success(good_code):
assert compiler.compile(good_code) is not None
def test_slice_success(good_code):
assert compiler.compile(good_code) is not None
def test_as_wei_success(good_code):
assert compiler.compile(good_code) is not None
def test_block_fail(bad_code):
with raises(TypeMismatchException):
compiler.compile(bad_code)
def test_public_success(good_code):
assert compiler.compile(good_code) is not None
def test_block_fail(bad_code):
with raises(TypeMismatchException):
compiler.compile(bad_code)
def test_as_wei_success(good_code):
assert compiler.compile(good_code) is not None
def generate_compiled_json(file_path: str) -> None:
vmc_code = open(file_path).read()
abi = compiler.mk_full_signature(vmc_code)
bytecode = compiler.compile(vmc_code)
bytecode_hex = '0x' + bytecode.hex()
contract_json = {
'abi': abi,
'bytecode': bytecode_hex,
}
# write json
basename = os.path.basename(file_path)
dirname = os.path.dirname(file_path)
contract_name = basename.split('.')[0]
with open(dirname + "/{}.json".format(contract_name), 'w') as f_write:
json.dump(contract_json, f_write)