From 80d1830a00aeda0c6fc3bc2f5d4c6f57b781d6e0 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 21 Jun 2023 16:51:41 +0200 Subject: [PATCH] no async for deserialization functions --- cashu/wallet/api/router.py | 6 +++--- cashu/wallet/cli/cli.py | 4 ++-- cashu/wallet/helpers.py | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cashu/wallet/api/router.py b/cashu/wallet/api/router.py index a8ad7964..8b8aed22 100644 --- a/cashu/wallet/api/router.py +++ b/cashu/wallet/api/router.py @@ -178,7 +178,7 @@ async def receive_command( ): initial_balance = wallet.available_balance if token: - tokenObj: TokenV3 = await deserialize_token_from_string(token) + tokenObj: TokenV3 = deserialize_token_from_string(token) await verify_mints(wallet, tokenObj) balance = await receive(wallet, tokenObj, lock) elif nostr: @@ -191,7 +191,7 @@ async def receive_command( for _, value in groupby(reserved_proofs, key=itemgetter("send_id")): # type: ignore proofs = list(value) token = await wallet.serialize_proofs(proofs) - tokenObj = await deserialize_token_from_string(token) + tokenObj = deserialize_token_from_string(token) await verify_mints(wallet, tokenObj) balance = await receive(wallet, tokenObj, lock) else: @@ -268,7 +268,7 @@ async def pending( ): grouped_proofs = list(value) token = await wallet.serialize_proofs(grouped_proofs) - tokenObj = await deserialize_token_from_string(token) + tokenObj = deserialize_token_from_string(token) mint = [t.mint for t in tokenObj.token][0] reserved_date = datetime.utcfromtimestamp( int(grouped_proofs[0].time_reserved) diff --git a/cashu/wallet/cli/cli.py b/cashu/wallet/cli/cli.py index 2e4d99e3..fb18830b 100644 --- a/cashu/wallet/cli/cli.py +++ b/cashu/wallet/cli/cli.py @@ -334,7 +334,7 @@ async def receive_cli( wallet.status() if token: - tokenObj = await deserialize_token_from_string(token) + tokenObj = deserialize_token_from_string(token) # verify that we trust all mints in these tokens # ask the user if they want to trust the new mints for mint_url in set([t.mint for t in tokenObj.token if t.mint]): @@ -450,7 +450,7 @@ async def pending(ctx: Context, legacy, number: int, offset: int): ): grouped_proofs = list(value) token = await wallet.serialize_proofs(grouped_proofs) - tokenObj = await deserialize_token_from_string(token) + tokenObj = deserialize_token_from_string(token) mint = [t.mint for t in tokenObj.token][0] # token_hidden_secret = await wallet.serialize_proofs(grouped_proofs) reserved_date = datetime.utcfromtimestamp( diff --git a/cashu/wallet/helpers.py b/cashu/wallet/helpers.py index ac43aca1..5eb2963f 100644 --- a/cashu/wallet/helpers.py +++ b/cashu/wallet/helpers.py @@ -49,7 +49,7 @@ async def redeem_TokenV3_multimint( print(f"Received {sum_proofs(redeem_proofs)} sats") -async def serialize_TokenV2_to_TokenV3(tokenv2: TokenV2): +def serialize_TokenV2_to_TokenV3(tokenv2: TokenV2): """Helper function to receive legacy TokenV2 tokens. Takes a list of proofs and constructs a *serialized* TokenV3 to be received through the ordinary path. @@ -64,7 +64,7 @@ async def serialize_TokenV2_to_TokenV3(tokenv2: TokenV2): return token_serialized -async def serialize_TokenV1_to_TokenV3(tokenv1: TokenV1): +def serialize_TokenV1_to_TokenV3(tokenv1: TokenV1): """Helper function to receive legacy TokenV1 tokens. Takes a list of proofs and constructs a *serialized* TokenV3 to be received through the ordinary path. @@ -77,7 +77,7 @@ async def serialize_TokenV1_to_TokenV3(tokenv1: TokenV1): return token_serialized -async def deserialize_token_from_string(token: str) -> TokenV3: +def deserialize_token_from_string(token: str) -> TokenV3: # deserialize token # ----- backwards compatibility ----- @@ -86,7 +86,7 @@ async def deserialize_token_from_string(token: str) -> TokenV3: if token.startswith("eyJwcm9"): try: tokenv2 = TokenV2.parse_obj(json.loads(base64.urlsafe_b64decode(token))) - token = await serialize_TokenV2_to_TokenV3(tokenv2) + token = serialize_TokenV2_to_TokenV3(tokenv2) except: pass @@ -94,7 +94,7 @@ async def deserialize_token_from_string(token: str) -> TokenV3: if token.startswith("W3siaWQ"): try: tokenv1 = TokenV1.parse_obj(json.loads(base64.urlsafe_b64decode(token))) - token = await serialize_TokenV1_to_TokenV3(tokenv1) + token = serialize_TokenV1_to_TokenV3(tokenv1) except: pass