Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliyb committed Nov 21, 2024
1 parent b861940 commit c00bb1a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions packages/evm/jsonrpc/jsonrpctest/jsonrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ func TestRPCTraceBlock(t *testing.T) {
require.Equal(t, strings.ToLower(creatorAddress.String()), strings.ToLower(call11Action["from"].(string)))
require.Equal(t, strings.ToLower(contractAddress.String()), strings.ToLower(call11Action["to"].(string)))
require.Equal(t, "0x7b", call11Action["value"].(string))
expectedInput, err := contractABI.Pack("sendTo", common.Address{0x1}, big.NewInt(2)) //nolint:govet
expectedInput, err := contractABI.Pack("sendTo", common.Address{0x1}, big.NewInt(2))
require.NoError(t, err)
require.Equal(t, hex.EncodeToString(expectedInput), call11Action["input"].(string)[2:])
require.Empty(t, call11.Error)
Expand All @@ -845,7 +845,7 @@ func TestRPCTraceBlock(t *testing.T) {
require.Equal(t, strings.ToLower(creatorAddress2.String()), strings.ToLower(call21Action["from"].(string)))
require.Equal(t, strings.ToLower(contractAddress.String()), strings.ToLower(call21Action["to"].(string)))
require.Equal(t, "0x141", call21Action["value"].(string))
expectedInput, err = contractABI.Pack("sendTo", common.Address{0x2}, big.NewInt(3)) //nolint:govet
expectedInput, err = contractABI.Pack("sendTo", common.Address{0x2}, big.NewInt(3))
require.NoError(t, err)
require.Equal(t, hex.EncodeToString(expectedInput), call21Action["input"].(string)[2:])
require.Empty(t, call21.Error)
Expand Down
38 changes: 19 additions & 19 deletions packages/evm/jsonrpc/trace_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ type TraceResult struct {

// Trace types
const (
CALL = "call"
STATIC_CALL = "staticcall"
DELEGATE_CALL = "delegatecall"
CREATE = "create"
SUICIDE = "suicide"
call = "call"
staticCall = "staticcall"
delegateCall = "delegatecall"
create = "create"
suicide = "suicide"
)

func convertToTrace(debugTrace CallFrame, blockHash *common.Hash, blockNumber uint64, txHash *common.Hash, txPosition uint64) []*Trace {
Expand Down Expand Up @@ -123,17 +123,17 @@ func parseTraceInternal(debugTrace CallFrame, blockHash *common.Hash, blockNumbe

traceCopy := make([]int, len(traceAddress))
copy(traceCopy, traceAddress)
subTraceAddress := append(traceCopy, subCalls)
traceCopy = append(traceCopy, subCalls)
var traces []*Trace
traces, _ = parseTraceInternal(call, blockHash, blockNumber, txHash, txPosition, subTraceAddress)
traces, _ = parseTraceInternal(call, blockHash, blockNumber, txHash, txPosition, traceCopy)
traceResult = append(traceResult, traces...)
subCalls += 1
subCalls++
}

traceEntry.Subtraces = subCalls

switch traceTypeSimple {
case CALL:
case call:
action := CallTraceAction{}
action.CallType = traceType
action.From = &debugTrace.From
Expand All @@ -149,7 +149,7 @@ func parseTraceInternal(debugTrace CallFrame, blockHash *common.Hash, blockNumbe
result.Output = debugTrace.Output

traceEntry.Result = result
case CREATE:
case create:
action := CreateTraceAction{}
action.From = &debugTrace.From
action.Gas = hexutil.Uint64(gas)
Expand All @@ -164,7 +164,7 @@ func parseTraceInternal(debugTrace CallFrame, blockHash *common.Hash, blockNumbe
result.Address = debugTrace.To

traceEntry.Result = result
case SUICIDE:
case suicide:
action := SuicideTraceAction{}
action.Address = &debugTrace.From
action.RefundAddress = debugTrace.To
Expand All @@ -179,27 +179,27 @@ func parseTraceInternal(debugTrace CallFrame, blockHash *common.Hash, blockNumbe
func mapTraceType(traceType string) string {
switch traceType {
case "CALL", "CALLCODE":
return CALL
return call
case "STATICCALL":
return STATIC_CALL
return staticCall
case "DELEGATECALL":
return DELEGATE_CALL
return delegateCall
case "CREATE", "CREATE2":
return CREATE
return create
case "SELFDESTRUCT":
return SUICIDE
return suicide
}
return ""
}

func mapTraceTypeSimple(traceType string) string {
switch traceType {
case "CALL", "CALLCODE", "STATICCALL", "DELEGATECALL":
return CALL
return call
case "CREATE", "CREATE2":
return CREATE
return create
case "SELFDESTRUCT":
return SUICIDE
return suicide
}
return ""
}
8 changes: 4 additions & 4 deletions packages/evm/jsonrpc/trace_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ func TestConvertToTrace(t *testing.T) {
expectedAction, ok := expected[i].Action.(map[string]interface{})
assert.True(t, ok, "Expected action should be a map")

actionJson, err := json.Marshal(actual[i].Action)
actionJSON, err := json.Marshal(actual[i].Action)
assert.NoError(t, err)
actualAction := map[string]interface{}{}
err = json.Unmarshal(actionJson, &actualAction)
err = json.Unmarshal(actionJSON, &actualAction)
assert.NoError(t, err)

resultJson, err := json.Marshal(actual[i].Result)
resultJSON, err := json.Marshal(actual[i].Result)
assert.NoError(t, err)
actualResult := map[string]interface{}{}
err = json.Unmarshal(resultJson, &actualResult)
err = json.Unmarshal(resultJSON, &actualResult)
assert.NoError(t, err)

assert.Equal(t, expectedAction["from"], actualAction["from"])
Expand Down

0 comments on commit c00bb1a

Please sign in to comment.