From d0d17a4c0fc154bd903a248c3b0615443e6115e2 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 26 Apr 2025 10:38:55 +0000 Subject: [PATCH] proto.eth.contract.Contract: add initializer --- mmgen/proto/eth/contract.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mmgen/proto/eth/contract.py b/mmgen/proto/eth/contract.py index 58a286af..2a33f4ea 100755 --- a/mmgen/proto/eth/contract.py +++ b/mmgen/proto/eth/contract.py @@ -36,6 +36,14 @@ def parse_abi(s): class Contract: + def __init__(self, cfg, proto, addr, *, rpc=None): + from ...util2 import get_keccak + self.keccak_256 = get_keccak(cfg) + self.cfg = cfg + self.proto = proto + self.addr = ContractAddr(proto, addr) + self.rpc = rpc + def strip(self, s): return ''.join([chr(b) for b in s if 32 <= b <= 127]).strip() @@ -96,13 +104,8 @@ class Contract: class Token(Contract): - def __init__(self, cfg, proto, addr, *, decimals=None, rpc=None): - from ...util2 import get_keccak - self.keccak_256 = get_keccak(cfg) - self.cfg = cfg - self.proto = proto - self.addr = ContractAddr(proto, addr) - self.rpc = rpc + def __init__(self, cfg, proto, addr, *, rpc=None, decimals=None): + Contract.__init__(self, cfg, proto, addr, rpc=rpc) if decimals: assert isinstance(decimals, int), f'decimals param must be int instance, not {type(decimals)}' self.decimals = decimals