fix: remove unsupported chainIDs from opensea client

This commit is contained in:
Dario Gabriel Lipicar 2023-07-12 14:43:22 -03:00 committed by dlipicar
parent 8bcc493477
commit 9ee523be99
1 changed files with 9 additions and 4 deletions

View File

@ -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)