mirror of
git://holbrook.no/eth-address-index
synced 2025-01-08 18:17:32 +01:00
Add settable gas price, nonce, optional send
This commit is contained in:
parent
59603b7e50
commit
500d7a7f64
@ -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.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('-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('-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('--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('subject_address', type=str, help='Ethereum address to add declaration to')
|
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')
|
argparser.add_argument('declaration', type=str, help='SHA256 sum of endorsement data to add')
|
||||||
@ -71,9 +80,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 = None
|
||||||
|
if args.nonce != None:
|
||||||
|
nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
|
||||||
|
else:
|
||||||
nonce_oracle = RPCNonceOracle(signer_address, rpc)
|
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)
|
gas_oracle = RPCGasOracle(rpc, code_callback=AddressDeclarator.gas)
|
||||||
|
|
||||||
|
dummy = args.d
|
||||||
|
|
||||||
contract_address = args.a
|
contract_address = args.a
|
||||||
subject_address = args.subject_address
|
subject_address = args.subject_address
|
||||||
declaration = args.declaration
|
declaration = args.declaration
|
||||||
@ -83,6 +103,10 @@ def main():
|
|||||||
c = AddressDeclarator(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
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)
|
(tx_hash_hex, o) = c.add_declaration(contract_address, signer_address, subject_address, declaration)
|
||||||
rpc.do(o)
|
rpc.do(o)
|
||||||
|
if dummy:
|
||||||
|
print(tx_hash_hex)
|
||||||
|
print(o)
|
||||||
|
else:
|
||||||
if block_last:
|
if block_last:
|
||||||
r = rpc.wait(tx_hash_hex)
|
r = rpc.wait(tx_hash_hex)
|
||||||
if r['status'] == 0:
|
if r['status'] == 0:
|
||||||
|
@ -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('--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('owner_description_digest', type=str, help='SHA256 of description metadata of contract deployer')
|
argparser.add_argument('owner_description_digest', type=str, help='SHA256 of description metadata of contract deployer')
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
@ -70,15 +79,30 @@ 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 = None
|
||||||
|
if args.nonce != None:
|
||||||
|
nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
|
||||||
|
else:
|
||||||
nonce_oracle = RPCNonceOracle(signer_address, rpc)
|
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)
|
gas_oracle = RPCGasOracle(rpc, code_callback=AddressDeclarator.gas)
|
||||||
|
|
||||||
|
dummy = args.d
|
||||||
|
|
||||||
initial_description = args.owner_description_digest
|
initial_description = args.owner_description_digest
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
c = AddressDeclarator(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
c = AddressDeclarator(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||||
(tx_hash_hex, o) = c.constructor(signer_address, initial_description)
|
(tx_hash_hex, o) = c.constructor(signer_address, initial_description)
|
||||||
rpc.do(o)
|
rpc.do(o)
|
||||||
|
if dummy:
|
||||||
|
print(tx_hash_hex)
|
||||||
|
print(o)
|
||||||
|
else:
|
||||||
if block_last:
|
if block_last:
|
||||||
r = rpc.wait(tx_hash_hex)
|
r = rpc.wait(tx_hash_hex)
|
||||||
if r['status'] == 0:
|
if r['status'] == 0:
|
||||||
@ -91,8 +115,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print(tx_hash_hex)
|
print(tx_hash_hex)
|
||||||
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -17,8 +17,14 @@ import hashlib
|
|||||||
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 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.erc20 import ERC20
|
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('-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('-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('token_address', type=str, help='Token address to add to index')
|
argparser.add_argument('token_address', type=str, help='Token address to add to index')
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
@ -72,8 +81,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 = None
|
||||||
|
if args.nonce != None:
|
||||||
|
nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
|
||||||
|
else:
|
||||||
nonce_oracle = RPCNonceOracle(signer_address, rpc)
|
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)
|
gas_oracle = RPCGasOracle(rpc, code_callback=TokenUniqueSymbolIndex.gas)
|
||||||
|
|
||||||
|
dummy = args.d
|
||||||
|
|
||||||
contract_address = args.a
|
contract_address = args.a
|
||||||
token_address = args.token_address
|
token_address = args.token_address
|
||||||
|
|
||||||
@ -81,6 +102,10 @@ token_address = args.token_address
|
|||||||
def main():
|
def main():
|
||||||
c = TokenUniqueSymbolIndex(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
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)
|
(tx_hash_hex, o) = c.register(contract_address, signer_address, token_address)
|
||||||
|
if dummy:
|
||||||
|
print(tx_hash_hex)
|
||||||
|
print(o)
|
||||||
|
else:
|
||||||
rpc.do(o)
|
rpc.do(o)
|
||||||
if block_last:
|
if block_last:
|
||||||
r = rpc.wait(tx_hash_hex)
|
r = rpc.wait(tx_hash_hex)
|
||||||
|
@ -16,8 +16,14 @@ import logging
|
|||||||
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 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
|
||||||
|
|
||||||
@ -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('-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('--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()
|
||||||
|
|
||||||
@ -68,14 +77,28 @@ 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 = None
|
||||||
|
if args.nonce != None:
|
||||||
|
nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
|
||||||
|
else:
|
||||||
nonce_oracle = RPCNonceOracle(signer_address, rpc)
|
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)
|
gas_oracle = RPCGasOracle(rpc, code_callback=TokenUniqueSymbolIndex.gas)
|
||||||
|
|
||||||
|
dummy = args.d
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
c = TokenUniqueSymbolIndex(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
c = TokenUniqueSymbolIndex(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||||
(tx_hash_hex, o) = c.constructor(signer_address)
|
(tx_hash_hex, o) = c.constructor(signer_address)
|
||||||
|
if dummy:
|
||||||
|
print(tx_hash_hex)
|
||||||
|
print(o)
|
||||||
|
else:
|
||||||
rpc.do(o)
|
rpc.do(o)
|
||||||
if block_last:
|
if block_last:
|
||||||
r = rpc.wait(tx_hash_hex)
|
r = rpc.wait(tx_hash_hex)
|
||||||
@ -89,8 +112,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print(tx_hash_hex)
|
print(tx_hash_hex)
|
||||||
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -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-address-index
|
name = eth-address-index
|
||||||
version = 0.1.1a7
|
version = 0.1.1a8
|
||||||
description = Signed metadata declarations for ethereum addresses
|
description = Signed metadata declarations for ethereum addresses
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
Loading…
Reference in New Issue
Block a user