Class: Web3::Eth::Debug::DebugModule
- Inherits:
-
Object
- Object
- Web3::Eth::Debug::DebugModule
show all
- Includes:
- Utility
- Defined in:
- lib/web3/eth/debug/debug_module.rb
Constant Summary
collapse
- PREFIX =
'debug_'
Instance Method Summary
collapse
Methods included from Utility
#from_hex, #hex, #remove_0x_head, #wei_to_ether
Constructor Details
#initialize(web3_rpc) ⇒ DebugModule
Returns a new instance of DebugModule.
9
10
11
|
# File 'lib/web3/eth/debug/debug_module.rb', line 9
def initialize web3_rpc
@web3_rpc = web3_rpc
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
34
35
36
|
# File 'lib/web3/eth/debug/debug_module.rb', line 34
def method_missing m, *args
@web3_rpc.request "#{PREFIX}#{m}", args[0]
end
|
Instance Method Details
#traceBlockByHash(hash, tracer = 'callTracer', convert_to_object = true) ⇒ Object
28
29
30
31
|
# File 'lib/web3/eth/debug/debug_module.rb', line 28
def traceBlockByHash hash, tracer = 'callTracer', convert_to_object = true
raw = @web3_rpc.request("#{PREFIX}#{__method__}", [hash, {tracer: tracer}])
convert_to_object ? raw.map{|r| TransactionCallTrace.new(r['result'])} : raw
end
|
#traceBlockByNumber(number, tracer = 'callTracer', convert_to_object = true) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/web3/eth/debug/debug_module.rb', line 20
def traceBlockByNumber number, tracer = 'callTracer', convert_to_object = true
timeout = @web3_rpc.connect_options[:read_timeout] || 120
raw = @web3_rpc.request("#{PREFIX}#{__method__}", [hex(number), {tracer: tracer,
timeout: "#{timeout}s"}])
raise raw.first['error'] if (raw.first && raw.first['error'])
convert_to_object ? raw.map{|r| TransactionCallTrace.new(r['result'])} : raw
end
|
#traceTransaction(hash, tracer = 'callTracer', convert_to_object = true) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/web3/eth/debug/debug_module.rb', line 13
def traceTransaction hash, tracer = 'callTracer', convert_to_object = true
timeout = @web3_rpc.connect_options[:read_timeout] || 120
raw = @web3_rpc.request("#{PREFIX}#{__method__}", [hash, {tracer: tracer,
timeout: "#{timeout}s"}])
convert_to_object ? TransactionCallTrace.new(raw) : raw
end
|