2023-04-25 12:00:17 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2024-07-31 06:21:11 +00:00
|
|
|
"fmt"
|
2023-04-25 12:00:17 +00:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/status-im/status-go/params"
|
|
|
|
"github.com/status-im/status-go/protocol/requests"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2023-11-16 20:46:01 +00:00
|
|
|
mainnetChainID uint64 = 1
|
|
|
|
goerliChainID uint64 = 5
|
|
|
|
sepoliaChainID uint64 = 11155111
|
|
|
|
optimismChainID uint64 = 10
|
|
|
|
optimismGoerliChainID uint64 = 420
|
|
|
|
optimismSepoliaChainID uint64 = 11155420
|
|
|
|
arbitrumChainID uint64 = 42161
|
|
|
|
arbitrumGoerliChainID uint64 = 421613
|
|
|
|
arbitrumSepoliaChainID uint64 = 421614
|
|
|
|
sntSymbol = "SNT"
|
|
|
|
sttSymbol = "STT"
|
2023-04-25 12:00:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var ganacheTokenAddress = common.HexToAddress("0x8571Ddc46b10d31EF963aF49b6C7799Ea7eff818")
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
func mainnet(stageName string) params.Network {
|
|
|
|
return params.Network{
|
|
|
|
ChainID: mainnetChainID,
|
|
|
|
ChainName: "Mainnet",
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/ethereum/mainnet/", stageName),
|
2024-08-14 15:35:48 +00:00
|
|
|
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/mainnet/", stageName),
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/mainnet/", stageName),
|
2024-10-14 14:39:37 +00:00
|
|
|
RPCURL: "https://mainnet.infura.io/v3/",
|
|
|
|
FallbackURL: "https://eth-archival.rpc.grove.city/v1/",
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
}
|
|
|
|
func sepolia(stageName string) params.Network {
|
|
|
|
return params.Network{
|
|
|
|
ChainID: sepoliaChainID,
|
|
|
|
ChainName: "Mainnet",
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/ethereum/sepolia/", stageName),
|
2024-08-14 15:35:48 +00:00
|
|
|
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/ethereum/sepolia/", stageName),
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/ethereum/sepolia/", stageName),
|
2024-10-14 14:39:37 +00:00
|
|
|
RPCURL: "https://sepolia.infura.io/v3/",
|
|
|
|
FallbackURL: "https://sepolia-archival.rpc.grove.city/v1/",
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2024-02-02 13:55:46 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
func optimism(stageName string) params.Network {
|
|
|
|
return params.Network{
|
|
|
|
ChainID: optimismChainID,
|
|
|
|
ChainName: "Optimism",
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/optimism/mainnet/", stageName),
|
2024-08-14 15:35:48 +00:00
|
|
|
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/mainnet/", stageName),
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/optimism/mainnet/", stageName),
|
2024-10-14 14:39:37 +00:00
|
|
|
RPCURL: "https://optimism-mainnet.infura.io/v3/",
|
|
|
|
FallbackURL: "https://optimism-archival.rpc.grove.city/v1/",
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
2024-02-02 13:55:46 +00:00
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
func optimismSepolia(stageName string) params.Network {
|
|
|
|
return params.Network{
|
|
|
|
ChainID: optimismSepoliaChainID,
|
|
|
|
ChainName: "Optimism",
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/optimism/sepolia/", stageName),
|
2024-08-14 15:35:48 +00:00
|
|
|
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/optimism/sepolia/", stageName),
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/optimism/sepolia/", stageName),
|
2024-10-14 14:39:37 +00:00
|
|
|
RPCURL: "https://optimism-sepolia.infura.io/v3/",
|
|
|
|
FallbackURL: "https://optimism-sepolia-archival.rpc.grove.city/v1/",
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2024-02-02 13:55:46 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
func arbitrum(stageName string) params.Network {
|
|
|
|
return params.Network{
|
|
|
|
ChainID: arbitrumChainID,
|
|
|
|
ChainName: "Arbitrum",
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/arbitrum/mainnet/", stageName),
|
2024-08-14 15:35:48 +00:00
|
|
|
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/mainnet/", stageName),
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/mainnet/", stageName),
|
2024-10-14 14:39:37 +00:00
|
|
|
RPCURL: "https://arbitrum-mainnet.infura.io/v3/",
|
|
|
|
FallbackURL: "https://arbitrum-one.rpc.grove.city/v1/",
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
func arbitrumSepolia(stageName string) params.Network {
|
|
|
|
return params.Network{
|
|
|
|
ChainID: arbitrumSepoliaChainID,
|
|
|
|
ChainName: "Arbitrum",
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultRPCURL: fmt.Sprintf("https://%s.api.status.im/nodefleet/arbitrum/sepolia/", stageName),
|
2024-08-14 15:35:48 +00:00
|
|
|
DefaultFallbackURL: fmt.Sprintf("https://%s.api.status.im/infura/arbitrum/sepolia/", stageName),
|
2024-10-02 08:20:03 +00:00
|
|
|
DefaultFallbackURL2: fmt.Sprintf("https://%s.api.status.im/grove/arbitrum/sepolia/", stageName),
|
2024-10-14 14:39:37 +00:00
|
|
|
RPCURL: "https://arbitrum-sepolia.infura.io/v3/",
|
|
|
|
FallbackURL: "https://arbitrum-sepolia-archival.rpc.grove.city/v1/",
|
2024-08-14 15:35:48 +00:00
|
|
|
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,
|
|
|
|
}
|
2024-02-02 13:55:46 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
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),
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var mainnetGanacheTokenOverrides = params.TokenOverride{
|
|
|
|
Symbol: sntSymbol,
|
|
|
|
Address: ganacheTokenAddress,
|
|
|
|
}
|
|
|
|
|
|
|
|
var goerliGanacheTokenOverrides = params.TokenOverride{
|
|
|
|
Symbol: sttSymbol,
|
|
|
|
Address: ganacheTokenAddress,
|
|
|
|
}
|
|
|
|
|
2023-05-24 15:02:53 +00:00
|
|
|
func setRPCs(networks []params.Network, request *requests.WalletSecretsConfig) []params.Network {
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
var networksWithRPC []params.Network
|
|
|
|
|
2024-10-14 14:39:37 +00:00
|
|
|
const (
|
|
|
|
infura = "infura.io/"
|
|
|
|
grove = "grove.city/"
|
|
|
|
)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-10-14 14:39:37 +00:00
|
|
|
appendToken := func(url string) string {
|
|
|
|
if strings.Contains(url, infura) && request.InfuraToken != "" {
|
|
|
|
return url + request.InfuraToken
|
|
|
|
} else if strings.Contains(url, grove) && request.PoktToken != "" {
|
|
|
|
return url + request.PoktToken
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
2024-10-14 14:39:37 +00:00
|
|
|
return url
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-10-14 14:39:37 +00:00
|
|
|
for _, n := range networks {
|
|
|
|
n.DefaultRPCURL = appendToken(n.DefaultRPCURL)
|
|
|
|
n.DefaultFallbackURL = appendToken(n.DefaultFallbackURL)
|
|
|
|
n.DefaultFallbackURL2 = appendToken(n.DefaultFallbackURL2)
|
|
|
|
n.RPCURL = appendToken(n.RPCURL)
|
|
|
|
n.FallbackURL = appendToken(n.FallbackURL)
|
2023-04-25 12:00:17 +00:00
|
|
|
|
|
|
|
if request.GanacheURL != "" {
|
|
|
|
n.RPCURL = request.GanacheURL
|
|
|
|
n.FallbackURL = request.GanacheURL
|
2024-10-14 14:39:37 +00:00
|
|
|
switch n.ChainID {
|
|
|
|
case mainnetChainID:
|
|
|
|
n.TokenOverrides = []params.TokenOverride{mainnetGanacheTokenOverrides}
|
|
|
|
case goerliChainID:
|
|
|
|
n.TokenOverrides = []params.TokenOverride{goerliGanacheTokenOverrides}
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
networksWithRPC = append(networksWithRPC, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
return networksWithRPC
|
|
|
|
}
|
|
|
|
|
2024-04-22 12:33:23 +00:00
|
|
|
func BuildDefaultNetworks(walletSecretsConfig *requests.WalletSecretsConfig) []params.Network {
|
2024-08-14 15:35:48 +00:00
|
|
|
return setRPCs(defaultNetworks(walletSecretsConfig.StatusProxyStageName), walletSecretsConfig)
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|