Skip to content

Commit

Permalink
DotNet library update and start with CreateTokenPage.razor
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Sep 3, 2024
1 parent b8a9a4d commit e18a237
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 5 deletions.
74 changes: 74 additions & 0 deletions src/aoWebWallet/Pages/CreateTokenPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@page "/create-token"
@using aoWebWallet.Models
@inherits MvvmComponentBase<MainViewModel>
@inject IDialogService DialogService
@inject ISnackbar Snackbar
@inject NavigationManager NavigationManager
@inject TokenDataService dataService
@inject WalletDetailViewModel WalletDetailViewModel
@using Soenneker.Blazor.Utils.Navigation.Abstract
@inject INavigationUtil NavigationUtil

<PageTitle>Create Token @Program.PageTitlePostFix</PageTitle>

<MudContainer Class="mt-2 px-8" MaxWidth="MaxWidth.False">
<MudBreadcrumbs Class="breadcrumbs-aoww mb-4" Items="_items"></MudBreadcrumbs>

<SelectActiveWalletComponent ReadOnly="readOnly" />

<MudText Typo="Typo.h5">Create a new token</MudText>

<MudForm @ref="form" Model="tokenModel" Validated="OnValidated">
<MudTextField @bind-Value="tokenModel.Name" Label="Token Name" Required="true" />
<MudTextField @bind-Value="tokenModel.Ticker" Label="Ticker Symbol" MaxLength="5" Required="true" />
<MudTextField @bind-Value="tokenModel.LogoUrl" Label="Logo URL" />
<MudNumericField @bind-Value="tokenModel.Denomination" Label="Denomination" Required="true" />
<MudNumericField @bind-Value="tokenModel.TotalSupply" Label="Total Number of Tokens" Required="true" />

<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Submit" Class="mt-8">Submit</MudButton>
</MudForm>
</MudContainer>

@code {
private bool readOnly = false;
private MudForm? form;
private TokenModel tokenModel = new TokenModel();
private List<BreadcrumbItem> _items = new List<BreadcrumbItem>
{
new BreadcrumbItem("Home", href: "/"),
new BreadcrumbItem("Create Token", href: null, disabled: true)
};

private async void Submit()
{
if(form != null)
await form.Validate();

Snackbar.Add("TEST", Severity.Success);

}

private async void OnValidated()

Check warning on line 51 in src/aoWebWallet/Pages/CreateTokenPage.razor

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
if (form?.IsValid ?? false)
{
// Create a new process and load token code
//await dataService.CreateTokenProcess(tokenModel);
Snackbar.Add("Token created successfully!", Severity.Success);
NavigationManager.NavigateTo("/wallet");
}
else
{
Snackbar.Add("Please fill in all required fields.", Severity.Error);
}
}

private class TokenModel
{
public string? Name { get; set; }
public string? Ticker { get; set; }
public string? LogoUrl { get; set; }
public int Denomination { get; set; }
public int TotalSupply { get; set; }
}
}
1 change: 1 addition & 0 deletions src/aoWebWallet/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<MudNavLink Href="/scan-qr" Match="NavLinkMatch.Prefix" Class="aoww-main-nav-text" Icon="@Icons.Material.Filled.QrCode">QR Scanner</MudNavLink>
<MudNavLink Href="/apps" Match="NavLinkMatch.Prefix" Class="aoww-main-nav-text" Icon="@Icons.Material.Filled.Apps">Apps</MudNavLink>
<MudNavLink Href="meme-frames" Match="NavLinkMatch.Prefix" Class="aoww-main-nav-text" Icon="@Icons.Material.Filled.Api">Meme Frames</MudNavLink>
@* <MudNavLink Href="create-token" Icon="@Icons.Material.Filled.AddCircle" Match="NavLinkMatch.All">Create Token</MudNavLink> *@

<div style="margin-top: auto; display:flex; flex-direction: row; margin-bottom:20px">
<div style="border-right: 1px solid gray;">
Expand Down
6 changes: 3 additions & 3 deletions src/aoWebWallet/aoWebWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
<ItemGroup>
<PackageReference Include="Append.Blazor.WebShare" Version="7.0.0" />
<PackageReference Include="ArweaveAO" Version="0.0.8" />
<PackageReference Include="ArweaveBlazor" Version="0.0.10" />
<PackageReference Include="ArweaveBlazor" Version="0.0.11" />
<PackageReference Include="ClipLazor" Version="2.1.1" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.0.1" />
<PackageReference Include="MudBlazor" Version="7.6.0" />
<PackageReference Include="MudBlazor" Version="7.7.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" PrivateAssets="all" />
<PackageReference Include="ReactorBlazorQRCodeScanner" Version="1.0.7" />
<PackageReference Include="Soenneker.Blazor.Utils.Navigation" Version="2.1.296" />
<PackageReference Include="Soenneker.Blazor.Utils.Navigation" Version="2.1.299" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/aoww.Services.Tests/GraphqlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public async Task GetMintTest()
{
var graph = new GraphqlClient(new HttpClient(), Options.Create<GraphqlConfig>(new()));

var result = await graph.GetTokenTransfers("CeiYr2VjUVAFXmPJvfj-Pfk6zmprBzeqNeRWAbImbOo");
//var result = await graph.GetTokenTransfers("CeiYr2VjUVAFXmPJvfj-Pfk6zmprBzeqNeRWAbImbOo");
var result = await graph.GetTokenTransfersIn("YCH7ugqKwIo_bQebG_eT_7QY0sxVXbnv7BTgmRi7FZk");

Assert.IsNotNull(result);
}
Expand Down
2 changes: 1 addition & 1 deletion src/aoww.Services/GraphqlClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public async Task<List<TokenTransfer>> GetTokenTransfersIn(string address, strin
if (!string.IsNullOrEmpty(fromProcess))
transaction.From = fromProcess;

transaction.TokenId = edge.GetFirstTagValue("TokenId");
transaction.TokenId = edge.GetFirstTagValue("TokenId") ?? transaction.From;

transaction.To = edge.GetFirstTagValue("Recipient");

Expand Down

0 comments on commit e18a237

Please sign in to comment.