From 4d8997a8d5b74a2599dba41c3ee3241b4b5eb7a1 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 20 Apr 2022 12:16:21 +0800 Subject: [PATCH] max: pass context background to the request --- pkg/exchange/max/maxapi/account.go | 12 ++++++------ pkg/exchange/max/maxapi/order.go | 8 ++++---- pkg/exchange/max/maxapi/reward.go | 2 +- pkg/exchange/max/maxapi/trade.go | 2 +- pkg/exchange/max/maxapi/withdrawal.go | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/exchange/max/maxapi/account.go b/pkg/exchange/max/maxapi/account.go index a534a2ad1..97faa5c05 100644 --- a/pkg/exchange/max/maxapi/account.go +++ b/pkg/exchange/max/maxapi/account.go @@ -72,7 +72,7 @@ type VipLevel struct { } func (s *AccountService) VipLevel() (*VipLevel, error) { - req, err := s.client.newAuthenticatedRequest(nil, "GET", "v2/members/vip_level", nil, nil, nil) + req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/members/vip_level", nil, nil, nil) if err != nil { return nil, err } @@ -92,7 +92,7 @@ func (s *AccountService) VipLevel() (*VipLevel, error) { } func (s *AccountService) Account(currency string) (*Account, error) { - req, err := s.client.newAuthenticatedRequest(nil, "GET", "v2/members/accounts/"+currency, nil, nil, nil) + req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/members/accounts/"+currency, nil, nil, nil) if err != nil { return nil, err } @@ -129,7 +129,7 @@ func (s *AccountService) NewAccountsRequest() *GetAccountsRequest { } func (s *AccountService) Accounts() ([]Account, error) { - req, err := s.client.newAuthenticatedRequest(nil, "GET", "v2/members/accounts", nil, nil, nil) + req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/members/accounts", nil, nil, nil) if err != nil { return nil, err } @@ -150,7 +150,7 @@ func (s *AccountService) Accounts() ([]Account, error) { // Me returns the current user info by the current used MAX key and secret func (s *AccountService) Me() (*UserInfo, error) { - req, err := s.client.newAuthenticatedRequest(nil, "GET", "v2/members/me", nil, nil, nil) + req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/members/me", nil, nil, nil) if err != nil { return nil, err } @@ -222,7 +222,7 @@ func (r *GetDepositHistoryRequest) To(to int64) *GetDepositHistoryRequest { } func (r *GetDepositHistoryRequest) Do(ctx context.Context) (deposits []Deposit, err error) { - req, err := r.client.newAuthenticatedRequest(nil, "GET", "v2/deposits", nil, &r.params, nil) + req, err := r.client.newAuthenticatedRequest(context.Background(), "GET", "v2/deposits", nil, &r.params, nil) if err != nil { return deposits, err } @@ -308,7 +308,7 @@ func (r *GetWithdrawHistoryRequest) To(to int64) *GetWithdrawHistoryRequest { } func (r *GetWithdrawHistoryRequest) Do(ctx context.Context) (withdraws []Withdraw, err error) { - req, err := r.client.newAuthenticatedRequest(nil, "GET", "v2/withdrawals", nil, &r.params, nil) + req, err := r.client.newAuthenticatedRequest(context.Background(), "GET", "v2/withdrawals", nil, &r.params, nil) if err != nil { return withdraws, err } diff --git a/pkg/exchange/max/maxapi/order.go b/pkg/exchange/max/maxapi/order.go index 5eca12ba8..e86bada44 100644 --- a/pkg/exchange/max/maxapi/order.go +++ b/pkg/exchange/max/maxapi/order.go @@ -126,7 +126,7 @@ func (s *OrderService) Closed(market string, options QueryOrderOptions) ([]Order payload["order_by"] = options.OrderBy } - req, err := s.client.newAuthenticatedRequest(nil, "GET", "v2/orders", nil, payload, relUrlV2Orders) + req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/orders", nil, payload, relUrlV2Orders) if err != nil { return nil, err } @@ -157,7 +157,7 @@ func (s *OrderService) Open(market string, options QueryOrderOptions) ([]Order, payload["group_id"] = options.GroupID } - req, err := s.client.newAuthenticatedRequest(nil, "GET", "v2/orders", nil, payload, relUrlV2Orders) + req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/orders", nil, payload, relUrlV2Orders) if err != nil { return nil, err } @@ -219,7 +219,7 @@ func (s *OrderService) All(market string, limit, page int, states ...OrderState) "order_by": "desc", } - req, err := s.client.newAuthenticatedRequest(nil, "GET", "v2/orders", nil, payload, relUrlV2Orders) + req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/orders", nil, payload, relUrlV2Orders) if err != nil { return nil, err } @@ -344,7 +344,7 @@ func (r *CreateMultiOrderRequest) Do(ctx context.Context) (multiOrderResponse *M payload["orders"] = r.orders - req, err := r.client.newAuthenticatedRequest(nil, "POST", "v2/orders/multi/onebyone", nil, payload, relUrlV2OrdersMultiOneByOne) + req, err := r.client.newAuthenticatedRequest(context.Background(), "POST", "v2/orders/multi/onebyone", nil, payload, relUrlV2OrdersMultiOneByOne) if err != nil { return multiOrderResponse, errors.Wrapf(err, "order create error") } diff --git a/pkg/exchange/max/maxapi/reward.go b/pkg/exchange/max/maxapi/reward.go index 507141924..85ee914d7 100644 --- a/pkg/exchange/max/maxapi/reward.go +++ b/pkg/exchange/max/maxapi/reward.go @@ -188,7 +188,7 @@ func (r *RewardsRequest) Do(ctx context.Context) (rewards []Reward, err error) { refURL += "/" + string(*r.pathType) } - req, err := r.client.newAuthenticatedRequest(nil, "GET", refURL, nil, payload, nil) + req, err := r.client.newAuthenticatedRequest(context.Background(), "GET", refURL, nil, payload, nil) if err != nil { return rewards, err } diff --git a/pkg/exchange/max/maxapi/trade.go b/pkg/exchange/max/maxapi/trade.go index aa0f8cd9b..98a63c20c 100644 --- a/pkg/exchange/max/maxapi/trade.go +++ b/pkg/exchange/max/maxapi/trade.go @@ -220,7 +220,7 @@ func (r *PrivateTradeRequest) Do(ctx context.Context) (trades []Trade, err error payload["offset"] = r.offset } - req, err := r.client.newAuthenticatedRequest(nil, "GET", "v2/trades/my", nil, payload, nil) + req, err := r.client.newAuthenticatedRequest(context.Background(), "GET", "v2/trades/my", nil, payload, nil) if err != nil { return trades, err } diff --git a/pkg/exchange/max/maxapi/withdrawal.go b/pkg/exchange/max/maxapi/withdrawal.go index 227e9a20e..6de1e5820 100644 --- a/pkg/exchange/max/maxapi/withdrawal.go +++ b/pkg/exchange/max/maxapi/withdrawal.go @@ -71,7 +71,7 @@ func (r *WithdrawalRequest) Do(ctx context.Context) (*Withdraw, error) { "amount": r.amount, } - req, err := r.client.newAuthenticatedRequest(nil, "POST", "v2/withdrawal", nil, payload, nil) + req, err := r.client.newAuthenticatedRequest(context.Background(), "POST", "v2/withdrawal", nil, payload, nil) if err != nil { return nil, err } @@ -121,7 +121,7 @@ func (r *GetWithdrawalAddressesRequest) Do(ctx context.Context) ([]WithdrawalAdd "currency": r.currency, } - req, err := r.client.newAuthenticatedRequest(nil, "GET", "v2/withdraw_addresses", nil, payload, nil) + req, err := r.client.newAuthenticatedRequest(context.Background(), "GET", "v2/withdraw_addresses", nil, payload, nil) if err != nil { return nil, err }