2023-04-25 12:00:17 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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")
|
|
|
|
|
|
|
|
var mainnet = params.Network{
|
|
|
|
ChainID: mainnetChainID,
|
|
|
|
ChainName: "Ethereum Mainnet",
|
2024-01-11 15:48:40 +00:00
|
|
|
RPCURL: "https://eth-archival.rpc.grove.city/v1/",
|
2023-04-25 12:00:17 +00:00
|
|
|
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,
|
2023-07-13 14:03:49 +00:00
|
|
|
RelatedChainID: goerliChainID,
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var goerli = params.Network{
|
|
|
|
ChainID: goerliChainID,
|
2024-02-02 13:55:46 +00:00
|
|
|
ChainName: "Ethereum Goerli",
|
2024-03-06 09:53:32 +00:00
|
|
|
RPCURL: "https://goerli.infura.io/v3/",
|
|
|
|
FallbackURL: "",
|
2023-04-25 12:00:17 +00:00
|
|
|
BlockExplorerURL: "https://goerli.etherscan.io/",
|
|
|
|
IconURL: "network/Network=Testnet",
|
2024-02-28 12:27:39 +00:00
|
|
|
ChainColor: "#627EEA",
|
2023-04-25 12:00:17 +00:00
|
|
|
ShortName: "goEth",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: true,
|
|
|
|
Layer: 1,
|
|
|
|
Enabled: true,
|
2023-07-13 14:03:49 +00:00
|
|
|
RelatedChainID: mainnetChainID,
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
var sepolia = params.Network{
|
|
|
|
ChainID: sepoliaChainID,
|
|
|
|
ChainName: "Ethereum Sepolia",
|
2024-03-06 09:53:32 +00:00
|
|
|
RPCURL: "https://sepolia.infura.io/v3/",
|
|
|
|
FallbackURL: "",
|
2024-02-02 13:55:46 +00:00
|
|
|
BlockExplorerURL: "https://sepolia.etherscan.io/",
|
|
|
|
IconURL: "network/Network=Testnet",
|
2024-02-28 12:27:39 +00:00
|
|
|
ChainColor: "#627EEA",
|
2024-02-02 13:55:46 +00:00
|
|
|
ShortName: "eth",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: true,
|
|
|
|
Layer: 1,
|
|
|
|
Enabled: true,
|
|
|
|
RelatedChainID: mainnetChainID,
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:00:17 +00:00
|
|
|
var optimism = params.Network{
|
|
|
|
ChainID: optimismChainID,
|
|
|
|
ChainName: "Optimism",
|
2024-01-11 15:48:40 +00:00
|
|
|
RPCURL: "https://optimism-mainnet.rpc.grove.city/v1/",
|
2023-04-25 12:00:17 +00:00
|
|
|
FallbackURL: "https://optimism-mainnet.infura.io/v3/",
|
|
|
|
BlockExplorerURL: "https://optimistic.etherscan.io",
|
|
|
|
IconURL: "network/Network=Optimism",
|
|
|
|
ChainColor: "#E90101",
|
|
|
|
ShortName: "opt",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: false,
|
|
|
|
Layer: 2,
|
|
|
|
Enabled: true,
|
2023-07-13 14:03:49 +00:00
|
|
|
RelatedChainID: optimismGoerliChainID,
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var optimismGoerli = params.Network{
|
|
|
|
ChainID: optimismGoerliChainID,
|
2024-02-02 13:55:46 +00:00
|
|
|
ChainName: "Optimism Goerli",
|
2023-04-25 12:00:17 +00:00
|
|
|
RPCURL: "https://optimism-goerli.infura.io/v3/",
|
|
|
|
FallbackURL: "",
|
|
|
|
BlockExplorerURL: "https://goerli-optimism.etherscan.io/",
|
|
|
|
IconURL: "network/Network=Testnet",
|
2024-02-28 12:27:39 +00:00
|
|
|
ChainColor: "#E90101",
|
2023-04-25 12:00:17 +00:00
|
|
|
ShortName: "goOpt",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: true,
|
|
|
|
Layer: 2,
|
|
|
|
Enabled: false,
|
2023-07-13 14:03:49 +00:00
|
|
|
RelatedChainID: optimismChainID,
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
2024-02-02 13:55:46 +00:00
|
|
|
|
|
|
|
var optimismSepolia = params.Network{
|
|
|
|
ChainID: optimismSepoliaChainID,
|
|
|
|
ChainName: "Optimism Sepolia",
|
|
|
|
RPCURL: "https://optimism-sepolia.infura.io/v3/",
|
|
|
|
FallbackURL: "",
|
|
|
|
BlockExplorerURL: "https://sepolia-optimism.etherscan.io/",
|
|
|
|
IconURL: "network/Network=Testnet",
|
2024-02-28 12:27:39 +00:00
|
|
|
ChainColor: "#E90101",
|
2024-02-02 13:55:46 +00:00
|
|
|
ShortName: "opt",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: true,
|
|
|
|
Layer: 2,
|
|
|
|
Enabled: false,
|
|
|
|
RelatedChainID: optimismChainID,
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:00:17 +00:00
|
|
|
var arbitrum = params.Network{
|
|
|
|
ChainID: arbitrumChainID,
|
|
|
|
ChainName: "Arbitrum",
|
2024-01-11 15:48:40 +00:00
|
|
|
RPCURL: "https://arbitrum-one.rpc.grove.city/v1/",
|
2023-04-25 12:00:17 +00:00
|
|
|
FallbackURL: "https://arbitrum-mainnet.infura.io/v3/",
|
|
|
|
BlockExplorerURL: "https://arbiscan.io/",
|
|
|
|
IconURL: "network/Network=Arbitrum",
|
|
|
|
ChainColor: "#51D0F0",
|
|
|
|
ShortName: "arb",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: false,
|
|
|
|
Layer: 2,
|
|
|
|
Enabled: true,
|
2023-07-13 14:03:49 +00:00
|
|
|
RelatedChainID: arbitrumGoerliChainID,
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var arbitrumGoerli = params.Network{
|
|
|
|
ChainID: arbitrumGoerliChainID,
|
|
|
|
ChainName: "Arbitrum Goerli",
|
|
|
|
RPCURL: "https://arbitrum-goerli.infura.io/v3/",
|
|
|
|
FallbackURL: "",
|
|
|
|
BlockExplorerURL: "https://goerli.arbiscan.io/",
|
|
|
|
IconURL: "network/Network=Testnet",
|
2024-02-28 12:27:39 +00:00
|
|
|
ChainColor: "#51D0F0",
|
2023-04-25 12:00:17 +00:00
|
|
|
ShortName: "goArb",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: true,
|
|
|
|
Layer: 2,
|
|
|
|
Enabled: false,
|
2023-07-13 14:03:49 +00:00
|
|
|
RelatedChainID: arbitrumChainID,
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
var arbitrumSepolia = params.Network{
|
|
|
|
ChainID: arbitrumSepoliaChainID,
|
|
|
|
ChainName: "Arbitrum Sepolia",
|
|
|
|
RPCURL: "https://arbitrum-sepolia.infura.io/v3/",
|
|
|
|
FallbackURL: "",
|
|
|
|
BlockExplorerURL: "https://sepolia-explorer.arbitrum.io/",
|
|
|
|
IconURL: "network/Network=Testnet",
|
|
|
|
ChainColor: "#51D0F0",
|
|
|
|
ShortName: "arb",
|
|
|
|
NativeCurrencyName: "Ether",
|
|
|
|
NativeCurrencySymbol: "ETH",
|
|
|
|
NativeCurrencyDecimals: 18,
|
|
|
|
IsTest: true,
|
|
|
|
Layer: 2,
|
|
|
|
Enabled: false,
|
|
|
|
RelatedChainID: arbitrumChainID,
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:00:17 +00:00
|
|
|
var defaultNetworks = []params.Network{
|
|
|
|
mainnet,
|
|
|
|
goerli,
|
2024-02-02 13:55:46 +00:00
|
|
|
sepolia,
|
2023-04-25 12:00:17 +00:00
|
|
|
optimism,
|
|
|
|
optimismGoerli,
|
2024-02-02 13:55:46 +00:00
|
|
|
optimismSepolia,
|
2023-04-25 12:00:17 +00:00
|
|
|
arbitrum,
|
|
|
|
arbitrumGoerli,
|
2024-02-02 13:55:46 +00:00
|
|
|
arbitrumSepolia,
|
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
|
|
|
|
|
|
|
|
for _, n := range networks {
|
|
|
|
|
|
|
|
if request.InfuraToken != "" {
|
|
|
|
if strings.Contains(n.RPCURL, "infura") {
|
|
|
|
n.RPCURL += request.InfuraToken
|
|
|
|
}
|
|
|
|
if strings.Contains(n.FallbackURL, "infura") {
|
|
|
|
n.FallbackURL += request.InfuraToken
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if request.PoktToken != "" {
|
2024-01-11 15:48:40 +00:00
|
|
|
if strings.Contains(n.RPCURL, "grove") {
|
2023-04-25 12:00:17 +00:00
|
|
|
n.RPCURL += request.PoktToken
|
|
|
|
}
|
2024-01-11 15:48:40 +00:00
|
|
|
if strings.Contains(n.FallbackURL, "grove") {
|
2023-04-25 12:00:17 +00:00
|
|
|
n.FallbackURL += request.PoktToken
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if request.GanacheURL != "" {
|
|
|
|
n.RPCURL = request.GanacheURL
|
|
|
|
n.FallbackURL = request.GanacheURL
|
|
|
|
if n.ChainID == mainnetChainID {
|
|
|
|
n.TokenOverrides = []params.TokenOverride{
|
|
|
|
mainnetGanacheTokenOverrides,
|
|
|
|
}
|
|
|
|
} else if n.ChainID == goerliChainID {
|
|
|
|
n.TokenOverrides = []params.TokenOverride{
|
|
|
|
goerliGanacheTokenOverrides,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
networksWithRPC = append(networksWithRPC, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
return networksWithRPC
|
|
|
|
}
|
|
|
|
|
2024-01-03 10:29:21 +00:00
|
|
|
func BuildDefaultNetworks(request *requests.CreateAccount) []params.Network {
|
2023-05-24 15:02:53 +00:00
|
|
|
return setRPCs(defaultNetworks, &request.WalletSecretsConfig)
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|