Skip to content

Commit 02c48fb

Browse files
committed
bump version of anchor py
minor configuration changes
1 parent 7f3fe5f commit 02c48fb

4 files changed

Lines changed: 37 additions & 32 deletions

File tree

solana-python/launch_cancel_escrow.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ async def main():
2828

2929
keypair_paths = KeypairPaths()
3030

31-
#business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair)
32-
business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_GQRD)
33-
31+
business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair)
32+
#business, business_pk = get_local_keypair_pubkey()
3433

3534
_, influencer_pk = get_local_keypair_pubkey(path=keypair_paths.influencer_keypair)
3635

solana-python/launch_create_escrow.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
from solders.pubkey import Pubkey
21
from solana.rpc.types import TxOpts
32

4-
from pyxfluencer.utils import get_local_keypair_pubkey, select_client, sign_and_send_transaction_sync
3+
from pathlib import Path
4+
from solders.pubkey import Pubkey # type: ignore
5+
from anchorpy import Idl, Program
6+
7+
import asyncio
8+
from solders.system_program import ID as SYS_PROGRAM_ID
9+
10+
11+
from pyxfluencer.utils import get_local_keypair_pubkey, select_client
512
from pyxfluencer.utils import sign_and_send_transaction
613
from pyxfluencer.program_id import PROGRAM_ID
714

@@ -21,7 +28,8 @@ async def main():
2128

2229
configuration = load_configuration()
2330

24-
network = configuration["network"]
31+
network = configuration["rpc"]["mainnet"]
32+
2533

2634
print("Network selected: ",network)
2735
client = select_client(network=network, async_client=False)
@@ -36,11 +44,7 @@ async def main():
3644
#print(validation) # way to get base58 from keypair seed
3745

3846
_, validation_authority_pk = get_local_keypair_pubkey(path=keypair_paths.validation_authority)
39-
40-
#business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair)
41-
business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_GQRD)
42-
43-
47+
business, business_pk = get_local_keypair_pubkey(path=keypair_paths.bussines_keypair)
4448
_, influencer_pk = get_local_keypair_pubkey(path=keypair_paths.influencer_keypair)
4549

4650
assert str(validation_authority_pk) == configuration["platform"]
@@ -66,8 +70,8 @@ async def main():
6670
amount = configuration["amount"]["lamports"]
6771
order_code = configuration["order_code"]
6872

69-
args = {"amount":int(amount),
70-
"order_code":int(order_code) }
73+
args = {"amount":int(amount),
74+
"order_code":int(order_code)}
7175

7276
SEEDS = [b"escrow",
7377
bytes(business_pk),
@@ -84,20 +88,20 @@ async def main():
8488
"to":influencer_pk
8589
}
8690

91+
client = select_client(network=network, async_client=False)
92+
93+
latest_blockhash = client.get_latest_blockhash().value.last_valid_block_height
94+
95+
8796
opts = TxOpts(skip_confirmation = False,
8897
skip_preflight = False,
98+
max_retries=1,
99+
last_valid_block_height=latest_blockhash,
89100
preflight_commitment="processed")
90101

91-
92102
print_tittle("Instruction description")
93103

94-
95-
96-
97104
ix = create_escrow(args, accounts, program_id=PROGRAM_ID)
98-
99-
print(ix)
100-
101105
signers = [business]
102106

103107
## forming the transaction
@@ -113,7 +117,6 @@ async def main():
113117
#sign_status = await sign_and_send_transaction(ix, signers, opts, network)
114118
#sign_status = sign_and_send_transaction_sync(ix, signers, opts, network)
115119

116-
#print(sign_status)
117120
try:
118121
print("Network selected: ",network)
119122
client = select_client(network=network, async_client=False)
@@ -124,7 +127,6 @@ async def main():
124127

125128
#print(simulate_response.value.err)
126129

127-
#exit()
128130
print("Start Sending transactions with options", opts)
129131

130132
tx_res = client.send_transaction(tx, *signers, opts=opts)
@@ -139,8 +141,9 @@ async def main():
139141
return signature_status.to_json()
140142
except RPCException as e:
141143
raise RPCException(f"RPC exception happened: {e}")
144+
145+
142146

143-
import asyncio
144147

145148
asyncio.run(main())
146149

solana-python/pyxfluencer/utils.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import os
2+
import json
3+
14
from solders.keypair import Keypair
25
from solders.pubkey import Pubkey
6+
from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price
37

48
from solana.rpc.api import Client
59
from solana.rpc.async_api import AsyncClient
6-
import json
710

811
from solana.transaction import Transaction
912
from solana.rpc.core import RPCException
1013

11-
import os
12-
1314
from anchorpy import Wallet, Provider
1415
from anchorpy.utils import token
1516
from anchorpy.utils.rpc import AccountInfo
@@ -75,12 +76,15 @@ async def get_token_account_info(ata_address: str, network : str) -> AccountInfo
7576
except Exception as e:
7677
raise Exception(f"Getting Token Account Info {e}")
7778

78-
async def sign_and_send_transaction(ix, signers, opts, network):
79+
80+
async def sign_and_send_transaction(ix,
81+
signers, opts, network,
82+
async_client: bool = True):
7983

8084
try:
81-
print("Network selected: ",network)
82-
client = select_client(network=network, async_client=True)
83-
tx = Transaction().add(ix)
85+
client = select_client(network=network, async_client=async_client)
86+
tx = Transaction().add(ix).add()
87+
8488

8589
print("Start Sending transactions with options", opts)
8690

@@ -97,7 +101,6 @@ async def sign_and_send_transaction(ix, signers, opts, network):
97101
except RPCException as e:
98102
raise RPCException(f"RPC exception happened: {e}")
99103

100-
from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price
101104

102105
def sign_and_send_transaction_sync(ix, signers, opts, network):
103106

solana-python/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
anchorpy[cli] == 0.19.1
1+
anchorpy[cli] == 0.20.0
22
setuptools == 59.6.0

0 commit comments

Comments
 (0)