Skip to content

Commit 538d70e

Browse files
committed
add token on wallet details page fix
1 parent c5e869f commit 538d70e

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

src/aoWebWallet/Pages/WalletDetail.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
private void OpenAddTokenDialog()
203203
{
204204
var options = new DialogOptions { CloseOnEscapeKey = true };
205-
DialogService.Show<AddTokenDialog>("Add Token", options);
205+
DialogService.Show<AddTokenToWalletDialog>("Add Token", options);
206206
}
207207

208208
private async void EditWallet(Wallet wallet)

src/aoWebWallet/Pages/WalletDetail.razor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ private void BindingContext_PropertyChanged(object? sender, System.ComponentMode
3333
}
3434
}
3535

36-
private void TokenList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
36+
private async void TokenList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
3737
{
38-
BindingContext.TokenAddedRefresh();
38+
await BindingContext.TokenAddedRefresh();
3939
}
4040

4141
protected override async Task OnParametersSetAsync()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@inject TokenDataService dataService
2+
@inherits MvvmComponentBase<WalletDetailViewModel>
3+
@inject ISnackbar Snackbar
4+
5+
<MudDialog>
6+
<DialogContent>
7+
Add a token to view your balance. Provide a process-id that implements the token standard.
8+
<MudFocusTrap DefaultFocus="DefaultFocus.FirstChild">
9+
<MudTextField @bind-Value="TokenId" Label="Token Id" Mask="@(new RegexMask("^[a-zA-Z0-9_\\-]{0,43}$"))" MaxLength="43" Variant="Variant.Text"></MudTextField>
10+
</MudFocusTrap>
11+
<MudText Color="Color.Secondary">@Progress</MudText>
12+
</DialogContent>
13+
<DialogActions>
14+
<MudButton OnClick="Cancel">Cancel</MudButton>
15+
<MudButton Color="Color.Primary" OnClick="Submit">Ok</MudButton>
16+
</DialogActions>
17+
</MudDialog>
18+
@code {
19+
[CascadingParameter] MudDialogInstance MudDialog { get; set; } = default!;
20+
21+
public string? TokenId { get; set; }
22+
public string? Progress { get; set; }
23+
24+
public async Task Submit()
25+
{
26+
if (string.IsNullOrWhiteSpace(TokenId))
27+
{
28+
Progress = "Input the process-id of an ao-process implementing the token standard.";
29+
return;
30+
}
31+
if(TokenId.Length != 43)
32+
{
33+
Progress = "Length must be 43 characters.";
34+
return;
35+
}
36+
37+
Progress = "Checking metadata...";
38+
try
39+
{
40+
var token = await dataService.LoadTokenAsync(TokenId);
41+
var data = token.TokenData;
42+
if (data != null)
43+
{
44+
BindingContext.VisibleTokenList.Add(TokenId);
45+
BindingContext.TokenAddedRefresh();
46+
47+
Snackbar.Add($"Token added ({data.Name})", Severity.Info);
48+
49+
MudDialog.Close(DialogResult.Ok(true));
50+
}
51+
else
52+
{
53+
Progress = "Could not find token metadata.";
54+
}
55+
}
56+
catch
57+
{
58+
Progress = "Could not find token metadata.";
59+
}
60+
}
61+
62+
//void Submit() => MudDialog.Close(DialogResult.Ok(true));
63+
void Cancel() => MudDialog.Cancel();
64+
}

src/aoWebWallet/aoWebWallet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="ArweaveAO" Version="0.0.3" />
16-
<PackageReference Include="ArweaveBlazor" Version="0.0.7" />
16+
<PackageReference Include="ArweaveBlazor" Version="0.0.8" />
1717
<PackageReference Include="ClipLazor" Version="2.1.1" />
1818
<PackageReference Include="MudBlazor" Version="6.19.1" />
1919
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />

0 commit comments

Comments
 (0)