fix(wallet)_: set a separate id (and circuit) for the cryptcompare proxy

This commit is contained in:
Dario Gabriel Lipicar 2024-08-19 16:27:53 -03:00 committed by Andrea Maria Piana
parent 83aa01c7da
commit 1d173734a6
3 changed files with 27 additions and 5 deletions

View File

@ -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,

View File

@ -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
}

View File

@ -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())
}