diff --git a/src/aoWebWallet/Pages/ActionPage.razor b/src/aoWebWallet/Pages/ActionPage.razor index 31413ec..8ed798f 100644 --- a/src/aoWebWallet/Pages/ActionPage.razor +++ b/src/aoWebWallet/Pages/ActionPage.razor @@ -95,12 +95,33 @@ private bool readOnly = false; private bool started = false; - private void Preview() + private async void Preview() { //transactionService.LastTransaction.Data = new Transaction() { Id = "test" }; validation = AoAction.IsValid(); readOnly = string.IsNullOrEmpty(validation); + + if (BindingContext.WalletList.Data == null) + return; + + var wallet = BindingContext.WalletList.Data.Where(x => x.Address == selectedWallet).FirstOrDefault(); + if (wallet == null) + { + if (selectedWalletObj?.Address == selectedWallet) + { + wallet = selectedWalletObj; + } + } + + if (wallet == null) + return; + + //Do we need the owner wallet? + Wallet? ownerWallet = BindingContext.WalletList.Data.Where(x => x.Address == wallet.OwnerAddress).FirstOrDefault(); + + //await transactionService.DryRunAction(wallet, ownerWallet, AoAction); + } private void Cancel() { @@ -133,7 +154,6 @@ Wallet? ownerWallet = BindingContext.WalletList.Data.Where(x => x.Address == wallet.OwnerAddress).FirstOrDefault(); started = true; - await transactionService.DryRunAction(wallet, ownerWallet, AoAction); await transactionService.SendAction(wallet, ownerWallet, AoAction); } diff --git a/src/aoWebWallet/Program.cs b/src/aoWebWallet/Program.cs index 515a58d..382a683 100644 --- a/src/aoWebWallet/Program.cs +++ b/src/aoWebWallet/Program.cs @@ -99,6 +99,7 @@ private static void ConfigureServices(IServiceCollection services, string baseAd services.AddScoped(); services.AddArweaveBlazor(); + services.AddScoped(); //Register ViewModels diff --git a/src/aoWebWallet/Services/TransactionService.cs b/src/aoWebWallet/Services/TransactionService.cs index 98d2456..4e7e830 100644 --- a/src/aoWebWallet/Services/TransactionService.cs +++ b/src/aoWebWallet/Services/TransactionService.cs @@ -1,6 +1,7 @@ using aoWebWallet.Extensions; using aoWebWallet.Models; using ArweaveAO.Requests; +using ArweaveAO.Responses; using ArweaveBlazor; using CommunityToolkit.Mvvm.ComponentModel; using webvNext.DataLoader; @@ -30,17 +31,19 @@ public void Reset() return null; } - public async Task DryRunAction(Wallet wallet, Wallet? ownerWallet, AoAction action) + public async Task DryRunAction(Wallet wallet, Wallet? ownerWallet, AoAction action) { var target = action.Target?.Value ?? string.Empty; var druRunRequest = new DryRunRequest() { Target = target, + Owner = ownerWallet?.Address ?? wallet.Address, Tags = action.ToDryRunTags() }; - var result = aODataClient.DryRun(target, druRunRequest); + var result = await aODataClient.DryRun(target, druRunRequest); + return result; } public async Task SendAction(Wallet wallet, Wallet? ownerWallet, AoAction action) diff --git a/src/aoWebWallet/Shared/Components/ActionQuantityComponent.razor b/src/aoWebWallet/Shared/Components/ActionQuantityComponent.razor index 123d811..1ca1e11 100644 --- a/src/aoWebWallet/Shared/Components/ActionQuantityComponent.razor +++ b/src/aoWebWallet/Shared/Components/ActionQuantityComponent.razor @@ -16,7 +16,7 @@ Please select a wallet... return; } -@if (ActionParam.ParamType == ActionParamType.Balance && BalanceData == null) +@if (ActionParam.ParamType == ActionParamType.Balance && BalanceData == null && !ReadOnly) { Loading balance... @@ -86,7 +86,9 @@ if (token.TokenData?.Denomination != null) Token = token; - if (ActionParam.ParamType == ActionParamType.Balance && !string.IsNullOrEmpty(Address)) + if (ActionParam.ParamType == ActionParamType.Balance + && !string.IsNullOrEmpty(Address) + && !ReadOnly) { BalanceData = await tokenClient.GetBalance(token.TokenId, Address); }