Refactor RPC/IPC argument processing

pull/33/head
Bernhard Mueller 7 years ago
parent 16b737ab5e
commit a6d877c53b
  1. 37
      myth
  2. 6
      mythril/ether/contractstorage.py
  3. 2
      signatures.json

37
myth

@ -103,6 +103,24 @@ elif (args.hash):
print("0x" + utils.sha3(args.hash)[:4].hex())
sys.exit()
# Establish RPC/IPC connection if necessary
if (args.address or len(args.solidity_file) or args.init_db):
if args.ipc:
eth = EthIpc()
else:
if args.infura_mainnet:
eth = EthJsonRpc('mainnet.infura.io', 443, True)
elif args.infura_rinkeby:
eth = EthJsonRpc('rinkeby.infura.io', 443, True)
elif args.infura_kovan:
eth = EthJsonRpc('kovan.infura.io', 443, True)
elif args.infura_ropsten:
eth = EthJsonRpc('ropsten.infura.io', 443, True)
else:
eth = EthJsonRpc(args.rpchost, args.rpcport, args.rpctls)
# Database search ops
if args.search or args.init_db:
@ -117,27 +135,10 @@ if args.search or args.init_db:
exitWithError("Syntax error in search expression.")
elif (args.init_db):
contract_storage.initialize(args.rpchost, args.rpcport, args.rpctls, args.sync_all, args.ipc)
contract_storage.initialize(eth, args.sync_all)
sys.exit()
# Establish RPC/IPC connection if necessary
if (args.address or len(args.solidity_file)):
if args.ipc:
eth = EthIpc()
else:
if args.infura_mainnet:
eth = EthJsonRpc('mainnet.infura.io', 443, True)
elif args.infura_rinkeby:
eth = EthJsonRpc('rinkeby.infura.io', 443, True)
elif args.infura_kovan:
eth = EthJsonRpc('kovan.infura.io', 443, True)
elif args.infura_ropsten:
eth = EthJsonRpc('ropsten.infura.io', 443, True)
else:
eth = EthJsonRpc(args.rpchost, args.rpcport, args.rpctls)
# If no function signature file exists, create it. Function signatures from Solidity source code are added automatically.

@ -47,11 +47,7 @@ class ContractStorage(persistent.Persistent):
return self.contracts[contract_hash]
def initialize(self, rpchost, rpcport, rpctls, sync_all, ipc):
if ipc:
eth = EthIpc()
else:
eth = EthJsonRpc(rpchost, rpcport, rpctls)
def initialize(self, eth, sync_all):
if self.last_block:
blockNum = self.last_block

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save