shadowPaySDK 0.2.0.27__py3-none-any.whl → 0.2.0.28__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 +95 -21
- {shadowpaysdk-0.2.0.27.dist-info → shadowpaysdk-0.2.0.28.dist-info}/METADATA +1 -1
- {shadowpaysdk-0.2.0.27.dist-info → shadowpaysdk-0.2.0.28.dist-info}/RECORD +6 -6
- {shadowpaysdk-0.2.0.27.dist-info → shadowpaysdk-0.2.0.28.dist-info}/WHEEL +0 -0
- {shadowpaysdk-0.2.0.27.dist-info → shadowpaysdk-0.2.0.28.dist-info}/licenses/LICENSE +0 -0
- {shadowpaysdk-0.2.0.27.dist-info → shadowpaysdk-0.2.0.28.dist-info}/top_level.txt +0 -0
shadowPaySDK/types/SOLcheque.py
CHANGED
@@ -18,7 +18,7 @@ from solders.message import Message
|
|
18
18
|
import spl
|
19
19
|
import spl.token
|
20
20
|
import spl.token.constants
|
21
|
-
from spl.token.instructions import get_associated_token_address, create_associated_token_account, transfer, close_account, TransferParams
|
21
|
+
from spl.token.instructions import get_associated_token_address, create_associated_token_account,TransferCheckedParams, transfer_checked, transfer, close_account, TransferParams
|
22
22
|
from solders.system_program import transfer as ts
|
23
23
|
from solders.system_program import TransferParams as tsf
|
24
24
|
from solders.pubkey import Pubkey
|
@@ -48,10 +48,10 @@ import re
|
|
48
48
|
import struct
|
49
49
|
from shadowPaySDK.const import LAMPORTS_PER_SOL
|
50
50
|
|
51
|
-
PROGRAM_ID = Pubkey.from_string("
|
51
|
+
PROGRAM_ID = Pubkey.from_string("4PYNfaoDaJR8hrmUCngrwxJHAD9vkdnFySndPYC8HgNH")
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
CONFIG_PDA=Pubkey.find_program_address([b"config"], PROGRAM_ID)
|
54
|
+
PROGRAM_ID_STR = "5nfYDCgBgm72XdpYFEtWX2X1JQSyZdeBH2uuBZ6ZvQfi"
|
55
55
|
|
56
56
|
class SOLCheque:
|
57
57
|
def __init__(self, rpc_url: str = "https://api.mainnet-beta.solana.com", key: Wallet = None):
|
@@ -80,7 +80,6 @@ class SOLCheque:
|
|
80
80
|
CHEQUE_PDA_SIGNATURE = None
|
81
81
|
CHEQUE_SPACE = SPACE
|
82
82
|
CHEQUE_RENT = self.provider.get_minimum_balance_for_rent_exemption(CHEQUE_SPACE)
|
83
|
-
print("Minimum balance for rent exemption:", CHEQUE_RENT.value / LAMPORTS_PER_SOL, "SOL")
|
84
83
|
sol = SOL(
|
85
84
|
KEYPAIR=self.key
|
86
85
|
)
|
@@ -112,12 +111,8 @@ class SOLCheque:
|
|
112
111
|
|
113
112
|
r = Pubkey.from_string(recipient)
|
114
113
|
|
115
|
-
# 1 byte - tag
|
116
|
-
# 32 bytes - recipient pubkey
|
117
|
-
# 8 bytes - lamports (u64 LE)
|
118
114
|
data = bytes([0]) + bytes(r) + struct.pack("<Q", total_lamports)
|
119
115
|
|
120
|
-
# === Инструкция ===
|
121
116
|
|
122
117
|
|
123
118
|
instruction = Instruction(
|
@@ -135,21 +130,24 @@ class SOLCheque:
|
|
135
130
|
message = Message(instructions=[instruction], payer=pubkey)
|
136
131
|
tx = Transaction(message=message, from_keypairs=[payer], recent_blockhash=recent_blockhash)
|
137
132
|
response = self.provider.send_transaction(tx,opts=TxOpts(skip_preflight=True))
|
133
|
+
confirm = self.provider.confirm_transaction(response.value)
|
134
|
+
|
138
135
|
data = {
|
139
|
-
"
|
140
|
-
"
|
141
|
-
"
|
142
|
-
"
|
143
|
-
"
|
144
|
-
|
136
|
+
"cheque_pda": str(CHEQUE_PDA),
|
137
|
+
"signature": str(response.value),
|
138
|
+
"create_signature": str(CHEQUE_PDA_SIGNATURE),
|
139
|
+
"cheque_amount": cheque_amount,
|
140
|
+
"pda_rent_sol": CHEQUE_RENT.value / LAMPORTS_PER_SOL,
|
145
141
|
}
|
146
142
|
return data
|
147
143
|
|
148
|
-
def claim_cheque(self, pda_acc: str):
|
144
|
+
def claim_cheque(self, pda_acc: str, rent_resiver:str = None ):
|
149
145
|
instruction_data = bytes([1])
|
150
146
|
payer = self.key
|
151
147
|
payer_pubkey = payer.pubkey()
|
152
|
-
|
148
|
+
if not rent_resiver:
|
149
|
+
rent_resiver = payer_pubkey
|
150
|
+
rent_resiver = Pubkey.from_string(rent_resiver)
|
153
151
|
|
154
152
|
ix = Instruction(
|
155
153
|
program_id=PROGRAM_ID,
|
@@ -157,16 +155,92 @@ class SOLCheque:
|
|
157
155
|
accounts = [
|
158
156
|
AccountMeta(pubkey=payer_pubkey, is_signer=True, is_writable=True),
|
159
157
|
AccountMeta(pubkey=Pubkey.from_string(pda_acc), is_signer=False, is_writable=True),
|
158
|
+
AccountMeta(pubkey=rent_resiver, is_signer=False, is_writable=True) # rent receiver
|
160
159
|
]
|
161
160
|
)
|
162
161
|
|
163
|
-
# Создаём и отправляем транзакцию
|
164
162
|
recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
|
165
|
-
message = Message(instructions=[
|
163
|
+
message = Message(instructions=[ix], payer=payer_pubkey)
|
166
164
|
tx = Transaction(message=message, from_keypairs=[payer], recent_blockhash=recent_blockhash)
|
167
165
|
response = self.provider.send_transaction(tx,opts=TxOpts(skip_preflight=True))
|
168
|
-
return
|
166
|
+
return {
|
167
|
+
"signature": str(response.value),
|
168
|
+
"pda_account": pda_acc,
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
def init_token_cheque(self, token_mint: str, token_amount,token_decimals, recipient: str, treasury: str, CHEQUE_SPACE: int = 105):
|
173
|
+
if not self.key:
|
174
|
+
raise ValueError("Keypair not set")
|
169
175
|
|
176
|
+
payer = self.key
|
177
|
+
payer_pubkey = payer.pubkey()
|
178
|
+
token_mint_pubkey = Pubkey.from_string(token_mint)
|
179
|
+
recipient_pubkey = Pubkey.from_string(recipient)
|
180
|
+
treasury_pubkey = Pubkey.from_string(treasury)
|
181
|
+
|
182
|
+
cheque_acc = solders.keypair.Keypair()
|
183
|
+
cheque_pda = cheque_acc.pubkey()
|
184
|
+
|
185
|
+
rent = self.provider.get_minimum_balance_for_rent_exemption(CHEQUE_SPACE).value
|
186
|
+
|
187
|
+
create_cheque_acc = create_account(
|
188
|
+
CreateAccountParams(
|
189
|
+
from_pubkey=payer_pubkey,
|
190
|
+
to_pubkey=cheque_pda,
|
191
|
+
lamports=rent,
|
192
|
+
space=CHEQUE_SPACE,
|
193
|
+
owner=PROGRAM_ID
|
194
|
+
)
|
195
|
+
)
|
196
|
+
|
197
|
+
tx1 = Transaction(
|
198
|
+
message=Message(instructions=[create_cheque_acc], payer=payer_pubkey),
|
199
|
+
recent_blockhash=self.provider.get_latest_blockhash().value.blockhash,
|
200
|
+
from_keypairs=[payer, cheque_acc]
|
201
|
+
)
|
202
|
+
self.provider.send_transaction(tx1, opts=TxOpts(skip_preflight=True))
|
170
203
|
|
204
|
+
sender_ata = get_associated_token_address(payer_pubkey, token_mint_pubkey)
|
205
|
+
cheque_ata = get_associated_token_address(cheque_pda, token_mint_pubkey)
|
206
|
+
treasury_ata = get_associated_token_address(treasury_pubkey, token_mint_pubkey)
|
207
|
+
|
208
|
+
ix_create_ata = create_associated_token_account(payer_pubkey, cheque_pda, token_mint_pubkey)
|
209
|
+
|
210
|
+
amount = int(token_amount * (10 ** token_decimals))
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
data = bytes([2]) + struct.pack("<Q", amount)
|
215
|
+
|
216
|
+
ix_program = Instruction(
|
217
|
+
program_id=PROGRAM_ID,
|
218
|
+
data=data,
|
219
|
+
accounts=[
|
220
|
+
AccountMeta(payer_pubkey, is_signer=True, is_writable=True),
|
221
|
+
AccountMeta(cheque_pda, is_signer=True, is_writable=True),
|
222
|
+
AccountMeta(token_mint_pubkey, is_signer=False, is_writable=True),
|
223
|
+
AccountMeta(sender_ata, is_signer=False, is_writable=True),
|
224
|
+
AccountMeta(cheque_ata, is_signer=False, is_writable=True),
|
225
|
+
AccountMeta(treasury_ata, is_signer=False, is_writable=True),
|
226
|
+
AccountMeta(Pubkey.from_string("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), is_signer=False, is_writable=False),
|
227
|
+
]
|
228
|
+
)
|
229
|
+
|
230
|
+
# === 6. Собираем и отправляем всё в одном tx ===
|
231
|
+
print("Accounts (ix_program):")
|
232
|
+
for i, acc in enumerate(ix_program.accounts):
|
233
|
+
print(f"[{i}] {acc.pubkey} | signer={acc.is_signer} | writable={acc.is_writable}")
|
234
|
+
|
235
|
+
tx2 = Transaction(
|
236
|
+
message=Message(instructions=[ix_create_ata, ix_program], payer=payer_pubkey),
|
237
|
+
recent_blockhash=self.provider.get_latest_blockhash().value.blockhash,
|
238
|
+
from_keypairs=[payer, cheque_acc]
|
239
|
+
)
|
171
240
|
|
172
|
-
|
241
|
+
sig = self.provider.send_transaction(tx2, opts=TxOpts(skip_preflight=True)).value
|
242
|
+
return {
|
243
|
+
"cheque_pda": str(cheque_pda),
|
244
|
+
"signature": str(sig),
|
245
|
+
"amount": token_amount
|
246
|
+
}
|
@@ -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=QxRJVPQKOn3n0Y0FQf4REjt0-garpp-L2E9B9PddDTA,10414
|
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.28.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
|
14
|
+
shadowpaysdk-0.2.0.28.dist-info/METADATA,sha256=jNmFSnt4Wv5zXzY0-BfpoQkBGRFEZFsGN3N-p52kaoM,964
|
15
|
+
shadowpaysdk-0.2.0.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
shadowpaysdk-0.2.0.28.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
|
17
|
+
shadowpaysdk-0.2.0.28.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|