Add new accounts page
This commit is contained in:
parent
8b644a9b67
commit
3a6e9b8704
|
@ -0,0 +1,37 @@
|
|||
import transaction_database
|
||||
import postgres_connection
|
||||
import json
|
||||
|
||||
def build_account_details(pubkey: str):
|
||||
(transactions, is_limit_exceeded) = list(transaction_database.query_transactions_by_address(pubkey))
|
||||
account = {}
|
||||
account['pubkey'] = pubkey
|
||||
|
||||
blocks = postgres_connection.query(
|
||||
"""
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
slot,
|
||||
total_cu_consumed,
|
||||
prioritization_fees_info
|
||||
FROM banking_stage_results_2.accounts_map_blocks
|
||||
WHERE acc_id = (select acc_id from banking_stage_results_2.accounts where account_key = %s) and is_write_locked = true
|
||||
order by slot desc
|
||||
limit 10
|
||||
) AS data
|
||||
""", args=[pubkey])
|
||||
for row in blocks:
|
||||
pf = json.loads(row['prioritization_fees_info'])
|
||||
row['min'] = pf['min']
|
||||
row['med'] = pf['med']
|
||||
row['max'] = pf['max']
|
||||
row['p75'] = pf['p75']
|
||||
row['p90'] = pf['p90']
|
||||
row['p95'] = pf['p95']
|
||||
account['blocks'] = blocks
|
||||
return (account, transactions, is_limit_exceeded)
|
||||
|
||||
def main():
|
||||
build_account_details('AfASDKLEWG7Di9HtZDmHKftR1fsMXBtTSxP7qMo9qv7L')
|
||||
|
||||
|
15
app.py
15
app.py
|
@ -9,6 +9,7 @@ import block_details_database
|
|||
import config
|
||||
import locale
|
||||
from datetime import datetime
|
||||
import account_details_database
|
||||
|
||||
#
|
||||
# MAIN
|
||||
|
@ -86,6 +87,20 @@ def get_block(slot):
|
|||
print("block_details_database.find_block_by_slotnumber() took", elapsed, "seconds")
|
||||
return render_template('block_details.html', config=this_config, block=block)
|
||||
|
||||
@webapp.route('/account/<path:pubkey>')
|
||||
def get_account(pubkey):
|
||||
this_config = config.get_config()
|
||||
start = time.time()
|
||||
if not is_b58_44(pubkey):
|
||||
return "Invalid account", 404
|
||||
start = time.time()
|
||||
(account, transactions, is_limit_exceeded) = account_details_database.build_account_details(pubkey)
|
||||
elapsed = time.time() - start
|
||||
if elapsed > .5:
|
||||
print("account_details_database.build_account_details() took", elapsed, "seconds")
|
||||
return render_template('account_details.html', config=this_config, account=account, transactions=transactions, limit_exceeded=is_limit_exceeded)
|
||||
|
||||
|
||||
def is_slot_number(raw_string):
|
||||
return re.fullmatch("[0-9,]+", raw_string) is not None
|
||||
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Account Details</title>
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
<link rel="preconnect" href="https://api.fonts.coollabs.io" crossorigin>
|
||||
<link href="https://api.fonts.coollabs.io/css2?family=Rubik&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='a72bf4ce55ad4320.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="main-content pb-6">
|
||||
|
||||
{% include "_navbar.html" %}
|
||||
|
||||
<div class="container mt-n2">
|
||||
<div class="header">
|
||||
<div class="header-body"><h6 class="header-pretitle">Details</h6>
|
||||
<h2 class="header-title">Account {{ account.pubkey }}</h2></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header"><h3 class="card-header-title mb-0 d-flex align-items-center">Overview</h3>
|
||||
</div>
|
||||
<div class="table-responsive mb-0">
|
||||
<table class="table table-sm table-nowrap card-table">
|
||||
<tbody class="list">
|
||||
<tr>
|
||||
<td class="w-100">Account</td>
|
||||
<td class="text-lg-end font-monospace"><span class="font-monospace"><a href="https://explorer.solana.com//address/{{account.pubkey}}?cluster={{config.cluster}}">{{ account.pubkey }}</a></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="header-body pt-0">
|
||||
<ul class="nav nav-tabs nav-overflow header-tabs">
|
||||
<!-- note: local anchors are not hx-boost'ed -->
|
||||
<li class="nav-item"><a class="nav-link" href="#recent-blocks">Recent Blocks</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#recent-banking-errors">Recent Banking Errors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="recent-blocks" class="card">
|
||||
<div class="card-header align-items-center"><h3 class="card-header-title">Recent Block Data</h3></div>
|
||||
|
||||
<div class="table-responsive mb-0">
|
||||
<table class="table table-sm table-nowrap card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-muted table-cell-width-account">Slot</th>
|
||||
<th class="text-muted text-end table-cell-width-number">CU Consumed</th>
|
||||
<th class="text-muted text-end table-cell-width-number">Min</th>
|
||||
<th class="text-muted text-end table-cell-width-number">Median</th>
|
||||
<th class="text-muted text-end table-cell-width-number">p75</th>
|
||||
<th class="text-muted text-end table-cell-width-number">p90</th>
|
||||
<th class="text-muted text-end table-cell-width-number">p95</th>
|
||||
<th class="text-muted text-end table-cell-width-number">Max</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for block in account.blocks %}
|
||||
<tr>
|
||||
<td>
|
||||
<a hx-boost="false" href="/block/{{block.slot}}">
|
||||
<div class="d-none d-lg-flex align-items-center "><span class="font-size-tiny me-2"><span
|
||||
class=""></span></span><span
|
||||
class="font-monospace"><span class="">{{block.slot}}</span></span>
|
||||
</div>
|
||||
</a></td>
|
||||
<td class="text-end font-monospace">
|
||||
<div class="font-monospace">
|
||||
{{ block.total_cu_consumed | lamports }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end font-monospace">
|
||||
<div class="font-monospace">
|
||||
{{ block.min | lamports }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end font-monospace">
|
||||
<div class="font-monospace">
|
||||
{{ block.med | lamports }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end font-monospace">
|
||||
<div class="font-monospace">
|
||||
{{ block.p75 | lamports }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end font-monospace">
|
||||
<div class="font-monospace">
|
||||
{{ block.p90 | lamports }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end font-monospace">
|
||||
<div class="font-monospace">
|
||||
{{ block.p95 | lamports }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end font-monospace">
|
||||
<div class="font-monospace">
|
||||
{{ block.max | lamports }}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="recent-banking-errors" class="card">
|
||||
|
||||
{% include "_txlist.html" %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -122,7 +122,7 @@
|
|||
<tr>
|
||||
|
||||
<td>
|
||||
<a hx-boost="false" href="https://explorer.solana.com/account/{{ write_account.key }}?cluster={{config.cluster}}">
|
||||
<a hx-boost="false" href="/account/{{ write_account.key }}">
|
||||
<div class="d-none d-lg-flex align-items-center "><span class="font-size-tiny me-2"><span
|
||||
class=""></span></span><span
|
||||
class="font-monospace"><span class="">{{write_account.key}}</span></span>
|
||||
|
@ -181,7 +181,7 @@
|
|||
{% for read_account in block.heavily_readlocked_accounts_parsed %}
|
||||
<tr>
|
||||
<td>
|
||||
<a hx-boost="false" href="https://explorer.solana.com/account/{{ read_account.key }}?cluster={{config.cluster}}">
|
||||
<a hx-boost="false" href="/account/{{read_account.key}}">
|
||||
<div class="d-none d-lg-flex align-items-center "><span class="font-size-tiny me-2"><span
|
||||
class=""></span></span><span
|
||||
class="font-monospace"><span class="">{{read_account.key}}</span></span>
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
<tr>
|
||||
|
||||
<td>
|
||||
<a href="https://explorer.solana.com/account/{{ write_account.key }}?cluster={{config.cluster}}">
|
||||
<a href="/account/{{write_account.key}}">
|
||||
<div class="d-none d-lg-flex align-items-center "><span class="font-size-tiny me-2"><span
|
||||
class=""></span></span><span
|
||||
class="font-monospace"><span class="">{{ write_account.key }}</span></span>
|
||||
|
@ -204,7 +204,7 @@
|
|||
<tr>
|
||||
|
||||
<td>
|
||||
<a href="https://explorer.solana.com/account/{{ read_account.key }}?cluster={{config.cluster}}">
|
||||
<a href="/account/{{read_account.key}}">
|
||||
<div class="d-none d-lg-flex align-items-center">
|
||||
<span class="font-size-tiny me-2">
|
||||
<span class="font-monospace">{{ read_account.key }}</span>
|
||||
|
|
Loading…
Reference in New Issue