From c6441921f6189b8084425ef62797be7b0f6bc47f Mon Sep 17 00:00:00 2001 From: Abel Armoa <30988000+aarmoa@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:07:51 -0300 Subject: [PATCH] (fix) Fix pre-commit issues --- client/chain/chain.go | 42 ++++++++++++------------ client/chain/chain_test_support.go | 14 ++++---- client/exchange/exchange.go | 12 +++---- client/exchange/exchange_test_support.go | 4 +-- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/client/chain/chain.go b/client/chain/chain.go index 6cbbefff..19748aed 100644 --- a/client/chain/chain.go +++ b/client/chain/chain.go @@ -135,8 +135,8 @@ type ChainClient interface { StreamEventOrderFail(sender string, failEventCh chan map[string]uint) StreamEventOrderFailWithWebsocket(sender string, websocket *rpchttp.HTTP, failEventCh chan map[string]uint) - StreamOrderbookUpdateEvents(orderbookType OrderbookType, marketIds []string, orderbookCh chan exchangetypes.Orderbook) - StreamOrderbookUpdateEventsWithWebsocket(orderbookType OrderbookType, marketIds []string, websocket *rpchttp.HTTP, orderbookCh chan exchangetypes.Orderbook) + StreamOrderbookUpdateEvents(orderbookType OrderbookType, marketIDs []string, orderbookCh chan exchangetypes.Orderbook) + StreamOrderbookUpdateEventsWithWebsocket(orderbookType OrderbookType, marketIDs []string, websocket *rpchttp.HTTP, orderbookCh chan exchangetypes.Orderbook) ChainStream(ctx context.Context, req chainstreamtypes.StreamRequest) (chainstreamtypes.Stream_StreamClient, error) @@ -184,14 +184,14 @@ type ChainClient interface { FetchSubaccountDeposit(ctx context.Context, subaccountId string, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) FetchExchangeBalances(ctx context.Context) (*exchangetypes.QueryExchangeBalancesResponse, error) FetchAggregateVolume(ctx context.Context, account string) (*exchangetypes.QueryAggregateVolumeResponse, error) - FetchAggregateVolumes(ctx context.Context, accounts []string, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) + FetchAggregateVolumes(ctx context.Context, accounts []string, marketIDs []string) (*exchangetypes.QueryAggregateVolumesResponse, error) FetchAggregateMarketVolume(ctx context.Context, marketId string) (*exchangetypes.QueryAggregateMarketVolumeResponse, error) - FetchAggregateMarketVolumes(ctx context.Context, marketIds []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) + FetchAggregateMarketVolumes(ctx context.Context, marketIDs []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) FetchDenomDecimal(ctx context.Context, denom string) (*exchangetypes.QueryDenomDecimalResponse, error) FetchDenomDecimals(ctx context.Context, denoms []string) (*exchangetypes.QueryDenomDecimalsResponse, error) - FetchChainSpotMarkets(ctx context.Context, status string, marketIds []string) (*exchangetypes.QuerySpotMarketsResponse, error) + FetchChainSpotMarkets(ctx context.Context, status string, marketIDs []string) (*exchangetypes.QuerySpotMarketsResponse, error) FetchChainSpotMarket(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMarketResponse, error) - FetchChainFullSpotMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) + FetchChainFullSpotMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) FetchChainFullSpotMarket(ctx context.Context, marketId string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketResponse, error) FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional sdkmath.LegacyDec, limitCumulativeQuantity sdkmath.LegacyDec) (*exchangetypes.QuerySpotOrderbookResponse, error) FetchChainTraderSpotOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) @@ -206,7 +206,7 @@ type ChainClient interface { FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) - FetchChainDerivativeMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) + FetchChainDerivativeMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) FetchChainDerivativeMarket(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketResponse, error) FetchDerivativeMarketAddress(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketAddressResponse, error) FetchSubaccountTradeNonce(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) @@ -1347,7 +1347,7 @@ func (c *chainClient) StreamEventOrderFailWithWebsocket(sender string, websocket } } -func (c *chainClient) StreamOrderbookUpdateEvents(orderbookType OrderbookType, marketIds []string, orderbookCh chan exchangetypes.Orderbook) { +func (c *chainClient) StreamOrderbookUpdateEvents(orderbookType OrderbookType, marketIDs []string, orderbookCh chan exchangetypes.Orderbook) { var cometbftClient *rpchttp.HTTP var err error @@ -1369,11 +1369,11 @@ func (c *chainClient) StreamOrderbookUpdateEvents(orderbookType OrderbookType, m } }() - c.StreamOrderbookUpdateEventsWithWebsocket(orderbookType, marketIds, cometbftClient, orderbookCh) + c.StreamOrderbookUpdateEventsWithWebsocket(orderbookType, marketIDs, cometbftClient, orderbookCh) } -func (c *chainClient) StreamOrderbookUpdateEventsWithWebsocket(orderbookType OrderbookType, marketIds []string, websocket *rpchttp.HTTP, orderbookCh chan exchangetypes.Orderbook) { +func (c *chainClient) StreamOrderbookUpdateEventsWithWebsocket(orderbookType OrderbookType, marketIDs []string, websocket *rpchttp.HTTP, orderbookCh chan exchangetypes.Orderbook) { filter := fmt.Sprintf("tm.event='NewBlock' AND %s EXISTS", orderbookType) eventCh, err := websocket.Subscribe(context.Background(), "OrderbookUpdate", filter, 10000) if err != nil { @@ -1382,7 +1382,7 @@ func (c *chainClient) StreamOrderbookUpdateEventsWithWebsocket(orderbookType Ord // turn array into map for convenient lookup marketIDsMap := map[string]bool{} - for _, id := range marketIds { + for _, id := range marketIDs { marketIDsMap[id] = true } @@ -1729,10 +1729,10 @@ func (c *chainClient) FetchAggregateVolume(ctx context.Context, account string) return res, err } -func (c *chainClient) FetchAggregateVolumes(ctx context.Context, accounts, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { +func (c *chainClient) FetchAggregateVolumes(ctx context.Context, accounts, marketIDs []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { req := &exchangetypes.QueryAggregateVolumesRequest{ Accounts: accounts, - MarketIds: marketIds, + MarketIds: marketIDs, } res, err := common.ExecuteCall(ctx, c.network.ChainCookieAssistant, c.exchangeQueryClient.AggregateVolumes, req) @@ -1748,9 +1748,9 @@ func (c *chainClient) FetchAggregateMarketVolume(ctx context.Context, marketId s return res, err } -func (c *chainClient) FetchAggregateMarketVolumes(ctx context.Context, marketIds []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) { +func (c *chainClient) FetchAggregateMarketVolumes(ctx context.Context, marketIDs []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) { req := &exchangetypes.QueryAggregateMarketVolumesRequest{ - MarketIds: marketIds, + MarketIds: marketIDs, } res, err := common.ExecuteCall(ctx, c.network.ChainCookieAssistant, c.exchangeQueryClient.AggregateMarketVolumes, req) @@ -1775,9 +1775,9 @@ func (c *chainClient) FetchDenomDecimals(ctx context.Context, denoms []string) ( return res, err } -func (c *chainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIds []string) (*exchangetypes.QuerySpotMarketsResponse, error) { +func (c *chainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIDs []string) (*exchangetypes.QuerySpotMarketsResponse, error) { req := &exchangetypes.QuerySpotMarketsRequest{ - MarketIds: marketIds, + MarketIds: marketIDs, } if status != "" { req.Status = status @@ -1796,9 +1796,9 @@ func (c *chainClient) FetchChainSpotMarket(ctx context.Context, marketId string) return res, err } -func (c *chainClient) FetchChainFullSpotMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) { +func (c *chainClient) FetchChainFullSpotMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) { req := &exchangetypes.QueryFullSpotMarketsRequest{ - MarketIds: marketIds, + MarketIds: marketIDs, WithMidPriceAndTob: withMidPriceAndTob, } if status != "" { @@ -1953,9 +1953,9 @@ func (c *chainClient) FetchChainTraderDerivativeTransientOrders(ctx context.Cont return res, err } -func (c *chainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) { +func (c *chainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) { req := &exchangetypes.QueryDerivativeMarketsRequest{ - MarketIds: marketIds, + MarketIds: marketIDs, WithMidPriceAndTob: withMidPriceAndTob, } if status != "" { diff --git a/client/chain/chain_test_support.go b/client/chain/chain_test_support.go index 2d8af3ab..afacd061 100644 --- a/client/chain/chain_test_support.go +++ b/client/chain/chain_test_support.go @@ -214,10 +214,10 @@ func (c *MockChainClient) StreamEventOrderFail(sender string, failEventCh chan m func (c *MockChainClient) StreamEventOrderFailWithWebsocket(sender string, websocket *rpchttp.HTTP, failEventCh chan map[string]uint) { } -func (c *MockChainClient) StreamOrderbookUpdateEvents(orderbookType OrderbookType, marketIds []string, orderbookCh chan exchangetypes.Orderbook) { +func (c *MockChainClient) StreamOrderbookUpdateEvents(orderbookType OrderbookType, marketIDs []string, orderbookCh chan exchangetypes.Orderbook) { } -func (c *MockChainClient) StreamOrderbookUpdateEventsWithWebsocket(orderbookType OrderbookType, marketIds []string, websocket *rpchttp.HTTP, orderbookCh chan exchangetypes.Orderbook) { +func (c *MockChainClient) StreamOrderbookUpdateEventsWithWebsocket(orderbookType OrderbookType, marketIDs []string, websocket *rpchttp.HTTP, orderbookCh chan exchangetypes.Orderbook) { } func (c *MockChainClient) ChainStream(ctx context.Context, req chainstreamtypes.StreamRequest) (chainstreamtypes.Stream_StreamClient, error) { @@ -348,7 +348,7 @@ func (c *MockChainClient) FetchAggregateVolume(ctx context.Context, account stri return &exchangetypes.QueryAggregateVolumeResponse{}, nil } -func (c *MockChainClient) FetchAggregateVolumes(ctx context.Context, accounts, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { +func (c *MockChainClient) FetchAggregateVolumes(ctx context.Context, accounts, marketIDs []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { return &exchangetypes.QueryAggregateVolumesResponse{}, nil } @@ -356,7 +356,7 @@ func (c *MockChainClient) FetchAggregateMarketVolume(ctx context.Context, market return &exchangetypes.QueryAggregateMarketVolumeResponse{}, nil } -func (c *MockChainClient) FetchAggregateMarketVolumes(ctx context.Context, marketIds []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) { +func (c *MockChainClient) FetchAggregateMarketVolumes(ctx context.Context, marketIDs []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) { return &exchangetypes.QueryAggregateMarketVolumesResponse{}, nil } @@ -368,7 +368,7 @@ func (c *MockChainClient) FetchDenomDecimals(ctx context.Context, denoms []strin return &exchangetypes.QueryDenomDecimalsResponse{}, nil } -func (c *MockChainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIds []string) (*exchangetypes.QuerySpotMarketsResponse, error) { +func (c *MockChainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIDs []string) (*exchangetypes.QuerySpotMarketsResponse, error) { return &exchangetypes.QuerySpotMarketsResponse{}, nil } @@ -376,7 +376,7 @@ func (c *MockChainClient) FetchChainSpotMarket(ctx context.Context, marketId str return &exchangetypes.QuerySpotMarketResponse{}, nil } -func (c *MockChainClient) FetchChainFullSpotMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) { +func (c *MockChainClient) FetchChainFullSpotMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) { return &exchangetypes.QueryFullSpotMarketsResponse{}, nil } @@ -436,7 +436,7 @@ func (c *MockChainClient) FetchChainTraderDerivativeTransientOrders(ctx context. return &exchangetypes.QueryTraderDerivativeOrdersResponse{}, nil } -func (c *MockChainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) { +func (c *MockChainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIDs []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) { return &exchangetypes.QueryDerivativeMarketsResponse{}, nil } diff --git a/client/exchange/exchange.go b/client/exchange/exchange.go index 61a6ca01..cc4b3f3b 100644 --- a/client/exchange/exchange.go +++ b/client/exchange/exchange.go @@ -28,7 +28,7 @@ type ExchangeClient interface { // StreamDerivativeOrderbook deprecated API StreamDerivativeOrderbookV2(ctx context.Context, marketIDs []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrderbookV2Client, error) StreamDerivativeOrderbookUpdate(ctx context.Context, marketIDs []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamOrderbookUpdateClient, error) - StreamDerivativeMarket(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) + StreamDerivativeMarket(ctx context.Context, marketIDs []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) GetDerivativeOrders(ctx context.Context, req *derivativeExchangePB.OrdersRequest) (*derivativeExchangePB.OrdersResponse, error) GetDerivativeMarkets(ctx context.Context, req *derivativeExchangePB.MarketsRequest) (*derivativeExchangePB.MarketsResponse, error) GetDerivativePositions(ctx context.Context, req *derivativeExchangePB.PositionsRequest) (*derivativeExchangePB.PositionsResponse, error) @@ -69,7 +69,7 @@ type ExchangeClient interface { StreamSpotOrderbookUpdate(ctx context.Context, marketIDs []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrderbookUpdateClient, error) GetSpotMarkets(ctx context.Context, req *spotExchangePB.MarketsRequest) (*spotExchangePB.MarketsResponse, error) GetSpotMarket(ctx context.Context, marketId string) (*spotExchangePB.MarketResponse, error) - StreamSpotMarket(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) + StreamSpotMarket(ctx context.Context, marketIDs []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) StreamSpotOrders(ctx context.Context, req *spotExchangePB.StreamOrdersRequest) (spotExchangePB.InjectiveSpotExchangeRPC_StreamOrdersClient, error) GetSpotTrades(ctx context.Context, req *spotExchangePB.TradesRequest) (*spotExchangePB.TradesResponse, error) GetSpotTradesV2(ctx context.Context, req *spotExchangePB.TradesV2Request) (*spotExchangePB.TradesV2Response, error) @@ -290,9 +290,9 @@ func (c *exchangeClient) GetDerivativeMarket(ctx context.Context, marketId strin return res, nil } -func (c *exchangeClient) StreamDerivativeMarket(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) { +func (c *exchangeClient) StreamDerivativeMarket(ctx context.Context, marketIDs []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) { req := derivativeExchangePB.StreamMarketRequest{ - MarketIds: marketIds, + MarketIds: marketIDs, } stream, err := common.ExecuteStreamCall(ctx, c.network.ExchangeCookieAssistant, c.derivativeExchangeClient.StreamMarket, &req) @@ -741,9 +741,9 @@ func (c *exchangeClient) GetSpotMarket(ctx context.Context, marketId string) (*s return res, nil } -func (c *exchangeClient) StreamSpotMarket(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) { +func (c *exchangeClient) StreamSpotMarket(ctx context.Context, marketIDs []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) { req := spotExchangePB.StreamMarketsRequest{ - MarketIds: marketIds, + MarketIds: marketIDs, } stream, err := common.ExecuteStreamCall(ctx, c.network.ExchangeCookieAssistant, c.spotExchangeClient.StreamMarkets, &req) diff --git a/client/exchange/exchange_test_support.go b/client/exchange/exchange_test_support.go index bd00910a..5c31f5e8 100644 --- a/client/exchange/exchange_test_support.go +++ b/client/exchange/exchange_test_support.go @@ -48,7 +48,7 @@ func (e *MockExchangeClient) StreamDerivativeOrderbookUpdate(ctx context.Context return nil, nil } -func (e *MockExchangeClient) StreamDerivativeMarket(ctx context.Context, marketIds []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) { +func (e *MockExchangeClient) StreamDerivativeMarket(ctx context.Context, marketIDs []string) (derivativeExchangePB.InjectiveDerivativeExchangeRPC_StreamMarketClient, error) { return nil, nil } @@ -230,7 +230,7 @@ func (e *MockExchangeClient) GetSpotMarket(ctx context.Context, marketId string) return &spotExchangePB.MarketResponse{}, nil } -func (e *MockExchangeClient) StreamSpotMarket(ctx context.Context, marketIds []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) { +func (e *MockExchangeClient) StreamSpotMarket(ctx context.Context, marketIDs []string) (spotExchangePB.InjectiveSpotExchangeRPC_StreamMarketsClient, error) { return nil, nil }