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()
|
cryptoCompare := cryptocompare.NewClient()
|
||||||
coingecko := coingecko.NewClient()
|
coingecko := coingecko.NewClient()
|
||||||
cryptoCompareProxy := cryptocompare.NewClientWithParams(cryptocompare.Params{
|
cryptoCompareProxy := cryptocompare.NewClientWithParams(cryptocompare.Params{
|
||||||
|
ID: fmt.Sprintf("%s-proxy", cryptoCompare.ID()),
|
||||||
URL: fmt.Sprintf("https://%s.api.status.im/cryptocompare/", statusProxyStageName),
|
URL: fmt.Sprintf("https://%s.api.status.im/cryptocompare/", statusProxyStageName),
|
||||||
User: config.WalletConfig.StatusProxyMarketUser,
|
User: config.WalletConfig.StatusProxyMarketUser,
|
||||||
Password: config.WalletConfig.StatusProxyMarketPassword,
|
Password: config.WalletConfig.StatusProxyMarketPassword,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/status-im/status-go/services/wallet/thirdparty/utils"
|
"github.com/status-im/status-go/services/wallet/thirdparty/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const baseID = "cryptocompare"
|
||||||
const extraParamStatus = "Status.im"
|
const extraParamStatus = "Status.im"
|
||||||
const baseURL = "https://min-api.cryptocompare.com"
|
const baseURL = "https://min-api.cryptocompare.com"
|
||||||
|
|
||||||
|
@ -34,22 +35,24 @@ type MarketValuesContainer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Params struct {
|
type Params struct {
|
||||||
|
ID string
|
||||||
URL string
|
URL string
|
||||||
User string
|
User string
|
||||||
Password string
|
Password string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
id string
|
||||||
httpClient *thirdparty.HTTPClient
|
httpClient *thirdparty.HTTPClient
|
||||||
baseURL string
|
baseURL string
|
||||||
creds *thirdparty.BasicCreds
|
creds *thirdparty.BasicCreds
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient() *Client {
|
func NewClient() *Client {
|
||||||
return &Client{
|
return NewClientWithParams(Params{
|
||||||
httpClient: thirdparty.NewHTTPClient(),
|
ID: baseID,
|
||||||
baseURL: baseURL,
|
URL: baseURL,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClientWithParams(params Params) *Client {
|
func NewClientWithParams(params Params) *Client {
|
||||||
|
@ -62,6 +65,7 @@ func NewClientWithParams(params Params) *Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
|
id: params.ID,
|
||||||
httpClient: thirdparty.NewHTTPClient(),
|
httpClient: thirdparty.NewHTTPClient(),
|
||||||
baseURL: params.URL,
|
baseURL: params.URL,
|
||||||
creds: creds,
|
creds: creds,
|
||||||
|
@ -215,5 +219,5 @@ func (c *Client) FetchHistoricalDailyPrices(symbol string, currency string, limi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ID() string {
|
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