diff --git a/crypto/sol/modules/SolanaAPI.py b/crypto/sol/modules/SolanaAPI.py
index 015ef22..97e373a 100644
--- a/crypto/sol/modules/SolanaAPI.py
+++ b/crypto/sol/modules/SolanaAPI.py
@@ -756,7 +756,7 @@ class SolanaAPI:
if self.pk is None:
self.pk = await get_pk()
- for retry in range(3):
+ for retry in range(1):
try:
private_key = Keypair.from_bytes(base58.b58decode(self.pk))
async_client = AsyncClient(SOLANA_WS_URL)
@@ -806,59 +806,59 @@ class SolanaAPI:
# )
# working - no priority fee
- # signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message))
- # signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature])
+ signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message))
+ signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature])
+ # # # # # # # # # # # # # # # # # #
# new - not working
# signature = private_key.sign_message(new_message.to_bytes_versioned())
# signed_txn = VersionedTransaction.populate(new_message, [signature])
- from solders.compute_budget import set_compute_unit_price, ID as COMPUTE_BUDGET_ID
+ # from solders.compute_budget import set_compute_unit_price, ID as COMPUTE_BUDGET_ID
- priority_fee_ix = set_compute_unit_price(priority_fee)
+ # priority_fee_ix = set_compute_unit_price(priority_fee)
+
+ # # Get the current message
+ # msg = raw_transaction.message
+
+ # new_account_keys = msg.account_keys
+ # program_id_index = 0
+ # if COMPUTE_BUDGET_ID not in msg.account_keys:
+ # new_account_keys = msg.account_keys + [COMPUTE_BUDGET_ID]
+ # program_id_index = len(msg.account_keys) # Index of the newly added program ID
+ # else:
+ # new_account_keys = msg.account_keys
+ # program_id_index = msg.account_keys.index(COMPUTE_BUDGET_ID)
+
+ # # Compile the priority fee instruction
+ # compiled_priority_fee_ix = CompiledInstruction(
+ # program_id_index=program_id_index,
+ # accounts=bytes([]),
+ # data=priority_fee_ix.data
+ # )
+
+ # # Add priority fee instruction at the beginning
+ # new_instructions = [compiled_priority_fee_ix] + msg.instructions
+
+ # # Create new message with updated instructions
+ # new_message = Message.new_with_compiled_instructions(
+ # num_required_signatures=msg.header.num_required_signatures,
+ # num_readonly_signed_accounts=msg.header.num_readonly_signed_accounts,
+ # num_readonly_unsigned_accounts=msg.header.num_readonly_unsigned_accounts,
+ # account_keys=new_account_keys,
+ # recent_blockhash=msg.recent_blockhash,
+ # instructions=new_instructions
+ # )
+
+ # signature = private_key.sign_message(message.to_bytes_versioned(new_message))
+ # signed_txn = VersionedTransaction.populate(new_message, [signature])
+ # # # # # # # # # # # # # # # # # #
- # Get the current message
- msg = raw_transaction.message
-
- new_account_keys = msg.account_keys
- program_id_index = 0
- if COMPUTE_BUDGET_ID not in msg.account_keys:
- new_account_keys = msg.account_keys + [COMPUTE_BUDGET_ID]
- program_id_index = len(msg.account_keys) # Index of the newly added program ID
- else:
- new_account_keys = msg.account_keys
- program_id_index = msg.account_keys.index(COMPUTE_BUDGET_ID)
-
- # Compile the priority fee instruction
- compiled_priority_fee_ix = CompiledInstruction(
- program_id_index=program_id_index,
- accounts=bytes([]),
- data=priority_fee_ix.data
- )
-
- # Add priority fee instruction at the beginning
- new_instructions = [compiled_priority_fee_ix] + msg.instructions
-
- # Create new message with updated instructions
- new_message = Message.new_with_compiled_instructions(
- num_required_signatures=msg.header.num_required_signatures,
- num_readonly_signed_accounts=msg.header.num_readonly_signed_accounts,
- num_readonly_unsigned_accounts=msg.header.num_readonly_unsigned_accounts,
- account_keys=new_account_keys,
- recent_blockhash=msg.recent_blockhash,
- instructions=new_instructions
- )
-
- #signature = private_key.sign_message(new_message.to_bytes_versioned())
- signature = private_key.sign_message(message.to_bytes_versioned(new_message))
- signed_txn = VersionedTransaction.populate(new_message, [signature])
-
opts = TxOpts(
skip_preflight=False,
preflight_commitment=Processed,
- # max_retries=10,
- # priority_fee =fee.value
)
+
# send the transaction
- result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts )
+ result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts)
transaction_id = json.loads(result.to_json())['result']
notification = f"Follow Transaction Sent:\nTransaction: swapping {amount_to_swap:.2f} {token_name_in}"