Skip to content

Commit

Permalink
Show name and logo for MemeFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Jun 19, 2024
1 parent 29f038b commit ba3fbb8
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 33 deletions.
56 changes: 40 additions & 16 deletions src/aoWebWallet/Pages/MemeFrames.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
@page "/meme-frames"
@using aoWebWallet.Models
@using aoww.ProcesModels
@using aoww.ProcesModels.Metadata
@inherits MvvmComponentBase<MainViewModel>
@inject IDialogService DialogService
@inject ISnackbar Snackbar
@inject NavigationManager NavigationManager
@inject StorageService StorageService
@inject TransactionService TransactionService
@inject GatewayUrlHelper UrlHelper


<PageTitle>@Program.PageTitlePostFix</PageTitle>
Expand All @@ -21,32 +23,37 @@

@foreach (var memeProcess in memeList)
{
var readActions = memeProcess.GetActionMetadata().Where(x => x.ActionType == aoww.ProcesModels.Metadata.ActionType.DryRun).ToList();
var messageActions = memeProcess.GetActionMetadata().Where(x => x.ActionType == aoww.ProcesModels.Metadata.ActionType.Message).ToList();
var readActions = memeProcess.GetDryRunActions();
var messageActions = memeProcess.GetMessageActions();

<MudItem xs="12" sm="4">
<MudCard>
<MudCardHeader>
<CardHeaderAvatar>
<MudAvatar Color="Color.Secondary">I</MudAvatar>
@if (!string.IsNullOrEmpty(memeProcess.Logo))
{
<MudAvatar Class="mr-3" Image="@UrlHelper.GetArweaveUrl(memeProcess.Logo)" Size="Size.Large" />
}
else
{
<MudAvatar Color="Color.Secondary">@memeProcess.ProcessId</MudAvatar>
}
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.body1">Id: @memeProcess.ProcessId</MudText>
<MudText Typo="Typo.body1">Name: MEME</MudText>
<MudText Typo="Typo.body2">Creator: Andy Tudhope</MudText>
<MudText Typo="Typo.body2"> Mint cap: 1,000,000 CRED </MudText>
<MudText Typo="Typo.body1">Name: @memeProcess.Name</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pb-0">
<MudProgressLinear Color="Color.Info" Size="Size.Large" Value="25" Class="mb-2">
@* <MudProgressLinear Color="Color.Info" Size="Size.Large" Value="25" Class="mb-2">
<MudText Typo="Typo.subtitle1" Color="Color.Secondary">
<b>25%</b>
</MudText>
</MudProgressLinear>
<MudText Class="mb-2" Typo="Typo.body2">
</MudProgressLinear> *@
@* <MudText Class="mb-2" Typo="Typo.body2">
Theme: The zeroth memecoin minted on ao: winner of hackathon prizes, poet of iframes, informer of votes, verifier of processes, pilgrim of the hyper parallel spaces between, believer in dreams, drafter of the dankest memes.
</MudText>
<MudTextField Class="mt-0" T="string" Label="Amount" HelperText="The amount to perform below action" HelperTextOnFocus="true" Variant="Variant.Text" />
<MudTextField Class="mt-0" T="string" Label="Amount" HelperText="The amount to perform below action" HelperTextOnFocus="true" Variant="Variant.Text" /> *@
</MudCardContent>

@if (readActions.Any())
Expand All @@ -55,7 +62,7 @@
<MudButtonGroup Color="Color.Primary" Variant="Variant.Filled">
@foreach (var action in readActions)
{
<MudButton OnClick="() => DryRun(action.AoAction)">@action.Name</MudButton>
<MudButton OnClick="() => DryRun(action)">@action.Name</MudButton>
}
</MudButtonGroup>
</MudCardActions>
Expand Down Expand Up @@ -101,20 +108,37 @@
if (firstRender)
{
memeList = await StorageService.GetMemeFrames();

foreach(var meme in memeList)
{
var initActions = meme.GetAutoRunActions();

foreach(var initAction in initActions)
{
DryRun(initAction);

Check warning on line 118 in src/aoWebWallet/Pages/MemeFrames.razor

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
}
}

StateHasChanged();
}

await base.OnAfterRenderAsync(firstRender);
}

