Add missing import in checksum cli
This commit is contained in:
parent
df4d62e3e7
commit
29f4fdb777
@ -108,7 +108,7 @@ class ERC20(TxFactory):
|
||||
|
||||
def transfer_from(self, contract_address, sender_address, holder_address, recipient_address, value, tx_format=TxFormat.JSONRPC):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('transfer')
|
||||
enc.method('transferFrom')
|
||||
enc.typ(ABIContractType.ADDRESS)
|
||||
enc.typ(ABIContractType.ADDRESS)
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
@ -122,12 +122,12 @@ class ERC20(TxFactory):
|
||||
return tx
|
||||
|
||||
|
||||
def approve(self, contract_address, sender_address, recipient_address, value, tx_format=TxFormat.JSONRPC):
|
||||
def approve(self, contract_address, sender_address, spender_address, value, tx_format=TxFormat.JSONRPC):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('approve')
|
||||
enc.typ(ABIContractType.ADDRESS)
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.address(recipient_address)
|
||||
enc.address(spender_address)
|
||||
enc.uint256(value)
|
||||
data = add_0x(enc.get())
|
||||
tx = self.template(sender_address, contract_address, use_nonce=True)
|
||||
|
@ -94,11 +94,13 @@ class OverrideGasOracle(RPCGasOracle):
|
||||
self.limit = limit
|
||||
self.price = price
|
||||
|
||||
if self.limit == None or self.price == None:
|
||||
price_conn = None
|
||||
|
||||
if self.limit == None or self.price == None:
|
||||
if self.price == None:
|
||||
price_conn = conn
|
||||
logg.debug('override gas oracle with rpc fallback; price {} limit {}'.format(self.price, self.limit))
|
||||
|
||||
super(OverrideGasOracle, self).__init__(price_conn, code_callback)
|
||||
|
||||
|
||||
|
@ -1,8 +1,15 @@
|
||||
# standard imports
|
||||
import sys
|
||||
|
||||
# external imports
|
||||
from hexathon import strip_0x
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
|
||||
def main():
|
||||
print(to_checksum_address(strip_0x(sys.argv[1])))
|
||||
|
||||
print(to_checksum_address(sys.argv[1]))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -60,7 +60,7 @@ elif args.v:
|
||||
|
||||
conn = EthHTTPConnection(args.p)
|
||||
|
||||
tx_hash = args.tx_hash
|
||||
tx_hash = add_0x(args.tx_hash)
|
||||
|
||||
|
||||
class Status(enum.Enum):
|
||||
|
@ -104,7 +104,7 @@ def _max_gas(code=None):
|
||||
return 8000000
|
||||
|
||||
gas_oracle = None
|
||||
if args.price != None:
|
||||
if args.gas_price != None or args.gas_limit != None:
|
||||
gas_oracle = OverrideGasOracle(price=args.gas_price, limit=args.gas_limit)
|
||||
else:
|
||||
gas_oracle = RPCGasOracle(conn, code_callback=_max_gas)
|
||||
|
@ -14,6 +14,7 @@ from rlp import decode as rlp_decode
|
||||
from rlp import encode as rlp_encode
|
||||
from crypto_dev_signer.eth.transaction import EIP155Transaction
|
||||
from crypto_dev_signer.encoding import public_key_to_address
|
||||
from potaahto.symbols import snake_and_camel
|
||||
|
||||
|
||||
# local imports
|
||||
@ -30,6 +31,7 @@ from chainlib.jsonrpc import jsonrpc_template
|
||||
logg = logging.getLogger().getChild(__name__)
|
||||
|
||||
|
||||
|
||||
class TxFormat(enum.IntEnum):
|
||||
DICT = 0x00
|
||||
RAW = 0x01
|
||||
@ -271,8 +273,6 @@ class TxFactory:
|
||||
|
||||
class Tx:
|
||||
|
||||
re_camel_snake = re.compile(r'([a-z0-9]+)([A-Z])')
|
||||
|
||||
# TODO: force tx type schema parser (whether expect hex or int etc)
|
||||
def __init__(self, src, block=None, rcpt=None):
|
||||
logg.debug('src {}'.format(src))
|
||||
@ -324,7 +324,7 @@ class Tx:
|
||||
if inpt != '0x':
|
||||
inpt = strip_0x(inpt)
|
||||
else:
|
||||
inpt = None
|
||||
inpt = ''
|
||||
self.payload = inpt
|
||||
|
||||
to = src['to']
|
||||
@ -349,29 +349,14 @@ class Tx:
|
||||
|
||||
@classmethod
|
||||
def src_normalize(self, src):
|
||||
src_normal = {}
|
||||
for k in src.keys():
|
||||
s = ''
|
||||
right_pos = 0
|
||||
for m in self.re_camel_snake.finditer(k):
|
||||
g = m.group(0)
|
||||
s += g[:len(g)-1]
|
||||
s += '_' + g[len(g)-1].lower()
|
||||
right_pos = m.span()[1]
|
||||
|
||||
|
||||
s += k[right_pos:]
|
||||
src_normal[k] = src[k]
|
||||
if s != k:
|
||||
logg.debug('adding snake {} for camel {}'.format(s, k))
|
||||
src_normal[s] = src[k]
|
||||
|
||||
return src_normal
|
||||
|
||||
return snake_and_camel(src)
|
||||
|
||||
def apply_receipt(self, rcpt):
|
||||
logg.debug('rcpt {}'.format(rcpt))
|
||||
try:
|
||||
status_number = int(rcpt['status'], 16)
|
||||
except TypeError:
|
||||
status_number = int(rcpt['status'])
|
||||
if status_number == 1:
|
||||
self.status = Status.SUCCESS
|
||||
elif status_number == 0:
|
||||
@ -383,7 +368,10 @@ class Tx:
|
||||
if contract_address != None:
|
||||
self.contract = contract_address
|
||||
self.logs = rcpt['logs']
|
||||
try:
|
||||
self.gas_used = int(rcpt['gasUsed'], 16)
|
||||
except TypeError:
|
||||
self.gas_used = int(rcpt['gasUsed'])
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -122,7 +122,6 @@ class TestRPCConnection(RPCConnection):
|
||||
|
||||
def eth_getTransactionReceipt(self, p):
|
||||
rcpt = self.backend.get_transaction_receipt(p[0])
|
||||
# TODO: use camelcase to snake case converter
|
||||
if rcpt.get('block_number') == None:
|
||||
rcpt['block_number'] = rcpt['blockNumber']
|
||||
else:
|
||||
|
@ -1,5 +1,5 @@
|
||||
crypto-dev-signer~=0.4.14a17
|
||||
crypto-dev-signer~=0.4.14b2
|
||||
pysha3==1.0.2
|
||||
hexathon~=0.0.1a7
|
||||
websocket-client==0.57.0
|
||||
redis==3.5.3
|
||||
potaahto~=0.0.1a1
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = chainlib
|
||||
version = 0.0.2a8
|
||||
version = 0.0.2a14
|
||||
description = Generic blockchain access library and tooling
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
|
@ -3,7 +3,7 @@ import unittest
|
||||
import datetime
|
||||
|
||||
# external imports
|
||||
from chainlib.stat import Stat
|
||||
from chainlib.stat import ChainStat
|
||||
from chainlib.eth.block import Block
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user