Skip to content

Commit

Permalink
Fix admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Mar 21, 2024
1 parent ac75156 commit 868b15a
Showing 1 changed file with 53 additions and 12 deletions.
65 changes: 53 additions & 12 deletions safe_transaction_service/account_abstraction/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from django.contrib import admin

from eth_typing import ChecksumAddress, HexStr

from safe_transaction_service.history import models as history_models

from .models import SafeOperation, UserOperation, UserOperationReceipt


@admin.register(UserOperation)
class UserOperationAdmin(admin.ModelAdmin):
list_display = ("hash", "ethereum_tx_id", "sender", "nonce", "receipt__success")
list_display = ("hash", "ethereum_tx", "sender", "nonce", "success")
list_filter = [
"receipt__success",
]
Expand All @@ -14,37 +18,74 @@ class UserOperationAdmin(admin.ModelAdmin):
]
ordering = ["-nonce"]

@admin.display(boolean=True, description="Is successful?")
def success(self, obj: UserOperation) -> bool:
return obj.receipt.success


@admin.register(UserOperationReceipt)
class UserOperationReceiptAdmin(admin.ModelAdmin):
list_display = (
"user_operation__hash",
"user_operation__sender",
"user_operation__nonce",
"user_operation_hash",
"user_operation_sender",
"user_operation_nonce",
"success",
"deposited",
)
list_filter = [
"success",
]
search_fields = [
"==sender",
"==user_operation__sender",
]
ordering = ["-nonce"]

@admin.display()
def user_operation_hash(self, obj: UserOperationReceipt) -> HexStr:
return obj.user_operation.hash

@admin.display()
def user_operation_sender(self, obj: UserOperationReceipt) -> ChecksumAddress:
return obj.user_operation.sender

@admin.display()
def user_operation_nonce(self, obj: UserOperationReceipt) -> int:
return obj.user_operation.nonce


@admin.register(SafeOperation)
class SafeOperationAdmin(admin.ModelAdmin):
list_display = (
"hash",
"user_operation__hash",
"ethereum_tx_id",
"user_operation__sender",
"user_operation__nonce",
"user_operation_hash",
"ethereum_tx",
"user_operation_sender",
"user_operation_nonce",
"success",
"module_address",
)
list_filter = ["module_address"]
list_select_related = ["user_operation__receipt"]
search_fields = [
"==sender",
"==user_operation__sender",
]
ordering = ["-nonce"]
ordering = ["-modified"]

@admin.display()
def ethereum_tx(self, obj: SafeOperation) -> history_models.EthereumTx:
return obj.user_operation.ethereum_tx

@admin.display()
def user_operation_hash(self, obj: SafeOperation) -> HexStr:
return obj.user_operation.hash

@admin.display()
def user_operation_sender(self, obj: SafeOperation) -> ChecksumAddress:
return obj.user_operation.sender

@admin.display()
def user_operation_nonce(self, obj: SafeOperation) -> int:
return obj.user_operation.nonce

@admin.display(boolean=True, description="Is successful?")
def success(self, obj: SafeOperation) -> bool:
return obj.user_operation.receipt.success

0 comments on commit 868b15a

Please sign in to comment.