From 9ee523be99483a14f83c3e7a74220d5695ee755a Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Wed, 12 Jul 2023 14:43:22 -0300 Subject: [PATCH] fix: remove unsupported chainIDs from opensea client --- services/wallet/thirdparty/opensea/client.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/wallet/thirdparty/opensea/client.go b/services/wallet/thirdparty/opensea/client.go index 4f870314f..8ff432bdb 100644 --- a/services/wallet/thirdparty/opensea/client.go +++ b/services/wallet/thirdparty/opensea/client.go @@ -2,6 +2,7 @@ package opensea import ( "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" @@ -32,17 +33,21 @@ const RequestTimeout = 5 * time.Second const GetRequestRetryMaxCount = 15 const GetRequestWaitTime = 300 * time.Millisecond -const ChainIDRequiringAPIKey = 1 +const ChainIDRequiringAPIKey = walletCommon.EthereumMainnet + +var ( + ErrChainIDNotSupported = errors.New("chainID not supported by opensea API") +) func getbaseURL(chainID uint64) (string, error) { switch chainID { - case walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet: + case walletCommon.EthereumMainnet: return "https://api.opensea.io/api/v1", nil - case walletCommon.EthereumGoerli, walletCommon.OptimismGoerli, walletCommon.ArbitrumGoerli: + case walletCommon.EthereumGoerli: return "https://testnets-api.opensea.io/api/v1", nil } - return "", fmt.Errorf("chainID not supported: %d", chainID) + return "", ErrChainIDNotSupported } var OpenseaClientInstances = make(map[uint64]*Client)