feat(wallet): add support for proxy basic auth for market providers

feat(wallet): add status proxy URLs for blockchain providers
This commit is contained in:
Ivan Belyakov 2024-07-17 18:42:40 +02:00 committed by IvanBelyakoff
parent baa1baa17f
commit adb0f7551c
8 changed files with 89 additions and 19 deletions

View File

@ -1,10 +1,15 @@
import json
import ../../constants as main_constants
import strformat
let STATUS_PROXY_HOST = "api.status.im"
var NETWORKS* = %* [
{
"chainId": 1,
"chainName": "Mainnet",
"defaultRpcUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/grove/ethereum/mainnet/{POKT_TOKEN_RESOLVED}",
"defaultFallbackUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/infura/ethereum/mainnet/{INFURA_TOKEN_RESOLVED}",
"rpcUrl": "https://eth-archival.rpc.grove.city/v1/" & POKT_TOKEN_RESOLVED,
"fallbackUrl": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://etherscan.io/",
@ -39,7 +44,9 @@ var NETWORKS* = %* [
{
"chainId": 10,
"chainName": "Optimism",
"rpcUrl": "https://optimism-mainnet.rpc.grove.city/v1/" & POKT_TOKEN_RESOLVED,
"defaultRpcUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/grove/optimism/mainnet/{POKT_TOKEN_RESOLVED}",
"defaultFallbackUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/infura/optimism/mainnet/{INFURA_TOKEN_RESOLVED}",
"rpcUrl": "https://optimism-archival.rpc.grove.city/v1/" & POKT_TOKEN_RESOLVED,
"fallbackUrl": "https://optimism-mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://optimistic.etherscan.io",
"iconUrl": "network/Network=Optimism",
@ -73,6 +80,8 @@ var NETWORKS* = %* [
{
"chainId": 42161,
"chainName": "Arbitrum",
"defaultRpcUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/grove/arbitrum/mainnet/{POKT_TOKEN_RESOLVED}",
"defaultFallbackUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/infura/arbitrum/mainnet/{INFURA_TOKEN_RESOLVED}",
"rpcUrl": "https://arbitrum-one.rpc.grove.city/v1/" & POKT_TOKEN_RESOLVED,
"fallbackUrl": "https://arbitrum-mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://arbiscan.io/",
@ -107,6 +116,8 @@ var NETWORKS* = %* [
{
"chainId": 11155111,
"chainName": "Mainnet",
"defaultRpcUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/grove/ethereum/sepolia/{POKT_TOKEN_RESOLVED}",
"defaultFallbackUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/infura/ethereum/sepolia/{INFURA_TOKEN_RESOLVED}",
"rpcUrl": "https://sepolia-archival.rpc.grove.city/v1/" & POKT_TOKEN_RESOLVED,
"fallbackUrl": "https://sepolia.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://sepolia.etherscan.io/",
@ -124,6 +135,8 @@ var NETWORKS* = %* [
{
"chainId": 11155420,
"chainName": "Optimism",
"defaultRpcUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/grove/optimism/sepolia/{POKT_TOKEN_RESOLVED}",
"defaultFallbackUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/infura/optimism/sepolia/{INFURA_TOKEN_RESOLVED}",
"rpcUrl": "https://optimism-sepolia-archival.rpc.grove.city/v1/" & POKT_TOKEN_RESOLVED,
"fallbackUrl": "https://optimism-sepolia.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://sepolia-optimism.etherscan.io/",
@ -141,6 +154,8 @@ var NETWORKS* = %* [
{
"chainId": 421614,
"chainName": "Arbitrum",
"defaultRpcUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/grove/arbitrum/sepolia/{POKT_TOKEN_RESOLVED}",
"defaultFallbackUrl": fmt"https://{BUILD_MODE}.{STATUS_PROXY_HOST}/infura/arbitrum/sepolia/{INFURA_TOKEN_RESOLVED}",
"rpcUrl": "https://arbitrum-sepolia-archival.rpc.grove.city/v1/" & POKT_TOKEN_RESOLVED,
"fallbackUrl": "https://arbitrum-sepolia.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://sepolia-explorer.arbitrum.io/",

View File

@ -45,6 +45,7 @@ type
keycardInstanceUID*: string
keycardPairingDataFile*: string
apiConfig*: APIConfig
statusProxyEnabled*: bool
proc toJson*(self: CreateAccountRequest): JsonNode =
result = %*{
@ -66,7 +67,8 @@ proc toJson*(self: CreateAccountRequest): JsonNode =
"keycardPairingDataFile": self.keycardPairingDataFile,
"apiConfig": self.apiConfig,
"wakuV2EnableStoreConfirmationForMessagesSent": self.wakuV2EnableStoreConfirmationForMessagesSent,
"wakuV2EnableMissingMessageVerification": self.wakuV2EnableMissingMessageVerification
"wakuV2EnableMissingMessageVerification": self.wakuV2EnableMissingMessageVerification,
"statusProxyEnabled": self.statusProxyEnabled,
}
if self.logLevel.isSome():

View File

@ -17,6 +17,8 @@ type
mnemonic*: string
walletSecretsConfig*: WalletSecretsConfig
apiConfig*: APIConfig
statusProxyEnabled*: bool
proc toJson*(self: LoginAccountRequest): JsonNode =
result = %* {
@ -28,7 +30,8 @@ proc toJson*(self: LoginAccountRequest): JsonNode =
"bandwidthStatsEnabled": self.bandwidthStatsEnabled,
"keycardWhisperPrivateKey": self.keycardWhisperPrivateKey,
"mnemonic": self.mnemonic,
"apiConfig": self.apiConfig
"apiConfig": self.apiConfig,
"statusProxyEnabled": self.statusProxyEnabled
}
for key, value in self.walletSecretsConfig.toJson().pairs():
result[key] = value

View File

@ -17,6 +17,10 @@ type
alchemyOptimismMainnetToken*: string
alchemyOptimismGoerliToken*: string
alchemyOptimismSepoliaToken*: string
statusProxyMarketUser*: string
statusProxyMarketPassword*: string
statusProxyBlockchainUser*: string
statusProxyBlockchainPassword*: string
proc toJson*(self: WalletSecretsConfig): JsonNode =
return %* {
@ -34,5 +38,9 @@ proc toJson*(self: WalletSecretsConfig): JsonNode =
"alchemyArbitrumSepoliaToken": self.alchemyArbitrumSepoliaToken,
"alchemyOptimismMainnetToken": self.alchemyOptimismMainnetToken,
"alchemyOptimismGoerliToken": self.alchemyOptimismGoerliToken,
"alchemyOptimismSepoliaToken": self.alchemyOptimismSepoliaToken
"alchemyOptimismSepoliaToken": self.alchemyOptimismSepoliaToken,
"statusProxyMarketUser": self.statusProxyMarketUser,
"statusProxyMarketPassword": self.statusProxyMarketPassword,
"statusProxyBlockchainUser": self.statusProxyBlockchainUser,
"statusProxyBlockchainPassword": self.statusProxyBlockchainPassword,
}

View File

@ -219,6 +219,10 @@ QtObject:
alchemyOptimismMainnetToken: ALCHEMY_OPTIMISM_MAINNET_TOKEN_RESOLVED,
alchemyOptimismGoerliToken: ALCHEMY_OPTIMISM_GOERLI_TOKEN_RESOLVED,
alchemyOptimismSepoliaToken: ALCHEMY_OPTIMISM_SEPOLIA_TOKEN_RESOLVED,
statusProxyMarketUser: STATUS_PROXY_MARKET_USER_RESOLVED,
statusProxyMarketPassword: STATUS_PROXY_MARKET_PASSWORD_RESOLVED,
statusProxyBlockchainUser: STATUS_PROXY_BLOCKCHAIN_USER_RESOLVED,
statusProxyBlockchainPassword: STATUS_PROXY_BLOCKCHAIN_PASSWORD_RESOLVED,
)
proc buildCreateAccountRequest(self: Service, password: string, displayName: string, imagePath: string, imageCropRectangle: ImageCropRectangle): CreateAccountRequest =
@ -240,14 +244,15 @@ QtObject:
torrentConfigPort: some(TORRENT_CONFIG_PORT),
keycardPairingDataFile: main_constants.KEYCARDPAIRINGDATAFILE,
walletSecretsConfig: self.buildWalletSecrets(),
apiConfig: defaultApiConfig()
apiConfig: defaultApiConfig(),
statusProxyEnabled: true,
)
proc createAccountAndLogin*(self: Service, password: string, displayName: string, imagePath: string, imageCropRectangle: ImageCropRectangle): string =
try:
let request = self.buildCreateAccountRequest(password, displayName, imagePath, imageCropRectangle)
let response = status_account.createAccountAndLogin(request)
if not response.result.contains("error"):
error "invalid status-go response", response
return "invalid response: no error field found"
@ -256,7 +261,7 @@ QtObject:
if error == "":
debug "Account saved succesfully"
return ""
error "createAccountAndLogin status-go error: ", error
return "createAccountAndLogin failed: " & error
@ -264,12 +269,12 @@ QtObject:
error "failed to create account or login", procName="createAccountAndLogin", errName = e.name, errDesription = e.msg
return e.msg
proc importAccountAndLogin*(self: Service,
mnemonic: string,
password: string,
recoverAccount: bool,
proc importAccountAndLogin*(self: Service,
mnemonic: string,
password: string,
recoverAccount: bool,
displayName: string,
imagePath: string,
imagePath: string,
imageCropRectangle: ImageCropRectangle,
keycardInstanceUID: string = "",
): string =
@ -280,14 +285,14 @@ QtObject:
createAccountRequest: self.buildCreateAccountRequest(password, displayName, imagePath, imageCropRectangle),
)
request.createAccountRequest.keycardInstanceUID = keycardInstanceUID
self.restoreAccountAndLogin(request)
proc restoreKeycardAccountAndLogin*(self: Service,
keycardData: KeycardEvent,
proc restoreKeycardAccountAndLogin*(self: Service,
keycardData: KeycardEvent,
recoverAccount: bool,
displayName: string,
imagePath: string,
imagePath: string,
imageCropRectangle: ImageCropRectangle,
): string =
@ -312,7 +317,7 @@ QtObject:
request.createAccountRequest.keycardInstanceUID = keycardData.instanceUid
return self.restoreAccountAndLogin(request)
proc restoreAccountAndLogin(self: Service, request: RestoreAccountRequest): string =
try:
let response = status_account.restoreAccountAndLogin(request)
@ -424,7 +429,8 @@ QtObject:
mnemonic: mnemonic,
walletSecretsConfig: self.buildWalletSecrets(),
bandwidthStatsEnabled: true,
apiConfig: defaultApiConfig()
apiConfig: defaultApiConfig(),
statusProxyEnabled: true # TODO: read from settings
)
if main_constants.runtimeLogLevelSet():

View File

@ -62,9 +62,14 @@ let
RARIBLE_MAINNET_API_KEY_RESOLVED* = desktopConfig.raribleMainnetApiKey
RARIBLE_TESTNET_API_KEY_RESOLVED* = desktopConfig.raribleTestnetApiKey
TENOR_API_KEY_RESOLVED* = desktopConfig.tenorApiKey
STATUS_PROXY_MARKET_USER_RESOLVED* = desktopConfig.statusProxyMarketUser
STATUS_PROXY_MARKET_PASSWORD_RESOLVED* = desktopConfig.statusProxyMarketPassword
STATUS_PROXY_BLOCKCHAIN_USER_RESOLVED* = desktopConfig.statusProxyBlockchainUser
STATUS_PROXY_BLOCKCHAIN_PASSWORD_RESOLVED* = desktopConfig.statusProxyBlockchainPassword
WALLET_CONNECT_PROJECT_ID* = BUILD_WALLET_CONNECT_PROJECT_ID
MIXPANEL_APP_ID* = desktopConfig.mixpanelAppId
MIXPANEL_TOKEN* = desktopConfig.mixpanelToken
BUILD_MODE* = if defined(production): "prod" else: "test"
proc hasLogLevelOption*(): bool =
for p in cliParams:

View File

@ -26,6 +26,12 @@ const BASE_NAME_ALCHEMY_OPTIMISM_MAINNET_TOKEN = "ALCHEMY_OPTIMISM_MAINNET_TOKEN
const BASE_NAME_ALCHEMY_OPTIMISM_GOERLI_TOKEN = "ALCHEMY_OPTIMISM_GOERLI_TOKEN"
const BASE_NAME_ALCHEMY_OPTIMISM_SEPOLIA_TOKEN = "ALCHEMY_OPTIMISM_SEPOLIA_TOKEN"
const BASE_NAME_TENOR_API_KEY = "TENOR_API_KEY"
const BASE_NAME_STATUS_PROXY_USER = "PROXY_USER"
const BASE_NAME_STATUS_PROXY_PASSWORD = "PROXY_PASSWORD"
const BASE_NAME_STATUS_PROXY_MARKET_USER = "PROXY_MARKET_USER"
const BASE_NAME_STATUS_PROXY_MARKET_PASSWORD = "PROXY_MARKET_PASSWORD"
const BASE_NAME_STATUS_PROXY_BLOCKCHAIN_USER = "PROXY_BLOCKCHAIN_USER"
const BASE_NAME_STATUS_PROXY_BLOCKCHAIN_PASSWORD = "PROXY_BLOCKCHAIN_PASSWORD"
const BASE_NAME_WALLET_CONNECT_PROJECT_ID = "WALLET_CONNECT_PROJECT_ID"
const BASE_NAME_MIXPANEL_APP_ID = "MIXPANEL_APP_ID"
const BASE_NAME_MIXPANEL_TOKEN = "MIXPANEL_TOKEN"
@ -59,6 +65,11 @@ const BUILD_ALCHEMY_ARBITRUM_SEPOLIA_TOKEN = getEnv(BUILD_TIME_PREFIX & BASE_NAM
const BUILD_ALCHEMY_OPTIMISM_MAINNET_TOKEN = getEnv(BUILD_TIME_PREFIX & BASE_NAME_ALCHEMY_OPTIMISM_MAINNET_TOKEN)
const BUILD_ALCHEMY_OPTIMISM_GOERLI_TOKEN = getEnv(BUILD_TIME_PREFIX & BASE_NAME_ALCHEMY_OPTIMISM_GOERLI_TOKEN)
const BUILD_ALCHEMY_OPTIMISM_SEPOLIA_TOKEN = getEnv(BUILD_TIME_PREFIX & BASE_NAME_ALCHEMY_OPTIMISM_SEPOLIA_TOKEN)
const BUILD_STATUS_PROXY_MARKET_USER = getEnv(BUILD_TIME_PREFIX & BASE_NAME_STATUS_PROXY_USER)
const BUILD_STATUS_PROXY_MARKET_PASSWORD = getEnv(BUILD_TIME_PREFIX & BASE_NAME_STATUS_PROXY_PASSWORD)
const BUILD_STATUS_PROXY_BLOCKCHAIN_USER = BUILD_STATUS_PROXY_MARKET_USER
const BUILD_STATUS_PROXY_BLOCKCHAIN_PASSWORD = BUILD_STATUS_PROXY_MARKET_PASSWORD
const
DEFAULT_TENOR_API_KEY = "DU7DWZ27STB2"
BUILD_TENOR_API_KEY = getEnv(BUILD_TIME_PREFIX & BASE_NAME_TENOR_API_KEY, DEFAULT_TENOR_API_KEY)
@ -188,6 +199,26 @@ type StatusDesktopConfig = object
desc: "Sets tenor api key"
name: $BASE_NAME_TENOR_API_KEY
abbr: "tenor-api-key" .}: string
statusProxyMarketUser* {.
defaultValue: BUILD_STATUS_PROXY_MARKET_USER
desc: "Sets status market proxy username"
name: $BASE_NAME_STATUS_PROXY_MARKET_USER
abbr: "status-proxy-market-user" .}: string
statusProxyMarketPassword* {.
defaultValue: BUILD_STATUS_PROXY_MARKET_PASSWORD
desc: "Sets status market proxy password"
name: $BASE_NAME_STATUS_PROXY_MARKET_PASSWORD
abbr: "status-proxy-market-password" .}: string
statusProxyBlockchainUser* {.
defaultValue: BUILD_STATUS_PROXY_BLOCKCHAIN_USER
desc: "Sets status blockhain proxy username"
name: $BASE_NAME_STATUS_PROXY_BLOCKCHAIN_USER
abbr: "status-proxy-blockchain-user" .}: string
statusProxyBlockchainPassword* {.
defaultValue: BUILD_STATUS_PROXY_BLOCKCHAIN_PASSWORD
desc: "Sets status blockchain proxy password"
name: $BASE_NAME_STATUS_PROXY_BLOCKCHAIN_PASSWORD
abbr: "status-proxy-blockchain-password" .}: string
# runtime vars
dataDir* {.

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 8787da1b899d25a65332b0aee2440b8453062343
Subproject commit b74d9e6b4e9177f1aa9ba57f9de8beebf5b352e1