|
9 | 9 | from ethereum.slogging import LogRecorder, configure_logging, set_level
|
10 | 10 | from ethereum.utils import to_string
|
11 | 11 | from ethereum._solidity import get_solidity
|
| 12 | +from ethereum import slogging |
12 | 13 | import rlp
|
13 |
| -from rlp.utils import decode_hex, encode_hex, ascii_chr |
| 14 | +from rlp.utils import ascii_chr |
14 | 15 |
|
15 | 16 | serpent = None
|
16 | 17 |
|
@@ -141,8 +142,23 @@ def kall(*args, **kwargs):
|
141 | 142 | return outdata
|
142 | 143 | return kall
|
143 | 144 |
|
144 |
| - for f in self._translator.function_data: |
145 |
| - vars(self)[f] = kall_factory(f) |
| 145 | + for fname in self._translator.function_data: |
| 146 | + func = kall_factory(fname) |
| 147 | + # create wrapper with signature |
| 148 | + # in IPython: mycontract.yeah? |
| 149 | + # Definition: mycontract.yeah(uint32_number, uint256_counter, bool_really) |
| 150 | + signature = self._translator.function_data[fname]['signature'] |
| 151 | + fsig = ', '.join(name for typ, name in signature) |
| 152 | + if fsig: |
| 153 | + fsig += ', ' |
| 154 | + wfunc = 'def %s(%s**kargs): return func(%s**kargs)' % (fname, fsig, fsig) |
| 155 | + wfunc_code = compile(wfunc, 'na', 'exec') |
| 156 | + fakeglobals = {} |
| 157 | + eval(wfunc_code, {'func': func}, fakeglobals) # evil, use in tester only! |
| 158 | + func = fakeglobals[fname] |
| 159 | + func.__doc__ = '%s(%s)' % (fname, ', '.join(('%s %s' % x) for x in signature)) |
| 160 | + |
| 161 | + setattr(self, fname, func) |
146 | 162 |
|
147 | 163 | return _abi_contract(me, code, sender, endowment, language)
|
148 | 164 |
|
|
0 commit comments