private async Task DryRun(AoAction aoAction)
private async Task DryRun(ActionMetadata actionMetadata)
{
if (BindingContext.ActiveWalletAddress == null)
return;
AoAction aoAction = actionMetadata.AoAction;

var testWallet = new Wallet() { Address = BindingContext.ActiveWalletAddress };
var senderAddress = BindingContext.ActiveWalletAddress;
if (senderAddress == null)
senderAddress = aoAction.Target?.Value ?? string.Empty;

var testWallet = new Wallet() { Address = senderAddress };
var result = await TransactionService.DryRunAction(testWallet, aoAction);
Console.WriteLine(result?.Messages.FirstOrDefault()?.Data);

actionMetadata?.ProcessResult?.Invoke(result);

StateHasChanged();
}

private void GoToSend(AoAction aoAction)
Expand Down
2 changes: 1 addition & 1 deletion src/aoWebWallet/aoWebWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArweaveAO" Version="0.0.3" />
<PackageReference Include="ArweaveAO" Version="0.0.5" />
<PackageReference Include="ArweaveBlazor" Version="0.0.9" />
<PackageReference Include="ClipLazor" Version="2.1.1" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.9.2" />
Expand Down
18 changes: 16 additions & 2 deletions src/aoww.ProcesModels/MemeFrameProcess.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using aoww.ProcesModels.Action;
using aoww.ProcesModels.Metadata;
using ArweaveAO.Extensions;
using ArweaveAO.Responses;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -12,7 +14,8 @@ public class MemeFrameProcess : Process
{
public string? MintTokenId { get; set; }

public Dictionary<string, string>? InfoResult { get; set; }
public string? Name { get; set; }
public string? Logo { get; set; }

public MemeFrameProcess(string processId) : base(processId) { }

Expand All @@ -25,7 +28,8 @@ public override List<ActionMetadata> GetActionMetadata()
Name = "Info",
AutoRun = true,
ActionType = ActionType.DryRun,
AoAction = CreateAoActionGetInfo()
AoAction = CreateAoActionGetInfo(),
ProcessResult = ProcessInfoResult
},
new ActionMetadata
{
Expand Down Expand Up @@ -82,6 +86,16 @@ public override List<ActionMetadata> GetActionMetadata()
return actions;
}

private void ProcessInfoResult(MessageResult? result)
{
if (result == null)
return;

//Get name and logo
this.Name = result.GetFirstTagValue("Name");
this.Logo = result.GetFirstTagValue("Logo");
}

private AoAction CreateAoActionStake()
{
return new AoAction
Expand Down
4 changes: 3 additions & 1 deletion src/aoww.ProcesModels/Metadata/ActionMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using aoww.ProcesModels.Action;
using ArweaveAO.Responses;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -16,7 +17,8 @@ public class ActionMetadata

public required AoAction AoAction { get; set; }

public Action<bool>? IsEnabled { get; set; }
public Action<MessageResult?>? ProcessResult { get; set; }
public Func<bool>? IsEnabled { get; set; }

public string? LastResult { get; set; }

Expand Down
13 changes: 0 additions & 13 deletions src/aoww.ProcesModels/Metadata/ProcessMetadata.cs

This file was deleted.

22 changes: 22 additions & 0 deletions src/aoww.ProcesModels/Process.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,27 @@ public abstract class Process : IProcessMetadata
public Process(string processId) => ProcessId = processId;

public abstract List<ActionMetadata> GetActionMetadata();

public IEnumerable<ActionMetadata> GetDryRunActions()
{
var all = GetActionMetadata();

return all.Where(x => x.ActionType == ActionType.DryRun);
}

public IEnumerable<ActionMetadata> GetMessageActions()
{
var all = GetActionMetadata();

return all.Where(x => x.ActionType == ActionType.Message);
}

public IEnumerable<ActionMetadata> GetAutoRunActions()
{
var all = GetDryRunActions();

return all.Where(x => x.AutoRun);
}

}
}
4 changes: 4 additions & 0 deletions src/aoww.ProcesModels/aoww.ProcesModels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArweaveAO" Version="0.0.5" />
</ItemGroup>

</Project>

0 comments on commit ba3fbb8

Please sign in to comment.