Skip to content

Commit 5752fb9

Browse files
v13.3.2 (#21)
1 parent 7e3b639 commit 5752fb9

File tree

6 files changed

+60
-13
lines changed

6 files changed

+60
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sakit"
3-
version = "13.3.1"
3+
version = "13.3.2"
44
description = "Solana Agent Kit"
55
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
66
license = "MIT"

sakit/privy_recurring.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ async def _get_privy_embedded_wallet(
7070
return None
7171
data = resp.json()
7272

73-
# First, try to find app-first embedded wallet (SDK-created)
73+
# First, try to find embedded wallet with delegation
7474
for acct in data.get("linked_accounts", []):
7575
if acct.get("connector_type") == "embedded" and acct.get("delegated"):
76-
return {"wallet_id": acct["id"], "public_key": acct["public_key"]}
76+
wallet_id = acct.get("id")
77+
# Use 'address' field if 'public_key' is null (common for API-created wallets)
78+
address = acct.get("address") or acct.get("public_key")
79+
if wallet_id and address:
80+
return {"wallet_id": wallet_id, "public_key": address}
7781

7882
# Then, try to find bot-first wallet (API-created via privy_create_wallet)
7983
for acct in data.get("linked_accounts", []):

sakit/privy_transfer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ async def get_privy_embedded_wallet(
5959
resp.raise_for_status()
6060
data = resp.json()
6161

62-
# First, try to find app-first embedded wallet (SDK-created)
62+
# First, try to find embedded wallet with delegation
6363
for acct in data.get("linked_accounts", []):
6464
if acct.get("connector_type") == "embedded" and acct.get("delegated"):
65-
return {"wallet_id": acct["id"], "public_key": acct["public_key"]}
65+
wallet_id = acct.get("id")
66+
# Use 'address' field if 'public_key' is null (common for API-created wallets)
67+
address = acct.get("address") or acct.get("public_key")
68+
if wallet_id and address:
69+
return {"wallet_id": wallet_id, "public_key": address}
6670

6771
# Then, try to find bot-first wallet (API-created via privy_create_wallet)
6872
# These have type == "wallet" and include chain_type

sakit/privy_trigger.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ async def _get_privy_embedded_wallet(
7070
return None
7171
data = resp.json()
7272

73-
# First, try to find app-first embedded wallet (SDK-created)
73+
# First, try to find embedded wallet with delegation
7474
for acct in data.get("linked_accounts", []):
7575
if acct.get("connector_type") == "embedded" and acct.get("delegated"):
76-
return {"wallet_id": acct["id"], "public_key": acct["public_key"]}
76+
wallet_id = acct.get("id")
77+
# Use 'address' field if 'public_key' is null (common for API-created wallets)
78+
address = acct.get("address") or acct.get("public_key")
79+
if wallet_id and address:
80+
return {"wallet_id": wallet_id, "public_key": address}
7781

7882
# Then, try to find bot-first wallet (API-created via privy_create_wallet)
7983
for acct in data.get("linked_accounts", []):

sakit/privy_ultra.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,61 @@ async def get_privy_embedded_wallet(
6969
resp.raise_for_status()
7070
data = resp.json()
7171

72-
# First, try to find app-first embedded wallet (SDK-created)
73-
for acct in data.get("linked_accounts", []):
72+
linked_accounts = data.get("linked_accounts", [])
73+
logger.info(f"Privy user {user_id} has {len(linked_accounts)} linked accounts")
74+
75+
# Log all account types for debugging
76+
for i, acct in enumerate(linked_accounts):
77+
acct_type = acct.get("type", "unknown")
78+
connector_type = acct.get("connector_type", "none")
79+
chain_type = acct.get("chain_type", "none")
80+
delegated = acct.get("delegated", False)
81+
has_id = "id" in acct
82+
has_address = "address" in acct
83+
has_public_key = "public_key" in acct
84+
logger.info(
85+
f" Account {i}: type={acct_type}, connector_type={connector_type}, "
86+
f"chain_type={chain_type}, delegated={delegated}, "
87+
f"has_id={has_id}, has_address={has_address}, has_public_key={has_public_key}"
88+
)
89+
90+
# First, try to find embedded wallet with delegation
91+
for acct in linked_accounts:
7492
if acct.get("connector_type") == "embedded" and acct.get("delegated"):
75-
return {"wallet_id": acct["id"], "public_key": acct["public_key"]}
93+
wallet_id = acct.get("id")
94+
# Use 'address' field if 'public_key' is null (common for API-created wallets)
95+
address = acct.get("address") or acct.get("public_key")
96+
if wallet_id and address:
97+
logger.info(
98+
f"Found embedded delegated wallet: {wallet_id}, address: {address}"
99+
)
100+
return {"wallet_id": wallet_id, "public_key": address}
76101

77102
# Then, try to find bot-first wallet (API-created via privy_create_wallet)
78103
# These have type == "wallet" and include chain_type
79-
for acct in data.get("linked_accounts", []):
104+
for acct in linked_accounts:
80105
acct_type = acct.get("type", "")
81106
# Check for Solana embedded wallets created via API
82107
if acct_type == "wallet" and acct.get("chain_type") == "solana":
83108
wallet_id = acct.get("id")
84109
# API wallets use "address" field, SDK wallets use "public_key"
85110
address = acct.get("address") or acct.get("public_key")
86111
if wallet_id and address:
112+
logger.info(
113+
f"Found bot-first wallet: {wallet_id}, address: {address}"
114+
)
87115
return {"wallet_id": wallet_id, "public_key": address}
88116
# Also check for solana_embedded_wallet type
89117
if "solana" in acct_type.lower() and "embedded" in acct_type.lower():
90118
wallet_id = acct.get("id")
91119
address = acct.get("address") or acct.get("public_key")
92120
if wallet_id and address:
121+
logger.info(
122+
f"Found solana_embedded_wallet: {wallet_id}, address: {address}"
123+
)
93124
return {"wallet_id": wallet_id, "public_key": address}
94125

126+
logger.warning(f"No suitable wallet found for user {user_id}")
95127
return None
96128

97129

sakit/privy_wallet_address.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ async def get_privy_embedded_wallet_address(
2020
resp.raise_for_status()
2121
data = resp.json()
2222

23-
# First, try to find app-first embedded wallet (SDK-created)
23+
# First, try to find embedded wallet with delegation
2424
for acct in data.get("linked_accounts", []):
2525
if acct.get("connector_type") == "embedded" and acct.get("delegated"):
26-
return acct["public_key"]
26+
# Use 'address' field if 'public_key' is null (common for API-created wallets)
27+
address = acct.get("address") or acct.get("public_key")
28+
if address:
29+
return address
2730

2831
# Then, try to find bot-first wallet (API-created via privy_create_wallet)
2932
for acct in data.get("linked_accounts", []):

0 commit comments

Comments
 (0)