feat: GET /api/getWhitelist (walletList) + WalletAdmin; verifier grace no longer resurrects false rows

This commit is contained in:
proitlab committed 2026-08-26 18:41:57 +07:00
1 parent 7ae6b8f4f8
commit b00bd4f740
7 files changed
+83 -8

No files matched your search

+33 -1
View File
@@ -12,7 +12,7 @@ from wtforms.validators import DataRequired
from sqlalchemy import text
from app.auth import AdminAuthBackend, get_session_secret
from app.models import ICON_DIR, SessionLocal, Dapp, Token, Version
from app.models import ICON_DIR, SessionLocal, Dapp, Token, Version, Wallet
BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATES_DIR = str(BASE_DIR / "app" / "templates")
@@ -284,6 +284,37 @@ class VersionAdmin(ModelView, model=Version):
raise Exception("acceptableVersion must be <= latestVersion")
class WalletForm(Form):
account = StringField("Account", validators=[DataRequired()])
class WalletAdmin(ModelView, model=Wallet):
name = "Whitelisted Wallets"
icon = "fa-solid fa-wallet"
form = WalletForm
column_list = ["account", "created_at"]
column_details_list = ["id", "account", "created_at"]
column_searchable_list = ["account"]
column_default_sort = [("id", True)]
page_size = 25
def is_accessible(self, request: Request) -> bool:
return _is_authenticated(request)
async def on_model_change(self, data, model, is_created, request):
data.pop("id", None)
account = (data.get("account") or "").strip()
if not account:
raise Exception("Account is required")
with SessionLocal() as session:
exists = session.query(Wallet).filter(Wallet.account == account).first()
if exists and (is_created or exists.id != model.id):
raise Exception(f"'{account}' is already whitelisted")
data["account"] = account
if is_created:
data["created_at"] = _now_iso()
def create_admin(app):
auth_backend = AdminAuthBackend(get_session_secret())
admin = Admin(
@@ -297,4 +328,5 @@ def create_admin(app):
admin.add_view(TokenAdmin)
admin.add_view(VersionAdmin)
admin.add_view(DappAdmin)
admin.add_view(WalletAdmin)
return admin