From 193040cda51069326066ea055633358706304355 Mon Sep 17 00:00:00 2001 From: truemagic-coder Date: Thu, 4 Dec 2025 10:57:25 -0800 Subject: [PATCH] update --- .coverage | Bin 53248 -> 53248 bytes README.md | 4 ++++ pyproject.toml | 2 +- sakit/privy_trigger.py | 32 ++++++++++++++++++++++++------- tests/test_privy_trigger_tool.py | 18 +++++++++++++++++ 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/.coverage b/.coverage index 5ea50819089ab5d2cb7c94fef367f8ae974c7a3e..3e8b8166c2e5aa21f2dc08311f05335ca760c47d 100644 GIT binary patch delta 119 zcmV--0Eqv9paX!Q1F!~w0kV?^fF2#>45kc_40;Sa3>FLm3+4;D3yKR_3m*#a3fKy= zvk?$*3bV9|G6FhX4+Q}UfjSie?{6v3Jb)PhU=Ey{`Rr!TuY7)fo?YnQ-v#fz_nrXq ZfBm1+XZydqo%&4x;1dV{EVCYs;zHxUFkk=x delta 117 zcmV-*0E+*BpaX!Q1F!~w0ko3`fF2#@45$o}415ee3>XXq3+M~H3ycd}3n2>e3fc;^ zvk?$-3bV3`G6FbT4+Q}Ufi@Ka@2`|+9>5F$FbB@fe0H"] license = "MIT" diff --git a/sakit/privy_trigger.py b/sakit/privy_trigger.py index dbf5496..71418eb 100644 --- a/sakit/privy_trigger.py +++ b/sakit/privy_trigger.py @@ -19,6 +19,7 @@ from solders.message import to_bytes_versioned # type: ignore from sakit.utils.trigger import JupiterTrigger +from sakit.utils.wallet import send_raw_transaction_with_priority logger = logging.getLogger(__name__) @@ -192,6 +193,7 @@ def __init__(self, registry: Optional[ToolRegistry] = None): self._referral_account: Optional[str] = None self._referral_fee: Optional[int] = None self._payer_private_key: Optional[str] = None + self._rpc_url: Optional[str] = None def get_schema(self) -> Dict[str, Any]: return { @@ -265,6 +267,7 @@ def configure(self, config: Dict[str, Any]) -> None: self._referral_account = tool_cfg.get("referral_account") self._referral_fee = tool_cfg.get("referral_fee") self._payer_private_key = tool_cfg.get("payer_private_key") + self._rpc_url = tool_cfg.get("rpc_url") async def execute( self, @@ -372,13 +375,28 @@ async def _sign_and_execute( # pragma: no cover "message": "Failed to sign transaction via Privy.", } - # Execute - exec_result = await trigger.execute(signed_tx, request_id) - - if not exec_result.success: - return {"status": "error", "message": exec_result.error} - - return {"status": "success", "signature": exec_result.signature} + # Send via RPC or fallback to Jupiter execute + if self._rpc_url: + # Use configured RPC (Helius recommended) instead of Jupiter's execute endpoint + tx_bytes = base64.b64decode(signed_tx) + send_result = await send_raw_transaction_with_priority( + rpc_url=self._rpc_url, + tx_bytes=tx_bytes, + ) + if not send_result.get("success"): + return { + "status": "error", + "message": send_result.get( + "error", "Failed to send transaction" + ), + } + return {"status": "success", "signature": send_result.get("signature")} + else: + # Fallback to Jupiter execute if no RPC configured + exec_result = await trigger.execute(signed_tx, request_id) + if not exec_result.success: + return {"status": "error", "message": exec_result.error} + return {"status": "success", "signature": exec_result.signature} except Exception as e: logger.exception(f"Failed to sign and execute: {str(e)}") diff --git a/tests/test_privy_trigger_tool.py b/tests/test_privy_trigger_tool.py index b28a5c6..daeafa0 100644 --- a/tests/test_privy_trigger_tool.py +++ b/tests/test_privy_trigger_tool.py @@ -318,6 +318,24 @@ def test_configure_stores_optional_config(self, privy_trigger_tool_with_payer): assert privy_trigger_tool_with_payer._referral_account == "RefAcct123" assert privy_trigger_tool_with_payer._referral_fee == 50 + def test_configure_stores_rpc_url(self): + """Should store RPC URL from config for direct transaction sending.""" + tool = PrivyTriggerTool() + tool.configure( + { + "tools": { + "privy_trigger": { + "app_id": "test-app-id", + "app_secret": "test-app-secret", + "signing_key": f"wallet-auth:{TEST_EC_KEY_SEC1}", + "jupiter_api_key": "test-api-key", + "rpc_url": "https://mainnet.helius-rpc.com/?api-key=test", + } + } + } + ) + assert tool._rpc_url == "https://mainnet.helius-rpc.com/?api-key=test" + def test_configure_with_empty_config(self): """Should handle empty config gracefully.""" tool = PrivyTriggerTool()