Skip to content

Commit

Permalink
Create a token
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Oct 2, 2024
1 parent 27aeaff commit 76638cc
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 11 deletions.
3 changes: 0 additions & 3 deletions src/aoWebWallet/Pages/ActionPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
<br />
}
</MudCardContent>
@* <MudCardActions>
<MudButton Variant="Variant.Text" Color="Color.Primary">Learn More</MudButton>
</MudCardActions> *@
</MudCard>
}

Expand Down
5 changes: 3 additions & 2 deletions src/aoWebWallet/Services/TransactionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public void Reset()
{
Target = target,
Owner = wallet.Address,
Tags = action.ToDryRunTags()
Tags = action.ToDryRunTags(),
Data = action.DataValue
};

var result = await aODataClient.DryRun(target, druRunRequest);
Expand Down Expand Up @@ -171,7 +172,7 @@ static string RemoveColorCodes(string? input)
var transferTags = action.ToTags();
transferTags.Add(new ArweaveBlazor.Models.Tag() { Name = "X-Wallet", Value = "aoww" });

var idResult = await arweaveService.SendAsync(jwk, action.Target.Value, null, null, transferTags);
var idResult = await arweaveService.SendAsync(jwk, action.Target.Value, null, action.DataValue, transferTags);

return new Transaction { Id = idResult };
}, x => LastTransaction.Data = x);
Expand Down
5 changes: 5 additions & 0 deletions src/aoWebWallet/Shared/ActionEditor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
}
}

@if(AoAction.HasData)
{
<MudTextField @bind-Value="AoAction.DataValue" Label="Data" Lines="5" Variant="Variant.Outlined" Bind />
}

</MudStack>


Expand Down
10 changes: 9 additions & 1 deletion src/aoWebWallet/Shared/Components/ActionList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@
private void NavigateToActionBuilder(string? actionName = null)
{
string? action = actionName;
if (!string.IsNullOrEmpty(action))
if(action == "Eval")
{
var aoAction = new AoAction() { HasData = true };
aoAction.Params.Add(new ActionParam() { Key = "Target", Value = ProcessId, ParamType = ActionParamType.Target });
aoAction.Params.Add(new ActionParam() { Key = "Action", Value = action, ParamType = ActionParamType.Filled });

NavigationManager.NavigateTo($"/action?{aoAction.ToQueryString()}");
}
else if (!string.IsNullOrEmpty(action))
{
NavigationManager.NavigateTo($"/action-builder?processId={ProcessId}&actionName={Uri.EscapeDataString(action)}");
}
Expand Down
11 changes: 10 additions & 1 deletion src/aoWebWallet/Shared/Components/HandlerList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@
<MudList T="string">
@foreach (var handler in handlers)
{
<MudListItem>@handler</MudListItem>
if(handler == "_eval")
{
var aoAction = new AoAction() { HasData = true };
aoAction.Params.Add(new ActionParam() { Key = "Target", Value = ProcessId, ParamType = ActionParamType.Target });
aoAction.Params.Add(new ActionParam() { Key = "Action", Value = "Eval", ParamType = ActionParamType.Filled });
<MudButton OnClick="() => GoToSend(aoAction)">@handler</MudButton>
}
else{
<MudListItem>@handler</MudListItem>
}
}
</MudList>
}
Expand Down
2 changes: 1 addition & 1 deletion src/aoWebWallet/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<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="/process" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Build">Action Builder</MudNavLink>
@* <MudNavLink Href="/create-token" Icon="@Icons.Material.Filled.AddCircle" Match="NavLinkMatch.All">Create Token</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
2 changes: 1 addition & 1 deletion src/aoWebWallet/aoWebWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<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.329" />
<PackageReference Include="Soenneker.Blazor.Utils.Navigation" Version="2.1.344" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions src/aoww.ProcesModels.Tests/SchemaProtocolClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ public async Task GetActionsTests()
Assert.IsTrue(result.Any());
}

[TestMethod]
public async Task GetExternalActionsTests()
{
var processId = "kPjfXLFyjJogxGRRRe2ErdYNiexolpHpK6wGkz-UPVA";

var client = new SchemaProtocolClient(new AODataClient(Options.Create<ArweaveConfig>(new()), new HttpClient()));

var result = await client.GetSchemaProtocolActions(processId, schemaExternal: true);

Assert.IsNotNull(result);
Assert.IsTrue(result.Any());
}

[TestMethod]
public async Task NoActionsTests()
{
Expand Down
13 changes: 13 additions & 0 deletions src/aoww.ProcesModels/Action/ActionParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace aoww.ProcesModels.Action
public class AoAction
{
public List<ActionParam> Params { get; set; } = new();
public bool HasData { get; set; } = false;
public string? DataValue { get; set; }

public ActionParam? Target => Params.Where(x => x.ParamType == ActionParamType.Target).FirstOrDefault();
public IEnumerable<ActionParam> AllWithoutTarget => Params.Where(x => x.ParamType != ActionParamType.Target);
Expand Down Expand Up @@ -54,6 +56,9 @@ public string ToQueryString()
}
}

if(HasData)
sb.Append($"X-HasData=1&");

return sb.ToString().TrimEnd('&');
}

Expand Down Expand Up @@ -83,6 +88,14 @@ public static AoAction CreateFromQueryString(string qstring)
actionValue = actionValueSplit.First();
List<string> args = actionValueSplit.Skip(1).ToList();

if (key.Equals($"X-{nameof(HasData)}", StringComparison.InvariantCultureIgnoreCase))
{
if (actionValue == "1" || actionValue == "true")
action.HasData = true;

continue;
}

if (key.Equals("Target", StringComparison.InvariantCultureIgnoreCase))
actionParamType = ActionParamType.Target;
if (key.Equals("X-Quantity", StringComparison.InvariantCultureIgnoreCase))
Expand Down
10 changes: 8 additions & 2 deletions src/aoww.ProcesModels/SchemaProtocol/SchemaProtocolClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@

namespace aoww.ProcesModels.SchemaProtocol
{
/// <summary>
/// https://github.com/elliotsayes/Reality/blob/main/docs/Schema.md
/// </summary>
/// <param name="aoDataClient"></param>
public class SchemaProtocolClient(AODataClient aoDataClient)
{
public async Task<List<ActionMetadata>> GetSchemaProtocolActions(string processId)
public async Task<List<ActionMetadata>> GetSchemaProtocolActions(string processId, bool schemaExternal = false)
{
string actionValue = schemaExternal ? "SchemaExternal" : "Schema";

try
{
var result = await aoDataClient.DryRun(processId, new ArweaveAO.Requests.DryRunRequest
{
Target = processId,
Tags = new List<ArweaveAO.Models.Tag>
{
new ArweaveAO.Models.Tag() { Name = "Action", Value = "Schema" }
new ArweaveAO.Models.Tag() { Name = "Action", Value = actionValue }
}
});

Expand Down

0 comments on commit 76638cc

Please sign in to comment.