Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sakit"
version = "14.1.10"
version = "14.1.11"
description = "Solana Agent Kit"
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
license = "MIT"
Expand Down
38 changes: 32 additions & 6 deletions sakit/privy_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,38 @@ 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(
Expand Down