diff --git a/client/client_test.go b/client/client_test.go index 8cb21ec..016e740 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -18,7 +18,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "os" "strconv" "testing" @@ -54,7 +54,7 @@ func TestOpenEthTraceAPI_EmptyTrace(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile( + file, err := os.ReadFile( "testdata/trace_block_empty.json", ) assert.NoError(t, err) @@ -95,7 +95,7 @@ func TestTraceBlockByHash(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile( + file, err := os.ReadFile( "testdata/block_trace_0xd88e8376ec3eef899d9fbc6349e8330ebfc102b245fef784a999ac854091cb64.json", ) assert.NoError(t, err) @@ -154,7 +154,7 @@ func TestOpenEthTraceAPI_1Txn(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile( + file, err := os.ReadFile( "testdata/trace_block_1_tx.json", ) assert.NoError(t, err) @@ -206,7 +206,7 @@ func TestOpenEthTraceAPI_MultiTxns(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile( + file, err := os.ReadFile( "testdata/trace_block_many_traces.json", ) assert.NoError(t, err) @@ -257,7 +257,7 @@ func TestBalance(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(**types.Header) - file, err := ioutil.ReadFile("testdata/block_10992.json") + file, err := os.ReadFile("testdata/block_10992.json") assert.NoError(t, err) err = json.Unmarshal(file, &r) assert.NoError(t, err) @@ -308,7 +308,7 @@ func TestBalance(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*string) var expected map[string]interface{} - file, err := ioutil.ReadFile("testdata/call_balance_token_10992.json") + file, err := os.ReadFile("testdata/call_balance_token_10992.json") assert.NoError(t, err) err = json.Unmarshal(file, &expected) diff --git a/client/tracer.go b/client/tracer.go index 236dca6..3b13289 100644 --- a/client/tracer.go +++ b/client/tracer.go @@ -17,8 +17,8 @@ package client import ( "encoding/json" "fmt" - "io/ioutil" "math/big" + "os" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -47,7 +47,7 @@ func GetTraceConfig(useNative bool) (*tracers.TraceConfig, error) { } func loadTraceConfig() (*tracers.TraceConfig, error) { - loadedFile, err := ioutil.ReadFile(tracerPath) + loadedFile, err := os.ReadFile(tracerPath) if err != nil { return nil, fmt.Errorf("could not load tracer file: %w", err) } diff --git a/client/utils.go b/client/utils.go index 1c1b7b8..a31b0e9 100644 --- a/client/utils.go +++ b/client/utils.go @@ -16,9 +16,9 @@ package client import ( "encoding/json" + "log" "math/big" "strings" - "log" "github.com/coinbase/rosetta-geth-sdk/configuration" @@ -181,7 +181,7 @@ func GenerateErc20TransferData(toAddress string, value *big.Int) []byte { } func (tx *LoadedTransaction) GetMint() *big.Int { - if tx.Mint == "" { + if tx.Mint == "" { return big.NewInt(0) } hexString := tx.Mint[2:] diff --git a/go.sum b/go.sum index 8afb9eb..da96fe5 100644 --- a/go.sum +++ b/go.sum @@ -11,7 +11,6 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIO github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= -github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6 h1:1d9pzdbkth4D9AX6ndKSl7of3UTV0RYl3z64U2dXMGo= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= diff --git a/services/block_service_test.go b/services/block_service_test.go index d79e324..97ef85c 100644 --- a/services/block_service_test.go +++ b/services/block_service_test.go @@ -17,8 +17,8 @@ package services import ( "context" "encoding/json" - "io/ioutil" "log" + "os" EthTypes "github.com/ethereum/go-ethereum/core/types" @@ -40,11 +40,11 @@ import ( ) const ( - hsh = "0xd83b1dcf7d47c4115d78ce0361587604e8157591b118bd64ada02e86c9d5ca7e" + hsh = "0xd83b1dcf7d47c4115d78ce0361587604e8157591b118bd64ada02e86c9d5ca7e" ) func loadTokenWhiteList() []configuration.Token { - content, err := ioutil.ReadFile("testdata/tokenList.json") + content, err := os.ReadFile("testdata/tokenList.json") if err != nil { log.Fatal("Error when opening file: ", err) } @@ -111,7 +111,7 @@ func TestBlockService_Online(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile("testdata/block_10992.json") + file, err := os.ReadFile("testdata/block_10992.json") assert.NoError(t, err) *r = json.RawMessage(file) @@ -180,7 +180,7 @@ func TestBlockService_Online(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile("testdata/block_10992.json") + file, err := os.ReadFile("testdata/block_10992.json") assert.NoError(t, err) *r = json.RawMessage(file) @@ -221,7 +221,7 @@ func TestBlockService_Online(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile("testdata/block_10994.json") + file, err := os.ReadFile("testdata/block_10994.json") assert.NoError(t, err) *r = json.RawMessage(file) @@ -230,15 +230,15 @@ func TestBlockService_Online(t *testing.T) { m := make(map[string][]*client.FlatCall) m[hsh] = append(m[hsh], &client.FlatCall{ - Type: "call", + Type: "call", BeforeEVMTransfers: nil, AfterEVMTransfers: nil, - From: common.HexToAddress("0x1234"), - To: common.HexToAddress("0x4566"), - Value: big.NewInt(900000), - GasUsed: big.NewInt(10000), - Revert: false, - ErrorMessage: "", + From: common.HexToAddress("0x1234"), + To: common.HexToAddress("0x4566"), + Value: big.NewInt(900000), + GasUsed: big.NewInt(10000), + Revert: false, + ErrorMessage: "", }) // TraceBlockByHash returns valid traces map @@ -279,12 +279,12 @@ func TestBlockService_Online(t *testing.T) { OperationIdentifier: &RosettaTypes.OperationIdentifier{ Index: 0, }, - Type: AssetTypes.CallOpType, - Status: RosettaTypes.String(AssetTypes.SuccessStatus), + Type: AssetTypes.CallOpType, + Status: RosettaTypes.String(AssetTypes.SuccessStatus), Account: &RosettaTypes.AccountIdentifier{ Address: mock.Anything, }, - Amount: client.Amount(big.NewInt(-1), AssetTypes.Currency), + Amount: client.Amount(big.NewInt(-1), AssetTypes.Currency), }, { @@ -351,7 +351,7 @@ func TestBlockService_Online(t *testing.T) { func(args mock.Arguments) { r := args.Get(1).(*json.RawMessage) - file, err := ioutil.ReadFile("testdata/block_10994.json") + file, err := os.ReadFile("testdata/block_10994.json") assert.NoError(t, err) *r = json.RawMessage(file) @@ -440,12 +440,12 @@ func TestBlockService_Online(t *testing.T) { OperationIdentifier: &RosettaTypes.OperationIdentifier{ Index: 0, }, - Type: AssetTypes.FeeOpType, - Status: RosettaTypes.String(AssetTypes.SuccessStatus), + Type: AssetTypes.FeeOpType, + Status: RosettaTypes.String(AssetTypes.SuccessStatus), Account: &RosettaTypes.AccountIdentifier{ Address: "0x0000000000000000000000000000000000001234", }, - Amount: client.Amount(big.NewInt(-10000), AssetTypes.Currency), + Amount: client.Amount(big.NewInt(-10000), AssetTypes.Currency), }, { @@ -489,9 +489,9 @@ func TestBlockService_Online(t *testing.T) { "GetRosettaConfig", ).Return( configuration.RosettaConfig{ - FilterTokens: true, + FilterTokens: true, TokenWhiteList: loadTokenWhiteList(), - TracePrefix: "arbtrace", + TracePrefix: "arbtrace", }, ) diff --git a/services/construction/combine_test.go b/services/construction/combine_test.go index 3c6a5be..ba4f903 100644 --- a/services/construction/combine_test.go +++ b/services/construction/combine_test.go @@ -17,9 +17,10 @@ package construction import ( "context" "encoding/json" - AssetTypes "github.com/coinbase/rosetta-geth-sdk/types" "testing" + AssetTypes "github.com/coinbase/rosetta-geth-sdk/types" + "github.com/coinbase/rosetta-sdk-go/types" "github.com/stretchr/testify/assert" ) diff --git a/services/construction/parse.go b/services/construction/parse.go index 5c61844..bff9135 100644 --- a/services/construction/parse.go +++ b/services/construction/parse.go @@ -22,6 +22,7 @@ import ( "math/big" "errors" + "github.com/coinbase/rosetta-geth-sdk/client" sdkTypes "github.com/coinbase/rosetta-geth-sdk/types" goEthTypes "github.com/ethereum/go-ethereum/core/types" diff --git a/services/construction/submit.go b/services/construction/submit.go index 257469f..16e2be5 100644 --- a/services/construction/submit.go +++ b/services/construction/submit.go @@ -29,7 +29,6 @@ import ( // ConstructionSubmit implements /construction/submit endpoint. // // Submit a pre-signed Transaction to the node. -// func (s *APIService) ConstructionSubmit( ctx context.Context, req *types.ConstructionSubmitRequest, diff --git a/services/mapper_test.go b/services/mapper_test.go index 075c084..541c565 100644 --- a/services/mapper_test.go +++ b/services/mapper_test.go @@ -15,12 +15,13 @@ package services import ( - evmClient "github.com/coinbase/rosetta-geth-sdk/client" - "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/assert" - "math/big" - "testing" - ) + "math/big" + "testing" + + evmClient "github.com/coinbase/rosetta-geth-sdk/client" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/assert" +) func TestParseTransferOps(t *testing.T) { a1 := common.HexToAddress("0xdd4b76b0316dcafa98862a12a92791ac9426a0e2") @@ -180,7 +181,7 @@ func TestParseTransferOpsFirstIndexRelatedOps(t *testing.T) { From: &a2, Purpose: "refund", To: &a4, - Value: big.NewInt( 7441300000000), + Value: big.NewInt(7441300000000), }, &evmClient.EVMTransfer{ From: &a2,