TokenV3 and new Mint startup in tests (#149)

* tokenv3 send and receive
* receive v2 and v1 tokens with tests
This commit is contained in:
calle
2023-03-28 22:35:22 +02:00
committed by GitHub
parent 258de87a9a
commit db27105d17
10 changed files with 402 additions and 168 deletions

View File

@@ -331,3 +331,29 @@ class TokenV2(BaseModel):
)
else:
return dict(proofs=[p.to_dict() for p in self.proofs])
class TokenV3Token(BaseModel):
mint: Optional[str] = None
proofs: List[Proof]
def to_dict(self):
return_dict = dict(proofs=[p.to_dict() for p in self.proofs])
if self.mint:
return_dict.update(dict(mint=self.mint)) # type: ignore
return return_dict
class TokenV3(BaseModel):
"""
A Cashu token that includes proofs and their respective mints. Can include proofs from multiple different mints and keysets.
"""
token: List[TokenV3Token] = []
memo: Optional[str] = None
def to_dict(self):
return_dict = dict(token=[t.to_dict() for t in self.token])
if self.memo:
return_dict.update(dict(memo=self.memo)) # type: ignore
return return_dict