proto.eth.contract: TokenAddr -> ContractAddr
This commit is contained in:
parent
2adf35502d
commit
3d70d6eda9
7 changed files with 14 additions and 14 deletions
|
|
@ -195,7 +195,7 @@ class CoinAddr(HiliteStr, InitErrors, MMGenObject):
|
|||
def is_coin_addr(proto, s):
|
||||
return get_obj(CoinAddr, proto=proto, addr=s, silent=True, return_bool=True)
|
||||
|
||||
class TokenAddr(CoinAddr):
|
||||
class ContractAddr(CoinAddr):
|
||||
color = 'blue'
|
||||
|
||||
def ViewKey(proto, viewkey_str):
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class TestSuiteException(Exception): mmcode = 1
|
|||
class TestSuiteSpawnedScriptException(Exception): mmcode = 1
|
||||
|
||||
# 2: yellow hl, message only
|
||||
class InvalidTokenAddress(Exception): mmcode = 2
|
||||
class InvalidContractAddress(Exception): mmcode = 2
|
||||
class UnrecognizedTokenSymbol(Exception): mmcode = 2
|
||||
class TokenNotInBlockchain(Exception): mmcode = 2
|
||||
class TokenNotInWallet(Exception): mmcode = 2
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from . import erigon_sleep
|
|||
from ...util import msg, pp_msg, die
|
||||
from ...base_obj import AsyncInit
|
||||
from ...obj import CoinTxID
|
||||
from ...addr import CoinAddr, TokenAddr
|
||||
from ...addr import CoinAddr, ContractAddr
|
||||
|
||||
def parse_abi(s):
|
||||
return [s[:8]] + [s[8+x*64:8+(x+1)*64] for x in range(len(s[8:])//64)]
|
||||
|
|
@ -101,7 +101,7 @@ class Token(Contract):
|
|||
self.keccak_256 = get_keccak(cfg)
|
||||
self.cfg = cfg
|
||||
self.proto = proto
|
||||
self.addr = TokenAddr(proto, addr)
|
||||
self.addr = ContractAddr(proto, addr)
|
||||
self.rpc = rpc
|
||||
if decimals:
|
||||
assert isinstance(decimals, int), f'decimals param must be int instance, not {type(decimals)}'
|
||||
|
|
|
|||
|
|
@ -183,15 +183,15 @@ class EthereumTokenTwCtl(EthereumTwCtl):
|
|||
|
||||
if self.importing and token_addr:
|
||||
if not is_coin_addr(proto, token_addr):
|
||||
die('InvalidTokenAddress', f'{token_addr!r}: invalid token address')
|
||||
die('InvalidContractAddress', f'{token_addr!r}: invalid token address')
|
||||
else:
|
||||
assert token_addr is None, 'EthereumTokenTwCtl_chk1'
|
||||
token_addr = await self.sym2addr(proto.tokensym) # returns None on failure
|
||||
if not is_coin_addr(proto, token_addr):
|
||||
die('UnrecognizedTokenSymbol', f'Specified token {proto.tokensym!r} could not be resolved!')
|
||||
|
||||
from ....addr import TokenAddr
|
||||
self.token = TokenAddr(proto, token_addr)
|
||||
from ....addr import ContractAddr
|
||||
self.token = ContractAddr(proto, token_addr)
|
||||
|
||||
if self.token not in self.data['tokens']:
|
||||
if self.importing:
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ class OnlineSigned(Signed, TxBase.OnlineSigned):
|
|||
class TokenOnlineSigned(TokenSigned, OnlineSigned):
|
||||
|
||||
def parse_txfile_serialized_data(self):
|
||||
from ....addr import TokenAddr
|
||||
from ....addr import ContractAddr
|
||||
from ..contract import Token
|
||||
OnlineSigned.parse_txfile_serialized_data(self)
|
||||
o = self.txobj
|
||||
assert self.twctl.token == o['to']
|
||||
o['token_addr'] = TokenAddr(self.proto, o['to'])
|
||||
o['token_addr'] = ContractAddr(self.proto, o['to'])
|
||||
o['decimals'] = self.twctl.decimals
|
||||
t = Token(self.cfg, self.proto, o['token_addr'], decimals=o['decimals'])
|
||||
o['amt'] = t.transferdata2amt(o['data'])
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proto.eth.tx.signed: Ethereum signed transaction class
|
|||
|
||||
from ....tx import signed as TxBase
|
||||
from ....obj import CoinTxID, ETHNonce, HexStr
|
||||
from ....addr import CoinAddr, TokenAddr
|
||||
from ....addr import CoinAddr, ContractAddr
|
||||
from .completed import Completed, TokenCompleted
|
||||
|
||||
class Signed(Completed, TxBase.Signed):
|
||||
|
|
@ -40,7 +40,7 @@ class Signed(Completed, TxBase.Signed):
|
|||
'data': HexStr(d['data']) }
|
||||
if o['data'] and not o['to']: # token- or contract-creating transaction
|
||||
# NB: could be a non-token contract address:
|
||||
o['token_addr'] = TokenAddr(self.proto, etx.creates.hex())
|
||||
o['token_addr'] = ContractAddr(self.proto, etx.creates.hex())
|
||||
self.disable_fee_check = True
|
||||
txid = CoinTxID(etx.hash.hex())
|
||||
assert txid == self.coin_txid, "txid in tx.serialized doesn't match value in MMGen transaction file"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import json
|
|||
from ....tx import unsigned as TxBase
|
||||
from ....util import msg, msg_r, die
|
||||
from ....obj import CoinTxID, ETHNonce, Int, HexStr
|
||||
from ....addr import CoinAddr, TokenAddr
|
||||
from ....addr import CoinAddr, ContractAddr
|
||||
from ..contract import Token
|
||||
from .completed import Completed, TokenCompleted
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ class Unsigned(Completed, TxBase.Unsigned):
|
|||
if not self.is_swap:
|
||||
raise ValueError('contract-creating transaction cannot have to-address')
|
||||
else:
|
||||
self.txobj['token_addr'] = TokenAddr(self.proto, etx.creates.hex())
|
||||
self.txobj['token_addr'] = ContractAddr(self.proto, etx.creates.hex())
|
||||
|
||||
async def sign(self, tx_num_str, keys): # return TX object or False; don't exit or raise exception
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ class TokenUnsigned(TokenCompleted, Unsigned):
|
|||
def parse_txfile_serialized_data(self):
|
||||
d = Unsigned.parse_txfile_serialized_data(self)
|
||||
o = self.txobj
|
||||
o['token_addr'] = TokenAddr(self.proto, d['token_addr'])
|
||||
o['token_addr'] = ContractAddr(self.proto, d['token_addr'])
|
||||
o['decimals'] = Int(d['decimals'])
|
||||
o['token_to'] = o['to']
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue