commit 500d7a7f64c893a34cc11a1dc1338d0452a8b47f
parent 59603b7e50a708ce6f9f0dc59dd8dd7f08a870e0
Author: nolash <dev@holbrook.no>
Date: Mon, 12 Apr 2021 16:54:35 +0200
Add settable gas price, nonce, optional send
Diffstat:
6 files changed, 158 insertions(+), 66 deletions(-)
diff --git a/python/eth_address_declarator/runnable/add.py b/python/eth_address_declarator/runnable/add.py
@@ -16,8 +16,14 @@ from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
from crypto_dev_signer.keystore.dict import DictKeystore
from crypto_dev_signer.eth.helper import EthTxExecutor
from chainlib.chain import ChainSpec
-from chainlib.eth.nonce import RPCNonceOracle
-from chainlib.eth.gas import RPCGasOracle
+from chainlib.eth.nonce import (
+ RPCNonceOracle,
+ OverrideNonceOracle,
+ )
+from chainlib.eth.gas import (
+ RPCGasOracle,
+ OverrideGasOracle,
+ )
from chainlib.eth.connection import EthHTTPConnection
from chainlib.eth.tx import receipt
@@ -39,6 +45,9 @@ argparser.add_argument('-a', '--contract-address', dest='a', type=str, help='Add
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
+argparser.add_argument('-d', action='store_true', help='Dump RPC calls to terminal and do not send')
+argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price')
+argparser.add_argument('--nonce', type=int, help='Override transaction nonce')
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
argparser.add_argument('subject_address', type=str, help='Ethereum address to add declaration to')
argparser.add_argument('declaration', type=str, help='SHA256 sum of endorsement data to add')
@@ -71,8 +80,19 @@ signer = EIP155Signer(keystore)
chain_spec = ChainSpec.from_chain_str(args.i)
rpc = EthHTTPConnection(args.p)
-nonce_oracle = RPCNonceOracle(signer_address, rpc)
-gas_oracle = RPCGasOracle(rpc, code_callback=AddressDeclarator.gas)
+nonce_oracle = None
+if args.nonce != None:
+ nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
+else:
+ nonce_oracle = RPCNonceOracle(signer_address, rpc)
+
+gas_oracle = None
+if args.gas_price !=None:
+ gas_oracle = OverrideGasOracle(price=args.gas_price, conn=rpc, code_callback=AddressDeclarator.gas)
+else:
+ gas_oracle = RPCGasOracle(rpc, code_callback=AddressDeclarator.gas)
+
+dummy = args.d
contract_address = args.a
subject_address = args.subject_address
@@ -83,13 +103,17 @@ def main():
c = AddressDeclarator(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.add_declaration(contract_address, signer_address, subject_address, declaration)
rpc.do(o)
- if block_last:
- r = rpc.wait(tx_hash_hex)
- if r['status'] == 0:
- sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
- sys.exit(1)
-
- print(tx_hash_hex)
+ if dummy:
+ print(tx_hash_hex)
+ print(o)
+ else:
+ if block_last:
+ r = rpc.wait(tx_hash_hex)
+ if r['status'] == 0:
+ sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
+ sys.exit(1)
+
+ print(tx_hash_hex)
if __name__ == '__main__':
diff --git a/python/eth_address_declarator/runnable/deploy.py b/python/eth_address_declarator/runnable/deploy.py
@@ -17,8 +17,14 @@ from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
from crypto_dev_signer.keystore.dict import DictKeystore
from crypto_dev_signer.eth.helper import EthTxExecutor
from chainlib.chain import ChainSpec
-from chainlib.eth.nonce import RPCNonceOracle
-from chainlib.eth.gas import RPCGasOracle
+from chainlib.eth.nonce import (
+ RPCNonceOracle,
+ OverrideNonceOracle,
+ )
+from chainlib.eth.gas import (
+ RPCGasOracle,
+ OverrideGasOracle,
+ )
from chainlib.eth.connection import EthHTTPConnection
from chainlib.eth.tx import receipt
@@ -39,6 +45,9 @@ argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:et
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
+argparser.add_argument('-d', action='store_true', help='Dump RPC calls to terminal and do not send')
+argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price')
+argparser.add_argument('--nonce', type=int, help='Override transaction nonce')
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
argparser.add_argument('owner_description_digest', type=str, help='SHA256 of description metadata of contract deployer')
args = argparser.parse_args()
@@ -70,8 +79,19 @@ signer = EIP155Signer(keystore)
chain_spec = ChainSpec.from_chain_str(args.i)
rpc = EthHTTPConnection(args.p)
-nonce_oracle = RPCNonceOracle(signer_address, rpc)
-gas_oracle = RPCGasOracle(rpc, code_callback=AddressDeclarator.gas)
+nonce_oracle = None
+if args.nonce != None:
+ nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
+else:
+ nonce_oracle = RPCNonceOracle(signer_address, rpc)
+
+gas_oracle = None
+if args.gas_price !=None:
+ gas_oracle = OverrideGasOracle(price=args.gas_price, conn=rpc, code_callback=AddressDeclarator.gas)
+else:
+ gas_oracle = RPCGasOracle(rpc, code_callback=AddressDeclarator.gas)
+
+dummy = args.d
initial_description = args.owner_description_digest
@@ -79,19 +99,21 @@ def main():
c = AddressDeclarator(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.constructor(signer_address, initial_description)
rpc.do(o)
- if block_last:
- r = rpc.wait(tx_hash_hex)
- if r['status'] == 0:
- sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
- sys.exit(1)
- # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
- address = r['contractAddress']
-
- print(address)
- else:
+ if dummy:
print(tx_hash_hex)
-
- sys.exit(0)
+ print(o)
+ else:
+ if block_last:
+ r = rpc.wait(tx_hash_hex)
+ if r['status'] == 0:
+ sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
+ sys.exit(1)
+ # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
+ address = r['contractAddress']
+
+ print(address)
+ else:
+ print(tx_hash_hex)
if __name__ == '__main__':
diff --git a/python/eth_token_index/runnable/add.py b/python/eth_token_index/runnable/add.py
@@ -17,8 +17,14 @@ import hashlib
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
from crypto_dev_signer.keystore.dict import DictKeystore
from chainlib.chain import ChainSpec
-from chainlib.eth.nonce import RPCNonceOracle
-from chainlib.eth.gas import RPCGasOracle
+from chainlib.eth.nonce import (
+ RPCNonceOracle,
+ OverrideNonceOracle,
+ )
+from chainlib.eth.gas import (
+ RPCGasOracle,
+ OverrideGasOracle,
+ )
from chainlib.eth.connection import EthHTTPConnection
from chainlib.eth.tx import receipt
from chainlib.eth.erc20 import ERC20
@@ -41,6 +47,9 @@ argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:et
argparser.add_argument('-a', '--contract-address', dest='a', required=True, type=str, help='Token index contract address')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
+argparser.add_argument('-d', action='store_true', help='Dump RPC calls to terminal and do not send')
+argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price')
+argparser.add_argument('--nonce', type=int, help='Override transaction nonce')
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
argparser.add_argument('token_address', type=str, help='Token address to add to index')
args = argparser.parse_args()
@@ -72,8 +81,20 @@ signer = EIP155Signer(keystore)
chain_spec = ChainSpec.from_chain_str(args.i)
rpc = EthHTTPConnection(args.p)
-nonce_oracle = RPCNonceOracle(signer_address, rpc)
-gas_oracle = RPCGasOracle(rpc, code_callback=TokenUniqueSymbolIndex.gas)
+nonce_oracle = None
+if args.nonce != None:
+ nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
+else:
+ nonce_oracle = RPCNonceOracle(signer_address, rpc)
+
+gas_oracle = None
+if args.gas_price !=None:
+ gas_oracle = OverrideGasOracle(price=args.gas_price, conn=rpc, code_callback=TokenUniqueSymbolIndex.gas)
+else:
+ gas_oracle = RPCGasOracle(rpc, code_callback=TokenUniqueSymbolIndex.gas)
+
+dummy = args.d
+
contract_address = args.a
token_address = args.token_address
@@ -81,21 +102,25 @@ token_address = args.token_address
def main():
c = TokenUniqueSymbolIndex(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.register(contract_address, signer_address, token_address)
- rpc.do(o)
- if block_last:
- r = rpc.wait(tx_hash_hex)
- if r['status'] == 0:
- sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
- sys.exit(1)
-
- c = ERC20(chain_spec)
- o = c.symbol(token_address)
- r = rpc.do(o)
- token_symbol = ERC20.parse_symbol(r)
-
- logg.info('added token {} at {} to token index {}'.format(token_symbol, token_address, contract_address))
-
- print(tx_hash_hex)
+ if dummy:
+ print(tx_hash_hex)
+ print(o)
+ else:
+ rpc.do(o)
+ if block_last:
+ r = rpc.wait(tx_hash_hex)
+ if r['status'] == 0:
+ sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
+ sys.exit(1)
+
+ c = ERC20(chain_spec)
+ o = c.symbol(token_address)
+ r = rpc.do(o)
+ token_symbol = ERC20.parse_symbol(r)
+
+ logg.info('added token {} at {} to token index {}'.format(token_symbol, token_address, contract_address))
+
+ print(tx_hash_hex)
if __name__ == '__main__':
diff --git a/python/eth_token_index/runnable/deploy.py b/python/eth_token_index/runnable/deploy.py
@@ -16,8 +16,14 @@ import logging
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
from crypto_dev_signer.keystore.dict import DictKeystore
from chainlib.chain import ChainSpec
-from chainlib.eth.nonce import RPCNonceOracle
-from chainlib.eth.gas import RPCGasOracle
+from chainlib.eth.nonce import (
+ RPCNonceOracle,
+ OverrideNonceOracle,
+ )
+from chainlib.eth.gas import (
+ RPCGasOracle,
+ OverrideGasOracle,
+ )
from chainlib.eth.connection import EthHTTPConnection
from chainlib.eth.tx import receipt
@@ -38,6 +44,9 @@ argparser.add_argument('-ww', action='store_true', help='Wait for every transact
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
+argparser.add_argument('-d', action='store_true', help='Dump RPC calls to terminal and do not send')
+argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price')
+argparser.add_argument('--nonce', type=int, help='Override transaction nonce')
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
args = argparser.parse_args()
@@ -68,28 +77,40 @@ signer = EIP155Signer(keystore)
chain_spec = ChainSpec.from_chain_str(args.i)
rpc = EthHTTPConnection(args.p)
-nonce_oracle = RPCNonceOracle(signer_address, rpc)
-gas_oracle = RPCGasOracle(rpc, code_callback=TokenUniqueSymbolIndex.gas)
+nonce_oracle = None
+if args.nonce != None:
+ nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
+else:
+ nonce_oracle = RPCNonceOracle(signer_address, rpc)
+gas_oracle = None
+if args.gas_price !=None:
+ gas_oracle = OverrideGasOracle(price=args.gas_price, conn=rpc, code_callback=TokenUniqueSymbolIndex.gas)
+else:
+ gas_oracle = RPCGasOracle(rpc, code_callback=TokenUniqueSymbolIndex.gas)
+
+dummy = args.d
def main():
c = TokenUniqueSymbolIndex(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.constructor(signer_address)
- rpc.do(o)
- if block_last:
- r = rpc.wait(tx_hash_hex)
- if r['status'] == 0:
- sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
- sys.exit(1)
- # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
- address = r['contractAddress']
-
- print(address)
- else:
+ if dummy:
print(tx_hash_hex)
-
- sys.exit(0)
+ print(o)
+ else:
+ rpc.do(o)
+ if block_last:
+ r = rpc.wait(tx_hash_hex)
+ if r['status'] == 0:
+ sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
+ sys.exit(1)
+ # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
+ address = r['contractAddress']
+
+ print(address)
+ else:
+ print(tx_hash_hex)
if __name__ == '__main__':
diff --git a/python/requirements.txt b/python/requirements.txt
@@ -1,3 +1,3 @@
confini~=0.3.6rc3
-crypto-dev-signer~=0.4.14a17
-chainlib~=0.0.2a1
+crypto-dev-signer~=0.4.14b1
+chainlib~=0.0.2a8
diff --git a/python/setup.cfg b/python/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = eth-address-index
-version = 0.1.1a7
+version = 0.1.1a8
description = Signed metadata declarations for ethereum addresses
author = Louis Holbrook
author_email = dev@holbrook.no