mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 18:44:20 +01:00
no async for deserialization functions (#255)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user