mirror of
https://github.com/status-im/status-go.git
synced 2025-01-18 02:31:47 +00:00
fix_: issue from the PR
This commit is contained in:
parent
4113fea80f
commit
7de2670f54
@ -17,6 +17,14 @@ const (
|
|||||||
ArbitrumSepoliaChainID uint64 = 421614
|
ArbitrumSepoliaChainID uint64 = 421614
|
||||||
sntSymbol = "SNT"
|
sntSymbol = "SNT"
|
||||||
sttSymbol = "STT"
|
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 {
|
func proxyUrl(stageName, provider, chainName, networkName string) string {
|
||||||
@ -30,12 +38,12 @@ func mainnet(stageName string) params.Network {
|
|||||||
|
|
||||||
rpcProviders := []params.RpcProvider{
|
rpcProviders := []params.RpcProvider{
|
||||||
// Proxy providers
|
// Proxy providers
|
||||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), false),
|
||||||
// Direct providers
|
// Direct providers
|
||||||
*params.NewDirectProvider(chainID, "direct-infura", "https://mainnet.infura.io/v3/", true),
|
*params.NewDirectProvider(chainID, directInfura, "https://mainnet.infura.io/v3/", true),
|
||||||
*params.NewDirectProvider(chainID, "direct-grove", "https://eth-archival.rpc.grove.city/v1/", false),
|
*params.NewDirectProvider(chainID, directGrove, "https://eth-archival.rpc.grove.city/v1/", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params.Network{
|
return params.Network{
|
||||||
@ -63,12 +71,12 @@ func sepolia(stageName string) params.Network {
|
|||||||
|
|
||||||
rpcProviders := []params.RpcProvider{
|
rpcProviders := []params.RpcProvider{
|
||||||
// Proxy providers
|
// Proxy providers
|
||||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||||
// Direct providers
|
// Direct providers
|
||||||
*params.NewDirectProvider(chainID, "direct-infura", "https://sepolia.infura.io/v3/", true),
|
*params.NewDirectProvider(chainID, directInfura, "https://sepolia.infura.io/v3/", true),
|
||||||
*params.NewDirectProvider(chainID, "direct-grove", "https://sepolia-archival.rpc.grove.city/v1/", false),
|
*params.NewDirectProvider(chainID, directGrove, "https://sepolia-archival.rpc.grove.city/v1/", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params.Network{
|
return params.Network{
|
||||||
@ -88,6 +96,7 @@ func sepolia(stageName string) params.Network {
|
|||||||
RelatedChainID: MainnetChainID,
|
RelatedChainID: MainnetChainID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func optimism(stageName string) params.Network {
|
func optimism(stageName string) params.Network {
|
||||||
chainID := OptimismChainID
|
chainID := OptimismChainID
|
||||||
chainName := "optimism"
|
chainName := "optimism"
|
||||||
@ -95,12 +104,12 @@ func optimism(stageName string) params.Network {
|
|||||||
|
|
||||||
rpcProviders := []params.RpcProvider{
|
rpcProviders := []params.RpcProvider{
|
||||||
// Proxy providers
|
// Proxy providers
|
||||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||||
// Direct providers
|
// Direct providers
|
||||||
*params.NewDirectProvider(chainID, "direct-infura", "https://optimism-mainnet.infura.io/v3/", true),
|
*params.NewDirectProvider(chainID, directInfura, "https://optimism-mainnet.infura.io/v3/", true),
|
||||||
*params.NewDirectProvider(chainID, "direct-grove", "https://optimism-archival.rpc.grove.city/v1/", false),
|
*params.NewDirectProvider(chainID, directGrove, "https://optimism-archival.rpc.grove.city/v1/", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params.Network{
|
return params.Network{
|
||||||
@ -120,6 +129,7 @@ func optimism(stageName string) params.Network {
|
|||||||
RelatedChainID: OptimismSepoliaChainID,
|
RelatedChainID: OptimismSepoliaChainID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func optimismSepolia(stageName string) params.Network {
|
func optimismSepolia(stageName string) params.Network {
|
||||||
chainID := OptimismSepoliaChainID
|
chainID := OptimismSepoliaChainID
|
||||||
chainName := "optimism"
|
chainName := "optimism"
|
||||||
@ -127,12 +137,12 @@ func optimismSepolia(stageName string) params.Network {
|
|||||||
|
|
||||||
rpcProviders := []params.RpcProvider{
|
rpcProviders := []params.RpcProvider{
|
||||||
// Proxy providers
|
// Proxy providers
|
||||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||||
// Direct providers
|
// Direct providers
|
||||||
*params.NewDirectProvider(chainID, "direct-infura", "https://optimism-sepolia.infura.io/v3/", true),
|
*params.NewDirectProvider(chainID, directInfura, "https://optimism-sepolia.infura.io/v3/", true),
|
||||||
*params.NewDirectProvider(chainID, "direct-grove", "https://optimism-sepolia-archival.rpc.grove.city/v1/", false),
|
*params.NewDirectProvider(chainID, directGrove, "https://optimism-sepolia-archival.rpc.grove.city/v1/", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params.Network{
|
return params.Network{
|
||||||
@ -152,6 +162,7 @@ func optimismSepolia(stageName string) params.Network {
|
|||||||
RelatedChainID: OptimismChainID,
|
RelatedChainID: OptimismChainID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func arbitrum(stageName string) params.Network {
|
func arbitrum(stageName string) params.Network {
|
||||||
chainID := ArbitrumChainID
|
chainID := ArbitrumChainID
|
||||||
chainName := "arbitrum"
|
chainName := "arbitrum"
|
||||||
@ -159,12 +170,12 @@ func arbitrum(stageName string) params.Network {
|
|||||||
|
|
||||||
rpcProviders := []params.RpcProvider{
|
rpcProviders := []params.RpcProvider{
|
||||||
// Proxy providers
|
// Proxy providers
|
||||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||||
// Direct providers
|
// Direct providers
|
||||||
*params.NewDirectProvider(chainID, "direct-infura", "https://arbitrum-mainnet.infura.io/v3/", true),
|
*params.NewDirectProvider(chainID, directInfura, "https://arbitrum-mainnet.infura.io/v3/", true),
|
||||||
*params.NewDirectProvider(chainID, "direct-grove", "https://arbitrum-one.rpc.grove.city/v1/", false),
|
*params.NewDirectProvider(chainID, directGrove, "https://arbitrum-one.rpc.grove.city/v1/", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params.Network{
|
return params.Network{
|
||||||
@ -184,6 +195,7 @@ func arbitrum(stageName string) params.Network {
|
|||||||
RelatedChainID: ArbitrumSepoliaChainID,
|
RelatedChainID: ArbitrumSepoliaChainID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func arbitrumSepolia(stageName string) params.Network {
|
func arbitrumSepolia(stageName string) params.Network {
|
||||||
chainID := ArbitrumSepoliaChainID
|
chainID := ArbitrumSepoliaChainID
|
||||||
chainName := "arbitrum"
|
chainName := "arbitrum"
|
||||||
@ -191,12 +203,12 @@ func arbitrumSepolia(stageName string) params.Network {
|
|||||||
|
|
||||||
rpcProviders := []params.RpcProvider{
|
rpcProviders := []params.RpcProvider{
|
||||||
// Proxy providers
|
// Proxy providers
|
||||||
*params.NewProxyProvider(chainID, "proxy-nodefleet", proxyUrl(stageName, "nodefleet", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyNodefleet, proxyUrl(stageName, nodefleet, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-infura", proxyUrl(stageName, "infura", chainName, networkName), false),
|
*params.NewProxyProvider(chainID, proxyInfura, proxyUrl(stageName, infura, chainName, networkName), false),
|
||||||
*params.NewProxyProvider(chainID, "proxy-grove", proxyUrl(stageName, "grove", chainName, networkName), true),
|
*params.NewProxyProvider(chainID, proxyGrove, proxyUrl(stageName, grove, chainName, networkName), true),
|
||||||
// Direct providers
|
// Direct providers
|
||||||
*params.NewDirectProvider(chainID, "direct-infura", "https://arbitrum-sepolia.infura.io/v3/", true),
|
*params.NewDirectProvider(chainID, directInfura, "https://arbitrum-sepolia.infura.io/v3/", true),
|
||||||
*params.NewDirectProvider(chainID, "direct-grove", "https://arbitrum-sepolia-archival.rpc.grove.city/v1/", false),
|
*params.NewDirectProvider(chainID, directGrove, "https://arbitrum-sepolia-archival.rpc.grove.city/v1/", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params.Network{
|
return params.Network{
|
||||||
|
@ -63,7 +63,9 @@ func TestBuildDefaultNetworks(t *testing.T) {
|
|||||||
|
|
||||||
// Check direct providers for tokens
|
// Check direct providers for tokens
|
||||||
for _, provider := range n.RpcProviders {
|
for _, provider := range n.RpcProviders {
|
||||||
if provider.Type == params.EmbeddedDirectProviderType {
|
if provider.Type != params.EmbeddedDirectProviderType {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if strings.Contains(provider.URL, "infura.io") {
|
if strings.Contains(provider.URL, "infura.io") {
|
||||||
require.Equal(t, provider.AuthToken, infuraToken, "Direct provider URL should have infuraToken")
|
require.Equal(t, provider.AuthToken, infuraToken, "Direct provider URL should have infuraToken")
|
||||||
} else if strings.Contains(provider.URL, "grove.city") {
|
} else if strings.Contains(provider.URL, "grove.city") {
|
||||||
@ -72,4 +74,3 @@ func TestBuildDefaultNetworks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -70,6 +70,15 @@ type Network struct {
|
|||||||
RelatedChainID uint64 `json:"relatedChainId" validate:"omitempty"`
|
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 {
|
func newRpcProvider(chainID uint64, name, url string, enableRpsLimiter bool, providerType RpcProviderType) *RpcProvider {
|
||||||
return &RpcProvider{
|
return &RpcProvider{
|
||||||
ChainID: chainID,
|
ChainID: chainID,
|
||||||
|
@ -118,19 +118,10 @@ func OverrideEmbeddedProxyProviders(networks []params.Network, enabled bool, use
|
|||||||
return updatedNetworks
|
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 {
|
func DeepCopyNetworks(networks []params.Network) []params.Network {
|
||||||
updatedNetworks := make([]params.Network, len(networks))
|
updatedNetworks := make([]params.Network, len(networks))
|
||||||
for i, network := range networks {
|
for i, network := range networks {
|
||||||
updatedNetworks[i] = DeepCopyNetwork(network)
|
updatedNetworks[i] = network.DeepCopy()
|
||||||
}
|
}
|
||||||
return updatedNetworks
|
return updatedNetworks
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ func TestDeepCopyNetwork(t *testing.T) {
|
|||||||
{Symbol: "token1", Address: common.HexToAddress("0x123")},
|
{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")
|
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)
|
headers.Set("User-Agent", rpcUserAgentName)
|
||||||
|
|
||||||
// Set up authentication if needed
|
// Set up authentication if needed
|
||||||
if provider.AuthType != params.NoAuth {
|
|
||||||
switch provider.AuthType {
|
switch provider.AuthType {
|
||||||
case params.BasicAuth:
|
case params.BasicAuth:
|
||||||
authEncoded := base64.StdEncoding.EncodeToString([]byte(provider.AuthLogin + ":" + provider.AuthPassword))
|
authEncoded := base64.StdEncoding.EncodeToString([]byte(provider.AuthLogin + ":" + provider.AuthPassword))
|
||||||
headers.Set("Authorization", "Basic "+authEncoded)
|
headers.Set("Authorization", "Basic "+authEncoded)
|
||||||
case params.TokenAuth:
|
case params.TokenAuth:
|
||||||
provider.URL = provider.URL + provider.AuthToken
|
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))
|
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
|
// Dial the RPC client
|
||||||
rpcClient, err := gethrpc.DialOptions(context.Background(), provider.URL, opts...)
|
rpcClient, err := gethrpc.DialOptions(context.Background(), provider.URL, opts...)
|
||||||
if err != nil {
|
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.
|
// networkWithoutEmbeddedProviders returns a copy of the given network without embedded RPC providers.
|
||||||
func (nm *Manager) networkWithoutEmbeddedProviders(network *params.Network) *params.Network {
|
func (nm *Manager) networkWithoutEmbeddedProviders(network *params.Network) *params.Network {
|
||||||
networkCopy := networkhelper.DeepCopyNetwork(*network)
|
networkCopy := network.DeepCopy()
|
||||||
networkCopy.RpcProviders = networkhelper.GetUserProviders(network.RpcProviders)
|
networkCopy.RpcProviders = networkhelper.GetUserProviders(network.RpcProviders)
|
||||||
return &networkCopy
|
return &networkCopy
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user