From 2f36faacba17ffd2578a96db5d82ddd8e3ffa4ec Mon Sep 17 00:00:00 2001 From: truemagic-coder Date: Thu, 4 Dec 2025 09:23:59 -0800 Subject: [PATCH] update --- .coverage | Bin 53248 -> 53248 bytes pyproject.toml | 2 +- sakit/privy_transfer.py | 43 +++++++++++++++++++++++----------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.coverage b/.coverage index faff375266d5fab5419bf4305f5605c164c3a9fa..5ea50819089ab5d2cb7c94fef367f8ae974c7a3e 100644 GIT binary patch delta 132 zcmZozz}&Eac>`O6%@zj!AN-;GQv7UuXZW`9&E<>cbK+Cteaw55w~*JF=NZomo=H44 zJa#-1JS^NVxc6}Pa7S}1a((2w#kFO#pgx d_ut>YJN@6+|0jRm`}f;+|84{3&4s=FP5>`O6%~l5fAN-;GQv7UuXZW`9&E<>cbK+Cteaw55w~*I`=Q+sBhaed;t&9!y2pg=L#<}F?QOuE{9ER38H!v9{gFn|F&h&;du eBJ1|om!JRh`v2t5d;fl~t}9Pu+g#Y&?*sq"] license = "MIT" diff --git a/sakit/privy_transfer.py b/sakit/privy_transfer.py index 0ca72f9..3149305 100644 --- a/sakit/privy_transfer.py +++ b/sakit/privy_transfer.py @@ -80,32 +80,39 @@ async def get_privy_embedded_wallet( # pragma: no cover """ try: user = await privy_client.users.get(user_id) - data = user.model_dump() if hasattr(user, "model_dump") else user.__dict__ + linked_accounts = user.linked_accounts or [] # First, try to find embedded wallet with delegation - for acct in data.get("linked_accounts", []): - if acct.get("connector_type") == "embedded" and acct.get("delegated"): - wallet_id = acct.get("id") - # Use 'address' field if 'public_key' is null (common for API-created wallets) - address = acct.get("address") or acct.get("public_key") + for acct in linked_accounts: + if getattr(acct, "connector_type", None) == "embedded" and getattr( + acct, "delegated", False + ): + wallet_id = getattr(acct, "id", None) + address = getattr(acct, "address", None) or getattr( + acct, "public_key", None + ) if wallet_id and address: return {"wallet_id": wallet_id, "public_key": address} # Then, try to find bot-first wallet (API-created via privy_create_wallet) - # These have type == "wallet" and include chain_type - for acct in data.get("linked_accounts", []): - acct_type = acct.get("type", "") - # Check for Solana embedded wallets created via API - if acct_type == "wallet" and acct.get("chain_type") == "solana": - wallet_id = acct.get("id") - # API wallets use "address" field, SDK wallets use "public_key" - address = acct.get("address") or acct.get("public_key") + for acct in linked_accounts: + acct_type = getattr(acct, "type", "") + if acct_type == "wallet" and getattr(acct, "chain_type", None) == "solana": + wallet_id = getattr(acct, "id", None) + address = getattr(acct, "address", None) or getattr( + acct, "public_key", None + ) if wallet_id and address: return {"wallet_id": wallet_id, "public_key": address} - # Also check for solana_embedded_wallet type - if "solana" in acct_type.lower() and "embedded" in acct_type.lower(): - wallet_id = acct.get("id") - address = acct.get("address") or acct.get("public_key") + if ( + acct_type + and "solana" in acct_type.lower() + and "embedded" in acct_type.lower() + ): + wallet_id = getattr(acct, "id", None) + address = getattr(acct, "address", None) or getattr( + acct, "public_key", None + ) if wallet_id and address: return {"wallet_id": wallet_id, "public_key": address}