11""" A simple way of interacting to a ethereum node through JSON RPC commands. """
22import logging
3- import time
3+ import os
44import warnings
55import json
66
99from ethereum .keys import privtoaddr
1010from ethereum .transactions import Transaction
1111from ethereum .utils import denoms , int_to_big_endian , big_endian_to_int , normalize_address
12- from ethereum ._solidity import solidity_unresolved_symbols , solidity_library_symbol , solidity_resolve_symbols
12+ from ethereum ._solidity import (
13+ solidity_unresolved_symbols ,
14+ solidity_library_symbol ,
15+ solidity_resolve_symbols
16+ )
1317from tinyrpc .protocols .jsonrpc import JSONRPCErrorResponse , JSONRPCSuccessResponse
1418from tinyrpc .protocols .jsonrpc import JSONRPCProtocol
1519from tinyrpc .transports .http import HttpPostClientTransport
@@ -208,14 +212,42 @@ def new_contract_proxy(self, contract_interface, address):
208212 self .eth_estimateGas ,
209213 )
210214
211- def deploy_solidity_contract (self , sender , contract_name , all_contracts , # pylint: disable=too-many-locals
212- libraries , constructor_parameters , timeout = None , gasprice = default_gasprice ):
215+ def deploy_solidity_contract (
216+ self , # pylint: disable=too-many-locals
217+ sender ,
218+ contract_name ,
219+ all_contracts ,
220+ libraries ,
221+ constructor_parameters ,
222+ contract_path = None ,
223+ timeout = None ,
224+ gasprice = default_gasprice
225+ ):
226+ """
227+ Deploy a solidity contract.
228+ Args:
229+ sender (address): the sender address
230+ contract_name (str): the name of the contract to compile
231+ all_contracts (dict): the json dictionary containing the result of compiling a file
232+ libraries (list): A list of libraries to use in deployment
233+ constructor_parameters (tuple): A tuple of arguments to pass to the constructor
234+ contract_path (str): If given then we are dealing with solc >= v0.4.9 and is
235+ a required argument to extract the contract data from the
236+ `all_contracts` dict.
237+ timeout (int): Amount of time to poll the chain to confirm deployment
238+ gasprice: The gasprice to provide for the transaction
239+ """
213240
214- if contract_name not in all_contracts :
215- raise ValueError ('Unkonwn contract {}' .format (contract_name ))
241+ if contract_path is None :
242+ if contract_name not in all_contracts :
243+ raise ValueError ('Unknown contract {}' .format (contract_name ))
244+ contract_key = contract_name
245+ else :
246+ _ , filename = os .path .split (contract_path )
247+ contract_key = filename + ":" + contract_name
216248
217249 libraries = dict (libraries )
218- contract = all_contracts [contract_name ]
250+ contract = all_contracts [contract_key ]
219251 contract_interface = contract ['abi' ]
220252 symbols = solidity_unresolved_symbols (contract ['bin_hex' ])
221253
@@ -231,11 +263,11 @@ def deploy_solidity_contract(self, sender, contract_name, all_contracts, # pyli
231263 raise Exception (msg )
232264
233265 dependencies = deploy_dependencies_symbols (all_contracts )
234- deployment_order = dependencies_order_of_build (contract_name , dependencies )
266+ deployment_order = dependencies_order_of_build (contract_key , dependencies )
235267
236268 deployment_order .pop () # remove `contract_name` from the list
237269
238- log .debug ('Deploing dependencies: {}' .format (str (deployment_order )))
270+ log .debug ('Deploying dependencies: {}' .format (str (deployment_order )))
239271
240272 for deploy_contract in deployment_order :
241273 dependency_contract = all_contracts [deploy_contract ]
0 commit comments