Skip to content

Commit a09dfc6

Browse files
fix: add unconfirmed tspend and tadds on /treasury (#2017)
Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
1 parent 923cb4f commit a09dfc6

2 files changed

Lines changed: 70 additions & 3 deletions

File tree

cmd/dcrdata/internal/explorer/explorerroutes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,11 +1484,13 @@ func (exp *explorerUI) TreasuryPage(w http.ResponseWriter, r *http.Request) {
14841484
Data *TreasuryInfo
14851485
FiatBalance *exchanges.Conversion
14861486
Pages []pageNumber
1487+
Mempool *types.MempoolInfo
14871488
}{
14881489
CommonPageData: exp.commonData(r),
14891490
Data: treasuryData,
14901491
FiatBalance: exp.xcBot.Conversion(dcrutil.Amount(treasuryBalance.Balance).ToCoin()),
14911492
Pages: calcPages(int(typeCount), int(limitN), int(offset), linkTemplate),
1493+
Mempool: exp.MempoolInventory(),
14921494
}
14931495
str, err := exp.templates.exec("treasury", pageData)
14941496
if err != nil {

cmd/dcrdata/views/treasury.tmpl

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
<html lang="en">
44
{{template "html-head" headData .CommonPageData "Decred Decentralized Treasury"}}
55
{{template "navbar" . }}
6+
{{- $mempool := .Mempool -}}
67
{{- with .Data}}
78
{{- $bal := .Balance -}}
89
{{- $TxnCount := $bal.TxCount}}
910
{{- $txType := .TxnType -}}
1011
<div class="container main"
11-
data-controller="address"
12+
data-controller="address time"
1213
data-address-dcraddress="treasury"
1314
data-address-offset="{{.Offset}}"
1415
data-address-txn-count="{{ $bal.TxCount}}"
@@ -144,7 +145,72 @@
144145
</div>
145146
</div>
146147
</div>
147-
148+
<div class="position-relative">
149+
<div class="row">
150+
<div class="col-sm-24">
151+
<div class="me-auto h4 col-24">Unconfirmed Treasury Spends</div>
152+
<table class="table">
153+
<thead>
154+
<tr>
155+
<th>Transaction ID</th>
156+
<th class="text-end">Amount</th>
157+
<th class="text-end">Time in Mempool</th>
158+
</tr>
159+
</thead>
160+
<tbody>
161+
{{if gt $mempool.NumTSpends 0 -}}
162+
{{- range $mempool.TSpends -}}
163+
<tr>
164+
<td class="break-word clipboard">
165+
<a class="hash lh1rem" href="/tx/{{.Hash}}" title="{{.Hash}}">{{.Hash}}</a>
166+
{{template "copyTextIcon"}}
167+
</td>
168+
<td class="mono fs15 text-end">
169+
{{template "decimalParts" (float64AsDecimalParts .TotalOut 8 false)}}
170+
</td>
171+
<td class="mono fs15 text-end" data-time-target="age" data-age="{{.Time}}"></td>
172+
</tr>
173+
{{- end -}}
174+
{{- else -}}
175+
<tr class="no-tx-tr">
176+
<td colspan="4">No treasury spends in mempool.</td>
177+
</tr>
178+
{{- end}}
179+
</tbody>
180+
</table>
181+
</div>
182+
</div>
183+
{{if gt $mempool.NumTAdds 0 -}}{{- /* this will be rare, so only show the section header and table if needed */ -}}
184+
<div class="row">
185+
<div class="col-sm-24">
186+
<div class="me-auto h4 col-24">Unconfirmed Treasury Adds</div>
187+
<table class="table">
188+
<thead>
189+
<tr>
190+
<th>Transaction ID</th>
191+
<th class="text-end">Amount</th>
192+
<th class="text-end">Time in Mempool</th>
193+
</tr>
194+
</thead>
195+
<tbody>
196+
{{range $mempool.TAdds -}}
197+
<tr>
198+
<td class="break-word clipboard">
199+
<a class="hash lh1rem" href="/tx/{{.Hash}}">{{.Hash}}</a>
200+
{{template "copyTextIcon"}}
201+
</td>
202+
<td class="mono fs15 text-end">
203+
{{template "decimalParts" (float64AsDecimalParts .TotalOut 8 false)}}
204+
</td>
205+
<td class="mono fs15 text-end" data-time-target="age" data-age="{{.Time}}"></td>
206+
</tr>
207+
{{- end}}
208+
</tbody>
209+
</table>
210+
</div>
211+
</div>
212+
{{- end}}
213+
</div>
148214
<div class="position-relative" data-address-target="listbox">
149215
<div class="row align-items-center">
150216
<div class="me-auto mb-0 h4 col-24 col-sm-6">Transactions</div>
@@ -182,7 +248,6 @@
182248
</div>
183249
</div>
184250
<div class="position-relative">
185-
{{- /* TODO: unconfirmed tadd and tspend txns */}}
186251
<div class="loader-v2" data-address-target="listLoader"></div>
187252
<div class="position-relative" data-address-target="table">
188253
{{template "treasuryTable" .}}

0 commit comments

Comments
 (0)