Skip to content

Commit bd449f6

Browse files
v14.1.11 (#42)
1 parent 2220568 commit bd449f6

File tree

2 files changed

+33
-7
lines changed

2 files changed

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

sakit/privy_trigger.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,38 @@ async def _sign_and_execute( # pragma: no cover
389389
message_bytes = to_bytes_versioned(transaction.message)
390390
payer_signature = payer_keypair.sign_message(message_bytes)
391391

392-
# Create partially signed transaction
393-
partially_signed = VersionedTransaction.populate(
394-
transaction.message,
395-
[payer_signature, transaction.signatures[1]],
396-
)
397-
tx_to_sign = base64.b64encode(bytes(partially_signed)).decode("utf-8")
392+
# Find the payer's position in the account keys
393+
# The first N accounts (where N = num_required_signatures) are signers
394+
payer_pubkey = payer_keypair.pubkey()
395+
num_signers = transaction.message.header.num_required_signatures
396+
account_keys = transaction.message.account_keys
397+
398+
payer_index = None
399+
for i in range(num_signers):
400+
if account_keys[i] == payer_pubkey:
401+
payer_index = i
402+
break
403+
404+
if payer_index is None:
405+
logger.warning(
406+
f"Payer pubkey {payer_pubkey} not found in signers. "
407+
f"Signers: {[str(account_keys[i]) for i in range(num_signers)]}"
408+
)
409+
# Payer not in transaction - this might be a non-gasless transaction
410+
# Just pass through to Privy signing
411+
else:
412+
# Create signature list with payer signature in correct position
413+
new_signatures = list(transaction.signatures)
414+
new_signatures[payer_index] = payer_signature
415+
logger.info(f"Payer signed at index {payer_index}")
416+
417+
partially_signed = VersionedTransaction.populate(
418+
transaction.message,
419+
new_signatures,
420+
)
421+
tx_to_sign = base64.b64encode(bytes(partially_signed)).decode(
422+
"utf-8"
423+
)
398424

399425
# Step 4: Sign with Privy using the official SDK
400426
signed_tx = await _privy_sign_transaction(

0 commit comments

Comments
 (0)