Remove ununsed utility methods

pull/22/head
Bernhard Mueller 7 years ago
parent ba97b30894
commit db929fe4ab
  1. 7
      myth
  2. 42
      mythril/ether/util.py

@ -14,6 +14,7 @@ from mythril.rpc.client import EthJsonRpc
from mythril.ipc.client import EthIpc
from ethereum import utils
from laser.ethereum import laserfree
import yaml
import logging
import binascii
import sys
@ -62,12 +63,18 @@ options.add_argument('--ipc', help='use IPC interface instead of RPC', action='s
options.add_argument('--enable-physics', type=bool, default=False, help='enable graph physics simulation')
options.add_argument('-v', type=int, help='log level (0-2)', metavar='LOG_LEVEL')
# Get config values
try:
db_dir = os.environ['DB_DIR']
except KeyError:
db_dir = None
try:
solc_binary = os.environ['SOLC']
except KeyError:
solc_binary = 'solc'
args = parser.parse_args()
if not (args.search or args.init_db or args.hash or args.disassemble or args.graph or args.xrefs or args.fire_lasers or args.trace):

@ -1,5 +1,3 @@
from mythril.rpc.client import EthJsonRpc
from mythril.ipc.client import EthIpc
from ethereum.abi import encode_abi, encode_int
from ethereum.utils import zpad
from ethereum.abi import method_id
@ -21,48 +19,8 @@ def compile_solidity(file):
return m.group(1)
def bytecode_from_blockchain(creation_tx_hash, ipc, rpc_host='127.0.0.1', rpc_port=8545, rpc_tls=False):
"""Load bytecode from a local node via
creation_tx_hash = ID of transaction that created the contract.
"""
if ipc:
eth = EthIpc()
else:
eth = EthJsonRpc(rpc_host, rpc_port, rpc_tls)
trace = eth.traceTransaction(creation_tx_hash)
if trace['returnValue']:
return trace['returnValue']
raise RuntimeError("Transaction trace didn't return any bytecode")
def encode_calldata(func_name, arg_types, args):
mid = method_id(func_name, arg_types)
function_selector = zpad(encode_int(mid), 4)
args = encode_abi(arg_types, args)
return "0x" + function_selector.hex() + args.hex()
def raw_bytes_to_file(filename, bytestring):
with open(filename, 'wb') as f:
f.write(bytestring)
def file_to_raw_bytes(filename):
with open(filename, 'rb') as f:
data = f.read()
return data
def string_to_file(filename, string):
with open(filename, 'w') as f:
f.write(string)
def file_to_string(filename):
with open(filename, 'r') as f:
data = f.read()
return data

Loading…
Cancel
Save