shadowPaySDK 16.7.2025.512__py3-none-any.whl → 16.7.2025.514__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.
@@ -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,TransferCheckedParams, transfer_checked, 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
@@ -94,6 +94,29 @@ class SOLCheque:
94
94
  "token_out_bps": token_out_bps,
95
95
  "initialized": initialized,
96
96
  }
97
+ def parse_token_cheque_data(self,pda):
98
+ if isinstance(pda, str):
99
+ pda_pubkey = Pubkey.from_string(pda)
100
+ pda_pubkey = pda
101
+ response = self.provider.get_account_info(pda_pubkey)
102
+ if response.value is None:
103
+ return None
104
+
105
+ raw_data = bytes(response.value.data)
106
+ id = int.from_bytes(raw_data[0:8], "little")
107
+ amount = int.from_bytes(raw_data[8:16], "little")
108
+ mint = Pubkey.from_bytes(raw_data[16:48])
109
+ recipient = Pubkey.from_bytes(raw_data[48:80])
110
+ claimed = raw_data[80] != 0
111
+
112
+ return {
113
+ "id": id,
114
+ "amount": amount,
115
+ "mint": str(mint),
116
+ "recipient": str(recipient),
117
+ "claimed": claimed,
118
+ }
119
+
97
120
  def set_params(self, rpc_url = None, key = None):
98
121
  if rpc_url:
99
122
  self.rpc_url = rpc_url
@@ -202,81 +225,146 @@ class SOLCheque:
202
225
  "pda_account": pda_acc,
203
226
  }
204
227
 
205
- # init_token_cheque need fix...
228
+ # init_token_cheque work succesfuly
206
229
 
207
- def init_token_cheque(self, token_mint: str, token_amount,token_decimals, recipient: str, treasury: str, CHEQUE_SPACE: int = 105):
230
+ def init_token_cheque(
231
+ self,
232
+ token_mint: str,
233
+ token_amount,
234
+ token_decimals,
235
+ recipient: str,
236
+ CHEQUE_SPACE: int = 155
237
+ ):
208
238
  if not self.key:
209
239
  raise ValueError("Keypair not set")
210
240
 
211
241
  payer = self.key
212
242
  payer_pubkey = payer.pubkey()
243
+
213
244
  token_mint_pubkey = Pubkey.from_string(token_mint)
214
245
  recipient_pubkey = Pubkey.from_string(recipient)
215
- treasury_pubkey = Pubkey.from_string(treasury)
216
246
 
217
247
  cheque_acc = solders.keypair.Keypair()
218
- cheque_pda = cheque_acc.pubkey()
248
+ cheque_pubkey = cheque_acc.pubkey()
219
249
 
220
250
  rent = self.provider.get_minimum_balance_for_rent_exemption(CHEQUE_SPACE).value
221
251
 
