From 0954a4ad13960002b986815aabaf8c8bcff2fb02 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Wed, 14 Aug 2024 16:35:48 +0100 Subject: [PATCH] feat!: drive proxy stage name from the client --- Makefile | 5 - api/default_networks.go | 359 +++++++++--------- api/default_networks_test.go | 19 +- api/defaults.go | 10 +- api/geth_backend.go | 2 +- buildinfo/apiproxystage_dev.go | 5 - buildinfo/apiproxystage_prod.go | 5 - node/status_node_services.go | 5 +- params/config.go | 1 + protocol/requests/create_account.go | 20 +- services/wallet/keycard_pairings_test.go | 2 +- services/wallet/service.go | 4 +- .../wallet/thirdparty/cryptocompare/client.go | 3 - 13 files changed, 233 insertions(+), 207 deletions(-) delete mode 100644 buildinfo/apiproxystage_dev.go delete mode 100644 buildinfo/apiproxystage_prod.go diff --git a/Makefile b/Makefile index 6cde89f39..be509e8e7 100644 --- a/Makefile +++ b/Makefile @@ -61,11 +61,6 @@ 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) \ diff --git a/api/default_networks.go b/api/default_networks.go index d20c5385d..c4eb0ac39 100644 --- a/api/default_networks.go +++ b/api/default_networks.go @@ -5,7 +5,6 @@ import ( "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" ) @@ -26,190 +25,210 @@ const ( var ganacheTokenAddress = common.HexToAddress("0x8571Ddc46b10d31EF963aF49b6C7799Ea7eff818") -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/", - IconURL: "network/Network=Ethereum", - ChainColor: "#627EEA", - ShortName: "eth", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: false, - Layer: 1, - Enabled: true, - RelatedChainID: goerliChainID, +func mainnet(stageName string) params.Network { + return params.Network{ + ChainID: mainnetChainID, + ChainName: "Mainnet", + DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/mainnet/", stageName), + DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/mainnet/", stageName), + RPCURL: "https://eth-archival.rpc.grove.city/v1/", + FallbackURL: "https://mainnet.infura.io/v3/", + BlockExplorerURL: "https://etherscan.io/", + IconURL: "network/Network=Ethereum", + ChainColor: "#627EEA", + ShortName: "eth", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: false, + Layer: 1, + Enabled: true, + RelatedChainID: goerliChainID, + } } -var goerli = params.Network{ - ChainID: goerliChainID, - ChainName: "Mainnet", - RPCURL: "https://goerli.infura.io/v3/", - FallbackURL: "", - BlockExplorerURL: "https://goerli.etherscan.io/", - IconURL: "network/Network=Ethereum", - ChainColor: "#627EEA", - ShortName: "goEth", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: true, - Layer: 1, - Enabled: true, - RelatedChainID: mainnetChainID, +func goerli(stageName string) params.Network { + return params.Network{ + ChainID: goerliChainID, + ChainName: "Mainnet", + RPCURL: "https://goerli.infura.io/v3/", + FallbackURL: "", + BlockExplorerURL: "https://goerli.etherscan.io/", + IconURL: "network/Network=Ethereum", + ChainColor: "#627EEA", + ShortName: "goEth", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: true, + Layer: 1, + Enabled: true, + RelatedChainID: mainnetChainID, + } + +} +func sepolia(stageName string) params.Network { + return params.Network{ + ChainID: sepoliaChainID, + ChainName: "Mainnet", + DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/sepolia/", stageName), + DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/sepolia/", stageName), + RPCURL: "https://sepolia-archival.rpc.grove.city/v1/", + FallbackURL: "https://sepolia.infura.io/v3/", + BlockExplorerURL: "https://sepolia.etherscan.io/", + IconURL: "network/Network=Ethereum", + ChainColor: "#627EEA", + ShortName: "eth", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: true, + Layer: 1, + Enabled: true, + RelatedChainID: mainnetChainID, + } } -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/", - IconURL: "network/Network=Ethereum", - ChainColor: "#627EEA", - ShortName: "eth", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: true, - Layer: 1, - Enabled: true, - RelatedChainID: mainnetChainID, +func optimism(stageName string) params.Network { + return params.Network{ + ChainID: optimismChainID, + ChainName: "Optimism", + DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/optimism/mainnet/", stageName), + DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/mainnet/", stageName), + RPCURL: "https://optimism-archival.rpc.grove.city/v1/", + FallbackURL: "https://optimism-mainnet.infura.io/v3/", + BlockExplorerURL: "https://optimistic.etherscan.io", + IconURL: "network/Network=Optimism", + ChainColor: "#E90101", + ShortName: "oeth", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: false, + Layer: 2, + Enabled: true, + RelatedChainID: optimismGoerliChainID, + } } -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", - IconURL: "network/Network=Optimism", - ChainColor: "#E90101", - ShortName: "oeth", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: false, - Layer: 2, - Enabled: true, - RelatedChainID: optimismGoerliChainID, +func optimismGoerli(stageName string) params.Network { + return params.Network{ + ChainID: optimismGoerliChainID, + ChainName: "Optimism", + RPCURL: "https://optimism-goerli.infura.io/v3/", + FallbackURL: "", + BlockExplorerURL: "https://goerli-optimism.etherscan.io/", + IconURL: "network/Network=Optimism", + ChainColor: "#E90101", + ShortName: "goOpt", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: true, + Layer: 2, + Enabled: false, + RelatedChainID: optimismChainID, + } } -var optimismGoerli = params.Network{ - ChainID: optimismGoerliChainID, - ChainName: "Optimism", - RPCURL: "https://optimism-goerli.infura.io/v3/", - FallbackURL: "", - BlockExplorerURL: "https://goerli-optimism.etherscan.io/", - IconURL: "network/Network=Optimism", - ChainColor: "#E90101", - ShortName: "goOpt", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: true, - Layer: 2, - Enabled: false, - RelatedChainID: optimismChainID, +func optimismSepolia(stageName string) params.Network { + return params.Network{ + ChainID: optimismSepoliaChainID, + ChainName: "Optimism", + DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/optimism/sepolia/", stageName), + DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/sepolia/", stageName), + RPCURL: "https://optimism-sepolia-archival.rpc.grove.city/v1/", + FallbackURL: "https://optimism-sepolia.infura.io/v3/", + BlockExplorerURL: "https://sepolia-optimism.etherscan.io/", + IconURL: "network/Network=Optimism", + ChainColor: "#E90101", + ShortName: "oeth", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: true, + Layer: 2, + Enabled: false, + RelatedChainID: optimismChainID, + } } -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/", - IconURL: "network/Network=Optimism", - ChainColor: "#E90101", - ShortName: "oeth", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: true, - Layer: 2, - Enabled: false, - RelatedChainID: optimismChainID, +func arbitrum(stageName string) params.Network { + return params.Network{ + ChainID: arbitrumChainID, + ChainName: "Arbitrum", + DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/mainnet/", stageName), + DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/mainnet/", stageName), + RPCURL: "https://arbitrum-one.rpc.grove.city/v1/", + FallbackURL: "https://arbitrum-mainnet.infura.io/v3/", + BlockExplorerURL: "https://arbiscan.io/", + IconURL: "network/Network=Arbitrum", + ChainColor: "#51D0F0", + ShortName: "arb1", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: false, + Layer: 2, + Enabled: true, + RelatedChainID: arbitrumGoerliChainID, + } } -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/", - IconURL: "network/Network=Arbitrum", - ChainColor: "#51D0F0", - ShortName: "arb1", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: false, - Layer: 2, - Enabled: true, - RelatedChainID: arbitrumGoerliChainID, +func arbitrumGoerli(stageName string) params.Network { + return params.Network{ + ChainID: arbitrumGoerliChainID, + ChainName: "Arbitrum", + RPCURL: "https://arbitrum-goerli.infura.io/v3/", + FallbackURL: "", + BlockExplorerURL: "https://goerli.arbiscan.io/", + IconURL: "network/Network=Arbitrum", + ChainColor: "#51D0F0", + ShortName: "goArb", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: true, + Layer: 2, + Enabled: false, + RelatedChainID: arbitrumChainID, + } } -var arbitrumGoerli = params.Network{ - ChainID: arbitrumGoerliChainID, - ChainName: "Arbitrum", - RPCURL: "https://arbitrum-goerli.infura.io/v3/", - FallbackURL: "", - BlockExplorerURL: "https://goerli.arbiscan.io/", - IconURL: "network/Network=Arbitrum", - ChainColor: "#51D0F0", - ShortName: "goArb", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: true, - Layer: 2, - Enabled: false, - RelatedChainID: arbitrumChainID, +func arbitrumSepolia(stageName string) params.Network { + return params.Network{ + ChainID: arbitrumSepoliaChainID, + ChainName: "Arbitrum", + DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/sepolia/", stageName), + DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/sepolia/", stageName), + RPCURL: "https://arbitrum-sepolia-archival.rpc.grove.city/v1/", + FallbackURL: "https://arbitrum-sepolia.infura.io/v3/", + BlockExplorerURL: "https://sepolia-explorer.arbitrum.io/", + IconURL: "network/Network=Arbitrum", + ChainColor: "#51D0F0", + ShortName: "arb1", + NativeCurrencyName: "Ether", + NativeCurrencySymbol: "ETH", + NativeCurrencyDecimals: 18, + IsTest: true, + Layer: 2, + Enabled: false, + RelatedChainID: arbitrumChainID, + } } -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/", - IconURL: "network/Network=Arbitrum", - ChainColor: "#51D0F0", - ShortName: "arb1", - NativeCurrencyName: "Ether", - NativeCurrencySymbol: "ETH", - NativeCurrencyDecimals: 18, - IsTest: true, - Layer: 2, - Enabled: false, - RelatedChainID: arbitrumChainID, -} - -var defaultNetworks = []params.Network{ - mainnet, - goerli, - sepolia, - optimism, - optimismGoerli, - optimismSepolia, - arbitrum, - arbitrumGoerli, - arbitrumSepolia, +func defaultNetworks(stageName string) []params.Network { + return []params.Network{ + mainnet(stageName), + goerli(stageName), + sepolia(stageName), + optimism(stageName), + optimismGoerli(stageName), + optimismSepolia(stageName), + arbitrum(stageName), + arbitrumGoerli(stageName), + arbitrumSepolia(stageName), + } } var mainnetGanacheTokenOverrides = params.TokenOverride{ @@ -268,5 +287,5 @@ func setRPCs(networks []params.Network, request *requests.WalletSecretsConfig) [ } func BuildDefaultNetworks(walletSecretsConfig *requests.WalletSecretsConfig) []params.Network { - return setRPCs(defaultNetworks, walletSecretsConfig) + return setRPCs(defaultNetworks(walletSecretsConfig.StatusProxyStageName), walletSecretsConfig) } diff --git a/api/default_networks_test.go b/api/default_networks_test.go index 31c4490c2..9b1f68187 100644 --- a/api/default_networks_test.go +++ b/api/default_networks_test.go @@ -12,10 +12,12 @@ import ( func TestBuildDefaultNetworks(t *testing.T) { poktToken := "grove-token" infuraToken := "infura-token" + stageName := "fast-n-bulbous" request := &requests.CreateAccount{ WalletSecretsConfig: requests.WalletSecretsConfig{ - PoktToken: poktToken, - InfuraToken: infuraToken, + PoktToken: poktToken, + InfuraToken: infuraToken, + StatusProxyStageName: stageName, }, } @@ -27,6 +29,8 @@ func TestBuildDefaultNetworks(t *testing.T) { require.True(t, strings.Contains(actualNetworks[0].RPCURL, poktToken)) require.True(t, strings.Contains(actualNetworks[0].FallbackURL, infuraToken)) + require.True(t, strings.Contains(actualNetworks[0].DefaultRPCURL, stageName)) + require.True(t, strings.Contains(actualNetworks[0].DefaultFallbackURL, stageName)) require.Equal(t, goerliChainID, actualNetworks[1].ChainID) @@ -36,11 +40,15 @@ func TestBuildDefaultNetworks(t *testing.T) { require.True(t, strings.Contains(actualNetworks[2].RPCURL, poktToken)) require.True(t, strings.Contains(actualNetworks[2].FallbackURL, infuraToken)) + require.True(t, strings.Contains(actualNetworks[2].DefaultRPCURL, stageName)) + require.True(t, strings.Contains(actualNetworks[2].DefaultFallbackURL, stageName)) require.Equal(t, optimismChainID, actualNetworks[3].ChainID) require.True(t, strings.Contains(actualNetworks[3].RPCURL, poktToken)) require.True(t, strings.Contains(actualNetworks[3].FallbackURL, infuraToken)) + require.True(t, strings.Contains(actualNetworks[3].DefaultRPCURL, stageName)) + require.True(t, strings.Contains(actualNetworks[3].DefaultFallbackURL, stageName)) require.Equal(t, optimismGoerliChainID, actualNetworks[4].ChainID) @@ -51,11 +59,15 @@ func TestBuildDefaultNetworks(t *testing.T) { require.True(t, strings.Contains(actualNetworks[5].RPCURL, poktToken)) require.True(t, strings.Contains(actualNetworks[5].FallbackURL, infuraToken)) + require.True(t, strings.Contains(actualNetworks[5].DefaultRPCURL, stageName)) + require.True(t, strings.Contains(actualNetworks[5].DefaultFallbackURL, stageName)) require.Equal(t, arbitrumChainID, actualNetworks[6].ChainID) require.True(t, strings.Contains(actualNetworks[6].RPCURL, poktToken)) require.True(t, strings.Contains(actualNetworks[6].FallbackURL, infuraToken)) + require.True(t, strings.Contains(actualNetworks[6].DefaultRPCURL, stageName)) + require.True(t, strings.Contains(actualNetworks[6].DefaultFallbackURL, stageName)) require.Equal(t, arbitrumGoerliChainID, actualNetworks[7].ChainID) @@ -66,6 +78,9 @@ func TestBuildDefaultNetworks(t *testing.T) { require.True(t, strings.Contains(actualNetworks[8].RPCURL, poktToken)) require.True(t, strings.Contains(actualNetworks[8].FallbackURL, infuraToken)) + require.True(t, strings.Contains(actualNetworks[8].DefaultRPCURL, stageName)) + require.True(t, strings.Contains(actualNetworks[8].DefaultFallbackURL, stageName)) + } func TestBuildDefaultNetworksGanache(t *testing.T) { diff --git a/api/defaults.go b/api/defaults.go index db05e8548..bae23c4b7 100644 --- a/api/defaults.go +++ b/api/defaults.go @@ -167,6 +167,10 @@ func buildWalletConfig(request *requests.WalletSecretsConfig, statusProxyEnabled AlchemyAPIKeys: make(map[uint64]string), } + if request.StatusProxyStageName != "" { + walletConfig.StatusProxyStageName = request.StatusProxyStageName + } + if request.OpenseaAPIKey != "" { walletConfig.OpenseaAPIKey = request.OpenseaAPIKey } @@ -285,7 +289,7 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount, o URL: request.UpstreamConfig, } } else { - nodeConfig.UpstreamConfig.URL = defaultNetworks[0].RPCURL + nodeConfig.UpstreamConfig.URL = mainnet(request.WalletSecretsConfig.StatusProxyStageName).RPCURL nodeConfig.UpstreamConfig.Enabled = true } @@ -346,13 +350,13 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount, o if request.VerifyTransactionURL != nil { nodeConfig.ShhextConfig.VerifyTransactionURL = *request.VerifyTransactionURL } else { - nodeConfig.ShhextConfig.VerifyTransactionURL = defaultNetworks[0].FallbackURL + nodeConfig.ShhextConfig.VerifyTransactionURL = mainnet(request.WalletSecretsConfig.StatusProxyStageName).FallbackURL } if request.VerifyENSURL != nil { nodeConfig.ShhextConfig.VerifyENSURL = *request.VerifyENSURL } else { - nodeConfig.ShhextConfig.VerifyENSURL = defaultNetworks[0].FallbackURL + nodeConfig.ShhextConfig.VerifyENSURL = mainnet(request.WalletSecretsConfig.StatusProxyStageName).FallbackURL } if request.VerifyTransactionChainID != nil { diff --git a/api/geth_backend.go b/api/geth_backend.go index 864ddb2dd..92712c05f 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -547,7 +547,7 @@ func (b *GethStatusBackend) updateAccountColorHashAndColorID(keyUID string, acco } func (b *GethStatusBackend) overrideNetworks(conf *params.NodeConfig, request *requests.Login) { - conf.Networks = setRPCs(defaultNetworks, &request.WalletSecretsConfig) + conf.Networks = setRPCs(defaultNetworks(request.WalletSecretsConfig.StatusProxyStageName), &request.WalletSecretsConfig) } func (b *GethStatusBackend) LoginAccount(request *requests.Login) error { diff --git a/buildinfo/apiproxystage_dev.go b/buildinfo/apiproxystage_dev.go deleted file mode 100644 index 8144c086a..000000000 --- a/buildinfo/apiproxystage_dev.go +++ /dev/null @@ -1,5 +0,0 @@ -//go:build !release - -package buildinfo - -var ApiProxyStageName = "test" diff --git a/buildinfo/apiproxystage_prod.go b/buildinfo/apiproxystage_prod.go deleted file mode 100644 index 56ff32e37..000000000 --- a/buildinfo/apiproxystage_prod.go +++ /dev/null @@ -1,5 +0,0 @@ -//go:build release - -package buildinfo - -var ApiProxyStageName = "prod" diff --git a/node/status_node_services.go b/node/status_node_services.go index 6136943d6..41aa52420 100644 --- a/node/status_node_services.go +++ b/node/status_node_services.go @@ -107,7 +107,7 @@ func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server // Wallet Service is used by wakuExtSrvc/wakuV2ExtSrvc // Keep this initialization before the other two if config.WalletConfig.Enabled { - walletService := b.walletService(accDB, b.appDB, accountsFeed, settingsFeed, &b.walletFeed) + walletService := b.walletService(accDB, b.appDB, accountsFeed, settingsFeed, &b.walletFeed, config.WalletConfig.StatusProxyStageName) services = append(services, walletService) } @@ -573,7 +573,7 @@ func (b *StatusNode) SetWalletCommunityInfoProvider(provider thirdparty.Communit } } -func (b *StatusNode) walletService(accountsDB *accounts.Database, appDB *sql.DB, accountsFeed *event.Feed, settingsFeed *event.Feed, walletFeed *event.Feed) *wallet.Service { +func (b *StatusNode) walletService(accountsDB *accounts.Database, appDB *sql.DB, accountsFeed *event.Feed, settingsFeed *event.Feed, walletFeed *event.Feed, statusProxyStageName string) *wallet.Service { if b.walletSrvc == nil { b.walletSrvc = wallet.NewService( b.walletDB, accountsDB, appDB, b.rpcClient, accountsFeed, settingsFeed, b.gethAccountManager, b.transactor, b.config, @@ -582,6 +582,7 @@ func (b *StatusNode) walletService(accountsDB *accounts.Database, appDB *sql.DB, b.pendingTracker, walletFeed, b.httpServer, + statusProxyStageName, ) } return b.walletSrvc diff --git a/params/config.go b/params/config.go index 910d18577..ef59a65c2 100644 --- a/params/config.go +++ b/params/config.go @@ -580,6 +580,7 @@ type WalletConfig struct { StatusProxyBlockchainUser string `json:"StatusProxyBlockchainUser"` StatusProxyBlockchainPassword string `json:"StatusProxyBlockchainPassword"` StatusProxyEnabled bool `json:"StatusProxyEnabled"` + StatusProxyStageName string `json:"StatusProxyStageName"` EnableCelerBridge bool `json:"EnableCelerBridge"` } diff --git a/protocol/requests/create_account.go b/protocol/requests/create_account.go index d2f9cfa59..bf9e10e8a 100644 --- a/protocol/requests/create_account.go +++ b/protocol/requests/create_account.go @@ -92,15 +92,17 @@ 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"` + 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"` + + StatusProxyStageName string `json:"statusProxyStageName"` StatusProxyMarketUser string `json:"statusProxyMarketUser"` StatusProxyMarketPassword string `json:"statusProxyMarketPassword"` StatusProxyBlockchainUser string `json:"statusProxyBlockchainUser"` diff --git a/services/wallet/keycard_pairings_test.go b/services/wallet/keycard_pairings_test.go index 883af087e..df1b200ff 100644 --- a/services/wallet/keycard_pairings_test.go +++ b/services/wallet/keycard_pairings_test.go @@ -29,7 +29,7 @@ func TestKeycardPairingsFile(t *testing.T) { accountFeed := &event.Feed{} - service := NewService(db, accountsDb, appDB, &rpc.Client{NetworkManager: network.NewManager(db)}, accountFeed, nil, nil, nil, ¶ms.NodeConfig{}, nil, nil, nil, nil, nil) + service := NewService(db, accountsDb, appDB, &rpc.Client{NetworkManager: network.NewManager(db)}, accountFeed, nil, nil, nil, ¶ms.NodeConfig{}, nil, nil, nil, nil, nil, "") data, err := service.KeycardPairings().GetPairingsJSONFileContent() require.NoError(t, err) diff --git a/services/wallet/service.go b/services/wallet/service.go index 5e909cb99..7bd3dbaa9 100644 --- a/services/wallet/service.go +++ b/services/wallet/service.go @@ -3,6 +3,7 @@ package wallet import ( "database/sql" "encoding/json" + "fmt" "sync" "time" @@ -61,6 +62,7 @@ func NewService( pendingTxManager *transactions.PendingTxTracker, feed *event.Feed, mediaServer *server.MediaServer, + statusProxyStageName string, ) *Service { signals := &walletevent.SignalsTransmitter{ Publisher: feed, @@ -118,7 +120,7 @@ func NewService( cryptoCompare := cryptocompare.NewClient() coingecko := coingecko.NewClient() cryptoCompareProxy := cryptocompare.NewClientWithParams(cryptocompare.Params{ - URL: cryptocompare.CryptoCompareStatusProxyURL, + URL: fmt.Sprintf("https://%s.api.status.im/cryptocompare/", statusProxyStageName), User: config.WalletConfig.StatusProxyMarketUser, Password: config.WalletConfig.StatusProxyMarketPassword, }) diff --git a/services/wallet/thirdparty/cryptocompare/client.go b/services/wallet/thirdparty/cryptocompare/client.go index 0fbac544d..09df4cee0 100644 --- a/services/wallet/thirdparty/cryptocompare/client.go +++ b/services/wallet/thirdparty/cryptocompare/client.go @@ -7,7 +7,6 @@ import ( "net/url" "strings" - "github.com/status-im/status-go/buildinfo" "github.com/status-im/status-go/services/wallet/thirdparty" "github.com/status-im/status-go/services/wallet/thirdparty/utils" ) @@ -15,8 +14,6 @@ import ( const extraParamStatus = "Status.im" const baseURL = "https://min-api.cryptocompare.com" -var CryptoCompareStatusProxyURL = fmt.Sprintf("https://%s.api.status.im/cryptocompare/", buildinfo.ApiProxyStageName) - type HistoricalPricesContainer struct { Aggregated bool `json:"Aggregated"` TimeFrom int64 `json:"TimeFrom"`