Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options to TraceTransaction function #257

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions jsonrpc/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ type Debug struct {
c *Client
}

// Eth returns the reference to the eth namespace
// Debug returns the reference to the debug namespace
func (c *Client) Debug() *Debug {
return c.endpoints.d
}

type TraceTransactionOptions struct {
EnableMemory bool `json:"enableMemory"`
DisableStack bool `json:"disableStack"`
DisableStorage bool `json:"disableStorage"`
EnableReturnData bool `json:"enableReturnData"`
Timeout string `json:"timeout,omitempty"`
Tracer string `json:"tracer,omitempty"`
TracerConfig map[string]interface{} `json:"tracerConfig,omitempty"`
}

type TransactionTrace struct {
Gas uint64
ReturnValue string
Expand All @@ -28,8 +38,8 @@ type StructLogs struct {
Storage map[string]string
}

func (d *Debug) TraceTransaction(hash ethgo.Hash) (*TransactionTrace, error) {
func (d *Debug) TraceTransaction(hash ethgo.Hash, opts TraceTransactionOptions) (*TransactionTrace, error) {
var res *TransactionTrace
err := d.c.Call("debug_traceTransaction", &res, hash)
err := d.c.Call("debug_traceTransaction", &res, hash, opts)
return res, err
}
2 changes: 1 addition & 1 deletion jsonrpc/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestDebug_TraceTransaction(t *testing.T) {
r, err := s.TxnTo(addr, "setA2")
require.NoError(t, err)

trace, err := c.Debug().TraceTransaction(r.TransactionHash)
trace, err := c.Debug().TraceTransaction(r.TransactionHash, TraceTransactionOptions{})
assert.NoError(t, err)
assert.Greater(t, trace.Gas, uint64(20000))
assert.NotEmpty(t, trace.StructLogs)
Expand Down
Loading