222
- create_cheque_acc = create_account(
252
+ # 1. Create raw cheque account
253
+ create_cheque_ix = create_account(
223
254
  CreateAccountParams(
224
255
  from_pubkey=payer_pubkey,
225
- to_pubkey=cheque_pda,
256
+ to_pubkey=cheque_pubkey,
226
257
  lamports=rent,
227
258
  space=CHEQUE_SPACE,
228
259
  owner=PROGRAM_ID
229
260
  )
230
261
  )
231
262
 
263
+ blockhash = self.provider.get_latest_blockhash().value.blockhash
264
+
232
265
  tx1 = Transaction(
233
- message=Message(instructions=[create_cheque_acc], payer=payer_pubkey),
234
- recent_blockhash=self.provider.get_latest_blockhash().value.blockhash,
266
+ message=Message(instructions=[create_cheque_ix], payer=payer_pubkey),
267
+ recent_blockhash=blockhash,
235
268
  from_keypairs=[payer, cheque_acc]
236
269
  )
237
270
  self.provider.send_transaction(tx1, opts=TxOpts(skip_preflight=True))
238
271
 
239
- sender_ata = get_associated_token_address(payer_pubkey, token_mint_pubkey)
240
- cheque_ata = get_associated_token_address(cheque_pda, token_mint_pubkey)
241
- treasury_ata = get_associated_token_address(treasury_pubkey, token_mint_pubkey)
242
-
243
- ix_create_ata = create_associated_token_account(payer_pubkey, cheque_pda, token_mint_pubkey)
244
-
245
- amount = int(token_amount * (10 ** token_decimals))
246
272
 
247
273
 
274
+ ata_ix = create_associated_token_account(
275
+ payer=payer_pubkey,
276
+ owner=cheque_pubkey,
277
+ mint=token_mint_pubkey
278
+ )
279
+ cfg = self.get_config()
280
+ tressary = cfg["treasury"]
281
+ sender_ata = get_associated_token_address(payer_pubkey, token_mint_pubkey)
282
+ cheque_ata = get_associated_token_address(cheque_pubkey, token_mint_pubkey)
248
283
 
249
- data = bytes([2]) + struct.pack("<Q", amount)
284
+ # 4. Prepare your program instruction
285
+ amount = int(token_amount * (10 ** token_decimals))
286
+ data = bytes([2]) + struct.pack("<Q", amount) + bytes(recipient_pubkey)
250
287
 
251
288
  ix_program = Instruction(
252
289
  program_id=PROGRAM_ID,
253
290
  data=data,
254
291
  accounts=[
255
- AccountMeta(payer_pubkey, is_signer=True, is_writable=True),
256
- AccountMeta(cheque_pda, is_signer=True, is_writable=True),
257
- AccountMeta(token_mint_pubkey, is_signer=False, is_writable=True),
258
- AccountMeta(sender_ata, is_signer=False, is_writable=True),
259
- AccountMeta(cheque_ata, is_signer=False, is_writable=True),
260
- AccountMeta(treasury_ata, is_signer=False, is_writable=True),
261
- AccountMeta(Pubkey.from_string("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), is_signer=False, is_writable=False),
292
+ AccountMeta(pubkey=payer_pubkey, is_signer=True, is_writable=True), # 0 initializer
293
+ AccountMeta(pubkey=cheque_pubkey, is_signer=True, is_writable=True), # 1 cheque_pda
294
+ AccountMeta(pubkey=token_mint_pubkey, is_signer=False, is_writable=True), # 2 mint
295
+ AccountMeta(pubkey=sender_ata, is_signer=False, is_writable=True), # 3 sender ATA
296
+ AccountMeta(pubkey=cheque_ata, is_signer=False, is_writable=True), # 4 cheque ATA
297
+ AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False), # 5 token program
298
+ AccountMeta(pubkey=CONFIG_PDA[0], is_signer=False, is_writable=False), # 6 config PDA
299
+ AccountMeta(pubkey=Pubkey.from_string(tressary), is_signer=False, is_writable=True), # 7 treasury ATA
262
300
  ]
263
301
  )
264
302
 
303
+
265
304
  print("Accounts (ix_program):")
266
305
  for i, acc in enumerate(ix_program.accounts):
267
306
  print(f"[{i}] {acc.pubkey} | signer={acc.is_signer} | writable={acc.is_writable}")
268
307
 
308
+ # 5. Send final transaction with ATA crea tion + program call
309
+ blockhash = self.provider.get_latest_blockhash().value.blockhash
269
310
  tx2 = Transaction(
270
- message=Message(instructions=[ix_create_ata, ix_program], payer=payer_pubkey),
271
- recent_blockhash=self.provider.get_latest_blockhash().value.blockhash,
311
+ message=Message(instructions=[ata_ix, ix_program], payer=payer_pubkey),
312
+ recent_blockhash=blockhash,
272
313
  from_keypairs=[payer, cheque_acc]
273
314
  )
274
315
 
275
316
  sig = self.provider.send_transaction(tx2, opts=TxOpts(skip_preflight=True)).value
317
+
276
318
  return {
277
- "cheque_pda": str(cheque_pda),
319
+ "cheque_pubkey": str(cheque_pubkey),
278
320
  "signature": str(sig),
279
321
  "amount": token_amount
280
322
  }
281
- def claim_token_cheque(self, pda_acc: str):
282
- pass
323
+
324
+
325
+ def claim_token_cheque(self, pda_acc: str):
326
+ payer = self.key
327
+ payer_pubkey = payer.pubkey()
328
+ pada_acc = solders.keypair.Keypair.from_base58_string(pda_acc)
329
+ pda_pubkey = pada_acc.pubkey()
330
+ cheque_data = self.parse_token_cheque_data(pda=solders.keypair.Keypair.from_base58_string(pda_acc).pubkey())
331
+
332
+ cheque_token_account = get_associated_token_address(pda_pubkey, Pubkey.from_string(cheque_data["mint"]))
333
+ recipient_token_account = get_associated_token_address(
334
+ Pubkey.from_string(cheque_data["recipient"]), Pubkey.from_string(cheque_data["mint"])
335
+ )
336
+ cfg = self.get_config()
337
+ tressary = cfg["treasury"]
338
+ data = bytes([3])
339
+ ix_program = Instruction(
340
+ program_id=PROGRAM_ID,
341
+ data=bytes([3]),
342
+ accounts=[
343
+ AccountMeta(pubkey=payer_pubkey, is_signer=True, is_writable=True), # 0 claimer
344
+ AccountMeta(pubkey=pda_pubkey, is_signer=False, is_writable=True), # 1 cheque_pda
345
+ AccountMeta(pubkey=cheque_token_account, is_signer=False, is_writable=True), # 2 cheque_token_account
346
+ AccountMeta(pubkey=recipient_token_account, is_signer=False, is_writable=True), # 3 recipient_token_account
347
+ AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False), # 4 token_program
348
+ AccountMeta(pubkey=CONFIG_PDA[0], is_signer=False, is_writable=False), # 5 config_account
349
+ AccountMeta(pubkey=Pubkey.from_string(tressary), is_signer=False, is_writable=True), # 6 treasury_account
350
+ ]
351
+ )
352
+
353
+
354
+
355
+
356
+
357
+ blockhash = self.provider.get_latest_blockhash().value.blockhash
358
+
359
+ tx = Transaction(
360
+ message=Message(instructions=[ix_program], payer=payer_pubkey),
361
+ recent_blockhash=blockhash,
362
+ from_keypairs=[payer]
363
+ )
364
+
365
+ sig = self.provider.send_transaction(tx, opts=TxOpts(skip_preflight=True)).value
366
+
367
+ return {
368
+ "pda_pubkey": str(pda_pubkey),
369
+ "signature": str(sig)
370
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 16.7.2025.512
3
+ Version: 16.7.2025.514
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
5
  Author: dazay
6
6
  Author-email: shadowpay.protocol@gmail.com
@@ -5,12 +5,12 @@ shadowPaySDK/interface/erc20.py,sha256=zUTdwhf1hznSGxeEw0HsEFVf1nafHPcxj1X3djPcz
5
5
  shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
6
6
  shadowPaySDK/interface/sol.py,sha256=LsgwE8BzCstsVAxgcbKcYiXAORYMBHcQmNZdzsNkaLQ,7998
7
7
  shadowPaySDK/types/EVMcheque.py,sha256=RFhvTb-etNz2vF5x9WvDNNbjM84JHHJkd3V1wyURWv0,17912
8
- shadowPaySDK/types/SOLcheque.py,sha256=ZzQgQXBerwa9lelbV8O6JBr1nevCAmJDxrdo8FtKT-4,11795
8
+ shadowPaySDK/types/SOLcheque.py,sha256=uPFXw-rCRw6DftpgHj9F262fAq7ZL_WAvY3RkCN3p0w,15512
9
9
  shadowPaySDK/types/__init__.py,sha256=sG6pNZfKGvENXqsnv6MrQtKrJ898fAXkMvAZY1k1-Qg,97
10
10
  shadowPaySDK/utils/__init__.py,sha256=aja3iYO4rT-ptMM-pzw0GRFTziBdXdcEi-4kE84zH64,61
11
11
  shadowPaySDK/utils/utils.py,sha256=g4bGvLDdjhNGsAj1eaZnNWFNaiN-cVhhM-5PrnG5aIQ,720
12
- shadowpaysdk-16.7.2025.512.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
13
- shadowpaysdk-16.7.2025.512.dist-info/METADATA,sha256=cU5yetkRZJie2wtE3xCvI5wQ4vJqEyPpb6Mck23Uhzo,1047
14
- shadowpaysdk-16.7.2025.512.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- shadowpaysdk-16.7.2025.512.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
16
- shadowpaysdk-16.7.2025.512.dist-info/RECORD,,
12
+ shadowpaysdk-16.7.2025.514.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
13
+ shadowpaysdk-16.7.2025.514.dist-info/METADATA,sha256=piIWUez5L_kak2sK2vQUR_fu6tkmywCwuM6FXfewyyE,1047
14
+ shadowpaysdk-16.7.2025.514.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ shadowpaysdk-16.7.2025.514.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
16
+ shadowpaysdk-16.7.2025.514.dist-info/RECORD,,