shadowPaySDK 0.2.0.26__py3-none-any.whl → 0.2.0.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shadowPaySDK/types/SOLcheque.py +49 -22
- {shadowpaysdk-0.2.0.26.dist-info → shadowpaysdk-0.2.0.27.dist-info}/METADATA +1 -1
- {shadowpaysdk-0.2.0.26.dist-info → shadowpaysdk-0.2.0.27.dist-info}/RECORD +6 -6
- {shadowpaysdk-0.2.0.26.dist-info → shadowpaysdk-0.2.0.27.dist-info}/WHEEL +0 -0
- {shadowpaysdk-0.2.0.26.dist-info → shadowpaysdk-0.2.0.27.dist-info}/licenses/LICENSE +0 -0
- {shadowpaysdk-0.2.0.26.dist-info → shadowpaysdk-0.2.0.27.dist-info}/top_level.txt +0 -0
shadowPaySDK/types/SOLcheque.py
CHANGED
@@ -7,7 +7,6 @@ import solders
|
|
7
7
|
import spl.token.constants as spl_constants
|
8
8
|
from solana.rpc.api import Client
|
9
9
|
|
10
|
-
from types import Optional, Union
|
11
10
|
import asyncio
|
12
11
|
import solana
|
13
12
|
from solana.rpc.async_api import AsyncClient, GetTokenAccountsByOwnerResp
|
@@ -42,7 +41,6 @@ from solana.rpc.commitment import Confirmed
|
|
42
41
|
from solana.rpc.async_api import AsyncClient
|
43
42
|
import anchorpy
|
44
43
|
from anchorpy import Provider, Wallet, Idl
|
45
|
-
from typing import Optional, Union
|
46
44
|
import pprint
|
47
45
|
import httpx
|
48
46
|
import base64
|
@@ -50,6 +48,8 @@ import re
|
|
50
48
|
import struct
|
51
49
|
from shadowPaySDK.const import LAMPORTS_PER_SOL
|
52
50
|
|
51
|
+
PROGRAM_ID = Pubkey.from_string("5nfYDCgBgm72XdpYFEtWX2X1JQSyZdeBH2uuBZ6ZvQfi")
|
52
|
+
|
53
53
|
|
54
54
|
# PROGRAM_ID = "5nfYDCgBgm72XdpYFEtWX2X1JQSyZdeBH2uuBZ6ZvQfi"
|
55
55
|
|
@@ -64,33 +64,34 @@ class SOLCheque:
|
|
64
64
|
pubkey = SOL.get_pubkey(KEYPAIR=solders.keypair.Keypair.from_base58_string(self.keystore))
|
65
65
|
|
66
66
|
return pubkey
|
67
|
-
def set_params(self, rpc_url
|
67
|
+
def set_params(self, rpc_url = None, key = None):
|
68
68
|
if rpc_url:
|
69
69
|
self.rpc_url = rpc_url
|
70
70
|
self.provider = Client(rpc_url)
|
71
71
|
if key:
|
72
72
|
self.key = key
|
73
73
|
|
74
|
-
def init_cheque(self, cheque_amount, recipient: str,
|
74
|
+
def init_cheque(self, cheque_amount, recipient: str, SPACE: int = 100):
|
75
75
|
"""
|
76
76
|
Initialize a cheque withc the specified amount and recipient.
|
77
77
|
"""
|
78
78
|
if not self.key:
|
79
79
|
raise ValueError("Keypair is not set. Please set the keypair before initializing a cheque.")
|
80
|
-
|
81
|
-
|
82
|
-
CHEQUE_SPACE = 100
|
80
|
+
CHEQUE_PDA_SIGNATURE = None
|
81
|
+
CHEQUE_SPACE = SPACE
|
83
82
|
CHEQUE_RENT = self.provider.get_minimum_balance_for_rent_exemption(CHEQUE_SPACE)
|
84
|
-
print("Minimum balance for rent exemption:", CHEQUE_RENT.value)
|
85
|
-
sol = SOL(
|
83
|
+
print("Minimum balance for rent exemption:", CHEQUE_RENT.value / LAMPORTS_PER_SOL, "SOL")
|
84
|
+
sol = SOL(
|
85
|
+
KEYPAIR=self.key
|
86
|
+
)
|
86
87
|
payer = self.key
|
87
|
-
pubkey = self.key.pubkey
|
88
|
-
|
89
|
-
|
88
|
+
pubkey = self.key.pubkey()
|
89
|
+
newAcc = solders.keypair.Keypair()
|
90
|
+
newAccPubkey = newAcc.pubkey()
|
90
91
|
ix_create = create_account(
|
91
92
|
params=CreateAccountParams(
|
92
93
|
from_pubkey=pubkey,
|
93
|
-
to_pubkey=
|
94
|
+
to_pubkey=newAccPubkey,
|
94
95
|
lamports=CHEQUE_RENT.value,
|
95
96
|
space=CHEQUE_SPACE,
|
96
97
|
owner=PROGRAM_ID
|
@@ -99,16 +100,13 @@ class SOLCheque:
|
|
99
100
|
recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
|
100
101
|
message = Message(instructions=[ix_create], payer=pubkey)
|
101
102
|
|
102
|
-
t = Transaction(message=message, from_keypairs=[payer,
|
103
|
-
r = self.provider.send_transaction(t,opts=TxOpts(
|
104
|
-
|
105
|
-
CHEQUE_PDA =
|
103
|
+
t = Transaction(message=message, from_keypairs=[payer, newAcc], recent_blockhash=recent_blockhash)
|
104
|
+
r = self.provider.send_transaction(t,opts=TxOpts())
|
105
|
+
CHEQUE_PDA_SIGNATURE = r.value
|
106
|
+
CHEQUE_PDA = newAccPubkey
|
106
107
|
|
107
|
-
# === Автор ===
|
108
108
|
|
109
|
-
# === Получатели ===
|
110
109
|
|
111
|
-
# === Сумма ===
|
112
110
|
total_lamports = int(cheque_amount * LAMPORTS_PER_SOL)
|
113
111
|
|
114
112
|
|
@@ -133,12 +131,41 @@ class SOLCheque:
|
|
133
131
|
]
|
134
132
|
)
|
135
133
|
|
136
|
-
# === Отправка транзакции ===
|
137
134
|
recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
|
138
135
|
message = Message(instructions=[instruction], payer=pubkey)
|
139
136
|
tx = Transaction(message=message, from_keypairs=[payer], recent_blockhash=recent_blockhash)
|
140
137
|
response = self.provider.send_transaction(tx,opts=TxOpts(skip_preflight=True))
|
141
|
-
|
138
|
+
data = {
|
139
|
+
"signature": response.value,
|
140
|
+
"amount": cheque_amount,
|
141
|
+
"create_pda": CHEQUE_PDA_SIGNATURE,
|
142
|
+
"cheque_pda": CHEQUE_PDA,
|
143
|
+
"rent_pda": CHEQUE_RENT.value / LAMPORTS_PER_SOL,
|
144
|
+
|
145
|
+
}
|
146
|
+
return data
|
147
|
+
|
148
|
+
def claim_cheque(self, pda_acc: str):
|
149
|
+
instruction_data = bytes([1])
|
150
|
+
payer = self.key
|
151
|
+
payer_pubkey = payer.pubkey()
|
152
|
+
|
153
|
+
|
154
|
+
ix = Instruction(
|
155
|
+
program_id=PROGRAM_ID,
|
156
|
+
data=instruction_data,
|
157
|
+
accounts = [
|
158
|
+
AccountMeta(pubkey=payer_pubkey, is_signer=True, is_writable=True),
|
159
|
+
AccountMeta(pubkey=Pubkey.from_string(pda_acc), is_signer=False, is_writable=True),
|
160
|
+
]
|
161
|
+
)
|
162
|
+
|
163
|
+
# Создаём и отправляем транзакцию
|
164
|
+
recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
|
165
|
+
message = Message(instructions=[instruction_data], payer=payer_pubkey)
|
166
|
+
tx = Transaction(message=message, from_keypairs=[payer], recent_blockhash=recent_blockhash)
|
167
|
+
response = self.provider.send_transaction(tx,opts=TxOpts(skip_preflight=True))
|
168
|
+
return response.value
|
142
169
|
|
143
170
|
|
144
171
|
|
@@ -6,12 +6,12 @@ shadowPaySDK/interface/erc20.py,sha256=7p8eU5LzhI2MsH80PZhq6IRhbfMGlNYucGl3OtyS9
|
|
6
6
|
shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
|
7
7
|
shadowPaySDK/interface/sol.py,sha256=TDp62OtQkR8Wy9I4UBVmL_K_FQeMVS--Lojgbvq5T2E,8146
|
8
8
|
shadowPaySDK/types/EVMcheque.py,sha256=8M1EzpZGqf4uidrd9yDKiR7BvIl85p93A_9AMZtshSs,14570
|
9
|
-
shadowPaySDK/types/SOLcheque.py,sha256=
|
9
|
+
shadowPaySDK/types/SOLcheque.py,sha256=YN7bWqjWDL2FtZxqEOH91M9pT8B5DgSyiOUZbaFiCzI,6736
|
10
10
|
shadowPaySDK/types/__init__.py,sha256=sG6pNZfKGvENXqsnv6MrQtKrJ898fAXkMvAZY1k1-Qg,97
|
11
11
|
shadowPaySDK/utils/__init__.py,sha256=aja3iYO4rT-ptMM-pzw0GRFTziBdXdcEi-4kE84zH64,61
|
12
12
|
shadowPaySDK/utils/utils.py,sha256=g4bGvLDdjhNGsAj1eaZnNWFNaiN-cVhhM-5PrnG5aIQ,720
|
13
|
-
shadowpaysdk-0.2.0.
|
14
|
-
shadowpaysdk-0.2.0.
|
15
|
-
shadowpaysdk-0.2.0.
|
16
|
-
shadowpaysdk-0.2.0.
|
17
|
-
shadowpaysdk-0.2.0.
|
13
|
+
shadowpaysdk-0.2.0.27.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
|
14
|
+
shadowpaysdk-0.2.0.27.dist-info/METADATA,sha256=ysD2qNAuZO6VFiYRq5P64c54YIAjjiII5euIwkujV-E,964
|
15
|
+
shadowpaysdk-0.2.0.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
shadowpaysdk-0.2.0.27.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
|
17
|
+
shadowpaysdk-0.2.0.27.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|