mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-01-07 10:54:20 +01:00
Fix parsing of old format contact field in wallet (#589)
* wallet parse contact field if its old format * default checks for contacts
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, root_validator
|
||||
|
||||
from .base import (
|
||||
BlindedMessage,
|
||||
@@ -43,6 +43,21 @@ class GetInfoResponse(BaseModel):
|
||||
def supports(self, nut: int) -> Optional[bool]:
|
||||
return nut in self.nuts if self.nuts else None
|
||||
|
||||
# BEGIN DEPRECATED: NUT-06 contact field change
|
||||
# NUT-06 PR: https://github.com/cashubtc/nuts/pull/117
|
||||
@root_validator(pre=True)
|
||||
def preprocess_deprecated_contact_field(cls, values):
|
||||
if "contact" in values and values["contact"]:
|
||||
if isinstance(values["contact"][0], list):
|
||||
values["contact"] = [
|
||||
MintInfoContact(method=method, info=info)
|
||||
for method, info in values["contact"]
|
||||
if method and info
|
||||
]
|
||||
return values
|
||||
|
||||
# END DEPRECATED: NUT-06 contact field change
|
||||
|
||||
|
||||
class Nut15MppSupport(BaseModel):
|
||||
method: str
|
||||
|
||||
@@ -142,7 +142,7 @@ class MintInformation(CashuSettings):
|
||||
mint_info_name: str = Field(default="Cashu mint")
|
||||
mint_info_description: str = Field(default=None)
|
||||
mint_info_description_long: str = Field(default=None)
|
||||
mint_info_contact: List[List[str]] = Field(default=[["", ""]])
|
||||
mint_info_contact: List[List[str]] = Field(default=[])
|
||||
mint_info_motd: str = Field(default=None)
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ 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
|
||||
MintInfoContact(method=m, info=i)
|
||||
for m, i in settings.mint_info_contact
|
||||
if m and i
|
||||
]
|
||||
return GetInfoResponse(
|
||||
name=settings.mint_info_name,
|
||||
|
||||
Reference in New Issue
Block a user