Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lmittmann committed Oct 7, 2024
1 parent a7d3da2 commit 8cc48cd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions w3vm/hooks/call_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ var (
stylesDelegatecall = lipgloss.NewStyle().Foreground(lipgloss.Color("#FFA500"))
)

// TargetAddress can be used to match the target (to) address in the TargetStyler
// of [CallTracerOptions].
var TargetAddress = common.BytesToAddress([]byte("target"))

// CallTracerOptions configures the CallTracer hook. A zero CallTracerOptions
// consists entirely of default values.
type CallTracerOptions struct {
TargetStyler func(addr common.Address) lipgloss.Style
targetAddr common.Address
Expand Down Expand Up @@ -67,8 +73,6 @@ func (opts *CallTracerOptions) opStyler(op byte) lipgloss.Style {
return opts.OpStyler(op)
}

var TargetAddress = common.BytesToAddress([]byte("target"))

func defaultTargetStyler(addr common.Address) lipgloss.Style {
switch addr {
case TargetAddress:
Expand All @@ -78,10 +82,11 @@ func defaultTargetStyler(addr common.Address) lipgloss.Style {
}
}

func defaultOpStyler(op byte) lipgloss.Style {
func defaultOpStyler(byte) lipgloss.Style {
return lipgloss.NewStyle()
}

// NewCallTracer returns a new hook that writes to w and is configured with opts.
func NewCallTracer(w io.Writer, opts *CallTracerOptions) *tracing.Hooks {
if opts == nil {
opts = new(CallTracerOptions)
Expand Down

0 comments on commit 8cc48cd

Please sign in to comment.