Remove Infura IPFS usage because Infura closed public IPFS gateway
This commit is contained in:
parent
6564e9ec9d
commit
dae28fc04c
|
@ -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; }
|
|
@ -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<UploadResponse> UploadFile([Body] MultipartContent content, [Query("pin")] bool pin = true);
|
||||
}
|
|
@ -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<UploadResponse> UploadFile([Body] MultipartContent content, [Query("stream-channels")] bool streamChannels = true);
|
||||
}
|
|
@ -4,7 +4,6 @@ public enum IpfsGatewayType : byte
|
|||
{
|
||||
None = 0,
|
||||
IpfsOfficial = 1,
|
||||
Infura = 2,
|
||||
NftStorage = 3,
|
||||
Crust = 4,
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Select DataSource="@IpfsGateways"
|
||||
DefaultValue="@(nameof(IpfsGatewayType.Infura))"
|
||||
DefaultValue="@(nameof(IpfsGatewayType.Crust))"
|
||||
ValueName="@nameof(EnumWrapper<IpfsGatewayType>.ValueString)"
|
||||
LabelName="@nameof(EnumWrapper<IpfsGatewayType>.Description)"
|
||||
OnSelectedItemChanged="OnIpfsGatewayChange">
|
||||
|
|
|
@ -49,11 +49,13 @@ public class IpfsService : IIpfsService
|
|||
public async Task<Uri> Upload(string fileName, string fileType, byte[] fileBytes)
|
||||
{
|
||||
var fileUploadRequest = ToMultipartContent(fileName, fileType, fileBytes);
|
||||
var uploadClient = RestClient.For<IInfuraIpfsApiClient>();
|
||||
var uploadClient = RestClient.For<ICrustUploadApiClient>();
|
||||
var authHeader = GenerateAuthHeader();
|
||||
uploadClient.Auth = authHeader;
|
||||
var response = await uploadClient.UploadFile(fileUploadRequest);
|
||||
|
||||
var pinningClient = RestClient.For<ICrustApiClient>();
|
||||
pinningClient.Auth = GenerateAuthHeader();
|
||||
var pinningClient = RestClient.For<ICrustPinApiClient>();
|
||||
pinningClient.Auth = authHeader;
|
||||
var pinRequest = new PinRequest
|
||||
{
|
||||
cid = response.Hash,
|
||||
|
|
|
@ -61,10 +61,6 @@
|
|||
"Id": "IpfsOfficial",
|
||||
"BaseUrl": "https://ipfs.io/ipfs"
|
||||
},
|
||||
{
|
||||
"Id": "Infura",
|
||||
"BaseUrl": "https://ipfs.infura.io/ipfs"
|
||||
},
|
||||
{
|
||||
"Id": "NftStorage",
|
||||
"BaseUrl": "https://nftstorage.link/ipfs"
|
||||
|
|
Loading…
Reference in New Issue