shadowPaySDK 0.2.0.26__tar.gz → 0.2.0.27__tar.gz

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.
Files changed (22) hide show
  1. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/PKG-INFO +1 -1
  2. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/setup.py +1 -1
  3. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/types/SOLcheque.py +49 -22
  4. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK.egg-info/PKG-INFO +1 -1
  5. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/LICENSE +0 -0
  6. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/README.md +0 -0
  7. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/setup.cfg +0 -0
  8. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/__init__.py +0 -0
  9. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/api.py +0 -0
  10. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/const.py +0 -0
  11. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/interface/__init__.py +0 -0
  12. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/interface/erc20.py +0 -0
  13. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/interface/erc721.py +0 -0
  14. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/interface/sol.py +0 -0
  15. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/types/EVMcheque.py +0 -0
  16. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/types/__init__.py +0 -0
  17. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/utils/__init__.py +0 -0
  18. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK/utils/utils.py +0 -0
  19. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK.egg-info/SOURCES.txt +0 -0
  20. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
  21. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK.egg-info/requires.txt +0 -0
  22. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.27}/shadowPaySDK.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 0.2.0.26
3
+ Version: 0.2.0.27
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
5
  Author: dazay(aka dazarius_)
6
6
  Author-email: your@email.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='shadowPaySDK',
5
- version='0.2.0.26',
5
+ version='0.2.0.27',
6
6
  description='ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction',
7
7
  long_description=open('README.md').read(),
8
8
  long_description_content_type='text/markdown',
@@ -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: Optional[str] = None, key: Optional[Wallet] = None):
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, memo: Optional[str] = None):
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
- PROGRAM_ID = Pubkey.from_string("5nfYDCgBgm72XdpYFEtWX2X1JQSyZdeBH2uuBZ6ZvQfi")
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
- newAccount = sol.gen_wallet()
89
- newAccountPubkey = newAccount["pubkey"]
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=newAccountPubkey,
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, newAccount["keypair"]], recent_blockhash=recent_blockhash)
103
- r = self.provider.send_transaction(t,opts=TxOpts(skip_preflight=True))
104
- print("✅ CreateCheque Signature:", r.value)
105
- CHEQUE_PDA = newAccountPubkey # замените на актуальный адрес 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
- print("✅ InitCheque Signature:", response.value)
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 0.2.0.26
3
+ Version: 0.2.0.27
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
5
  Author: dazay(aka dazarius_)
6
6
  Author-email: your@email.com
File without changes