From 6bbc50b5c82e622ed249900ef6ffc9004ab5eec5 Mon Sep 17 00:00:00 2001 From: Alexander Kolotov Date: Sat, 17 Mar 2018 21:32:14 +0300 Subject: [PATCH] switched to get information from testing environment database --- erc20/get_balance_foreign_ipc.py | 14 +++++++-- erc20/get_transaction_foreign.py | 40 ++++++++++++++++++++++++ erc20/get_transaction_receipt_foreign.py | 8 ++++- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100755 erc20/get_transaction_foreign.py diff --git a/erc20/get_balance_foreign_ipc.py b/erc20/get_balance_foreign_ipc.py index e652135..105ce01 100755 --- a/erc20/get_balance_foreign_ipc.py +++ b/erc20/get_balance_foreign_ipc.py @@ -1,9 +1,19 @@ #!/opt/anaconda3/bin/python from web3 import Web3 -#from web3.utils.transactions import wait_for_transaction_receipt +from toml import load +import sys -web3 = Web3(Web3.IPCProvider('/home/koal/parity/PoA_foreign/jsonrpc.ipc')) +test_env_db = '/home/koal/parity/bridge/test_env_db.toml' +try: + test_env = load(test_env_db) +except: + sys.exit(1) + +bridge_config = load(test_env['bridge_config']) + +IPC_file = bridge_config['foreign']['ipc'] +web3 = Web3(Web3.IPCProvider(IPC_file)) signer = web3.toChecksumAddress("0xf3ee321df87781864f46f6464e764c2827fca73b") sender = web3.toChecksumAddress("0x37a30534da3d53aa1867adde26e114a3161b2b12") diff --git a/erc20/get_transaction_foreign.py b/erc20/get_transaction_foreign.py new file mode 100755 index 0000000..ed864bd --- /dev/null +++ b/erc20/get_transaction_foreign.py @@ -0,0 +1,40 @@ +#!/opt/anaconda3/bin/python + +from web3 import Web3 +from web3.utils.datastructures import AttributeDict +from toml import load +import json +import sys +import hexbytes + +test_env_db = '/home/koal/parity/bridge/test_env_db.toml' +try: + test_env = load(test_env_db) +except: + sys.exit(1) + +bridge_config = load(test_env['bridge_config']) + +_IPC_file = bridge_config['foreign']['ipc'] +web3 = Web3(Web3.IPCProvider(_IPC_file)) +#web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:48545")) + +if (len(sys.argv) == 2): + txHash = sys.argv[1] +else: + sys.exit(1) + +class ReceiptEncoder(json.JSONEncoder): + def default(self, obj): + if type(obj) == hexbytes.HexBytes: + return obj.hex() + elif type(obj) == AttributeDict: + return dict(obj) + # Let the base class default method raise the TypeError + return json.JSONEncoder.default(self, obj) + +#print(type(dict(web3.eth.getTransactionReceipt(txHash))['blockHash'])) +print(json.dumps(dict(web3.eth.getTransaction(txHash)), cls=ReceiptEncoder, indent=2)) +#print(json.dumps(dict(web3.eth.getTransactionReceipt(txHash)))) + +sys.exit(0) diff --git a/erc20/get_transaction_receipt_foreign.py b/erc20/get_transaction_receipt_foreign.py index de2447c..fd89889 100755 --- a/erc20/get_transaction_receipt_foreign.py +++ b/erc20/get_transaction_receipt_foreign.py @@ -7,7 +7,13 @@ import json import sys import hexbytes -bridge_config = load('/home/koal/parity/bridge/erc20.toml') +test_env_db = '/home/koal/parity/bridge/test_env_db.toml' +try: + test_env = load(test_env_db) +except: + sys.exit(1) + +bridge_config = load(test_env['bridge_config']) _IPC_file = bridge_config['foreign']['ipc'] web3 = Web3(Web3.IPCProvider(_IPC_file))