Skip to content

Commit

Permalink
feat(wallet)_: add status proxy RPC urls for blockchain providers
Browse files Browse the repository at this point in the history
Replace the status proxy URL for cryptocompare.
  • Loading branch information
IvanBelyakoff committed Aug 1, 2024
1 parent 780e3e5 commit b74d9e6
Show file tree
Hide file tree
Showing 23 changed files with 308 additions and 106 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ GIT_AUTHOR := $(shell git config user.email || echo $$USER)
ENABLE_METRICS ?= true
BUILD_TAGS ?= gowaku_no_rln

ifdef RELEASE
BUILD_TAGS += release
endif


BUILD_FLAGS ?= -ldflags="-X github.com/status-im/status-go/params.Version=$(RELEASE_TAG:v%=%) \
-X github.com/status-im/status-go/params.GitCommit=$(GIT_COMMIT) \
-X github.com/status-im/status-go/params.IpfsGatewayURL=$(IPFS_GATEWAY_URL) \
Expand Down
14 changes: 14 additions & 0 deletions api/default_networks.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package api

import (
"fmt"
"strings"

"github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-go/buildinfo"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/protocol/requests"
)
Expand All @@ -27,6 +29,8 @@ var ganacheTokenAddress = common.HexToAddress("0x8571Ddc46b10d31EF963aF49b6C7799
var mainnet = params.Network{
ChainID: mainnetChainID,
ChainName: "Mainnet",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/mainnet/", buildinfo.ApiProxyStageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/mainnet/", buildinfo.ApiProxyStageName),
RPCURL: "https://eth-archival.rpc.grove.city/v1/",
FallbackURL: "https://mainnet.infura.io/v3/",
BlockExplorerURL: "https://etherscan.io/",
Expand Down Expand Up @@ -63,6 +67,8 @@ var goerli = params.Network{
var sepolia = params.Network{
ChainID: sepoliaChainID,
ChainName: "Mainnet",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/sepolia/", buildinfo.ApiProxyStageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/sepolia/", buildinfo.ApiProxyStageName),
RPCURL: "https://sepolia-archival.rpc.grove.city/v1/",
FallbackURL: "https://sepolia.infura.io/v3/",
BlockExplorerURL: "https://sepolia.etherscan.io/",
Expand All @@ -81,6 +87,8 @@ var sepolia = params.Network{
var optimism = params.Network{
ChainID: optimismChainID,
ChainName: "Optimism",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/optimism/mainnet/", buildinfo.ApiProxyStageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/mainnet/", buildinfo.ApiProxyStageName),
RPCURL: "https://optimism-archival.rpc.grove.city/v1/",
FallbackURL: "https://optimism-mainnet.infura.io/v3/",
BlockExplorerURL: "https://optimistic.etherscan.io",
Expand Down Expand Up @@ -117,6 +125,8 @@ var optimismGoerli = params.Network{
var optimismSepolia = params.Network{
ChainID: optimismSepoliaChainID,
ChainName: "Optimism",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/optimism/sepolia/", buildinfo.ApiProxyStageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/sepolia/", buildinfo.ApiProxyStageName),
RPCURL: "https://optimism-sepolia-archival.rpc.grove.city/v1/",
FallbackURL: "https://optimism-sepolia.infura.io/v3/",
BlockExplorerURL: "https://sepolia-optimism.etherscan.io/",
Expand All @@ -135,6 +145,8 @@ var optimismSepolia = params.Network{
var arbitrum = params.Network{
ChainID: arbitrumChainID,
ChainName: "Arbitrum",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/mainnet/", buildinfo.ApiProxyStageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/mainnet/", buildinfo.ApiProxyStageName),
RPCURL: "https://arbitrum-one.rpc.grove.city/v1/",
FallbackURL: "https://arbitrum-mainnet.infura.io/v3/",
BlockExplorerURL: "https://arbiscan.io/",
Expand Down Expand Up @@ -171,6 +183,8 @@ var arbitrumGoerli = params.Network{
var arbitrumSepolia = params.Network{
ChainID: arbitrumSepoliaChainID,
ChainName: "Arbitrum",
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/sepolia/", buildinfo.ApiProxyStageName),
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/sepolia/", buildinfo.ApiProxyStageName),
RPCURL: "https://arbitrum-sepolia-archival.rpc.grove.city/v1/",
FallbackURL: "https://arbitrum-sepolia.infura.io/v3/",
BlockExplorerURL: "https://sepolia-explorer.arbitrum.io/",
Expand Down
12 changes: 10 additions & 2 deletions api/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func SetFleet(fleet string, nodeConfig *params.NodeConfig) error {
return nil
}

func buildWalletConfig(request *requests.WalletSecretsConfig) params.WalletConfig {
func buildWalletConfig(request *requests.WalletSecretsConfig, statusProxyEnabled bool) params.WalletConfig {
walletConfig := params.WalletConfig{
Enabled: true,
AlchemyAPIKeys: make(map[uint64]string),
Expand Down Expand Up @@ -220,6 +220,14 @@ func buildWalletConfig(request *requests.WalletSecretsConfig) params.WalletConfi
if request.StatusProxyMarketPassword != "" {
walletConfig.StatusProxyMarketPassword = request.StatusProxyMarketPassword
}
if request.StatusProxyBlockchainUser != "" {
walletConfig.StatusProxyBlockchainUser = request.StatusProxyBlockchainUser
}
if request.StatusProxyBlockchainPassword != "" {
walletConfig.StatusProxyBlockchainPassword = request.StatusProxyBlockchainPassword
}

walletConfig.StatusProxyEnabled = statusProxyEnabled

return walletConfig
}
Expand Down Expand Up @@ -287,7 +295,7 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount, o
nodeConfig.MaxPeers = DefaultMaxPeers
nodeConfig.MaxPendingPeers = DefaultMaxPendingPeers

nodeConfig.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig)
nodeConfig.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig, request.StatusProxyEnabled)

nodeConfig.LocalNotificationsConfig = params.LocalNotificationsConfig{Enabled: true}
nodeConfig.BrowsersConfig = params.BrowsersConfig{Enabled: true}
Expand Down
2 changes: 1 addition & 1 deletion api/geth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
KeycardPairingDataFile: DefaultKeycardPairingDataFile,
}

defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig)
defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig, request.StatusProxyEnabled)

err = b.UpdateNodeConfigFleet(acc, request.Password, defaultCfg)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions buildinfo/apiproxystage_dev.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !release

package buildinfo

var ApiProxyStageName = "test"
5 changes: 5 additions & 0 deletions buildinfo/apiproxystage_prod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build release

package buildinfo

var ApiProxyStageName = "prod"
15 changes: 14 additions & 1 deletion node/get_status_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,20 @@ func (n *StatusNode) setupRPCClient() (err error) {
if err != nil {
return
}
n.rpcClient, err = rpc.NewClient(gethNodeClient, n.config.NetworkID, n.config.UpstreamConfig, n.config.Networks, n.appDB)

// ProviderConfigs should be passed not in wallet secrets config on login
// but some other way, as it's not wallet specific and should not be passed with login request
// but currently there is no other way to pass it
providerConfigs := []params.ProviderConfig{
{
Enabled: n.config.WalletConfig.StatusProxyEnabled,
Name: rpc.ProviderStatusProxy,
User: n.config.WalletConfig.StatusProxyBlockchainUser,
Password: n.config.WalletConfig.StatusProxyBlockchainPassword,
},
}

n.rpcClient, err = rpc.NewClient(gethNodeClient, n.config.NetworkID, n.config.UpstreamConfig, n.config.Networks, n.appDB, providerConfigs)
if err != nil {
return
}
Expand Down
40 changes: 30 additions & 10 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ type UpstreamRPCConfig struct {
URL string
}

type ProviderConfig struct {
// Enabled flag specifies whether feature is enabled
Enabled bool `validate:"required"`

// To identify provider
Name string `validate:"required"`

// URL sets the rpc upstream host address for communication with
// a non-local infura endpoint.
User string `json:",omitempty"`
Password string `json:",omitempty"`
APIKey string `json:"APIKey,omitempty"`
APIKeySecret string `json:"APIKeySecret,omitempty"`
}

// ----------
// NodeConfig
// ----------
Expand Down Expand Up @@ -531,6 +546,8 @@ type TokenOverride struct {
type Network struct {
ChainID uint64 `json:"chainId"`
ChainName string `json:"chainName"`
DefaultRPCURL string `json:"defaultRpcUrl"` // proxy rpc url
DefaultFallbackURL string `json:"defaultFallbackURL"` // proxy fallback url
RPCURL string `json:"rpcUrl"`
OriginalRPCURL string `json:"originalRpcUrl"`
FallbackURL string `json:"fallbackURL"`
Expand All @@ -551,16 +568,19 @@ type Network struct {

// WalletConfig extra configuration for wallet.Service.
type WalletConfig struct {
Enabled bool
OpenseaAPIKey string `json:"OpenseaAPIKey"`
RaribleMainnetAPIKey string `json:"RaribleMainnetAPIKey"`
RaribleTestnetAPIKey string `json:"RaribleTestnetAPIKey"`
AlchemyAPIKeys map[uint64]string `json:"AlchemyAPIKeys"`
InfuraAPIKey string `json:"InfuraAPIKey"`
InfuraAPIKeySecret string `json:"InfuraAPIKeySecret"`
StatusProxyMarketUser string `json:"StatusProxyMarketUser"`
StatusProxyMarketPassword string `json:"StatusProxyMarketPassword"`
EnableCelerBridge bool `json:"EnableCelerBridge"`
Enabled bool
OpenseaAPIKey string `json:"OpenseaAPIKey"`
RaribleMainnetAPIKey string `json:"RaribleMainnetAPIKey"`
RaribleTestnetAPIKey string `json:"RaribleTestnetAPIKey"`
AlchemyAPIKeys map[uint64]string `json:"AlchemyAPIKeys"`
InfuraAPIKey string `json:"InfuraAPIKey"`
InfuraAPIKeySecret string `json:"InfuraAPIKeySecret"`
StatusProxyMarketUser string `json:"StatusProxyMarketUser"`
StatusProxyMarketPassword string `json:"StatusProxyMarketPassword"`
StatusProxyBlockchainUser string `json:"StatusProxyBlockchainUser"`
StatusProxyBlockchainPassword string `json:"StatusProxyBlockchainPassword"`
StatusProxyEnabled bool `json:"StatusProxyEnabled"`
EnableCelerBridge bool `json:"EnableCelerBridge"`
}

// LocalNotificationsConfig extra configuration for localnotifications.Service.
Expand Down
25 changes: 14 additions & 11 deletions protocol/requests/create_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type CreateAccount struct {

KeycardInstanceUID string `json:"keycardInstanceUID"`
KeycardPairingDataFile *string `json:"keycardPairingDataFile"`
StatusProxyEnabled bool `json:"statusProxyEnabled"`
}

type WalletSecretsConfig struct {
Expand All @@ -96,17 +97,19 @@ type WalletSecretsConfig struct {
RaribleMainnetAPIKey string `json:"raribleMainnetApiKey"`
RaribleTestnetAPIKey string `json:"raribleTestnetApiKey"`

AlchemyEthereumMainnetToken string `json:"alchemyEthereumMainnetToken"`
AlchemyEthereumGoerliToken string `json:"alchemyEthereumGoerliToken"`
AlchemyEthereumSepoliaToken string `json:"alchemyEthereumSepoliaToken"`
AlchemyArbitrumMainnetToken string `json:"alchemyArbitrumMainnetToken"`
AlchemyArbitrumGoerliToken string `json:"alchemyArbitrumGoerliToken"`
AlchemyArbitrumSepoliaToken string `json:"alchemyArbitrumSepoliaToken"`
AlchemyOptimismMainnetToken string `json:"alchemyOptimismMainnetToken"`
AlchemyOptimismGoerliToken string `json:"alchemyOptimismGoerliToken"`
AlchemyOptimismSepoliaToken string `json:"alchemyOptimismSepoliaToken"`
StatusProxyMarketUser string `json:"statusProxyMarketUser"`
StatusProxyMarketPassword string `json:"statusProxyMarketPassword"`
AlchemyEthereumMainnetToken string `json:"alchemyEthereumMainnetToken"`
AlchemyEthereumGoerliToken string `json:"alchemyEthereumGoerliToken"`
AlchemyEthereumSepoliaToken string `json:"alchemyEthereumSepoliaToken"`
AlchemyArbitrumMainnetToken string `json:"alchemyArbitrumMainnetToken"`
AlchemyArbitrumGoerliToken string `json:"alchemyArbitrumGoerliToken"`
AlchemyArbitrumSepoliaToken string `json:"alchemyArbitrumSepoliaToken"`
AlchemyOptimismMainnetToken string `json:"alchemyOptimismMainnetToken"`
AlchemyOptimismGoerliToken string `json:"alchemyOptimismGoerliToken"`
AlchemyOptimismSepoliaToken string `json:"alchemyOptimismSepoliaToken"`
StatusProxyMarketUser string `json:"statusProxyMarketUser"`
StatusProxyMarketPassword string `json:"statusProxyMarketPassword"`
StatusProxyBlockchainUser string `json:"statusProxyBlockchainUser"`
StatusProxyBlockchainPassword string `json:"statusProxyBlockchainPassword"`

// Testing
GanacheURL string `json:"ganacheURL"`
Expand Down
3 changes: 2 additions & 1 deletion protocol/requests/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ type Login struct {

WalletSecretsConfig

APIConfig *APIConfig `json:"apiConfig"`
APIConfig *APIConfig `json:"apiConfig"`
StatusProxyEnabled bool `json:"statusProxyEnabled"`
}

func (c *Login) Validate() error {
Expand Down
Loading

0 comments on commit b74d9e6

Please sign in to comment.