Skip to content

Commit

Permalink
Show description and current memeframe
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Jun 19, 2024
1 parent ba3fbb8 commit 116ce83
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 49 deletions.
1 change: 1 addition & 0 deletions src/aoWebWallet/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public static class Constants
{
public static string AoTokenId => "m3PaWzK4PTG9lAaqYQPaPdOcXdO8hYqi5Fe9NWqXd0w";
public static string CredTokenId => "Sa0iBLPNyJQrwpTTG-tWLQU-1QeUAJA73DdxGGiKoJc";
}
}
43 changes: 28 additions & 15 deletions src/aoWebWallet/Pages/MemeFrames.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

@foreach (var memeProcess in memeList)
{
var readActions = memeProcess.GetDryRunActions();
var messageActions = memeProcess.GetMessageActions();
var readActions = memeProcess.GetVisibleDryRunActions();
var messageActions = memeProcess.GetVisibleMessageActions();

<MudItem xs="12" sm="4">
<MudCard>
Expand All @@ -45,15 +45,15 @@
</CardHeaderContent>
</MudCardHeader>
<MudCardContent Class="pb-0">
@* <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">
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.
@* <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">
@memeProcess.Description
</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 @@ -64,7 +64,7 @@
{
<MudButton OnClick="() => DryRun(action)">@action.Name</MudButton>
}
</MudButtonGroup>
</MudButtonGroup>
</MudCardActions>
}

Expand All @@ -81,13 +81,24 @@
}

<MudCardActions>
<MudIconButton Icon="@Icons.Material.Filled.Share" Color="Color.Default" />
@if (memeProcess.FrameId != null)
{

<MudButton Href="@UrlHelper.GetArweaveUrl(memeProcess.FrameId)"
Target="_blank"
Variant="Variant.Filled"
EndIcon="@Icons.Material.Outlined.Link"
Color="Color.Primary">
View Current MemeFrame
</MudButton>
}

</MudCardActions>
</MudCard>
</MudItem>
}


</MudGrid>
</MudContainer>

Expand All @@ -109,11 +120,11 @@
{
memeList = await StorageService.GetMemeFrames();

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

foreach(var initAction in initActions)
foreach (var initAction in initActions)
{
DryRun(initAction);
}
Expand All @@ -138,6 +149,8 @@

actionMetadata?.ProcessResult?.Invoke(result);

await StorageService.SaveMemeFrames(memeList);

StateHasChanged();
}

Expand Down
18 changes: 9 additions & 9 deletions src/aoWebWallet/Services/StorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ public async ValueTask<List<MemeFrameProcess>> GetMemeFrames()
var result = await localStorage.GetItemAsync<List<MemeFrameProcess>>(MEMFRAME_LIST_KEY);
result = result ?? new();

AddSystemMemeFrames(result,"OT9qTE2467gcozb2g8R6D6N3nQS94ENcaAIJfUzHCww"); //TRUNK
AddSystemMemeFrames(result,"2gM9n9QO6JG1_bZhCWr3fuEKJtzRgx1xvYUB92nVFAs"); //AORTA
AddSystemMemeFrames(result,"-a4T7XLMDGTcu8_preKXdUT6__4sJkMhYLEJZkXUYd0"); //MEME
AddSystemMemeFrames(result,"rik3eCayInKVNzSMdoxeSEfpxNd5U7tx1H8NAveg4o8"); //FINCH-MEME
AddSystemMemeFrames(result,"OT9qTE2467gcozb2g8R6D6N3nQS94ENcaAIJfUzHCww", Constants.CredTokenId); //TRUNK
AddSystemMemeFrames(result,"2gM9n9QO6JG1_bZhCWr3fuEKJtzRgx1xvYUB92nVFAs", Constants.CredTokenId); //AORTA
AddSystemMemeFrames(result,"-a4T7XLMDGTcu8_preKXdUT6__4sJkMhYLEJZkXUYd0", Constants.CredTokenId); //MEME
AddSystemMemeFrames(result,"rik3eCayInKVNzSMdoxeSEfpxNd5U7tx1H8NAveg4o8", Constants.CredTokenId); //FINCH-MEME

