mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-01-11 12:44:19 +01:00
NUT-06: Mint contact info (#585)
* Implement NUT-06 change: https://github.com/cashubtc/nuts/pull/117 * wallet deserialize * ignore contact info for deprecated v0 response
This commit is contained in:
@@ -25,13 +25,18 @@ class MintMeltMethodSetting(BaseModel):
|
||||
max_amount: Optional[int] = None
|
||||
|
||||
|
||||
class MintInfoContact(BaseModel):
|
||||
method: str
|
||||
info: str
|
||||
|
||||
|
||||
class GetInfoResponse(BaseModel):
|
||||
name: Optional[str] = None
|
||||
pubkey: Optional[str] = None
|
||||
version: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
description_long: Optional[str] = None
|
||||
contact: Optional[List[List[str]]] = None
|
||||
contact: Optional[List[MintInfoContact]] = None
|
||||
motd: Optional[str] = None
|
||||
nuts: Optional[Dict[int, Any]] = None
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from ..core.models import (
|
||||
KeysetsResponseKeyset,
|
||||
KeysResponse,
|
||||
KeysResponseKeyset,
|
||||
MintInfoContact,
|
||||
PostCheckStateRequest,
|
||||
PostCheckStateResponse,
|
||||
PostMeltQuoteRequest,
|
||||
@@ -41,13 +42,16 @@ router: APIRouter = APIRouter()
|
||||
async def info() -> GetInfoResponse:
|
||||
logger.trace("> GET /v1/info")
|
||||
mint_features = ledger.mint_features()
|
||||
contact_info = [
|
||||
MintInfoContact(method=m, info=i) for m, i in settings.mint_info_contact
|
||||
]
|
||||
return GetInfoResponse(
|
||||
name=settings.mint_info_name,
|
||||
pubkey=ledger.pubkey.serialize().hex() if ledger.pubkey else None,
|
||||
version=f"Nutshell/{settings.version}",
|
||||
description=settings.mint_info_description,
|
||||
description_long=settings.mint_info_description_long,
|
||||
contact=settings.mint_info_contact,
|
||||
contact=contact_info,
|
||||
nuts=mint_features,
|
||||
motd=settings.mint_info_motd,
|
||||
)
|
||||
|
||||
@@ -2,10 +2,9 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from cashu.core.nuts import MPP_NUT, WEBSOCKETS_NUT
|
||||
|
||||
from ..core.base import Method, Unit
|
||||
from ..core.models import Nut15MppSupport
|
||||
from ..core.models import MintInfoContact, Nut15MppSupport
|
||||
from ..core.nuts import MPP_NUT, WEBSOCKETS_NUT
|
||||
|
||||
|
||||
class MintInfo(BaseModel):
|
||||
@@ -14,7 +13,7 @@ class MintInfo(BaseModel):
|
||||
version: Optional[str]
|
||||
description: Optional[str]
|
||||
description_long: Optional[str]
|
||||
contact: Optional[List[List[str]]]
|
||||
contact: Optional[List[MintInfoContact]]
|
||||
motd: Optional[str]
|
||||
nuts: Optional[Dict[int, Any]]
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class LedgerAPIDeprecated(SupportsHttpxClient, SupportsMintURL):
|
||||
GetInfoResponse_deprecated.parse_obj(data)
|
||||
)
|
||||
mint_info = GetInfoResponse(
|
||||
**mint_info_deprecated.dict(exclude={"parameter", "nuts"})
|
||||
**mint_info_deprecated.dict(exclude={"parameter", "nuts", "contact"})
|
||||
)
|
||||
return mint_info
|
||||
|
||||
|
||||
Reference in New Issue
Block a user