From 8e88d85a850b52147d52059591967fd3d5699b53 Mon Sep 17 00:00:00 2001 From: truemagic-coder Date: Thu, 4 Dec 2025 12:17:34 -0800 Subject: [PATCH 1/2] update --- pyproject.toml | 2 +- sakit/privy_trigger.py | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b672a4e..f5ce57b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "sakit" -version = "14.1.10" +version = "14.1.11" description = "Solana Agent Kit" authors = ["Bevan Hunt "] license = "MIT" diff --git a/sakit/privy_trigger.py b/sakit/privy_trigger.py index 93039f5..e6218c5 100644 --- a/sakit/privy_trigger.py +++ b/sakit/privy_trigger.py @@ -389,12 +389,36 @@ async def _sign_and_execute( # pragma: no cover message_bytes = to_bytes_versioned(transaction.message) payer_signature = payer_keypair.sign_message(message_bytes) - # Create partially signed transaction - partially_signed = VersionedTransaction.populate( - transaction.message, - [payer_signature, transaction.signatures[1]], - ) - tx_to_sign = base64.b64encode(bytes(partially_signed)).decode("utf-8") + # Find the payer's position in the account keys + # The first N accounts (where N = num_required_signatures) are signers + payer_pubkey = payer_keypair.pubkey() + num_signers = transaction.message.header.num_required_signatures + account_keys = transaction.message.account_keys + + payer_index = None + for i in range(num_signers): + if account_keys[i] == payer_pubkey: + payer_index = i + break + + if payer_index is None: + logger.warning( + f"Payer pubkey {payer_pubkey} not found in signers. " + f"Signers: {[str(account_keys[i]) for i in range(num_signers)]}" + ) + # Payer not in transaction - this might be a non-gasless transaction + # Just pass through to Privy signing + else: + # Create signature list with payer signature in correct position + new_signatures = list(transaction.signatures) + new_signatures[payer_index] = payer_signature + logger.info(f"Payer signed at index {payer_index}") + + partially_signed = VersionedTransaction.populate( + transaction.message, + new_signatures, + ) + tx_to_sign = base64.b64encode(bytes(partially_signed)).decode("utf-8") # Step 4: Sign with Privy using the official SDK signed_tx = await _privy_sign_transaction( From 94c8411feb6cb840d3889931b448af9fdec7c61e Mon Sep 17 00:00:00 2001 From: truemagic-coder Date: Thu, 4 Dec 2025 12:20:05 -0800 Subject: [PATCH 2/2] update --- sakit/privy_trigger.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sakit/privy_trigger.py b/sakit/privy_trigger.py index e6218c5..2e613f2 100644 --- a/sakit/privy_trigger.py +++ b/sakit/privy_trigger.py @@ -418,7 +418,9 @@ async def _sign_and_execute( # pragma: no cover transaction.message, new_signatures, ) - tx_to_sign = base64.b64encode(bytes(partially_signed)).decode("utf-8") + tx_to_sign = base64.b64encode(bytes(partially_signed)).decode( + "utf-8" + ) # Step 4: Sign with Privy using the official SDK signed_tx = await _privy_sign_transaction(