Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 4f26135

Browse files
committed
Move to ipfs.io gateway and set strict fetch timeout
1 parent f099703 commit 4f26135

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

thirdweb/options/sdk_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@dataclasses.dataclass
55
class SdkOptions:
6-
ipfs_gateway_url: str = "https://cloudflare-ipfs.com/ipfs/"
6+
ipfs_gateway_url: str = "https://ipfs.io/ipfs/"
77
registry_contract_address: str = ""
88
max_gas_price_in_gwei: int = 100
99
gas_speed: str = "fastest"

thirdweb/storage/ipfs_storage.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from requests import get, post
44
import json
55

6+
67
class IpfsStorage:
78
__nftlabsApiUrl = "https://upload.nftlabs.co"
89

@@ -14,7 +15,7 @@ def __init__(self, gateway_uri: str):
1415
def get(self, uri: str) -> str:
1516
ipfs_uri = replace_ipfs_prefix_with_gateway(uri, self.gateway_uri)
1617

17-
response = get(ipfs_uri)
18+
response = get(ipfs_uri, timeout=10)
1819

1920
if response.status_code != 200:
2021
raise Exception("Failed to download metadata")
@@ -24,6 +25,7 @@ def get(self, uri: str) -> str:
2425
"""
2526
Upload data to IPFS, data parameter
2627
"""
28+
2729
def upload(self, data, contract_address: str, signer_address: str) -> str:
2830
if isinstance(data, str) and data.startswith("ipfs://"):
2931
return data
@@ -40,7 +42,7 @@ def upload(self, data, contract_address: str, signer_address: str) -> str:
4042

4143
response = result.json()
4244
return response['IpfsUri']
43-
45+
4446
def upload_metadata(self, metadata: str, contract_address: str, signer_address: str) -> str:
4547
if type(metadata) == str:
4648
return self.upload(metadata, contract_address, signer_address)

0 commit comments

Comments
 (0)