Skip to content

Commit

Permalink
update fetch_contract to opensea V2 (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
brucedonovan authored Aug 31, 2023
1 parent 11ec2a6 commit 4edb0ee
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions integrations/opensea.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class NFTContract:
chain: str
address: str
slug: str
name: str
image_url: str


# this is a listing of an NFT asset
Expand All @@ -56,7 +54,7 @@ class NFTFulfillmentData:

def fetch_contract(address: str) -> NFTContract:
"""Fetch data about a contract (collection)."""
url = f"{API_V1_URL}/asset_contract/{address}"
url = f"{API_V2_URL}/chain/ethereum/contract/{address}/nfts"

def _exec_request():
response = requests.get(url, headers=HEADERS)
Expand All @@ -67,16 +65,12 @@ def _exec_request():
_exec_request,
[ErrorToRetry(requests.exceptions.HTTPError, _should_retry_exception)],
)
collection = obj["collection"]
return NFTContract(
chain=obj["chain_identifier"],
chain='ethereum',
address=address,
slug=collection["slug"],
name=collection["name"],
image_url=collection["image_url"],
slug=obj["nfts"][0]["collection"],
)


def fetch_listings(address: str, token_id: str) -> List[NFTListing]:
"""Fetch cheapest listing for an asset."""
chain = "ethereum"
Expand Down

0 comments on commit 4edb0ee

Please sign in to comment.