Skip to content

Commit 291a3cb

Browse files
v14.1.8 (#39)
1 parent 742e79d commit 291a3cb

File tree

5 files changed

+48
-8
lines changed

5 files changed

+48
-8
lines changed

.coverage

0 Bytes
Binary file not shown.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ config = {
327327
"app_secret": "your-privy-app-secret", # Required - your Privy application secret
328328
"signing_key": "wallet-auth:your-signing-key", # Required - your Privy wallet authorization signing key
329329
"jupiter_api_key": "my-jupiter-api-key", # Required - get free key at portal.jup.ag
330+
"rpc_url": "https://mainnet.helius-rpc.com/?api-key=YOUR_KEY", # Recommended - Helius RPC for reliable tx sending
330331
"referral_account": "my-referral-account", # Optional - for collecting fees
331332
"referral_fee": 50, # Optional - fee in basis points (50-255 bps)
332333
"payer_private_key": "payer-private-key", # Optional - for gasless transactions
@@ -335,6 +336,9 @@ config = {
335336
}
336337
```
337338

339+
**RPC URL (Recommended):**
340+
If configured, transactions are sent directly via RPC instead of Jupiter's execute endpoint, which can timeout. Helius RPC is recommended for reliable transaction landing.
341+
338342
**Actions:** Same as Jupiter Trigger (create, cancel, cancel_all, list)
339343

340344
### Privy Recurring

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 = "14.1.7"
3+
version = "14.1.8"
44
description = "Solana Agent Kit"
55
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
66
license = "MIT"

sakit/privy_trigger.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from solders.message import to_bytes_versioned # type: ignore
2020

2121
from sakit.utils.trigger import JupiterTrigger
22+
from sakit.utils.wallet import send_raw_transaction_with_priority
2223

2324
logger = logging.getLogger(__name__)
2425

@@ -192,6 +193,7 @@ def __init__(self, registry: Optional[ToolRegistry] = None):
192193
self._referral_account: Optional[str] = None
193194
self._referral_fee: Optional[int] = None
194195
self._payer_private_key: Optional[str] = None
196+
self._rpc_url: Optional[str] = None
195197

196198
def get_schema(self) -> Dict[str, Any]:
197199
return {
@@ -265,6 +267,7 @@ def configure(self, config: Dict[str, Any]) -> None:
265267
self._referral_account = tool_cfg.get("referral_account")
266268
self._referral_fee = tool_cfg.get("referral_fee")
267269
self._payer_private_key = tool_cfg.get("payer_private_key")
270+
self._rpc_url = tool_cfg.get("rpc_url")
268271

269272
async def execute(
270273
self,
@@ -372,13 +375,28 @@ async def _sign_and_execute( # pragma: no cover
372375
"message": "Failed to sign transaction via Privy.",
373376
}
374377

375-
# Execute
376-
exec_result = await trigger.execute(signed_tx, request_id)
377-
378-
if not exec_result.success:
379-
return {"status": "error", "message": exec_result.error}
380-
381-
return {"status": "success", "signature": exec_result.signature}
378+
# Send via RPC or fallback to Jupiter execute
379+
if self._rpc_url:
380+
# Use configured RPC (Helius recommended) instead of Jupiter's execute endpoint
381+
tx_bytes = base64.b64decode(signed_tx)
382+
send_result = await send_raw_transaction_with_priority(
383+
rpc_url=self._rpc_url,
384+
tx_bytes=tx_bytes,
385+
)
386+
if not send_result.get("success"):
387+
return {
388+
"status": "error",
389+
"message": send_result.get(
390+
"error", "Failed to send transaction"
391+
),
392+
}
393+
return {"status": "success", "signature": send_result.get("signature")}
394+
else:
395+
# Fallback to Jupiter execute if no RPC configured
396+
exec_result = await trigger.execute(signed_tx, request_id)
397+
if not exec_result.success:
398+
return {"status": "error", "message": exec_result.error}
399+
return {"status": "success", "signature": exec_result.signature}
382400

383401
except Exception as e:
384402
logger.exception(f"Failed to sign and execute: {str(e)}")

tests/test_privy_trigger_tool.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,24 @@ def test_configure_stores_optional_config(self, privy_trigger_tool_with_payer):
318318
assert privy_trigger_tool_with_payer._referral_account == "RefAcct123"
319319
assert privy_trigger_tool_with_payer._referral_fee == 50
320320

321+
def test_configure_stores_rpc_url(self):
322+
"""Should store RPC URL from config for direct transaction sending."""
323+
tool = PrivyTriggerTool()
324+
tool.configure(
325+
{
326+
"tools": {
327+
"privy_trigger": {
328+
"app_id": "test-app-id",
329+
"app_secret": "test-app-secret",
330+
"signing_key": f"wallet-auth:{TEST_EC_KEY_SEC1}",
331+
"jupiter_api_key": "test-api-key",
332+
"rpc_url": "https://mainnet.helius-rpc.com/?api-key=test",
333+
}
334+
}
335+
}
336+
)
337+
assert tool._rpc_url == "https://mainnet.helius-rpc.com/?api-key=test"
338+
321339
def test_configure_with_empty_config(self):
322340
"""Should handle empty config gracefully."""
323341
tool = PrivyTriggerTool()

0 commit comments

Comments
 (0)