Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sakit"
version = "14.1.6"
version = "14.1.7"
description = "Solana Agent Kit"
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
license = "MIT"
Expand Down
43 changes: 25 additions & 18 deletions sakit/privy_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down