return result;

}

private static void AddSystemMemeFrames(List<MemeFrameProcess> list, string processId)
private static void AddSystemMemeFrames(List<MemeFrameProcess> list, string processId, string mintTokenId)
{
var existing = list.Where(x => x.ProcessId == processId).FirstOrDefault();
if (existing == null)
list.Add(new MemeFrameProcess(processId));
list.Add(new MemeFrameProcess(processId) { MintTokenId = mintTokenId });
}

public ValueTask SaveMemeFrames(List<MemeFrameProcess> list)
Expand Down Expand Up @@ -68,10 +68,10 @@ public static void AddSystemTokens(List<Token> result)
Ticker = "AO"
}); //AO

AddSystemToken(result, "Sa0iBLPNyJQrwpTTG-tWLQU-1QeUAJA73DdxGGiKoJc",
AddSystemToken(result, Constants.CredTokenId,
new TokenData
{
TokenId = "Sa0iBLPNyJQrwpTTG-tWLQU-1QeUAJA73DdxGGiKoJc",
TokenId = Constants.CredTokenId,
Denomination = 3,
Logo = "eIOOJiqtJucxvB4k8a-sEKcKpKTh9qQgOV3Au7jlGYc",
Name = "AOCRED",
Expand Down Expand Up @@ -114,7 +114,7 @@ public static void AddSystemTokens(List<Token> result)
{
TokenId = "BUhZLMwQ6yZHguLtJYA5lLUa9LQzLXMXRfaq9FVcPJc",
Denomination = 12,
Logo = "nvx7DgTR8ws_k6VNCSe8vhwbZLx5jNbfNLJS0IKTTHA",
Logo = "quMiswyIjELM0FZtjVSiUtg9_-pvQ8K25yfxrp1TgnQ",
Name = "0rbit Points",
Ticker = "0RBT"
}); //0rbit
Expand Down
2 changes: 1 addition & 1 deletion src/aoWebWallet/ViewModels/WalletDetailViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task Initialize(string address)
{
VisibleTokenList = new();
VisibleTokenList.Add(Constants.AoTokenId); //AO
VisibleTokenList.Add("Sa0iBLPNyJQrwpTTG-tWLQU-1QeUAJA73DdxGGiKoJc"); //TESTNET-CRED
VisibleTokenList.Add(Constants.CredTokenId); //TESTNET-CRED

ResetTokenTransferlist();

Expand Down
100 changes: 82 additions & 18 deletions src/aoww.ProcesModels/MemeFrameProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@

namespace aoww.ProcesModels
{
/// <summary>
/// https://github.com/permaweb/memeframes
/// </summary>
public class MemeFrameProcess : Process
{
public string? MintTokenId { get; set; }

public string? Name { get; set; }
public string? Logo { get; set; }
public string? Description { get; set; }
public string? FrameId { get; set; }

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

Expand All @@ -27,23 +32,26 @@ public override List<ActionMetadata> GetActionMetadata()
{
Name = "Info",
AutoRun = true,
IsHidden = true,
ActionType = ActionType.DryRun,
AoAction = CreateAoActionGetInfo(),
ProcessResult = ProcessInfoResult
AoAction = CreateAoActionGetInfoBasic(),
ProcessResult = ProcessInfoBasicResult
},
new ActionMetadata
{
Name = "Get Description",
AutoRun = true,
IsHidden = true,
ActionType = ActionType.DryRun,
AoAction = CreateAoActionGetInfoDescription(),
ProcessResult = ProcessInfoDescriptionResult
},
new ActionMetadata
{
Name = "View Stakers",
ActionType = ActionType.DryRun,
AoAction = CreateAoActionViewStakers()
},
//new ActionMetadata
//{
// Name = "Get Frame",
// ActionType = ActionType.DryRun,
// AoAction = TokenProcess.CreateForTokenTransaction(this.ProcessId)
//},

new ActionMetadata
{
Name = "Stake",
Expand All @@ -61,14 +69,25 @@ public override List<ActionMetadata> GetActionMetadata()
Name = "Vote nay",
ActionType = ActionType.Message,
AoAction = CreateAoActionVote("nay")
},
new ActionMetadata
{
Name = "Get Votes",
ActionType = ActionType.DryRun,
AoAction = CreateAoActionGetVotes()
},
new ActionMetadata
{
Name = "Get Frame",
AutoRun = true,
IsHidden = true,
ActionType = ActionType.DryRun,
AoAction = CreateAoActionGetFrame(),
ProcessResult = (x) =>
{
this.FrameId = x?.Messages?.FirstOrDefault()?.Data;
}
}
,
//new ActionMetadata
//{
// Name = "Get Votes",
// ActionType = ActionType.DryRun,
// AoAction = TokenProcess.CreateForTokenTransaction(this.ProcessId)
//}
};

if (MintTokenId != null)
Expand All @@ -86,7 +105,7 @@ public override List<ActionMetadata> GetActionMetadata()
return actions;
}

private void ProcessInfoResult(MessageResult? result)
private void ProcessInfoBasicResult(MessageResult? result)
{
if (result == null)
return;
Expand All @@ -96,6 +115,15 @@ private void ProcessInfoResult(MessageResult? result)
this.Logo = result.GetFirstTagValue("Logo");
}

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

//Get name and logo
this.Description = result.Messages.FirstOrDefault()?.Data;
}

private AoAction CreateAoActionStake()
{
return new AoAction
Expand Down Expand Up @@ -124,7 +152,7 @@ private AoAction CreateAoActionVote(string vote)
};
}

private AoAction CreateAoActionGetInfo()
private AoAction CreateAoActionGetInfoBasic()
{
return new AoAction
{
Expand All @@ -136,6 +164,18 @@ private AoAction CreateAoActionGetInfo()
};
}

private AoAction CreateAoActionGetInfoDescription()
{
return new AoAction
{
Params = new List<ActionParam>
{
new ActionParam { Key= "Target", ParamType = ActionParamType.Target, Value= this.ProcessId },
new ActionParam { Key= "Action", ParamType = ActionParamType.Filled, Value= "Get-Info" },
}
};
}

private AoAction CreateAoActionViewStakers()
{
return new AoAction
Expand All @@ -147,5 +187,29 @@ private AoAction CreateAoActionViewStakers()
}
};
}

private AoAction CreateAoActionGetVotes()
{
return new AoAction
{
Params = new List<ActionParam>
{
new ActionParam { Key= "Target", ParamType = ActionParamType.Target, Value= this.ProcessId },
new ActionParam { Key= "Action", ParamType = ActionParamType.Filled, Value= "Votes" },
}
};
}

private AoAction CreateAoActionGetFrame()
{
return new AoAction
{
Params = new List<ActionParam>
{
new ActionParam { Key= "Target", ParamType = ActionParamType.Target, Value= this.ProcessId },
new ActionParam { Key= "Action", ParamType = ActionParamType.Filled, Value= "Get-Frame" },
}
};
}
}
}
1 change: 1 addition & 0 deletions src/aoww.ProcesModels/Metadata/ActionMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ActionMetadata

//Run on initialization
public bool AutoRun { get; set; }
public bool IsHidden { get; set; }
}


Expand Down
12 changes: 6 additions & 6 deletions src/aoww.ProcesModels/Process.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ public abstract class Process : IProcessMetadata

public abstract List<ActionMetadata> GetActionMetadata();

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

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

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

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

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

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

}
Expand Down

0 comments on commit 116ce83

Please sign in to comment.