From dae28fc04c9aad886ff4d3508dd03052347dc8a9 Mon Sep 17 00:00:00 2001 From: Ivan Yaremenchuk Date: Sun, 14 Aug 2022 21:29:59 -0500 Subject: [PATCH] Remove Infura IPFS usage because Infura closed public IPFS gateway --- .../{ICrustApiClient.cs => ICrustPinApiClient.cs} | 2 +- NftFaucet/ApiClients/ICrustUploadApiClient.cs | 14 ++++++++++++++ NftFaucet/ApiClients/IInfuraIpfsApiClient.cs | 11 ----------- NftFaucet/Models/Enums/IpfsGatewayType.cs | 1 - NftFaucet/Models/StateStorage.cs | 2 +- NftFaucet/Pages/Step2Page.razor | 2 +- NftFaucet/Services/IpfsService.cs | 8 +++++--- NftFaucet/wwwroot/appsettings.json | 4 ---- 8 files changed, 22 insertions(+), 22 deletions(-) rename NftFaucet/ApiClients/{ICrustApiClient.cs => ICrustPinApiClient.cs} (88%) create mode 100644 NftFaucet/ApiClients/ICrustUploadApiClient.cs delete mode 100644 NftFaucet/ApiClients/IInfuraIpfsApiClient.cs diff --git a/NftFaucet/ApiClients/ICrustApiClient.cs b/NftFaucet/ApiClients/ICrustPinApiClient.cs similarity index 88% rename from NftFaucet/ApiClients/ICrustApiClient.cs rename to NftFaucet/ApiClients/ICrustPinApiClient.cs index e8c5b73..7264566 100644 --- a/NftFaucet/ApiClients/ICrustApiClient.cs +++ b/NftFaucet/ApiClients/ICrustPinApiClient.cs @@ -4,7 +4,7 @@ using RestEase; namespace NftFaucet.ApiClients; [BaseAddress("https://pin.crustcode.com")] -public interface ICrustApiClient +public interface ICrustPinApiClient { [Header("Authorization")] public string Auth { get; set; } diff --git a/NftFaucet/ApiClients/ICrustUploadApiClient.cs b/NftFaucet/ApiClients/ICrustUploadApiClient.cs new file mode 100644 index 0000000..5347284 --- /dev/null +++ b/NftFaucet/ApiClients/ICrustUploadApiClient.cs @@ -0,0 +1,14 @@ +using NftFaucet.ApiClients.Models; +using RestEase; + +namespace NftFaucet.ApiClients; + +[BaseAddress("https://gw.crustapps.net")] +public interface ICrustUploadApiClient +{ + [Header("Authorization")] + public string Auth { get; set; } + + [Post("api/v0/add")] + Task UploadFile([Body] MultipartContent content, [Query("pin")] bool pin = true); +} diff --git a/NftFaucet/ApiClients/IInfuraIpfsApiClient.cs b/NftFaucet/ApiClients/IInfuraIpfsApiClient.cs deleted file mode 100644 index 4546c66..0000000 --- a/NftFaucet/ApiClients/IInfuraIpfsApiClient.cs +++ /dev/null @@ -1,11 +0,0 @@ -using NftFaucet.ApiClients.Models; -using RestEase; - -namespace NftFaucet.ApiClients; - -[BaseAddress("https://ipfs.infura.io:5001")] -public interface IInfuraIpfsApiClient -{ - [Post("api/v0/add")] - Task UploadFile([Body] MultipartContent content, [Query("stream-channels")] bool streamChannels = true); -} diff --git a/NftFaucet/Models/Enums/IpfsGatewayType.cs b/NftFaucet/Models/Enums/IpfsGatewayType.cs index ba5dff0..00da954 100644 --- a/NftFaucet/Models/Enums/IpfsGatewayType.cs +++ b/NftFaucet/Models/Enums/IpfsGatewayType.cs @@ -4,7 +4,6 @@ public enum IpfsGatewayType : byte { None = 0, IpfsOfficial = 1, - Infura = 2, NftStorage = 3, Crust = 4, } diff --git a/NftFaucet/Models/StateStorage.cs b/NftFaucet/Models/StateStorage.cs index 59b6c28..c574ba7 100644 --- a/NftFaucet/Models/StateStorage.cs +++ b/NftFaucet/Models/StateStorage.cs @@ -6,7 +6,7 @@ public class StateStorage { public string TokenName { get; set; } public string TokenDescription { get; set; } - public IpfsGatewayType IpfsGatewayType { get; set; } = IpfsGatewayType.Infura; + public IpfsGatewayType IpfsGatewayType { get; set; } = IpfsGatewayType.Crust; public TokenType TokenType { get; set; } = TokenType.ERC721; public double TokenAmount { get; set; } = 1; public Uri LocalImageUrl { get; set; } diff --git a/NftFaucet/Pages/Step2Page.razor b/NftFaucet/Pages/Step2Page.razor index 6fd2b36..4c2a887 100644 --- a/NftFaucet/Pages/Step2Page.razor +++ b/NftFaucet/Pages/Step2Page.razor @@ -86,7 +86,7 @@