Class: Web3::Eth::Debug::TransactionCallTrace
- Inherits:
-
Object
- Object
- Web3::Eth::Debug::TransactionCallTrace
show all
- Includes:
- Utility
- Defined in:
- lib/web3/eth/debug/transaction_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(raw, traceAddress = [], parent = nil) ⇒ TransactionCallTrace
Returns a new instance of TransactionCallTrace.
8
9
10
11
12
13
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 8
def initialize raw, traceAddress = [], parent = nil
@raw_data = raw
@traceAddress = traceAddress
@parent = parent
@calls = raw['calls'] ? raw['calls'].each_with_index.map{|c,i| TransactionCallTrace.new c, (traceAddress + [i]), self } : []
end
|
Instance Attribute Details
#calls ⇒ Object
Returns the value of attribute calls.
7
8
9
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 7
def calls
@calls
end
|
#parent ⇒ Object
Returns the value of attribute parent.
7
8
9
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 7
def parent
@parent
end
|
#raw_data ⇒ Object
Returns the value of attribute raw_data.
7
8
9
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 7
def raw_data
@raw_data
end
|
#traceAddress ⇒ Object
Returns the value of attribute traceAddress.
7
8
9
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 7
def traceAddress
@traceAddress
end
|
Instance Method Details
#action ⇒ Object
20
21
22
23
24
25
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 20
def action
{
'callType' => type.downcase,
'address' => ( suicide? ? parent.smart_contract : raw_data['to'])
}
end
|
93
94
95
96
97
98
99
100
101
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 93
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
31
32
33
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 31
def creates
(type=='CREATE' || type=='CREATE2') ? to : nil
end
|
#error ⇒ Object
83
84
85
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 83
def error
raw_data['error']
end
|
#from ⇒ Object
47
48
49
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 47
def from
raw_data['from']
end
|
#gas ⇒ Object
63
64
65
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 63
def gas
from_hex raw_data['gas']
end
|
#gas_used ⇒ Object
67
68
69
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 67
def gas_used
from_hex raw_data['gasUsed']
end
|
71
72
73
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 71
def input
raw_data['input']
end
|
#method_hash ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 35
def method_hash
if input && input.length>=10
input[2...10]
else
nil
end
end
|
#output ⇒ Object
75
76
77
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 75
def output
raw_data['output']
end
|
#smart_contract ⇒ Object
27
28
29
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 27
def smart_contract
['STATICCALL','CALL'].include?(type) ? to : from
end
|
#success? ⇒ Boolean
87
88
89
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 87
def success?
!raw_data['error']
end
|
#suicide? ⇒ Boolean
43
44
45
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 43
def suicide?
type=='SELFDESTRUCT'
end
|
#time ⇒ Object
79
80
81
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 79
def time
raw_data['time']
end
|
#to ⇒ Object
51
52
53
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 51
def to
raw_data['to']
end
|
#type ⇒ Object
CALL STATICCALL DELEGATECALL CREATE SELFDESTRUCT
16
17
18
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 16
def type
raw_data['type']
end
|
#value_eth ⇒ Object
59
60
61
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 59
def value_eth
wei_to_ether value_wei
end
|
#value_wei ⇒ Object
55
56
57
|
# File 'lib/web3/eth/debug/transaction_call_trace.rb', line 55
def value_wei
from_hex raw_data['value']
end
|