-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add token on wallet details page fix
- Loading branch information
1 parent
c5e869f
commit 538d70e
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
@inject TokenDataService dataService | ||
@inherits MvvmComponentBase<WalletDetailViewModel> | ||
@inject ISnackbar Snackbar | ||
|
||
<MudDialog> | ||
<DialogContent> | ||
Add a token to view your balance. Provide a process-id that implements the token standard. | ||
<MudFocusTrap DefaultFocus="DefaultFocus.FirstChild"> | ||
<MudTextField @bind-Value="TokenId" Label="Token Id" Mask="@(new RegexMask("^[a-zA-Z0-9_\\-]{0,43}$"))" MaxLength="43" Variant="Variant.Text"></MudTextField> | ||
</MudFocusTrap> | ||
<MudText Color="Color.Secondary">@Progress</MudText> | ||
</DialogContent> | ||
<DialogActions> | ||
<MudButton OnClick="Cancel">Cancel</MudButton> | ||
<MudButton Color="Color.Primary" OnClick="Submit">Ok</MudButton> | ||
</DialogActions> | ||
</MudDialog> | ||
@code { | ||
[CascadingParameter] MudDialogInstance MudDialog { get; set; } = default!; | ||
|
||
public string? TokenId { get; set; } | ||
public string? Progress { get; set; } | ||
|
||
public async Task Submit() | ||
{ | ||
if (string.IsNullOrWhiteSpace(TokenId)) | ||
{ | ||
Progress = "Input the process-id of an ao-process implementing the token standard."; | ||
return; | ||
} | ||
if(TokenId.Length != 43) | ||
{ | ||
Progress = "Length must be 43 characters."; | ||
return; | ||
} | ||
|
||
Progress = "Checking metadata..."; | ||
try | ||
{ | ||
var token = await dataService.LoadTokenAsync(TokenId); | ||
var data = token.TokenData; | ||
if (data != null) | ||
{ | ||
BindingContext.VisibleTokenList.Add(TokenId); | ||
BindingContext.TokenAddedRefresh(); | ||
|
||
Snackbar.Add($"Token added ({data.Name})", Severity.Info); | ||
|
||
MudDialog.Close(DialogResult.Ok(true)); | ||
} | ||
else | ||
{ | ||
Progress = "Could not find token metadata."; | ||
} | ||
} | ||
catch | ||
{ | ||
Progress = "Could not find token metadata."; | ||
} | ||
} | ||
|
||
//void Submit() => MudDialog.Close(DialogResult.Ok(true)); | ||
void Cancel() => MudDialog.Cancel(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters