diff --git a/solana-python/launch_cancel_escrow.py b/solana-python/launch_cancel_escrow.py index 3a1a4c6f..500c9946 100644 --- a/solana-python/launch_cancel_escrow.py +++ b/solana-python/launch_cancel_escrow.py @@ -28,9 +28,8 @@ async def main(): keypair_paths = KeypairPaths() - #business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair) - business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_GQRD) - + business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair) + #business, business_pk = get_local_keypair_pubkey() _, influencer_pk = get_local_keypair_pubkey(path=keypair_paths.influencer_keypair) diff --git a/solana-python/launch_create_escrow.py b/solana-python/launch_create_escrow.py index 302fdea9..eebbb836 100644 --- a/solana-python/launch_create_escrow.py +++ b/solana-python/launch_create_escrow.py @@ -1,7 +1,14 @@ -from solders.pubkey import Pubkey from solana.rpc.types import TxOpts -from pyxfluencer.utils import get_local_keypair_pubkey, select_client, sign_and_send_transaction_sync +from pathlib import Path +from solders.pubkey import Pubkey # type: ignore +from anchorpy import Idl, Program + +import asyncio +from solders.system_program import ID as SYS_PROGRAM_ID + + +from pyxfluencer.utils import get_local_keypair_pubkey, select_client from pyxfluencer.utils import sign_and_send_transaction from pyxfluencer.program_id import PROGRAM_ID @@ -21,7 +28,8 @@ async def main(): configuration = load_configuration() - network = configuration["network"] + network = configuration["rpc"]["mainnet"] + print("Network selected: ",network) client = select_client(network=network, async_client=False) @@ -36,11 +44,7 @@ async def main(): #print(validation) # way to get base58 from keypair seed _, validation_authority_pk = get_local_keypair_pubkey(path=keypair_paths.validation_authority) - - #business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair) - business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_GQRD) - - + business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair) _, influencer_pk = get_local_keypair_pubkey(path=keypair_paths.influencer_keypair) assert str(validation_authority_pk) == configuration["platform"] @@ -66,8 +70,8 @@ async def main(): amount = configuration["amount"]["lamports"] order_code = configuration["order_code"] - args = {"amount":int(amount), - "order_code":int(order_code) } + args = {"amount":int(amount), + "order_code":int(order_code)} SEEDS = [b"escrow", bytes(business_pk), @@ -84,20 +88,20 @@ async def main(): "to":influencer_pk } + client = select_client(network=network, async_client=False) + + latest_blockhash = client.get_latest_blockhash().value.last_valid_block_height + + opts = TxOpts(skip_confirmation = False, skip_preflight = False, + max_retries=1, + last_valid_block_height=latest_blockhash, preflight_commitment="processed") - print_tittle("Instruction description") - - - ix = create_escrow(args, accounts, program_id=PROGRAM_ID) - - print(ix) - signers = [business] ## forming the transaction @@ -113,7 +117,6 @@ async def main(): #sign_status = await sign_and_send_transaction(ix, signers, opts, network) #sign_status = sign_and_send_transaction_sync(ix, signers, opts, network) - #print(sign_status) try: print("Network selected: ",network) client = select_client(network=network, async_client=False) @@ -124,7 +127,6 @@ async def main(): #print(simulate_response.value.err) - #exit() print("Start Sending transactions with options", opts) tx_res = client.send_transaction(tx, *signers, opts=opts) @@ -139,8 +141,9 @@ async def main(): return signature_status.to_json() except RPCException as e: raise RPCException(f"RPC exception happened: {e}") + + -import asyncio asyncio.run(main()) diff --git a/solana-python/pyxfluencer/utils.py b/solana-python/pyxfluencer/utils.py index d6bf7177..fb034a85 100644 --- a/solana-python/pyxfluencer/utils.py +++ b/solana-python/pyxfluencer/utils.py @@ -1,15 +1,16 @@ +import os +import json + from solders.keypair import Keypair from solders.pubkey import Pubkey +from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price from solana.rpc.api import Client from solana.rpc.async_api import AsyncClient -import json from solana.transaction import Transaction from solana.rpc.core import RPCException -import os - from anchorpy import Wallet, Provider from anchorpy.utils import token from anchorpy.utils.rpc import AccountInfo @@ -75,12 +76,15 @@ async def get_token_account_info(ata_address: str, network : str) -> AccountInfo except Exception as e: raise Exception(f"Getting Token Account Info {e}") -async def sign_and_send_transaction(ix, signers, opts, network): + +async def sign_and_send_transaction(ix, + signers, opts, network, + async_client: bool = True): try: - print("Network selected: ",network) - client = select_client(network=network, async_client=True) - tx = Transaction().add(ix) + client = select_client(network=network, async_client=async_client) + tx = Transaction().add(ix).add() + print("Start Sending transactions with options", opts) @@ -97,7 +101,6 @@ async def sign_and_send_transaction(ix, signers, opts, network): except RPCException as e: raise RPCException(f"RPC exception happened: {e}") -from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price def sign_and_send_transaction_sync(ix, signers, opts, network): diff --git a/solana-python/requirements.txt b/solana-python/requirements.txt index 9cef5236..9c849c29 100644 --- a/solana-python/requirements.txt +++ b/solana-python/requirements.txt @@ -1,2 +1,2 @@ -anchorpy[cli] == 0.19.1 +anchorpy[cli] == 0.20.0 setuptools == 59.6.0