mirror of
git://holbrook.no/eth-contract-registry
synced 2024-12-22 20:27:32 +01:00
Make gas price, nonce settable, optional send
This commit is contained in:
parent
0fb5f18671
commit
cfeb143564
@ -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.keystore.dict import DictKeystore
|
||||||
from crypto_dev_signer.eth.helper import EthTxExecutor
|
from crypto_dev_signer.eth.helper import EthTxExecutor
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from chainlib.eth.nonce import RPCNonceOracle
|
from chainlib.eth.nonce import (
|
||||||
from chainlib.eth.gas import RPCGasOracle
|
RPCNonceOracle,
|
||||||
|
OverrideNonceOracle,
|
||||||
|
)
|
||||||
|
from chainlib.eth.gas import (
|
||||||
|
RPCGasOracle,
|
||||||
|
OverrideGasOracle,
|
||||||
|
)
|
||||||
from chainlib.eth.connection import EthHTTPConnection
|
from chainlib.eth.connection import EthHTTPConnection
|
||||||
from chainlib.eth.tx import receipt
|
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('-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('-v', action='store_true', help='Be verbose')
|
||||||
argparser.add_argument('-vv', action='store_true', help='Be more 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('--identifier', type=str, action='append', default=[], help='Add contract identifier')
|
argparser.add_argument('--identifier', type=str, action='append', default=[], help='Add contract identifier')
|
||||||
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('--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()
|
args = argparser.parse_args()
|
||||||
@ -70,8 +79,20 @@ signer = EIP155Signer(keystore)
|
|||||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||||
|
|
||||||
rpc = EthHTTPConnection(args.p)
|
rpc = EthHTTPConnection(args.p)
|
||||||
nonce_oracle = RPCNonceOracle(signer_address, rpc)
|
nonce_oracle = None
|
||||||
gas_oracle = RPCGasOracle(rpc, code_callback=Registry.gas)
|
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=Registry.gas)
|
||||||
|
else:
|
||||||
|
gas_oracle = RPCGasOracle(rpc, code_callback=Registry.gas)
|
||||||
|
|
||||||
|
dummy = args.d
|
||||||
|
|
||||||
identifiers = args.identifier
|
identifiers = args.identifier
|
||||||
if 'ContractRegistry' not in identifiers:
|
if 'ContractRegistry' not in identifiers:
|
||||||
identifiers = ['ContractRegistry'] + identifiers
|
identifiers = ['ContractRegistry'] + identifiers
|
||||||
@ -80,20 +101,22 @@ logg.debug('adding identifiers {}'.format(identifiers))
|
|||||||
def main():
|
def main():
|
||||||
c = Registry(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
c = Registry(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||||
(tx_hash_hex, o) = c.constructor(signer_address, identifiers)
|
(tx_hash_hex, o) = c.constructor(signer_address, identifiers)
|
||||||
rpc.do(o)
|
if dummy:
|
||||||
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)
|
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)
|
||||||
|
# TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
|
||||||
|
address = r['contractAddress']
|
||||||
|
|
||||||
sys.exit(0)
|
print(address)
|
||||||
|
else:
|
||||||
|
print(tx_hash_hex)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -12,13 +12,19 @@ import json
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# third-party imports
|
# external imports
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||||
from crypto_dev_signer.eth.helper import EthTxExecutor
|
from crypto_dev_signer.eth.helper import EthTxExecutor
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from chainlib.eth.nonce import RPCNonceOracle
|
from chainlib.eth.nonce import (
|
||||||
from chainlib.eth.gas import RPCGasOracle
|
RPCNonceOracle,
|
||||||
|
OverrideNonceOracle,
|
||||||
|
)
|
||||||
|
from chainlib.eth.gas import (
|
||||||
|
RPCGasOracle,
|
||||||
|
OverrideGasOracle,
|
||||||
|
)
|
||||||
from chainlib.eth.connection import EthHTTPConnection
|
from chainlib.eth.connection import EthHTTPConnection
|
||||||
from chainlib.eth.tx import receipt
|
from chainlib.eth.tx import receipt
|
||||||
from chainlib.eth.constant import ZERO_CONTENT
|
from chainlib.eth.constant import ZERO_CONTENT
|
||||||
@ -41,6 +47,9 @@ argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum ke
|
|||||||
argparser.add_argument('-r', '--registry', dest='r', type=str, help='Contract registry address')
|
argparser.add_argument('-r', '--registry', dest='r', type=str, help='Contract registry address')
|
||||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||||
argparser.add_argument('-vv', action='store_true', help='Be more 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('--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('identifier', type=str, help='Contract registry identifier')
|
argparser.add_argument('identifier', type=str, help='Contract registry identifier')
|
||||||
argparser.add_argument('address', type=str, help='Address to set for identifier')
|
argparser.add_argument('address', type=str, help='Address to set for identifier')
|
||||||
@ -73,11 +82,21 @@ signer = EIP155Signer(keystore)
|
|||||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||||
|
|
||||||
rpc = EthHTTPConnection(args.p)
|
rpc = EthHTTPConnection(args.p)
|
||||||
nonce_oracle = RPCNonceOracle(signer_address, rpc)
|
nonce_oracle = None
|
||||||
gas_oracle = RPCGasOracle(rpc, code_callback=Registry.gas)
|
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=Registry.gas)
|
||||||
|
else:
|
||||||
|
gas_oracle = RPCGasOracle(rpc, code_callback=Registry.gas)
|
||||||
|
|
||||||
|
dummy = args.d
|
||||||
|
|
||||||
registry_address = args.r
|
registry_address = args.r
|
||||||
if registry_address == None:
|
|
||||||
registry_address = args.a
|
|
||||||
if registry_address == None:
|
if registry_address == None:
|
||||||
raise ValueError('Registry address must be set')
|
raise ValueError('Registry address must be set')
|
||||||
identifier = args.identifier
|
identifier = args.identifier
|
||||||
@ -87,14 +106,18 @@ address = args.address
|
|||||||
def main():
|
def main():
|
||||||
c = Registry(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
c = Registry(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||||
(tx_hash_hex, o) = c.set(registry_address, signer_address, identifier, address, chain_spec, ZERO_CONTENT)
|
(tx_hash_hex, o) = c.set(registry_address, signer_address, identifier, address, chain_spec, ZERO_CONTENT)
|
||||||
rpc.do(o)
|
if dummy:
|
||||||
if block_last:
|
print(tx_hash_hex)
|
||||||
r = rpc.wait(tx_hash_hex)
|
print(o)
|
||||||
if r['status'] == 0:
|
else:
|
||||||
sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
|
rpc.do(o)
|
||||||
sys.exit(1)
|
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)
|
print(tx_hash_hex)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
BIN
python/gmon.out
BIN
python/gmon.out
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
confini~=0.3.6rc3
|
confini~=0.3.6rc3
|
||||||
crypto-dev-signer~=0.4.14a17
|
crypto-dev-signer~=0.4.14b1
|
||||||
chainlib~=0.0.2a1
|
chainlib~=0.0.2a8
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = eth-contract-registry
|
name = eth-contract-registry
|
||||||
version = 0.5.4a8
|
version = 0.5.4a9
|
||||||
description = Ethereum Smart Contract key-value registry
|
description = Ethereum Smart Contract key-value registry
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
Loading…
Reference in New Issue
Block a user