Class: Web3::Eth::CallTrace
- Inherits:
-
Object
- Object
- Web3::Eth::CallTrace
show all
- Includes:
- Utility
- Defined in:
- lib/web3ethereum/call_trace.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Utility
#from_hex, #hex, #remove_0x_head, #wei_to_ether
Constructor Details
#initialize(trace_data) ⇒ CallTrace
Returns a new instance of CallTrace.
10
11
12
13
14
15
16
17
18
|
# File 'lib/web3ethereum/call_trace.rb', line 10
def initialize trace_data
@raw_data = trace_data
trace_data.each do |k, v|
self.instance_variable_set("@#{k}", v)
self.class.send(:define_method, k, proc {self.instance_variable_get("@#{k}")})
end
end
|
Instance Attribute Details
#raw_data ⇒ Object
Returns the value of attribute raw_data.
8
9
10
|
# File 'lib/web3ethereum/call_trace.rb', line 8
def raw_data
@raw_data
end
|
Instance Method Details
#balance_ether ⇒ Object
77
78
79
|
# File 'lib/web3ethereum/call_trace.rb', line 77
def balance_ether
wei_to_ether action['balance'].to_i(16)
end
|
62
63
64
65
66
67
68
69
70
|
# File 'lib/web3ethereum/call_trace.rb', line 62
def call_input_data
if creates && input
input[/a165627a7a72305820\w{64}0029(\w*)/,1]
elsif input && input.length>10
input[10..input.length]
else
[]
end
end
|
#creates ⇒ Object
56
57
58
|
# File 'lib/web3ethereum/call_trace.rb', line 56
def creates
action && result && action['init'] && result['address']
end
|
#from ⇒ Object
28
29
30
|
# File 'lib/web3ethereum/call_trace.rb', line 28
def from
action['from']
end
|
#gas_used ⇒ Object
44
45
46
|
# File 'lib/web3ethereum/call_trace.rb', line 44
def gas_used
result && from_hex(result['gasUsed'])
end
|
36
37
38
|
# File 'lib/web3ethereum/call_trace.rb', line 36
def input
action['input'] || action['init']
end
|
#method_hash ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/web3ethereum/call_trace.rb', line 48
def method_hash
if input && input.length>=10
input[2...10]
else
nil
end
end
|
#output ⇒ Object
40
41
42
|
# File 'lib/web3ethereum/call_trace.rb', line 40
def output
result && result['output']
end
|
#success? ⇒ Boolean
81
82
83
|
# File 'lib/web3ethereum/call_trace.rb', line 81
def success?
!raw_data['error']
end
|
#suicide? ⇒ Boolean
73
74
75
|
# File 'lib/web3ethereum/call_trace.rb', line 73
def suicide?
type=='suicide'
end
|
#to ⇒ Object
32
33
34
|
# File 'lib/web3ethereum/call_trace.rb', line 32
def to
action['to']
end
|
#value_eth ⇒ Object
24
25
26
|
# File 'lib/web3ethereum/call_trace.rb', line 24
def value_eth
wei_to_ether from_hex action['value']
end
|
#value_wei ⇒ Object
20
21
22
|
# File 'lib/web3ethereum/call_trace.rb', line 20
def value_wei
from_hex action['value']
end
|