@@ -98,9 +98,16 @@ class ContractCreationFailed(Exception):
98
98
99
99
class ABIContract (object ): # pylint: disable=too-few-public-methods
100
100
101
- def __init__ (self , test_state , abi_translator , address , listen = True , log_listener = None , default_key = None ): # pylint: disable=too-many-arguments
101
+ def __init__ (self , _state , _abi , address , listen = True , # pylint: disable=too-many-arguments
102
+ log_listener = None , default_key = None ):
102
103
self .address = address
103
104
self .default_key = default_key or DEFAULT_KEY
105
+
106
+ if isinstance (_abi , ContractTranslator ):
107
+ abi_translator = _abi
108
+ else :
109
+ abi_translator = ContractTranslator (_abi )
110
+
104
111
self .translator = abi_translator
105
112
106
113
def listener (log ):
@@ -110,10 +117,10 @@ def listener(log):
110
117
log_listener (result )
111
118
112
119
if listen :
113
- test_state .block .log_listeners .append (listener )
120
+ _state .block .log_listeners .append (listener )
114
121
115
122
for function_name in self .translator .function_data :
116
- function = self .method_factory (test_state , function_name )
123
+ function = self .method_factory (_state , function_name )
117
124
method = types .MethodType (function , self )
118
125
setattr (self , function_name , method )
119
126
@@ -377,10 +384,13 @@ def trace(self, sender, to, value, data=None):
377
384
return recorder .pop_records ()
378
385
379
386
def mine (self , number_of_blocks = 1 , coinbase = DEFAULT_ACCOUNT , ** kwargs ):
380
- if 'n' in kwargs : # compatibility
387
+ if 'n' in kwargs : # compatibility
381
388
number_of_blocks = kwargs ['n' ]
382
- warnings .warn ('The argument \' n\' is deprecated and its support will be removed ' \
383
- 'in the future versions. Please use the name \' number_of_blocks\' .' )
389
+ warnings .warn (
390
+ "The argument 'n' is deprecated and its support will be removed "
391
+ "in the future versions. Please use the name 'number_of_blocks'."
392
+ )
393
+
384
394
for _ in range (number_of_blocks ):
385
395
self .block .finalize ()
386
396
self .block .commit_state ()
0 commit comments