mirror of
https://github.com/status-im/status-go.git
synced 2025-01-17 18:22:13 +00:00
fix_: issue from the PR
This commit is contained in:
parent
4113fea80f
commit
7de2670f54
@ -17,6 +17,14 @@ const (
|
||||
ArbitrumSepoliaChainID uint64 = 421614
|
||||
sntSymbol = "SNT"
|
||||
sttSymbol = "STT"
|
||||
proxyNodefleet = "proxy-nodefleet"
|
||||
proxyInfura = "proxy-infura"
|
||||
proxyGrove = "proxy-grove"
|
||||
nodefleet = "nodefleet"
|
||||
infura = "infura"
|
||||
grove = "grove"
|
||||
directInfura = "direct-infura"
|
||||
directGrove = "direct-grove"
|
||||
)
|
||||
|
||||
func proxyUrl(stageName, provider, chainName, networkName string) string {
|
||||
@ -30,12 +38,12 @@ func mainnet(stageName string) params.Network {
|
||||
|
||||
rpcProviders := []params.RpcProvider{
|
||||
// Proxy providers
|
||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), false),
|
||||
// Direct providers
|
||||
*params.NewDirectProvider(chainID, "direct-infura", "https://mainnet.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, "direct-grove", "https://eth-archival.rpc.grove.city/v1/", false),
|
||||
*params.NewDirectProvider(chainID, directInfura, "https://mainnet.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, directGrove, "https://eth-archival.rpc.grove.city/v1/", false),
|
||||
}
|
||||
|
||||
return params.Network{
|
||||
@ -63,12 +71,12 @@ func sepolia(stageName string) params.Network {
|
||||
|
||||
rpcProviders := []params.RpcProvider{
|
||||
// Proxy providers
|
||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
||||
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||
// Direct providers
|
||||
*params.NewDirectProvider(chainID, "direct-infura", "https://sepolia.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, "direct-grove", "https://sepolia-archival.rpc.grove.city/v1/", false),
|
||||
*params.NewDirectProvider(chainID, directInfura, "https://sepolia.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, directGrove, "https://sepolia-archival.rpc.grove.city/v1/", false),
|
||||
}
|
||||
|
||||
return params.Network{
|
||||
@ -88,6 +96,7 @@ func sepolia(stageName string) params.Network {
|
||||
RelatedChainID: MainnetChainID,
|
||||
}
|
||||
}
|
||||
|
||||
func optimism(stageName string) params.Network {
|
||||
chainID := OptimismChainID
|
||||
chainName := "optimism"
|
||||
@ -95,12 +104,12 @@ func optimism(stageName string) params.Network {
|
||||
|
||||
rpcProviders := []params.RpcProvider{
|
||||
// Proxy providers
|
||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
||||
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||
// Direct providers
|
||||
*params.NewDirectProvider(chainID, "direct-infura", "https://optimism-mainnet.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, "direct-grove", "https://optimism-archival.rpc.grove.city/v1/", false),
|
||||
*params.NewDirectProvider(chainID, directInfura, "https://optimism-mainnet.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, directGrove, "https://optimism-archival.rpc.grove.city/v1/", false),
|
||||
}
|
||||
|
||||
return params.Network{
|
||||
@ -120,6 +129,7 @@ func optimism(stageName string) params.Network {
|
||||
RelatedChainID: OptimismSepoliaChainID,
|
||||
}
|
||||
}
|
||||
|
||||
func optimismSepolia(stageName string) params.Network {
|
||||
chainID := OptimismSepoliaChainID
|
||||
chainName := "optimism"
|
||||
@ -127,12 +137,12 @@ func optimismSepolia(stageName string) params.Network {
|
||||
|
||||
rpcProviders := []params.RpcProvider{
|
||||
// Proxy providers
|
||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
||||
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||
// Direct providers
|
||||
*params.NewDirectProvider(chainID, "direct-infura", "https://optimism-sepolia.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, "direct-grove", "https://optimism-sepolia-archival.rpc.grove.city/v1/", false),
|
||||
*params.NewDirectProvider(chainID, directInfura, "https://optimism-sepolia.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, directGrove, "https://optimism-sepolia-archival.rpc.grove.city/v1/", false),
|
||||
}
|
||||
|
||||
return params.Network{
|
||||
@ -152,6 +162,7 @@ func optimismSepolia(stageName string) params.Network {
|
||||
RelatedChainID: OptimismChainID,
|
||||
}
|
||||
}
|
||||
|
||||
func arbitrum(stageName string) params.Network {
|
||||
chainID := ArbitrumChainID
|
||||
chainName := "arbitrum"
|
||||
@ -159,12 +170,12 @@ func arbitrum(stageName string) params.Network {
|
||||
|
||||
rpcProviders := []params.RpcProvider{
|
||||
// Proxy providers
|
||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
||||
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||
// Direct providers
|
||||
*params.NewDirectProvider(chainID, "direct-infura", "https://arbitrum-mainnet.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, "direct-grove", "https://arbitrum-one.rpc.grove.city/v1/", false),
|
||||
*params.NewDirectProvider(chainID, directInfura, "https://arbitrum-mainnet.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, directGrove, "https://arbitrum-one.rpc.grove.city/v1/", false),
|
||||
}
|
||||
|
||||
return params.Network{
|
||||
@ -184,6 +195,7 @@ func arbitrum(stageName string) params.Network {
|
||||
RelatedChainID: ArbitrumSepoliaChainID,
|
||||
}
|
||||
}
|
||||
|
||||
func arbitrumSepolia(stageName string) params.Network {
|
||||
chainID := ArbitrumSepoliaChainID
|
||||
chainName := "arbitrum"
|
||||
@ -191,12 +203,12 @@ func arbitrumSepolia(stageName string) params.Network {
|
||||
|
||||
rpcProviders := []params.RpcProvider{
|
||||
// Proxy providers
|
||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
||||
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||
// Direct providers
|
||||
*params.NewDirectProvider(chainID, "direct-infura", "https://arbitrum-sepolia.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, "direct-grove", "https://arbitrum-sepolia-archival.rpc.grove.city/v1/", false),
|
||||
*params.NewDirectProvider(chainID, directInfura, "https://arbitrum-sepolia.infura.io/v3/", true),
|
||||
*params.NewDirectProvider(chainID, directGrove, "https://arbitrum-sepolia-archival.rpc.grove.city/v1/", false),
|
||||
}
|
||||
|
||||
return params.Network{
|
||||
|
@ -63,12 +63,13 @@ func TestBuildDefaultNetworks(t *testing.T) {
|
||||
|
||||
// Check direct providers for tokens
|
||||
for _, provider := range n.RpcProviders {
|
||||
if provider.Type == params.EmbeddedDirectProviderType {
|
||||
if strings.Contains(provider.URL, "infura.io") {
|
||||
require.Equal(t, provider.AuthToken, infuraToken, "Direct provider URL should have infuraToken")
|
||||
} else if strings.Contains(provider.URL, "grove.city") {
|
||||
require.Equal(t, provider.AuthToken, poktToken, "Direct provider URL should have poktToken")
|
||||
}
|
||||
if provider.Type != params.EmbeddedDirectProviderType {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(provider.URL, "infura.io") {
|
||||
require.Equal(t, provider.AuthToken, infuraToken, "Direct provider URL should have infuraToken")
|
||||
} else if strings.Contains(provider.URL, "grove.city") {
|
||||
require.Equal(t, provider.AuthToken, poktToken, "Direct provider URL should have poktToken")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,15 @@ type Network struct {
|
||||
RelatedChainID uint64 `json:"relatedChainId" validate:"omitempty"`
|
||||
}
|
||||
|
||||
func (n *Network) DeepCopy() Network {
|
||||
updatedNetwork := *n
|
||||
updatedNetwork.RpcProviders = make([]RpcProvider, len(n.RpcProviders))
|
||||
copy(updatedNetwork.RpcProviders, n.RpcProviders)
|
||||
updatedNetwork.TokenOverrides = make([]TokenOverride, len(n.TokenOverrides))
|
||||
copy(updatedNetwork.TokenOverrides, n.TokenOverrides)
|
||||
return updatedNetwork
|
||||
}
|
||||
|
||||
func newRpcProvider(chainID uint64, name, url string, enableRpsLimiter bool, providerType RpcProviderType) *RpcProvider {
|
||||
return &RpcProvider{
|
||||
ChainID: chainID,
|
||||
|
@ -118,19 +118,10 @@ func OverrideEmbeddedProxyProviders(networks []params.Network, enabled bool, use
|
||||
return updatedNetworks
|
||||
}
|
||||
|
||||
func DeepCopyNetwork(network params.Network) params.Network {
|
||||
updatedNetwork := network
|
||||
updatedNetwork.RpcProviders = make([]params.RpcProvider, len(network.RpcProviders))
|
||||
copy(updatedNetwork.RpcProviders, network.RpcProviders)
|
||||
updatedNetwork.TokenOverrides = make([]params.TokenOverride, len(network.TokenOverrides))
|
||||
copy(updatedNetwork.TokenOverrides, network.TokenOverrides)
|
||||
return updatedNetwork
|
||||
}
|
||||
|
||||
func DeepCopyNetworks(networks []params.Network) []params.Network {
|
||||
updatedNetworks := make([]params.Network, len(networks))
|
||||
for i, network := range networks {
|
||||
updatedNetworks[i] = DeepCopyNetwork(network)
|
||||
updatedNetworks[i] = network.DeepCopy()
|
||||
}
|
||||
return updatedNetworks
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func TestDeepCopyNetwork(t *testing.T) {
|
||||
{Symbol: "token1", Address: common.HexToAddress("0x123")},
|
||||
}
|
||||
|
||||
copiedNetwork := networkhelper.DeepCopyNetwork(*originalNetwork)
|
||||
copiedNetwork := originalNetwork.DeepCopy()
|
||||
|
||||
assert.True(t, reflect.DeepEqual(originalNetwork, &copiedNetwork), "Copied network should be deeply equal to the original")
|
||||
|
||||
|
@ -297,18 +297,43 @@ func (c *Client) getEthClients(network *params.Network) []ethclient.RPSLimitedEt
|
||||
headers.Set("User-Agent", rpcUserAgentName)
|
||||
|
||||
// Set up authentication if needed
|
||||
if provider.AuthType != params.NoAuth {
|
||||
switch provider.AuthType {
|
||||
case params.BasicAuth:
|
||||
authEncoded := base64.StdEncoding.EncodeToString([]byte(provider.AuthLogin + ":" + provider.AuthPassword))
|
||||
headers.Set("Authorization", "Basic "+authEncoded)
|
||||
case params.TokenAuth:
|
||||
provider.URL = provider.URL + provider.AuthToken
|
||||
}
|
||||
switch provider.AuthType {
|
||||
case params.BasicAuth:
|
||||
authEncoded := base64.StdEncoding.EncodeToString([]byte(provider.AuthLogin + ":" + provider.AuthPassword))
|
||||
headers.Set("Authorization", "Basic "+authEncoded)
|
||||
case params.TokenAuth:
|
||||
provider.URL = provider.URL + provider.AuthToken
|
||||
case params.NoAuth:
|
||||
// no-op
|
||||
default:
|
||||
c.logger.Error("unknown auth type", zap.String("auth_type", string(provider.AuthType)))
|
||||
}
|
||||
|
||||
opts = append(opts, gethrpc.WithHeaders(headers))
|
||||
|
||||
// print provider details:
|
||||
c.logger.Info("RPC provider",
|
||||
zap.String("name", provider.Name),
|
||||
zap.String("url", provider.URL),
|
||||
zap.Bool("enabled", provider.Enabled),
|
||||
zap.Bool("rps_limiter", provider.EnableRPSLimiter),
|
||||
// token
|
||||
zap.String("auth_login", provider.AuthLogin),
|
||||
zap.String("auth_password", provider.AuthPassword),
|
||||
zap.String("auth_token", provider.AuthToken),
|
||||
)
|
||||
// print the same with fmt.println
|
||||
fmt.Println("RPC provider",
|
||||
"name", provider.Name,
|
||||
"url", provider.URL,
|
||||
"enabled", provider.Enabled,
|
||||
"rps_limiter", provider.EnableRPSLimiter,
|
||||
// token
|
||||
"auth_login", provider.AuthLogin,
|
||||
"auth_password", provider.AuthPassword,
|
||||
"auth_token", provider.AuthToken,
|
||||
)
|
||||
|
||||
// Dial the RPC client
|
||||
rpcClient, err := gethrpc.DialOptions(context.Background(), provider.URL, opts...)
|
||||
if err != nil {
|
||||
|
@ -138,7 +138,7 @@ func (nm *Manager) setEmbeddedProviders(networks []*params.Network) {
|
||||
|
||||
// networkWithoutEmbeddedProviders returns a copy of the given network without embedded RPC providers.
|
||||
func (nm *Manager) networkWithoutEmbeddedProviders(network *params.Network) *params.Network {
|
||||
networkCopy := networkhelper.DeepCopyNetwork(*network)
|
||||
networkCopy := network.DeepCopy()
|
||||
networkCopy.RpcProviders = networkhelper.GetUserProviders(network.RpcProviders)
|
||||
return &networkCopy
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user