forked from darkcodi/nft-faucet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
681 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using NftFaucet.Domain.Models.Abstraction; | ||
|
||
namespace NftFaucet.Domain.Services; | ||
|
||
public interface ITokenMediaDownloader | ||
{ | ||
public Task<ITokenMedia> Download(Uri location); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Net.Http; | ||
using NftFaucet.Domain.Models; | ||
using NftFaucet.Domain.Models.Abstraction; | ||
|
||
namespace NftFaucet.Domain.Services; | ||
|
||
public class TokenMediaDownloader : ITokenMediaDownloader | ||
{ | ||
public async Task<ITokenMedia> Download(Uri location) | ||
{ | ||
var httpClient = new HttpClient(); | ||
var response = await httpClient.GetAsync(location); | ||
if (!response.IsSuccessStatusCode) | ||
{ | ||
throw new Exception($"TokenMediaDownloader Status: {(int) response.StatusCode}. Reason: {response.ReasonPhrase}"); | ||
} | ||
|
||
var fileData = await response.Content.ReadAsByteArrayAsync(); | ||
var fileName = location.Segments[^1]; | ||
var fileType = response.Content.Headers.ContentType.MediaType; | ||
var fileSize = fileData.Length; | ||
return new TokenMedia | ||
{ | ||
FileName = fileName, | ||
FileType = fileType, | ||
FileData = $"data:{fileType};base64,{Convert.ToBase64String(fileData)}", | ||
FileSize = fileSize, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace NftFaucet.Infrastructure.Models.Dto; | ||
|
||
public class ImporterStateDto | ||
{ | ||
public Guid Id { get; set; } | ||
public string State { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using NftFaucet.Plugins.Models.Abstraction; | ||
|
||
namespace NftFaucet.Plugins; | ||
|
||
public interface IImporterPlugin | ||
{ | ||
public IReadOnlyCollection<IImporter> Importers { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Numerics; | ||
using NftFaucet.Domain.Models.Abstraction; | ||
|
||
namespace NftFaucet.Plugins.Models.Abstraction; | ||
|
||
public interface IImporter : INamedEntity, IEntityWithOrder, IStateful, IInitializable, IEntityWithProperties, IConfigurable | ||
{ | ||
public Task<IToken> Import(ulong chainId, string contractAddress, BigInteger tokenId); | ||
public bool IsChainIDSupported(ulong chainId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Numerics; | ||
using NftFaucet.Domain.Models.Abstraction; | ||
using NftFaucet.Plugins.Models.Abstraction; | ||
|
||
namespace NftFaucet.Plugins.Models; | ||
|
||
public abstract class Importer : DefaultEntity, IImporter | ||
{ | ||
public abstract Task<IToken> Import(ulong chainId, string contractAddress, BigInteger tokenId); | ||
public abstract bool IsChainIDSupported(ulong chainId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@page "/tokens/import" | ||
@inherits BasicComponent | ||
|
||
<PageTitle>Import new token</PageTitle> | ||
<RadzenContent Container="main"> | ||
<h3>Select importer</h3> | ||
<CardList Data="@ImporterCards" @bind-SelectedItems="@SelectedImporterIds"/> | ||
<div class="mb-4"> | ||
<RadzenText TextStyle="TextStyle.H6" Style="display: inline;">ChainID</RadzenText><text style="color: red"> *</text> | ||
<RadzenDropDown TextProperty="Name" ValueProperty="ChainId" Data="@SupportedNetworks" @bind-Value="@Model.ChainId" Class="w-100"/> | ||
</div> | ||
<div class="mb-4"> | ||
<RadzenText TextStyle="TextStyle.H6" Style="display: inline;">Contract Address</RadzenText><text style="color: red"> *</text> | ||
<RadzenTextBox Placeholder="0x06012c8cf97BEaD5deAe237070F9587f8E7A266d" MaxLength="42" @bind-Value="@Model.ContractAddress" Class="w-100"/> | ||
</div> | ||
<div class="mb-4"> | ||
<RadzenText TextStyle="TextStyle.H6" Style="display: inline;">TokenID</RadzenText><text style="color: red"> *</text> | ||
<RadzenTextBox Placeholder="0" MaxLength="78" @bind-Value="@Model.TokenId" Class="w-100"/> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12 text-right"> | ||
<RadzenButton Text="Cancel" Click="@(args => DialogService.Close())" ButtonStyle="ButtonStyle.Secondary" Disabled="IsImporting" Style="width: 120px" Class="mr-1"/> | ||
<RadzenButton Text="Import" Icon="eject" BusyText="Importing..." IsBusy=@IsImporting Click="@(async args => await OnImportPressed())" Disabled="@(SelectedImporter == null || !SelectedImporter.IsConfigured)" Style="width: 180px"/> | ||
</div> | ||
</div> | ||
</RadzenContent> |
Oops, something went wrong.