diff --git a/mmgen/proto/eth/contract.py b/mmgen/proto/eth/contract.py index 752503a9..182d0dbc 100755 --- a/mmgen/proto/eth/contract.py +++ b/mmgen/proto/eth/contract.py @@ -42,14 +42,6 @@ class Contract: def create_method_id(self, sig): return self.keccak_256(sig.encode()).hexdigest()[:8] - def transferdata2sendaddr(self, data): # online - return CoinAddr(self.proto, parse_abi(data)[1][-40:]) - - def transferdata2amt(self, data): # online - return self.proto.coin_amt( - int(parse_abi(data)[-1], 16) * self.base_unit, - from_decimal = True) - async def code(self): return (await self.rpc.call('eth_getCode', '0x'+self.addr))[2:] @@ -169,6 +161,14 @@ class Token(Contract): 'nonce': nonce, 'data': bytes.fromhex(data)} + def transferdata2sendaddr(self, data): # online + return CoinAddr(self.proto, parse_abi(data)[1][-40:]) + + def transferdata2amt(self, data): # online + return self.proto.coin_amt( + int(parse_abi(data)[-1], 16) * self.base_unit, + from_decimal = True) + # used for testing only: async def transfer( self, @@ -181,12 +181,12 @@ class Token(Contract): gasPrice, method_sig = 'transfer(address,uint256)'): tx_in = self.make_tx_in( - to_addr = to_addr, - amt = amt, - gas = gas, - gasPrice = gasPrice, - nonce = int(await self.rpc.call('eth_getTransactionCount', '0x'+from_addr, 'pending'), 16), - method_sig = method_sig) + to_addr = to_addr, + amt = amt, + gas = gas, + gasPrice = gasPrice, + nonce = int(await self.rpc.call('eth_getTransactionCount', '0x'+from_addr, 'pending'), 16), + method_sig = method_sig) res = await self.txsign(tx_in, key, from_addr) return await self.txsend(res.txhex) diff --git a/mmgen/proto/eth/tx/unsigned.py b/mmgen/proto/eth/tx/unsigned.py index 60483b2a..01741738 100755 --- a/mmgen/proto/eth/tx/unsigned.py +++ b/mmgen/proto/eth/tx/unsigned.py @@ -114,11 +114,11 @@ class TokenUnsigned(TokenCompleted, Unsigned): async def do_sign(self, o, wif): t = Token(self.cfg, self.proto, o['token_addr'], o['decimals']) tx_in = t.make_tx_in( - to_addr = o['to'], - amt = o['amt'], - gas = self.gas, - gasPrice = o['gasPrice'], - nonce = o['nonce']) + to_addr = o['to'], + amt = o['amt'], + gas = self.gas, + gasPrice = o['gasPrice'], + nonce = o['nonce']) res = await t.txsign(tx_in, wif, o['from'], chain_id=o['chainId']) self.serialized = res.txhex self.coin_txid = res.txid