-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add button to display raw transaction JSON for addresses and amounts #131
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6acd988
Add button to display raw transaction JSON for addresses and amounts
itailiors 92521f9
fix spaces
itailiors 16e2c8f
Update Wallet.razor
itailiors b71fa71
milad comment + option to copy
itailiors 25cdb60
remove duplicate
itailiors 6ab0951
Merge branch 'refs/heads/main' into show-raw-transaction-json
itailiors aed8e08
reformat
itailiors 27db3c5
Merge branch 'refs/heads/main' into show-raw-transaction-json
itailiors b2b7855
merge and fixup for comments
itailiors 0f31ac0
fix
itailiors File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,8 +243,6 @@ | |
} | ||
</div> | ||
|
||
|
||
|
||
</div> | ||
|
||
</div> | ||
|
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
@page "/wallet" | ||
|
||
|
||
@using System.Text.Json | ||
@using Angor.Client.Storage | ||
@using Angor.Shared | ||
@using Angor.Shared.Models | ||
@using Blockcore.NBitcoin | ||
@using Blockcore.Networks | ||
|
||
@inherits BaseComponent | ||
@inject HttpClient _httpClient; | ||
@inject IClientStorage storage; | ||
@inject ICacheStorage _cacheStorage; | ||
|
@@ -19,7 +20,7 @@ | |
@inject NavMenuState NavMenuState | ||
@inject IEncryptionService _encryptionService | ||
@inject IClipboardService ClipboardService | ||
@inherits BaseComponent | ||
|
||
|
||
<PageTitle>Wallet and balances</PageTitle> | ||
<NotificationComponent @ref="notificationComponent"/> | ||
|
@@ -471,8 +472,8 @@ else | |
var outpointStr = addressUtxoItem.outpoint.ToString(); | ||
var outpointLength = outpointStr.Length; | ||
var shortenedOutpoint = outpointLength > 20 | ||
? $"{outpointStr.Substring(0, 10)} ... {outpointStr.Substring(outpointLength - 10)}" | ||
: outpointStr; | ||
? $"{outpointStr.Substring(0, 10)} ... {outpointStr.Substring(outpointLength - 10)}" | ||
: outpointStr; | ||
|
||
var valueInBTC = Money.Satoshis(addressUtxoItem.value).ToUnit(MoneyUnit.BTC); | ||
var coinTicker = network.CoinTicker; | ||
|
@@ -487,7 +488,7 @@ else | |
|
||
</div> | ||
<div class="modal-footer"> | ||
<button class="btn btn-warning" @onclick="() => coinControlModal = false" >Submit</button> | ||
<button class="btn btn-warning" @onclick="() => coinControlModal = false">Submit</button> | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -619,6 +620,7 @@ else | |
<th class="text-uppercase text-xxs font-weight-bolder opacity-7" scope="col">Amount</th> | ||
<th class="text-uppercase text-xxs font-weight-bolder opacity-7" scope="col">Path</th> | ||
<th class="text-uppercase text-xxs font-weight-bolder opacity-7" scope="col">UTXO count</th> | ||
<th class="text-uppercase text-xxs font-weight-bolder opacity-7" scope="col">View Raw Json</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
|
@@ -631,17 +633,17 @@ else | |
{ | ||
<tr @onclick="() => ToggleCollapse(addressInfo.Address)" class="clickable-row" data-cy="adress-row" aria-expanded="@IsExpanded(addressInfo.Address).ToString().ToLower()" aria-controls="@($"collapse-{addressInfo.Address}")"> | ||
<td>@addressInfo.Address</td> | ||
<td> | ||
@Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker | ||
</td> | ||
<td>@Money.Satoshis(total).ToUnit(MoneyUnit.BTC) @network.CoinTicker</td> | ||
<td>@addressInfo.HdPath</td> | ||
<td>@count</td> | ||
<td> | ||
<button class="btn btn-border" @onclick="() => ShowRawTransactionJson(addressInfo)">Show</button> | ||
</td> | ||
</tr> | ||
|
||
@if (IsExpanded(addressInfo.Address)) | ||
{ | ||
<tr> | ||
<td colspan="4"> | ||
<td colspan="5"> | ||
<div class="collapse show" data-cy="expend-amount" id="@($"collapse-{addressInfo.Address}")"> | ||
<div class="card card-body"> | ||
<!-- Inner table goes here --> | ||
|
@@ -721,6 +723,9 @@ else | |
private int FeePosition = 1; | ||
private SendInfo _sendInfo = new(); | ||
|
||
private bool showRawTransactionModal; | ||
private string rawTransactionJson = string.Empty; | ||
|
||
private readonly AccountBalanceInfo accountBalanceInfo = new(); | ||
|
||
private readonly FeeEstimations FeeEstimations = new(); | ||
|
@@ -1243,7 +1248,7 @@ else | |
} | ||
catch (Exception ex) | ||
{ | ||
Logger.LogError(ex, $"Failed to read clipboard contents"); | ||
Logger.LogError(ex, "Failed to read clipboard contents"); | ||
} | ||
} | ||
|
||
|
@@ -1289,4 +1294,52 @@ else | |
} | ||
|
||
|
||
private void ShowRawTransactionJson(AddressInfo addressInfo) | ||
{ | ||
rawTransactionJson = GetRawTransactionJson(addressInfo); | ||
showRawTransactionModal = true; | ||
} | ||
|
||
private string GetRawTransactionJson(AddressInfo addressInfo) | ||
{ | ||
var options = new JsonSerializerOptions | ||
{ | ||
WriteIndented = true | ||
}; | ||
return JsonSerializer.Serialize(addressInfo, options); | ||
} | ||
|
||
private async Task CopyStringToClipboard(string msg) | ||
{ | ||
await _clipboardService.WriteTextAsync(msg); | ||
notificationComponent.ShowNotificationMessage("Copied to clipboard!", 3); | ||
StateHasChanged(); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
@if (showRawTransactionModal) | ||
{ | ||
<div class="modal-wrapper"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could become a component in the next PR. |
||
<div class="modal fade show d-block"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Raw Transaction JSON</h5> | ||
<span type="button" @onclick="() => showRawTransactionModal = false" aria-label="Close"> | ||
<Icon IconName="close-circle"/> | ||
<i @onclick="@(async () => await CopyStringToClipboard(rawTransactionJson))" class="ms-auto cursor-pointer user-select-none"> | ||
<Icon IconName="copy"></Icon> | ||
</i> | ||
</span> | ||
</div> | ||
<div class="modal-body"> | ||
<pre>@rawTransactionJson</pre> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this location for the html by convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Responding a bit late haha, happy to be back!
I took the convention from here:
https://blog.samferree.dev/basics-in-blazor-modal
if you prefer, I can move it to the top of the file or create a component for the modal (it can be much better if you can think of another place we could use the component) .