mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Huobi: Fix GetAvailableTransferChains returning unavailable chains (#1709)
This commit is contained in:
@@ -2625,13 +2625,9 @@ func TestGetHistoricTrades(t *testing.T) {
|
||||
|
||||
func TestGetAvailableTransferChains(t *testing.T) {
|
||||
t.Parallel()
|
||||
r, err := h.GetAvailableTransferChains(context.Background(), currency.USDT)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(r) < 2 {
|
||||
t.Error("expected more than one result")
|
||||
}
|
||||
c, err := h.GetAvailableTransferChains(context.Background(), currency.USDT)
|
||||
require.NoError(t, err)
|
||||
require.Greater(t, len(c), 2, "Must get more than 2 chains")
|
||||
}
|
||||
|
||||
func TestFormatFuturesPair(t *testing.T) {
|
||||
|
||||
@@ -35,7 +35,7 @@ type CurrenciesChainData struct {
|
||||
Currency string `json:"currency"`
|
||||
AssetType uint8 `json:"assetType"`
|
||||
InstStatus string `json:"instStatus"`
|
||||
ChainData []struct {
|
||||
ChainData []*struct {
|
||||
Chain string `json:"chain"`
|
||||
DisplayName string `json:"displayName"`
|
||||
BaseChain string `json:"baseChain"`
|
||||
|
||||
@@ -2116,21 +2116,24 @@ func compatibleVars(side, orderPriceType string, status int64) (OrderVars, error
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetAvailableTransferChains returns the available transfer blockchains for the specific
|
||||
// cryptocurrency
|
||||
// GetAvailableTransferChains returns the available transfer blockchains for the specific cryptocurrency
|
||||
func (h *HUOBI) GetAvailableTransferChains(ctx context.Context, cryptocurrency currency.Code) ([]string, error) {
|
||||
chains, err := h.GetCurrenciesIncludingChains(ctx, cryptocurrency)
|
||||
resp, err := h.GetCurrenciesIncludingChains(ctx, cryptocurrency)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(chains) == 0 {
|
||||
return nil, errors.New("chain data isn't populated")
|
||||
if len(resp) == 0 {
|
||||
return nil, errors.New("no chains returned from currencies API")
|
||||
}
|
||||
|
||||
availableChains := make([]string, len(chains[0].ChainData))
|
||||
for x := range chains[0].ChainData {
|
||||
availableChains[x] = chains[0].ChainData[x].Chain
|
||||
chains := resp[0].ChainData
|
||||
|
||||
availableChains := make([]string, 0, len(chains))
|
||||
for _, c := range chains {
|
||||
if c.DepositStatus == "allowed" || c.WithdrawStatus == "allowed" {
|
||||
availableChains = append(availableChains, c.Chain)
|
||||
}
|
||||
}
|
||||
return availableChains, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user