Skip to content

Commit 73b8758

Browse files
committed
Update IPFS default gateway
1 parent c95d9db commit 73b8758

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

Assets/Thirdweb/Core/Prefabs/ThirdwebManager.prefab

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ MonoBehaviour:
9393
appIcons:
9494
-
9595
appUrl:
96-
storageIpfsGatewayUrl: https://gateway.ipfscdn.io/ipfs/
96+
storageIpfsGatewayUrl:
9797
relayerUrl:
9898
forwarderAddress:
9999
forwarderDomainOverride:

Assets/Thirdweb/Core/Scripts/Storage.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public class Storage
2323
private readonly string BEARER_TOKEN_URI = "https://upload.nftlabs.co/grant";
2424
private readonly string PIN_URI = "https://api.pinata.cloud/pinning/pinFileToIPFS";
2525

26-
private string ipfsGatewayUrl = "https://gateway.ipfscdn.io/ipfs/";
26+
public string IPFSGateway { get; private set; }
2727

2828
public Storage(ThirdwebSDK.StorageOptions? storageOptions)
2929
{
3030
if (storageOptions != null)
31-
{
32-
this.ipfsGatewayUrl = string.IsNullOrEmpty(storageOptions.Value.ipfsGatewayUrl) ? "https://gateway.ipfscdn.io/ipfs/" : storageOptions.Value.ipfsGatewayUrl;
33-
}
31+
this.IPFSGateway = string.IsNullOrEmpty(storageOptions.Value.ipfsGatewayUrl) ? "https://ipfs.thirdwebstorage.com/ipfs/" : storageOptions.Value.ipfsGatewayUrl;
32+
else
33+
this.IPFSGateway = "https://ipfs.thirdwebstorage.com/ipfs/";
3434
}
3535

3636
public async Task<IPFSUploadResult> UploadText(string text)
@@ -80,7 +80,7 @@ public async Task<IPFSUploadResult> UploadFromPath(string path)
8080

8181
public async Task<T> DownloadText<T>(string textURI)
8282
{
83-
textURI = textURI.ReplaceIPFS(ipfsGatewayUrl);
83+
textURI = textURI.ReplaceIPFS();
8484

8585
using (UnityWebRequest req = UnityWebRequest.Get(textURI))
8686
{
@@ -97,7 +97,7 @@ public async Task<T> DownloadText<T>(string textURI)
9797

9898
public async Task<Sprite> DownloadImage(string imageURI)
9999
{
100-
imageURI = imageURI.ReplaceIPFS(ipfsGatewayUrl);
100+
imageURI = imageURI.ReplaceIPFS();
101101

102102
using (UnityWebRequest req = UnityWebRequestTexture.GetTexture(imageURI))
103103
{

Assets/Thirdweb/Core/Scripts/ThirdwebManager.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class ThirdwebManager : MonoBehaviour
5555
public string appUrl = null;
5656

5757
[Tooltip("IPFS Gateway Override")]
58-
public string storageIpfsGatewayUrl = "https://gateway.ipfscdn.io/ipfs/";
58+
public string storageIpfsGatewayUrl = null;
5959

6060
[Tooltip("Autotask URL")]
6161
public string relayerUrl = null;
@@ -161,7 +161,7 @@ private void Awake()
161161
chainOrRPC = currentChain.identifier;
162162
}
163163

164-
// Set up storage and gasless options (if an)
164+
// Set up storage and gasless options (if any)
165165

166166
var options = new ThirdwebSDK.Options();
167167

Assets/Thirdweb/Core/Scripts/Utils.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ public static bool IsWebGLBuild()
108108
#endif
109109
}
110110

111-
public static string ReplaceIPFS(this string uri, string gateway = "https://gateway.ipfscdn.io/ipfs/")
111+
public static string ReplaceIPFS(this string uri)
112112
{
113+
string gateway = ThirdwebManager.Instance.SDK.storage.IPFSGateway;
113114
if (!string.IsNullOrEmpty(uri) && uri.StartsWith("ipfs://"))
114115
return uri.Replace("ipfs://", gateway);
115116
else

0 commit comments

Comments
 (0)