refactor: consolidate blockchain explorer into single app and update backup ignore patterns
- Remove standalone explorer-web app (README, HTML, package files) - Add /web endpoint to blockchain-explorer for web interface access - Update .gitignore to exclude application backup archives (*.tar.gz, *.zip) - Add backup documentation files to .gitignore (BACKUP_INDEX.md, README.md) - Consolidate explorer functionality into main blockchain-explorer application
This commit is contained in:
134
apps/wallet/src/app/models/__init__.py
Normal file
134
apps/wallet/src/app/models/__init__.py
Normal file
@@ -0,0 +1,134 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from aitbc_sdk import SignatureValidation
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class SignatureValidationModel(BaseModel):
|
||||
key_id: str
|
||||
alg: str = "Ed25519"
|
||||
valid: bool
|
||||
|
||||
|
||||
class ReceiptVerificationModel(BaseModel):
|
||||
job_id: str
|
||||
receipt_id: str
|
||||
miner_signature: SignatureValidationModel
|
||||
coordinator_attestations: List[SignatureValidationModel]
|
||||
all_valid: bool
|
||||
|
||||
|
||||
class ReceiptVerifyResponse(BaseModel):
|
||||
result: ReceiptVerificationModel
|
||||
|
||||
|
||||
def _signature_to_model(sig: SignatureValidation | SignatureValidationModel) -> SignatureValidationModel:
|
||||
if isinstance(sig, SignatureValidationModel):
|
||||
return sig
|
||||
return SignatureValidationModel(key_id=sig.key_id, alg=sig.algorithm, valid=sig.valid)
|
||||
|
||||
|
||||
def from_validation_result(result) -> ReceiptVerificationModel:
|
||||
return ReceiptVerificationModel(
|
||||
job_id=result.job_id,
|
||||
receipt_id=result.receipt_id,
|
||||
miner_signature=_signature_to_model(result.miner_signature),
|
||||
coordinator_attestations=[_signature_to_model(att) for att in result.coordinator_attestations],
|
||||
all_valid=result.all_valid,
|
||||
)
|
||||
|
||||
|
||||
class ReceiptVerificationListResponse(BaseModel):
|
||||
items: List[ReceiptVerificationModel]
|
||||
|
||||
|
||||
class WalletDescriptor(BaseModel):
|
||||
wallet_id: str
|
||||
chain_id: str
|
||||
public_key: str
|
||||
address: Optional[str]
|
||||
metadata: Dict[str, Any]
|
||||
|
||||
|
||||
class WalletListResponse(BaseModel):
|
||||
items: List[WalletDescriptor]
|
||||
|
||||
|
||||
class WalletCreateRequest(BaseModel):
|
||||
chain_id: str
|
||||
wallet_id: str
|
||||
password: str
|
||||
metadata: Dict[str, Any] = {}
|
||||
secret_key: Optional[str] = None
|
||||
|
||||
|
||||
class WalletCreateResponse(BaseModel):
|
||||
wallet: WalletDescriptor
|
||||
|
||||
|
||||
class WalletUnlockRequest(BaseModel):
|
||||
password: str
|
||||
|
||||
|
||||
class WalletUnlockResponse(BaseModel):
|
||||
wallet_id: str
|
||||
chain_id: str
|
||||
unlocked: bool
|
||||
|
||||
|
||||
class WalletSignRequest(BaseModel):
|
||||
password: str
|
||||
message_base64: str
|
||||
|
||||
|
||||
class WalletSignResponse(BaseModel):
|
||||
wallet_id: str
|
||||
chain_id: str
|
||||
signature_base64: str
|
||||
|
||||
|
||||
class ChainInfo(BaseModel):
|
||||
chain_id: str
|
||||
name: str
|
||||
status: str
|
||||
coordinator_url: str
|
||||
created_at: str
|
||||
updated_at: str
|
||||
wallet_count: int
|
||||
recent_activity: int
|
||||
|
||||
|
||||
class ChainListResponse(BaseModel):
|
||||
chains: List[ChainInfo]
|
||||
total_chains: int
|
||||
active_chains: int
|
||||
|
||||
|
||||
class ChainCreateRequest(BaseModel):
|
||||
chain_id: str
|
||||
name: str
|
||||
coordinator_url: str
|
||||
coordinator_api_key: str
|
||||
metadata: Dict[str, Any] = {}
|
||||
|
||||
|
||||
class ChainCreateResponse(BaseModel):
|
||||
chain: ChainInfo
|
||||
|
||||
|
||||
class WalletMigrationRequest(BaseModel):
|
||||
source_chain_id: str
|
||||
target_chain_id: str
|
||||
wallet_id: str
|
||||
password: str
|
||||
new_password: Optional[str] = None
|
||||
|
||||
|
||||
class WalletMigrationResponse(BaseModel):
|
||||
success: bool
|
||||
source_wallet: WalletDescriptor
|
||||
target_wallet: WalletDescriptor
|
||||
migration_timestamp: str
|
||||
Reference in New Issue
Block a user