Open Wouimbly opened 9 months ago
Hello, can you share your code where you are importing Python modules? thanks
Pretty weird that the first call worked then now i'm getting the error...
Here is my setup:
-windows10
-python version and installation path: C:\Python312
-pip install jupiter-python-sdk
-pip install asyncio
-complete error stack:
C:\Temp\pyjupswapper>python swapper.py
Traceback (most recent call last):
File "C:\Temp\pyjupswapper\swapper.py", line 5, in
command: python swapper.js
content of swapper.js: import base58 import base64 import json
from solders import message from solders.keypair import Keypair from solders.transaction import VersionedTransaction
from solana.rpc.types import TxOpts from solana.rpc.async_api import AsyncClient from solana.rpc.commitment import Processed
from jupiter_python_sdk.jupiter import Jupiter
import asyncio
private_key = Keypair.from_bytes(base58.b58decode("myKEY")) async_client = AsyncClient("myRPC") jupiter = Jupiter(async_client, private_key)
async def swap():
transaction_data = await jupiter.swap(
input_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
output_mint="So11111111111111111111111111111111111111112",
amount=300_000,
slippage_bps=100,
)
raw_transaction = VersionedTransaction.from_bytes(base64.b64decode(transaction_data))
signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message))
signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature])
opts = TxOpts(skip_preflight=False, preflight_commitment=Processed)
result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts)
transaction_id = json.loads(result.to_json())['result']
print(f"Transaction sent: https://explorer.solana.com/tx/{transaction_id}")
if name == "main": asyncio.run(swap())
Hi! just tried your wrapper it seems that there is circular import... ImportError: cannot import name 'TypedDict' from partially initialized module 'typing_extensions' (most likely due to a circular import)
i'm running Python 3.12.2 on win10... thanks