shadowPaySDK 0.2.0.26__tar.gz → 0.2.0.28__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 (23) hide show
  1. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/PKG-INFO +1 -1
  2. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/setup.py +1 -1
  3. shadowpaysdk-0.2.0.28/shadowPaySDK/types/SOLcheque.py +246 -0
  4. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK.egg-info/PKG-INFO +1 -1
  5. shadowpaysdk-0.2.0.26/shadowPaySDK/types/SOLcheque.py +0 -145
  6. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/LICENSE +0 -0
  7. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/README.md +0 -0
  8. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/setup.cfg +0 -0
  9. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/__init__.py +0 -0
  10. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/api.py +0 -0
  11. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/const.py +0 -0
  12. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/interface/__init__.py +0 -0
  13. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/interface/erc20.py +0 -0
  14. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/interface/erc721.py +0 -0
  15. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/interface/sol.py +0 -0
  16. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/types/EVMcheque.py +0 -0
  17. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/types/__init__.py +0 -0
  18. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/utils/__init__.py +0 -0
  19. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK/utils/utils.py +0 -0
  20. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK.egg-info/SOURCES.txt +0 -0
  21. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
  22. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/shadowPaySDK.egg-info/requires.txt +0 -0
  23. {shadowpaysdk-0.2.0.26 → shadowpaysdk-0.2.0.28}/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.28
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.28',
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',
@@ -0,0 +1,246 @@
1
+
2
+ import anchorpy
3
+ from anchorpy import Idl, Provider, Wallet
4
+ import solders
5
+ from shadowPaySDK.interface.sol import SOL
6
+ import solders
7
+ import spl.token.constants as spl_constants
8
+ from solana.rpc.api import Client
9
+
10
+ import asyncio
11
+ import solana
12
+ from solana.rpc.async_api import AsyncClient, GetTokenAccountsByOwnerResp
13
+ from solders.transaction import Transaction
14
+ from solders.system_program import TransferParams as p
15
+ from solders.instruction import Instruction, AccountMeta
16
+ from solders.rpc.config import RpcSendTransactionConfig
17
+ from solders.message import Message
18
+ import spl
19
+ import spl.token
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
22
+ from solders.system_program import transfer as ts
23
+ from solders.system_program import TransferParams as tsf
24
+ from solders.pubkey import Pubkey
25
+ import os
26
+ from spl.token.constants import TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID
27
+ from solana.rpc.types import TxOpts, TokenAccountOpts
28
+ from solana.rpc.types import TxOpts
29
+ import solders
30
+ from solders.message import Message
31
+ from solders.system_program import create_account,CreateAccountParams
32
+
33
+ # from solders.pubkey import Pubkey
34
+ # from solders.keypair import Keypair
35
+ # from solders.signature import Signature
36
+ # from solders.transaction import Transaction
37
+ from spl.token.async_client import AsyncToken
38
+
39
+
40
+ from solana.rpc.commitment import Confirmed
41
+ from solana.rpc.async_api import AsyncClient
42
+ import anchorpy
43
+ from anchorpy import Provider, Wallet, Idl
44
+ import pprint
45
+ import httpx
46
+ import base64
47
+ import re
48
+ import struct
49
+ from shadowPaySDK.const import LAMPORTS_PER_SOL
50
+
51
+ PROGRAM_ID = Pubkey.from_string("4PYNfaoDaJR8hrmUCngrwxJHAD9vkdnFySndPYC8HgNH")
52
+
53
+ CONFIG_PDA=Pubkey.find_program_address([b"config"], PROGRAM_ID)
54
+ PROGRAM_ID_STR = "5nfYDCgBgm72XdpYFEtWX2X1JQSyZdeBH2uuBZ6ZvQfi"
55
+
56
+ class SOLCheque:
57
+ def __init__(self, rpc_url: str = "https://api.mainnet-beta.solana.com", key: Wallet = None):
58
+ self.rpc_url = rpc_url
59
+ self.key = solders.keypair.Keypair.from_base58_string(key)
60
+ self.provider = Client(rpc_url)
61
+ self.WRAPED_SOL = spl_constants.WRAPPED_SOL_MINT # wrapped SOL token mint address
62
+ # self.idl = Idl.from_json(sol_interface.Idl) # Load the IDL for the program
63
+ def get(self, keypair = None):
64
+ pubkey = SOL.get_pubkey(KEYPAIR=solders.keypair.Keypair.from_base58_string(self.keystore))
65
+
66
+ return pubkey
67
+ def set_params(self, rpc_url = None, key = None):
68
+ if rpc_url:
69
+ self.rpc_url = rpc_url
70
+ self.provider = Client(rpc_url)
71
+ if key:
72
+ self.key = key
73
+
74
+ def init_cheque(self, cheque_amount, recipient: str, SPACE: int = 100):
75
+ """
76
+ Initialize a cheque withc the specified amount and recipient.
77
+ """
78
+ if not self.key:
79
+ raise ValueError("Keypair is not set. Please set the keypair before initializing a cheque.")
80
+ CHEQUE_PDA_SIGNATURE = None
81
+ CHEQUE_SPACE = SPACE
82
+ CHEQUE_RENT = self.provider.get_minimum_balance_for_rent_exemption(CHEQUE_SPACE)
83
+ sol = SOL(
84
+ KEYPAIR=self.key
85
+ )
86
+ payer = self.key
87
+ pubkey = self.key.pubkey()
88
+ newAcc = solders.keypair.Keypair()
89
+ newAccPubkey = newAcc.pubkey()
90
+ ix_create = create_account(
91
+ params=CreateAccountParams(
92
+ from_pubkey=pubkey,
93
+ to_pubkey=newAccPubkey,
94
+ lamports=CHEQUE_RENT.value,
95
+ space=CHEQUE_SPACE,
96
+ owner=PROGRAM_ID
97
+ )
98
+ )
99
+ recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
100
+ message = Message(instructions=[ix_create], payer=pubkey)
101
+
102
+ t = Transaction(message=message, from_keypairs=[payer, newAcc], recent_blockhash=recent_blockhash)
103
+ r = self.provider.send_transaction(t,opts=TxOpts())
104
+ CHEQUE_PDA_SIGNATURE = r.value
105
+ CHEQUE_PDA = newAccPubkey
106
+
107
+
108
+
109
+ total_lamports = int(cheque_amount * LAMPORTS_PER_SOL)
110
+
111
+
112
+ r = Pubkey.from_string(recipient)
113
+
114
+ data = bytes([0]) + bytes(r) + struct.pack("<Q", total_lamports)
115
+
116
+
117
+
118
+ instruction = Instruction(
119
+ program_id=PROGRAM_ID,
120
+ data=data,
121
+ accounts=[
122
+ AccountMeta(pubkey=pubkey, is_signer=True, is_writable=True), # payer
123
+ AccountMeta(pubkey=CHEQUE_PDA, is_signer=False, is_writable=True), # cheque PDA
124
+ AccountMeta(pubkey=Pubkey.from_string("11111111111111111111111111111111"), is_signer=False, is_writable=False)
125
+
126
+ ]
127
+ )
128
+
129
+ recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
130
+ message = Message(instructions=[instruction], payer=pubkey)
131
+ tx = Transaction(message=message, from_keypairs=[payer], recent_blockhash=recent_blockhash)
132
+ response = self.provider.send_transaction(tx,opts=TxOpts(skip_preflight=True))
133
+ confirm = self.provider.confirm_transaction(response.value)
134
+
135
+ data = {
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,
141
+ }
142
+ return data
143
+
144
+ def claim_cheque(self, pda_acc: str, rent_resiver:str = None ):
145
+ instruction_data = bytes([1])
146
+ payer = self.key
147
+ payer_pubkey = payer.pubkey()
148
+ if not rent_resiver:
149
+ rent_resiver = payer_pubkey
150
+ rent_resiver = Pubkey.from_string(rent_resiver)
151
+
152
+ ix = Instruction(
153
+ program_id=PROGRAM_ID,
154
+ data=instruction_data,
155
+ accounts = [
156
+ AccountMeta(pubkey=payer_pubkey, is_signer=True, is_writable=True),
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
159
+ ]
160
+ )
161
+
162
+ recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
163
+ message = Message(instructions=[ix], payer=payer_pubkey)
164
+ tx = Transaction(message=message, from_keypairs=[payer], recent_blockhash=recent_blockhash)
165
+ response = self.provider.send_transaction(tx,opts=TxOpts(skip_preflight=True))
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")
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))
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
+ )
240
+
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
+ }
@@ -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.28
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
@@ -1,145 +0,0 @@
1
-
2
- import anchorpy
3
- from anchorpy import Idl, Provider, Wallet
4
- import solders
5
- from shadowPaySDK.interface.sol import SOL
6
- import solders
7
- import spl.token.constants as spl_constants
8
- from solana.rpc.api import Client
9
-
10
- from types import Optional, Union
11
- import asyncio
12
- import solana
13
- from solana.rpc.async_api import AsyncClient, GetTokenAccountsByOwnerResp
14
- from solders.transaction import Transaction
15
- from solders.system_program import TransferParams as p
16
- from solders.instruction import Instruction, AccountMeta
17
- from solders.rpc.config import RpcSendTransactionConfig
18
- from solders.message import Message
19
- import spl
20
- import spl.token
21
- import spl.token.constants
22
- from spl.token.instructions import get_associated_token_address, create_associated_token_account, transfer, close_account, TransferParams
23
- from solders.system_program import transfer as ts
24
- from solders.system_program import TransferParams as tsf
25
- from solders.pubkey import Pubkey
26
- import os
27
- from spl.token.constants import TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID
28
- from solana.rpc.types import TxOpts, TokenAccountOpts
29
- from solana.rpc.types import TxOpts
30
- import solders
31
- from solders.message import Message
32
- from solders.system_program import create_account,CreateAccountParams
33
-
34
- # from solders.pubkey import Pubkey
35
- # from solders.keypair import Keypair
36
- # from solders.signature import Signature
37
- # from solders.transaction import Transaction
38
- from spl.token.async_client import AsyncToken
39
-
40
-
41
- from solana.rpc.commitment import Confirmed
42
- from solana.rpc.async_api import AsyncClient
43
- import anchorpy
44
- from anchorpy import Provider, Wallet, Idl
45
- from typing import Optional, Union
46
- import pprint
47
- import httpx
48
- import base64
49
- import re
50
- import struct
51
- from shadowPaySDK.const import LAMPORTS_PER_SOL
52
-
53
-
54
- # PROGRAM_ID = "5nfYDCgBgm72XdpYFEtWX2X1JQSyZdeBH2uuBZ6ZvQfi"
55
-
56
- class SOLCheque:
57
- def __init__(self, rpc_url: str = "https://api.mainnet-beta.solana.com", key: Wallet = None):
58
- self.rpc_url = rpc_url
59
- self.key = solders.keypair.Keypair.from_base58_string(key)
60
- self.provider = Client(rpc_url)
61
- self.WRAPED_SOL = spl_constants.WRAPPED_SOL_MINT # wrapped SOL token mint address
62
- # self.idl = Idl.from_json(sol_interface.Idl) # Load the IDL for the program
63
- def get(self, keypair = None):
64
- pubkey = SOL.get_pubkey(KEYPAIR=solders.keypair.Keypair.from_base58_string(self.keystore))
65
-
66
- return pubkey
67
- def set_params(self, rpc_url: Optional[str] = None, key: Optional[Wallet] = None):
68
- if rpc_url:
69
- self.rpc_url = rpc_url
70
- self.provider = Client(rpc_url)
71
- if key:
72
- self.key = key
73
-
74
- def init_cheque(self, cheque_amount, recipient: str, memo: Optional[str] = None):
75
- """
76
- Initialize a cheque withc the specified amount and recipient.
77
- """
78
- if not self.key:
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
83
- 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()
86
- payer = self.key
87
- pubkey = self.key.pubkey
88
- newAccount = sol.gen_wallet()
89
- newAccountPubkey = newAccount["pubkey"]
90
- ix_create = create_account(
91
- params=CreateAccountParams(
92
- from_pubkey=pubkey,
93
- to_pubkey=newAccountPubkey,
94
- lamports=CHEQUE_RENT.value,
95
- space=CHEQUE_SPACE,
96
- owner=PROGRAM_ID
97
- )
98
- )
99
- recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
100
- message = Message(instructions=[ix_create], payer=pubkey)
101
-
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
106
-
107
- # === Автор ===
108
-
109
- # === Получатели ===
110
-
111
- # === Сумма ===
112
- total_lamports = int(cheque_amount * LAMPORTS_PER_SOL)
113
-
114
-
115
- r = Pubkey.from_string(recipient)
116
-
117
- # 1 byte - tag
118
- # 32 bytes - recipient pubkey
119
- # 8 bytes - lamports (u64 LE)
120
- data = bytes([0]) + bytes(r) + struct.pack("<Q", total_lamports)
121
-
122
- # === Инструкция ===
123
-
124
-
125
- instruction = Instruction(
126
- program_id=PROGRAM_ID,
127
- data=data,
128
- accounts=[
129
- AccountMeta(pubkey=pubkey, is_signer=True, is_writable=True), # payer
130
- AccountMeta(pubkey=CHEQUE_PDA, is_signer=False, is_writable=True), # cheque PDA
131
- AccountMeta(pubkey=Pubkey.from_string("11111111111111111111111111111111"), is_signer=False, is_writable=False)
132
-
133
- ]
134
- )
135
-
136
- # === Отправка транзакции ===
137
- recent_blockhash = self.provider.get_latest_blockhash().value.blockhash
138
- message = Message(instructions=[instruction], payer=pubkey)
139
- tx = Transaction(message=message, from_keypairs=[payer], recent_blockhash=recent_blockhash)
140
- response = self.provider.send_transaction(tx,opts=TxOpts(skip_preflight=True))
141
- print("✅ InitCheque Signature:", response.value)
142
-
143
-
144
-
145
-
File without changes