feat(Wallet): add API to fetch collectibles by owner and contract address
This commit is contained in:
parent
bbec93b501
commit
bd82250cf7
|
@ -332,6 +332,16 @@ func (api *API) GetOpenseaAssetsByOwnerWithCursor(ctx context.Context, chainID u
|
|||
return client.FetchAllAssetsByOwner(owner, cursor, limit)
|
||||
}
|
||||
|
||||
func (api *API) GetOpenseaAssetsByOwnerAndContractAddressWithCursor(ctx context.Context, chainID uint64, owner common.Address, contractAddresses []common.Address, cursor string, limit int) (*opensea.AssetContainer, error) {
|
||||
log.Debug("call to GetOpenseaAssetsByOwnerAndContractAddressWithCursor")
|
||||
client, err := opensea.NewOpenseaClient(chainID, api.s.openseaAPIKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return client.FetchAllAssetsByOwnerAndContractAddress(owner, contractAddresses, cursor, limit)
|
||||
}
|
||||
|
||||
func (api *API) GetOpenseaAssetsByNFTUniqueID(ctx context.Context, chainID uint64, uniqueIDs []opensea.NFTUniqueID, limit int) (*opensea.AssetContainer, error) {
|
||||
log.Debug("call to GetOpenseaAssetsByNFTUniqueID")
|
||||
|
||||
|
|
|
@ -216,6 +216,22 @@ func (o *Client) FetchAllAssetsByOwnerAndCollection(owner common.Address, collec
|
|||
return o.fetchAssets(queryParams, limit)
|
||||
}
|
||||
|
||||
func (o *Client) FetchAllAssetsByOwnerAndContractAddress(owner common.Address, contractAddresses []common.Address, cursor string, limit int) (*AssetContainer, error) {
|
||||
queryParams := url.Values{
|
||||
"owner": {owner.String()},
|
||||
}
|
||||
|
||||
for _, contractAddress := range contractAddresses {
|
||||
queryParams.Add("asset_contract_addresses", contractAddress.String())
|
||||
}
|
||||
|
||||
if len(cursor) > 0 {
|
||||
queryParams["cursor"] = []string{cursor}
|
||||
}
|
||||
|
||||
return o.fetchAssets(queryParams, limit)
|
||||
}
|
||||
|
||||
func (o *Client) FetchAllAssetsByOwner(owner common.Address, cursor string, limit int) (*AssetContainer, error) {
|
||||
queryParams := url.Values{
|
||||
"owner": {owner.String()},
|
||||
|
@ -246,8 +262,8 @@ func (o *Client) fetchAssets(queryParams url.Values, limit int) (*AssetContainer
|
|||
assets.PreviousCursor = queryParams["cursor"][0]
|
||||
}
|
||||
|
||||
tmpLimit := limit
|
||||
if AssetLimit < limit {
|
||||
tmpLimit := AssetLimit
|
||||
if limit > 0 && limit < tmpLimit {
|
||||
tmpLimit = AssetLimit
|
||||
}
|
||||
|
||||
|
@ -283,7 +299,7 @@ func (o *Client) fetchAssets(queryParams url.Values, limit int) (*AssetContainer
|
|||
|
||||
queryParams["cursor"] = []string{assets.NextCursor}
|
||||
|
||||
if len(assets.Assets) >= limit {
|
||||
if limit > 0 && len(assets.Assets) >= limit {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue