fix(wallet)_: set a separate id (and circuit) for the cryptcompare proxy
This commit is contained in:
parent
59b3334f2d
commit
90b3d0fdcc
|
@ -120,6 +120,7 @@ func NewService(
|
|||
cryptoCompare := cryptocompare.NewClient()
|
||||
coingecko := coingecko.NewClient()
|
||||
cryptoCompareProxy := cryptocompare.NewClientWithParams(cryptocompare.Params{
|
||||
ID: fmt.Sprintf("%s-proxy", cryptoCompare.ID()),
|
||||
URL: fmt.Sprintf("https://%s.api.status.im/cryptocompare/", statusProxyStageName),
|
||||
User: config.WalletConfig.StatusProxyMarketUser,
|
||||
Password: config.WalletConfig.StatusProxyMarketPassword,
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/status-im/status-go/services/wallet/thirdparty/utils"
|
||||
)
|
||||
|
||||
const baseID = "cryptocompare"
|
||||
const extraParamStatus = "Status.im"
|
||||
const baseURL = "https://min-api.cryptocompare.com"
|
||||
|
||||
|
@ -34,22 +35,24 @@ type MarketValuesContainer struct {
|
|||
}
|
||||
|
||||
type Params struct {
|
||||
ID string
|
||||
URL string
|
||||
User string
|
||||
Password string
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
id string
|
||||
httpClient *thirdparty.HTTPClient
|
||||
baseURL string
|
||||
creds *thirdparty.BasicCreds
|
||||
}
|
||||
|
||||
func NewClient() *Client {
|
||||
return &Client{
|
||||
httpClient: thirdparty.NewHTTPClient(),
|
||||
baseURL: baseURL,
|
||||
}
|
||||
return NewClientWithParams(Params{
|
||||
ID: baseID,
|
||||
URL: baseURL,
|
||||
})
|
||||
}
|
||||
|
||||
func NewClientWithParams(params Params) *Client {
|
||||
|
@ -62,6 +65,7 @@ func NewClientWithParams(params Params) *Client {
|
|||
}
|
||||
|
||||
return &Client{
|
||||
id: params.ID,
|
||||
httpClient: thirdparty.NewHTTPClient(),
|
||||
baseURL: params.URL,
|
||||
creds: creds,
|
||||
|
@ -215,5 +219,5 @@ func (c *Client) FetchHistoricalDailyPrices(symbol string, currency string, limi
|
|||
}
|
||||
|
||||
func (c *Client) ID() string {
|
||||
return "cryptocompare"
|
||||
return c.id
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package cryptocompare
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIDs(t *testing.T) {
|
||||
stdClient := NewClient()
|
||||
require.Equal(t, baseID, stdClient.ID())
|
||||
|
||||
clientWithParams := NewClientWithParams(Params{
|
||||
ID: "testID",
|
||||
})
|
||||
require.Equal(t, "testID", clientWithParams.ID())
|
||||
}
|
Loading…
Reference in New Issue