Handle the case of contracts with no constructor

pull/2319/head
David Núñez 2020-10-02 12:14:58 +02:00
parent efb62d1693
commit eac2d3bcab
2 changed files with 8 additions and 3 deletions

View File

@ -831,7 +831,8 @@ class BlockchainDeployerInterface(BlockchainInterface):
constructor_function,
*constructor_args,
**constructor_kwargs)
self.log.info(f"Constructor calldata: {constructor_calldata}")
if not constructor_calldata:
self.log.info(f"Constructor calldata: {constructor_calldata}")
#
# Transmit the deployment tx #

View File

@ -49,8 +49,12 @@ def encode_constructor_arguments(web3: Web3,
"""
Takes a web3 constructor function and the arguments passed to it, and produces an encoding hex string
of the constructor arguments, following the standard ABI encoding conventions.
If there's no constructor, it returns None.
"""
constructor_abi = get_constructor_abi(constructor_function.abi)
arguments = merge_args_and_kwargs(constructor_abi, constructor_args, constructor_kwargs)
data = encode_abi(web3, constructor_abi, arguments)
if constructor_abi:
arguments = merge_args_and_kwargs(constructor_abi, constructor_args, constructor_kwargs)
data = encode_abi(web3, constructor_abi, arguments)
else:
data = None
return data