diff --git a/services/wallet/common/const.go b/services/wallet/common/const.go new file mode 100644 index 000000000..99e2f3d97 --- /dev/null +++ b/services/wallet/common/const.go @@ -0,0 +1,13 @@ +package common + +type ChainID uint64 + +const ( + EthereumMainnet uint64 = 1 + EthereumGoerli uint64 = 5 + EthereumSepolia uint64 = 11155111 + OptimismMainnet uint64 = 10 + OptimismGoerli uint64 = 420 + ArbitrumMainnet uint64 = 42161 + ArbitrumGoerli uint64 = 421613 +) diff --git a/services/wallet/thirdparty/alchemy/client.go b/services/wallet/thirdparty/alchemy/client.go index 20b5da9b6..f2f3ec6b0 100644 --- a/services/wallet/thirdparty/alchemy/client.go +++ b/services/wallet/thirdparty/alchemy/client.go @@ -11,24 +11,25 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/status-im/status-go/services/wallet/bigint" + walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/thirdparty" ) func getBaseURL(chainID uint64) (string, error) { switch chainID { - case 1: + case walletCommon.EthereumMainnet: return "https://eth-mainnet.g.alchemy.com", nil - case 5: + case walletCommon.EthereumGoerli: return "https://eth-goerli.g.alchemy.com", nil - case 11155111: + case walletCommon.EthereumSepolia: return "https://eth-sepolia.g.alchemy.com", nil - case 10: + case walletCommon.OptimismMainnet: return "https://opt-mainnet.g.alchemy.com", nil - case 420: + case walletCommon.OptimismGoerli: return "https://opt-goerli.g.alchemy.com", nil - case 42161: + case walletCommon.ArbitrumMainnet: return "https://arb-mainnet.g.alchemy.com", nil - case 421613: + case walletCommon.ArbitrumGoerli: return "https://arb-goerli.g.alchemy.com", nil } diff --git a/services/wallet/thirdparty/infura/client.go b/services/wallet/thirdparty/infura/client.go index 894106ac1..c536514cf 100644 --- a/services/wallet/thirdparty/infura/client.go +++ b/services/wallet/thirdparty/infura/client.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/status-im/status-go/services/wallet/bigint" + walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/thirdparty" ) @@ -64,7 +65,7 @@ func (o *Client) doQuery(url string) (*http.Response, error) { func (o *Client) IsChainSupported(chainID uint64) bool { switch chainID { - case 1, 5, 42161, 11155111: + case walletCommon.EthereumMainnet, walletCommon.EthereumGoerli, walletCommon.EthereumSepolia, walletCommon.ArbitrumMainnet: return true } return false diff --git a/services/wallet/thirdparty/opensea/client.go b/services/wallet/thirdparty/opensea/client.go index ba99559f2..2d5a13006 100644 --- a/services/wallet/thirdparty/opensea/client.go +++ b/services/wallet/thirdparty/opensea/client.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/status-im/status-go/services/wallet/bigint" + walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/thirdparty" "github.com/status-im/status-go/services/wallet/walletevent" ) @@ -35,11 +36,9 @@ const ChainIDRequiringAPIKey = 1 func getbaseURL(chainID uint64) (string, error) { switch chainID { - case 1, 10, 42161: + case walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet: return "https://api.opensea.io/api/v1", nil - case 4: - return "https://rinkeby-api.opensea.io/api/v1", nil - case 5, 420, 421613: + case walletCommon.EthereumGoerli, walletCommon.OptimismGoerli, walletCommon.ArbitrumGoerli: return "https://testnets-api.opensea.io/api/v1", nil }