Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions server/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ func isSyscoinShortcut(coinShortcut string) bool {
return shortcut == "SYS" || shortcut == "TSYS"
}

// SYSCOIN
func isSyscoinNativeAsset(assetGuid string) bool {
return strings.TrimSpace(assetGuid) == "123456"
}

func (s *PublicServer) parseTemplates() []*template.Template {
templateFuncMap := template.FuncMap{
"timeSpan": timeSpan,
Expand All @@ -629,6 +634,7 @@ func (s *PublicServer) parseTemplates() []*template.Template {
"formatContractExplorerURL": s.formatContractExplorerURL, // SYSCOIN
"isNFT": isNFT, // SYSCOIN
"isSyscoinShortcut": isSyscoinShortcut, // SYSCOIN
"isSyscoinNativeAsset": isSyscoinNativeAsset, // SYSCOIN
"formatEncodeBase64": formatEncodeBase64, // SYSCOIN
"setTxToTemplateData": setTxToTemplateData,
"feePerByte": feePerByte,
Expand Down
20 changes: 10 additions & 10 deletions server/public_test.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,13 @@ span.btn-paging:hover {
font-weight: bold;
}

/* SYSCOIN: prevent summary labels from collapsing vertically in fixed-layout info tables. */
.info-table tr>td:first-child {
font-weight: normal;
color: #757575;
white-space: nowrap;
width: 25%;
overflow-wrap: normal;
}

.ns:before {
Expand Down
2 changes: 1 addition & 1 deletion static/css/main.min.4.css

Large diffs are not rendered by default.

54 changes: 46 additions & 8 deletions static/templates/address.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,39 @@ <h4 class="row">
<td>No. Transactions</td>
<td>{{formatInt $addr.UnconfirmedTxs}}</td>
</tr>
{{/* SYSCOIN: show unconfirmed SPT balances on normal address pages. */}}
{{if isSyscoinShortcut .CoinShortcut}}
{{if $addr.TokensAsset}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add backing address asset fields before rendering them

On SYS/TSYS address pages this if tries to read TokensAsset from api.Address, but that struct has no such field (nor the related UsedAssetTokens used in xpub.html). The first Syscoin address render that reaches this block will hit a template execution error for the missing field and truncate the page instead of displaying address details.

Useful? React with 👍 / 👎.

<tr>
<td>Syscoin Assets</td>
<td style="padding: 0;">
<table class="table data-table mt-0 mb-0">
<tbody>
<tr>
<th>Asset</th>
<th>Unconfirmed Balance</th>
<th class="text-end"><span class="d-none d-md-block">Transfers</span><span class="d-block d-md-none">#</span></th>
</tr>
{{range $t := $addr.TokensAsset}}
{{if $t.UnconfirmedBalanceSat}}
<tr>
<td><a href="/asset/{{$t.AssetGuid}}" class="copyable">{{$t.AssetGuid}}</a>&nbsp;<span class="text-muted">{{if $t.Symbol}}{{$t.Symbol}}{{else}}SPT{{end}}</span></td>
<td>{{formattedAmountSpan $t.UnconfirmedBalanceSat $t.Decimals $t.Symbol $data "copyable"}}</td>
<td class="text-end">{{formatInt $t.UnconfirmedTransfers}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
{{end}}
{{/* SYSCOIN: show SPT balances on normal address pages. */}}
{{if isSyscoinShortcut .CoinShortcut}}
{{if $addr.TokensAsset}}
<div class="accordion mt-2 mb-2" id="syscoinAssets">
<div class="accordion-item">
Expand All @@ -124,17 +154,23 @@ <h5 class="col-12 mb-md-0">Syscoin Assets <span class="badge bg-secondary">{{len
<table class="table data-table mt-0 mb-0">
<tbody>
<tr>
<th style="width: 25%;">Asset GUID</th>
<th style="width: 25%;">Symbol</th>
<th style="width: 30%;">Balance</th>
<th class="text-end" style="width: 20%;">Unconfirmed</th>
<th>Asset GUID</th>
<th>Symbol</th>
<th>Received</th>
<th>Sent</th>
<th>Balance</th>
<th>Unconfirmed</th>
<th class="text-end"><span class="d-none d-md-block">Transfers</span><span class="d-block d-md-none">#</span></th>
</tr>
{{range $t := $addr.TokensAsset}}
<tr>
<td><a href="/asset/{{$t.AssetGuid}}" class="copyable">{{$t.AssetGuid}}</a></td>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wire asset routes before linking to them

These new Syscoin asset links point at /asset/<guid>, but I searched server/ for assetTpl, explorerAsset, asset.html, and HandleFunc(...asset...) and found no route or template registration for the newly added asset.html/assets.html. Once the asset rows render, clicking any GUID falls through to the catch-all explorer handler instead of an asset detail page.

Useful? React with 👍 / 👎.

<td>{{if $t.Symbol}}{{$t.Symbol}}{{else}}SPT{{end}}</td>
<td>{{formattedAmountSpan $t.TotalReceivedSat $t.Decimals $t.Symbol $data "copyable"}}</td>
<td>{{formattedAmountSpan $t.TotalSentSat $t.Decimals $t.Symbol $data "copyable"}}</td>
<td>{{formattedAmountSpan $t.BalanceSat $t.Decimals $t.Symbol $data "copyable"}}</td>
<td class="text-end">{{if $t.UnconfirmedBalanceSat}}{{formattedAmountSpan $t.UnconfirmedBalanceSat $t.Decimals $t.Symbol $data "copyable"}}{{else}}0{{end}}</td>
<td>{{if $t.UnconfirmedBalanceSat}}{{formattedAmountSpan $t.UnconfirmedBalanceSat $t.Decimals $t.Symbol $data "copyable"}}{{else}}0{{end}}</td>
<td class="text-end">{{formatInt $t.Transfers}}</td>
</tr>
{{end}}
</tbody>
Expand All @@ -144,6 +180,7 @@ <h5 class="col-12 mb-md-0">Syscoin Assets <span class="badge bg-secondary">{{len
</div>
</div>
{{end}}
{{end}}
{{if eq .ChainType 1}}
{{if tokenCount $addr.Tokens .FungibleTokenName}}
<div class="accordion mt-2 mb-2" id="erc20">
Expand Down Expand Up @@ -171,7 +208,7 @@ <h5 class="col-md-8 mb-md-0"><span tt="Total value of tokens">{{summaryValuesSpa
<tr>
<td class="ellipsis"><a href="/address/{{$t.Contract}}">{{if $t.Name}}<span class="copyable" cc="{{$t.Contract}}" alias-type="Contract">{{$t.Name}}</span>{{else}}<span class="copyable">{{$t.Contract}}</span>{{end}}</a></td>
<td>{{formattedAmountSpan $t.BalanceSat $t.Decimals $t.Symbol $data "copyable"}}</td>
<td>{{summaryValuesSpan $t.BaseValue $t.SecondaryValue $data}}</span></td>
<td>{{summaryValuesSpan $t.BaseValue $t.SecondaryValue $data}}</td>
<td class="text-end">{{formatInt $t.Transfers}}</td>
</tr>
{{end}}
Expand Down Expand Up @@ -263,7 +300,7 @@ <h5 class="col-12 mb-md-0">{{.MultiTokenName}} Tokens <span class="badge bg-seco
<div class="accordion-header" id="stakingPoolsHeading">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#stakingPoolsBody" aria-expanded="false" aria-controls="stakingPoolsBody">
<div class="row g-0 w-100">
<h5 class="col-12 mb-md-0">Staking Pools <span class="badge bg-secondary">{{len $addr.StakingPools}}</span></span></h5>
<h5 class="col-12 mb-md-0">Staking Pools <span class="badge bg-secondary">{{len $addr.StakingPools}}</span></h5>
</div>
</button>
</div>
Expand Down Expand Up @@ -316,7 +353,8 @@ <h5 class="col-12 mb-md-0">Staking Pools <span class="badge bg-secondary">{{len
<div class="row pt-3 pb-1">
<h3 class="col-sm-6 col-lg-3 m-0 align-self-center">Transactions</h3>
<div class="col-sm-6 col-lg-3 my-2 my-lg-0 align-self-center">
{{if $addr.TokensAsset}}<select class="w-100" onchange="self.location='?assetMask='+options[selectedIndex].value+'&filter='+options[selectedIndex].value">{{else}}<select class="w-100" onchange="self.location='?filter='+options[selectedIndex].value">{{end}}
{{/* SYSCOIN: preserve SPT transaction filters when the address has assets. */}}
{{if isSyscoinShortcut .CoinShortcut}}{{if $addr.TokensAsset}}<select class="w-100" onchange="self.location='?assetMask='+options[selectedIndex].value+'&filter='+options[selectedIndex].value">{{else}}<select class="w-100" onchange="self.location='?filter='+options[selectedIndex].value">{{end}}{{else}}<select class="w-100" onchange="self.location='?filter='+options[selectedIndex].value">{{end}}
<option>All</option>
<option {{if eq $addr.Filter "inputs"}}selected{{end}} value="inputs">Address on input side</option>
<option {{if eq $addr.Filter "outputs"}}selected{{end}} value="outputs">Address on output side</option>
Expand Down
5 changes: 4 additions & 1 deletion static/templates/asset.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ <h5 class="col-12 d-flex h-data"><span class="ellipsis copyable">{{$asset.AssetD
{{if $asset.AssetDetails.Contract}}
<tr>
<td>Contract</td>
<td class="ellipsis"><a href="{{formatContractExplorerURL $asset.AssetDetails.Contract}}">{{$asset.AssetDetails.Contract}}</a></td>
{{$contractURL := formatContractExplorerURL $asset.AssetDetails.Contract}}
<td class="ellipsis">{{if $contractURL}}<a href="{{$contractURL}}">{{$asset.AssetDetails.Contract}}</a>{{else}}<span class="copyable">{{$asset.AssetDetails.Contract}}</span>{{end}}</td>
</tr>
{{end}}
{{if not (isSyscoinNativeAsset $asset.AssetDetails.AssetGuid)}}
<tr>
<td>Total Supply</td>
<td>{{formattedAmountSpan $asset.AssetDetails.TotalSupply $asset.AssetDetails.Decimals $asset.AssetDetails.Symbol $data "copyable"}}</td>
Expand All @@ -35,6 +37,7 @@ <h5 class="col-12 d-flex h-data"><span class="ellipsis copyable">{{$asset.AssetD
<td>Max Supply</td>
<td>{{formattedAmountSpan $asset.AssetDetails.MaxSupply $asset.AssetDetails.Decimals $asset.AssetDetails.Symbol $data "copyable"}}</td>
</tr>
{{end}}
{{if $asset.AssetDetails.MetaData}}
<tr>
<td>Metadata</td>
Expand Down
4 changes: 3 additions & 1 deletion static/templates/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ <h5 class="col-md-6 col-sm-12">{{formatInt $assets.NumAssets}} Assets found</h5>
<th>Metadata</th>
</tr>
{{range $assetDetails := $assets.AssetDetails}}
{{if $assetDetails}}
<tr>
<td>
<a href="/asset/{{$assetDetails.AssetGuid}}" class="copyable">{{$assetDetails.AssetGuid}}</a>&nbsp;
<span class="text-muted">{{$assetDetails.Symbol}}</span>
</td>
<td>{{formatInt $assetDetails.Txs}}</td>
<td class="ellipsis">
{{if $assetDetails.Contract}}<a href="{{formatContractExplorerURL $assetDetails.Contract}}">{{$assetDetails.Contract}}</a>{{end}}
{{if $assetDetails.Contract}}{{$contractURL := formatContractExplorerURL $assetDetails.Contract}}{{if $contractURL}}<a href="{{$contractURL}}">{{$assetDetails.Contract}}</a>{{else}}<span class="copyable">{{$assetDetails.Contract}}</span>{{end}}{{end}}
</td>
<td class="ellipsis">{{if $assetDetails.MetaData}}{{$assetDetails.MetaData}}{{end}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
{{template "paging" $data}}
Expand Down
3 changes: 2 additions & 1 deletion static/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
</ul>
<span class="navbar-form">
<form class="d-flex" id="search" action="/search" method="get">
<input name="q" type="text" class="form-control form-control-lg" placeholder="Search for block, transaction, address or xpub" focus="true">
{{/* SYSCOIN: Syscoin explorers support asset GUID/symbol search. */}}
<input name="q" type="text" class="form-control form-control-lg" placeholder="Search for block, transaction, address{{if isSyscoinShortcut .CoinShortcut}}, asset{{end}} or xpub" focus="true">
<button class="btn" type="submit">
<span class="search-icon"></span>
</button>
Expand Down
4 changes: 2 additions & 2 deletions static/templates/blocks.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<div class="row">
<div class="col-md-6"><h1>Blocks</h1></div>
<div class="col-md-6">{{if $blocks.Blocks}}{{template "paging" $data }}{{end}}</div>
</row>
</div>
{{if $blocks.Blocks}}
<div>
<table class="table table-hover data-table">
<thead>
<tr>
<th>Height</th>
<th class="col-md-6">Hash</th>
<th class="col-md-2">Timestamp</span></th>
<th class="col-md-2">Timestamp</th>
<th class="text-end">Transactions</th>
<th class="text-end">Size</th>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion static/templates/mempool.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="row">
<div class="col-lg-6"><h1>Mempool Transactions</h1><h5 class="mb-lg-0">{{$.MempoolTxids.MempoolSize}} transactions in mempool</h5></div>
<div class="col-lg-6">{{if $txs}}{{template "paging" $data }}{{end}}</div>
</row>
</div>
{{if $txs}}
<table class="table data-table table-hover">
<thead>
Expand Down
1 change: 1 addition & 0 deletions static/templates/sendtx.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ <h1>Send Raw Transaction</h1>
<label for="exampleFormControlTextarea1">Raw transaction data</label>
<textarea class="form-control" rows="8" name="hex">{{.SendTxHex}}</textarea>
</div>
{{/* SYSCOIN: expose Syscoin Core sendrawtransaction safety parameters. */}}
{{if isSyscoinShortcut .CoinShortcut}}
<div class="row mt-3">
<div class="form-group col-md-6">
Expand Down
3 changes: 3 additions & 0 deletions static/templates/tx_bitcointype.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ <h5 class="col-12 d-flex h-data"><span class="ellipsis copyable">{{$tx.Txid}}</s
<td>In Block</td>
<td class="ellipsis" style="max-width: 280px">{{if $tx.Confirmations}}{{$tx.Blockhash}}{{else}}<span class="badge bg-danger">Unconfirmed</span>{{end}}</td>
</tr>
{{/* SYSCOIN: expose SPT transaction metadata on the full transaction page. */}}
{{if isSyscoinShortcut $data.CoinShortcut}}
{{if $tx.TokenType}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add backing Tx fields before rendering Syscoin tx pages

For SYS/TSYS this branch is evaluated on every Bitcoin-type transaction page, but api.Tx does not define TokenType or Memo (and the later rows also use non-existent AssetGuid fields on api.TokenTransfer). Go templates return an execution error for missing struct fields, so Syscoin transaction pages render only partially instead of showing the transaction.

Useful? React with 👍 / 👎.

<tr>
<td>Syscoin Transaction Type</td>
Expand Down Expand Up @@ -53,6 +55,7 @@ <h5 class="col-12 d-flex h-data"><span class="ellipsis copyable">{{$tx.Txid}}</s
</td>
</tr>
{{end}}
{{end}}
{{if $tx.Confirmations}}
<tr>
<td>In Block Height</td>
Expand Down
16 changes: 14 additions & 2 deletions static/templates/txdetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
<div class="col-xs-7 col-md-8">
<a href="/tx/{{$tx.Txid}}" class="ellipsis copyable txid">{{$tx.Txid}}</a>
{{if $tx.Rbf}}<span class="ps-1" tt="Replace-by-Fee (RBF) transaction, could be overridden"> RBF</span>{{end}}
{{/* SYSCOIN: show SPT transaction type on every shared transaction list row. */}}
{{if isSyscoinShortcut $data.CoinShortcut}}
{{if $tx.TokenType}}
<div class="mt-1">
<span class="badge bg-secondary fw-normal" tt="Syscoin transaction type">{{$tx.TokenType}}</span>
</div>
{{end}}
{{end}}
</div>
{{if $tx.Blocktime}}<div class="col-xs-5 col-md-4 text-end">{{if $tx.Confirmations}}mined{{else}}first seen{{end}} <span class="txvalue ms-1">{{unixTimeSpan $tx.Blocktime}}</span></div>{{end}}
{{if $tx.ConfirmationETABlocks}}<div class="col-12 text-end">
Expand All @@ -27,12 +35,15 @@
<a class="outpoint" href="/tx/{{$vin.Txid}}" tt="Outpoint {{$vin.Txid}},{{$vin.Vout}}">←</a>
{{end}}
{{if $vin.Addresses}}{{amountSpan $vin.ValueSat $data "tx-amt copyable"}}{{end}}
{{/* SYSCOIN: show SPT metadata attached to transaction inputs. */}}
{{if isSyscoinShortcut $data.CoinShortcut}}
{{if $vin.AssetInfo}}
<span class="tx-amt small text-muted d-block">
SYSCOIN asset <a href="/asset/{{$vin.AssetInfo.AssetGuid}}">#{{$vin.AssetInfo.AssetGuid}}</a>:
<span class="copyable">{{$vin.AssetInfo.ValueStr}}</span>{{if $vin.AssetInfo.Symbol}} {{$vin.AssetInfo.Symbol}}{{end}}
</span>
{{end}}
{{end}}
</div>
{{else}}
<div class="col-12">No Inputs</div>
Expand All @@ -55,13 +66,14 @@
{{amountSpan $vout.ValueSat $data "copyable"}}{{if $vout.Spent}}<a class="spent" href="{{if $vout.SpentTxID}}/tx/{{$vout.SpentTxID}}{{else}}/spending/{{$tx.Txid}}/{{$vout.N}}{{end}}" tt="Spent">→</a>{{else}}<span class="unspent" tt="Unspent">×</span>
{{end}}
</span>
{{/* SYSCOIN: show SPT metadata attached to transaction outputs. */}}
{{if isSyscoinShortcut $data.CoinShortcut}}
{{if $vout.AssetInfo}}
<span class="tx-amt small text-muted d-block">
SYSCOIN asset <a href="/asset/{{$vout.AssetInfo.AssetGuid}}">#{{$vout.AssetInfo.AssetGuid}}</a>:
<span class="copyable">{{$vout.AssetInfo.ValueStr}}</span>{{if $vout.AssetInfo.Symbol}} {{$vout.AssetInfo.Symbol}}{{end}}
</span>
{{else}}
</td>
{{end}}
{{end}}
</div>
{{else}}
Expand Down
34 changes: 34 additions & 0 deletions static/templates/xpub.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ <h4 class="row">
<td>Used XPUB Addresses</td>
<td>{{formatInt $addr.UsedTokens}}</td>
</tr>
{{/* SYSCOIN: include SPT-derived XPUB usage in the summary. */}}
{{if isSyscoinShortcut .CoinShortcut}}
{{if $addr.UsedAssetTokens}}
<tr>
<td>Used XPUB Assets</td>
<td>{{formatInt $addr.UsedAssetTokens}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
<table class="table data-table">
Expand Down Expand Up @@ -87,6 +90,8 @@ <h4 class="row">
{{end}}
</div>
</div>
{{/* SYSCOIN: show SPT balances derived from XPUB addresses. */}}
{{if isSyscoinShortcut .CoinShortcut}}
{{if or $addr.TokensAsset $addr.UsedAssetTokens}}
<table class="table data-table">
<tbody>
Expand Down Expand Up @@ -119,6 +124,7 @@ <h4 class="row">
</tbody>
</table>
{{end}}
{{end}}
{{if $addr.UnconfirmedTxs}}
<table class="table data-table info-table">
<tbody>
Expand All @@ -134,6 +140,34 @@ <h4 class="row">
<td>No. Transactions</td>
<td>{{formatInt $addr.UnconfirmedTxs}}</td>
</tr>
{{/* SYSCOIN: show unconfirmed SPT balances derived from XPUB addresses. */}}
{{if isSyscoinShortcut .CoinShortcut}}
{{if $addr.TokensAsset}}
<tr>
<td>Syscoin Assets</td>
<td style="padding: 0;">
<table class="table data-table mt-0 mb-0">
<tbody>
<tr>
<th>Asset</th>
<th>Unconfirmed Balance</th>
<th class="text-end"><span class="d-none d-md-block">Transfers</span><span class="d-block d-md-none">#</span></th>
</tr>
{{range $t := $addr.TokensAsset}}
{{if $t.UnconfirmedBalanceSat}}
<tr>
<td><a href="/asset/{{$t.AssetGuid}}" class="copyable">{{$t.AssetGuid}}</a>&nbsp;<span class="text-muted">{{if $t.Symbol}}{{$t.Symbol}}{{else}}SPT{{end}}</span></td>
<td>{{formattedAmountSpan $t.UnconfirmedBalanceSat $t.Decimals $t.Symbol $data "copyable"}}</td>
<td class="text-end">{{formatInt $t.UnconfirmedTransfers}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
{{end}}
Expand Down
Loading