shadowPaySDK 16.7.2025.1__tar.gz → 16.7.2025.6__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-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/PKG-INFO +3 -3
  2. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/setup.py +3 -3
  3. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/const.py +3 -1
  4. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/interface/erc20.py +9 -15
  5. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/interface/sol.py +0 -5
  6. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/types/EVMcheque.py +63 -31
  7. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/types/SOLcheque.py +0 -2
  8. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK.egg-info/PKG-INFO +3 -3
  9. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK.egg-info/SOURCES.txt +0 -1
  10. shadowpaysdk-16.7.2025.1/shadowPaySDK/api.py +0 -48
  11. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/LICENSE +0 -0
  12. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/README.md +0 -0
  13. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/setup.cfg +0 -0
  14. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/__init__.py +0 -0
  15. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/interface/__init__.py +0 -0
  16. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/interface/erc721.py +0 -0
  17. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/types/__init__.py +0 -0
  18. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/utils/__init__.py +0 -0
  19. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK/utils/utils.py +0 -0
  20. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
  21. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK.egg-info/requires.txt +0 -0
  22. {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.6}/shadowPaySDK.egg-info/top_level.txt +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 16.7.2025.1
3
+ Version: 16.7.2025.6
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
- Author: dazay(aka dazarius_)
6
- Author-email: your@email.com
5
+ Author: dazay
6
+ Author-email: shadowpay.protocol@gmail.com
7
7
  License: MIT
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
@@ -2,12 +2,12 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='shadowPaySDK',
5
- version='16.07.2025.1',
5
+ version='16.07.2025.6',
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',
9
- author='dazay(aka dazarius_)',
10
- author_email='your@email.com',
9
+ author='dazay',
10
+ author_email='shadowpay.protocol@gmail.com',
11
11
  license='MIT',
12
12
  packages=find_packages(),
13
13
  classifiers=[
@@ -3,6 +3,7 @@ from solders.pubkey import Pubkey
3
3
  __ALLOW_CHAINS__ = [
4
4
  56, # BSC Mainnet
5
5
  97, # BSC Testnet
6
+ 10143,
6
7
  0x1,
7
8
  0x1f984,
8
9
  0x38,
@@ -30,7 +31,8 @@ __ERC20_ABI__ = json.loads("""[
30
31
  ]""")
31
32
 
32
33
  __SHADOWPAY_CONTRACT_ADDRESS__ERC20__ = {
33
- 97: "0x5487C0DdCbD5465F26B446c6CAB88D8d6F7DF23b"
34
+ 97: "0x5487C0DdCbD5465F26B446c6CAB88D8d6F7DF23b",
35
+ 10143: "0x35D7950dF4E593dAFaE608Ef34C4fB8b28F21cdC"
34
36
  }
35
37
 
36
38
  __SHADOWPAY_ABI__ERC20__= json.loads("""[
@@ -43,7 +43,7 @@ class ERC20Token:
43
43
  def get_balance(self, wallet_address: str) -> float:
44
44
  self._ensure_contract()
45
45
  raw = self.contract.functions.balanceOf(Web3.to_checksum_address(wallet_address)).call()
46
- return raw / (10 ** self.get_decimals())
46
+ return raw
47
47
 
48
48
  def allowance(self, owner: str, spender: str) -> float:
49
49
  self._ensure_contract()
@@ -51,31 +51,30 @@ class ERC20Token:
51
51
  Web3.to_checksum_address(owner),
52
52
  Web3.to_checksum_address(spender)
53
53
  ).call()
54
- return raw / (10 ** self.get_decimals())
54
+ return raw
55
55
 
56
- def ensure_allowance(self, private_key: str, spender: str, amount) -> Union[bool, str]:
56
+ def ensure_allowance(self, private_key: str, spender: str, amount, converted_amount: bool = False) -> Union[bool, str]:
57
57
  self._ensure_contract()
58
58
  account = self.web3.eth.account.from_key(private_key)
59
59
  current = self.allowance(account.address, spender)
60
60
  if current == amount:
61
61
  return True
62
- return self.approve(private_key, spender, amount)
62
+ return self.approve(private_key, spender, amount, conveted_amount=converted_amount)
63
63
 
64
64
  def transfer(self, private_key: str, to: str, amount: float) -> str:
65
65
  self._ensure_contract()
66
66
  account = self.web3.eth.account.from_key(private_key)
67
- decimals = self.get_decimals()
68
- value = int(amount * (10 ** decimals))
67
+
69
68
  estimated_gas = self.contract.functions.transfer(
70
69
  Web3.to_checksum_address(to),
71
- value
70
+ amount
72
71
  ).estimate_gas({
73
72
  'from': account.address,
74
73
  'gasPrice': self.web3.to_wei('5', 'gwei'),
75
74
  })
76
75
  txn = self.contract.functions.transfer(
77
76
  Web3.to_checksum_address(to),
78
- value
77
+ amount
79
78
  ).build_transaction({
80
79
  'from': account.address,
81
80
  'nonce': self.web3.eth.get_transaction_count(account.address),
@@ -87,7 +86,7 @@ class ERC20Token:
87
86
  tx_hash = self.web3.eth.send_raw_transaction(signed.raw_transaction)
88
87
  return self._format_tx(self.web3.to_hex(tx_hash))
89
88
 
90
- def approve(self, spender: str, amount: float,address:Optional[str] = None, private_key: Optional[str] = None, build_tx: bool = False) -> str:
89
+ def approve(self, spender: str, amount: float,address:Optional[str] = None, private_key: Optional[str] = None, conveted_amount: bool = True) -> str:
91
90
 
92
91
  self._ensure_contract()
93
92
  key = private_key
@@ -99,10 +98,6 @@ class ERC20Token:
99
98
  address = Web3.to_checksum_address(self.address)
100
99
  else:
101
100
  raise ValueError("No private key or address provided")
102
-
103
- decimals = self.get_decimals()
104
- amount = int(amount * (10 ** decimals))
105
-
106
101
  txn = self.contract.functions.approve(
107
102
  Web3.to_checksum_address(spender),
108
103
  amount
@@ -113,8 +108,7 @@ class ERC20Token:
113
108
 
114
109
  'gasPrice': self.web3.eth.gas_price,
115
110
  })
116
- if build_tx:
117
- return txn
111
+
118
112
 
119
113
  signed = self.web3.eth.account.sign_transaction(txn, key)
120
114
  tx_hash = self.web3.eth.send_raw_transaction(signed.raw_transaction)
@@ -118,12 +118,7 @@ class SOL:
118
118
 
119
119
 
120
120
  return token_data
121
- async def is_connected(self):
122
- return await self.client.is_connected()
123
121
 
124
- async def close(self):
125
- await self.client.close()
126
-
127
122
  async def fetch_metadata_raw(self,mint_address: str):
128
123
  METADATA_PROGRAM_ID = solders.pubkey.Pubkey.from_string("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
129
124
  mint = solders.pubkey.Pubkey.from_string(mint_address)
@@ -36,6 +36,7 @@ class Cheque:
36
36
  print(f"Failed to get cheque ID from transaction receipt: {str(e)}")
37
37
  return False
38
38
  def __allow__(self):
39
+ print("Checking if chain is allowed", self.w3.eth.chain_id)
39
40
  for chain in self.allowed_chains:
40
41
 
41
42
  if chain == self.w3.eth.chain_id:
@@ -46,15 +47,25 @@ class Cheque:
46
47
  raise ValueError(f"Chain {str(self.w3.eth.chain_id)} is not allowed. Allowed chains are: {self.allowed_chains}")
47
48
  def get_contract_for_chain(self,chain_id: str):
48
49
  c = None
49
- for chain in __SHADOWPAY_CONTRACT_ADDRESS__ERC20__ :
50
- if str(chain) == str(chain_id):
51
- c = __SHADOWPAY_CONTRACT_ADDRESS__ERC20__[chain_id]
52
- contract_address = Web3.to_checksum_address(c)
53
- contract = self.w3.eth.contract(address=contract_address, abi=__SHADOWPAY_ABI__ERC20__)
54
- self.contract = contract
55
- return contract
50
+ chain_id = int(chain_id)
51
+
52
+ for key,value in __SHADOWPAY_CONTRACT_ADDRESS__ERC20__.items():
53
+ print("Checking address", value, "for chain_id", chain_id)
54
+ if key == chain_id:
55
+ c = value
56
+ contract_address = Web3.to_checksum_address(c)
57
+ contract = self.w3.eth.contract(address=contract_address, abi=__SHADOWPAY_ABI__ERC20__)
58
+ self.contract = contract
59
+ return contract
56
60
  raise ValueError(f"Chain {chain_id} is not supported. Supported chains are: {list(__SHADOWPAY_CONTRACT_ADDRESS__ERC20__.keys())}")
57
-
61
+ async def get_address(self):
62
+ if self.address:
63
+ return self.address
64
+ elif self.w3:
65
+ return self.w3.eth.default_account
66
+ else:
67
+ raise ValueError("No address provided or Web3 instance is not set")
68
+
58
69
  def set_parameters(self,chain_id: Optional[str] = None, w3:Optional[Web3] = None, amount:Optional[int] = None, private_key:Optional[str] = None, token:Optional[str] = None,address:Optional[str] = None):
59
70
  if w3:
60
71
  self.w3 = w3
@@ -63,6 +74,7 @@ class Cheque:
63
74
  self.amount = amount
64
75
  if private_key:
65
76
  self.private_key = private_key
77
+ self.address = Web3.to_checksum_address(self.w3.eth.account.from_key(private_key).address)
66
78
  if token:
67
79
  self.token = token
68
80
  if address:
@@ -133,42 +145,55 @@ class Cheque:
133
145
  async def CashOutCheque(
134
146
  self,
135
147
  private_key: str,
136
- cheque_id: str # hex-строка типа "0xabc..."
148
+ cheque_id: str
137
149
  ):
138
150
  if not private_key:
139
151
  private_key = self.private_key
140
152
 
141
-
142
153
  account = self.w3.eth.account.from_key(private_key)
143
154
  sender_address = account.address or self.address
144
-
145
-
146
155
  nonce = self.w3.eth.get_transaction_count(sender_address)
147
156
 
148
- txn = self.contract.functions.CashOutCheque(
149
- Web3.to_bytes(hexstr=cheque_id)).build_transaction({
157
+ latest_block = self.w3.eth.get_block('latest')
158
+ supports_eip1559 = 'baseFeePerGas' in latest_block
159
+
160
+ tx_common = {
150
161
  'from': sender_address,
151
162
  'nonce': nonce,
152
163
  'gas': 300_000,
153
- 'gasPrice': self.w3.to_wei('5', 'gwei'),
154
- })
155
- if self.return_build_tx:
156
- return {
157
- "build_tx": txn
158
- }
164
+ }
159
165
 
160
- signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
166
+ if supports_eip1559:
167
+ # EIP-1559 style
168
+ base_fee = latest_block['baseFeePerGas']
169
+ priority_fee = self.w3.to_wei(2, 'gwei') # можно поднять до 5
170
+ max_fee = base_fee + priority_fee * 2
161
171
 
172
+ tx_common.update({
173
+ 'maxFeePerGas': max_fee,
174
+ 'maxPriorityFeePerGas': priority_fee
175
+ })
176
+ else:
177
+ # Legacy gas price style
178
+ tx_common.update({
179
+ 'gasPrice': self.w3.to_wei('5', 'gwei')
180
+ })
162
181
 
163
- tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
182
+ txn = self.contract.functions.CashOutCheque(
183
+ Web3.to_bytes(hexstr=cheque_id)
184
+ ).build_transaction(tx_common)
164
185
 
186
+ if self.return_build_tx:
187
+ return {"build_tx": txn}
188
+
189
+ signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
190
+ tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
165
191
  receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
192
+
166
193
  if receipt.status != 1:
167
194
  return False
168
- return {
169
- "hash": tx_hash.hex()
170
- }
171
-
195
+ return {"hash": tx_hash.hex()}
196
+
172
197
  async def InitTokenCheque(self, token_address:str, amount, reciver:str, private_key:Optional[str] = None):
173
198
  key = private_key or self.private_key
174
199
 
@@ -333,11 +358,19 @@ class Cheque:
333
358
  amount_out = swapDetail["amountOut"]
334
359
  erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
335
360
  erc20.set_params(token_address=token_out)
336
- encure_allowance = erc20.ensure_allowance(
337
- private_key=private_key,
361
+ encure_allowance = erc20.allowance(
338
362
  spender=self.contract.address,
339
- amount=amount_out,
363
+ owner=self.address,
340
364
  )
365
+ if encure_allowance < amount_out:
366
+ approve = erc20.approve(
367
+ spender=self.contract.address,
368
+ amount=amount_out,
369
+ private_key=private_key,
370
+ conveted_amount=False
371
+ )
372
+ if not approve:
373
+ return False
341
374
  estimated_gas = self.contract.functions.CashOutSwapCheque(
342
375
  Web3.to_bytes(hexstr=cheque_id)
343
376
  ).estimate_gas({
@@ -369,8 +402,7 @@ class Cheque:
369
402
 
370
403
 
371
404
  async def getComunityPool(self):
372
- # fee = self.contract.functions.getCollectedFee().call()
373
- fee = 50000000000000
405
+ fee = self.contract.functions.getCollectedFee().call()
374
406
  half_fee_eth = self.w3.from_wei(fee // 2, 'ether')
375
407
  return half_fee_eth
376
408
  async def getOwner(self):
@@ -71,7 +71,6 @@ class SOLCheque:
71
71
  print("❌ Config PDA not found.")
72
72
  return None
73
73
 
74
- # 🧠 У тебя data — это list[int], его нужно превратить в bytes
75
74
  raw = bytes(response.value.data)
76
75
 
77
76
  if len(raw) < 89:
@@ -263,7 +262,6 @@ class SOLCheque:
263
262
  ]
264
263
  )
265
264
 
266
- # === 6. Собираем и отправляем всё в одном tx ===
267
265
  print("Accounts (ix_program):")
268
266
  for i, acc in enumerate(ix_program.accounts):
269
267
  print(f"[{i}] {acc.pubkey} | signer={acc.is_signer} | writable={acc.is_writable}")
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 16.7.2025.1
3
+ Version: 16.7.2025.6
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
- Author: dazay(aka dazarius_)
6
- Author-email: your@email.com
5
+ Author: dazay
6
+ Author-email: shadowpay.protocol@gmail.com
7
7
  License: MIT
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
@@ -2,7 +2,6 @@ LICENSE
2
2
  README.md
3
3
  setup.py
4
4
  shadowPaySDK/__init__.py
5
- shadowPaySDK/api.py
6
5
  shadowPaySDK/const.py
7
6
  shadowPaySDK.egg-info/PKG-INFO
8
7
  shadowPaySDK.egg-info/SOURCES.txt
@@ -1,48 +0,0 @@
1
- import httpx
2
- import json
3
- from typing import Optional
4
- from web3 import Web3
5
-
6
- __MAIN__URL__= "http://0.0.0.0:8000"
7
- __CREATE__CHEQUE__ = f"{__MAIN__URL__}/validate"
8
- __MY__CHEQUES__ = f"{__MAIN__URL__}/mycheque"
9
-
10
-
11
-
12
- async def __validate__cheque__(id, sender,action, receiver:Optional[str] = None, chain_id: Optional[int] = None, type:Optional[str] = None):
13
- async with httpx.AsyncClient() as client:
14
- response = await client.post(
15
- __CREATE__CHEQUE__,
16
- json={
17
- "cheque_id": id,
18
- "chain_id":chain_id,
19
- "receiver": receiver,
20
- "type": type,
21
- "sender":sender,
22
- "action": action
23
- }
24
- )
25
- if response.status_code == 200:
26
- return response.json()
27
- else:
28
- print(f"Failed to create cheque: {response.text}")
29
- return False
30
-
31
-
32
- async def get_my_cheques(private_key):
33
- if not private_key:
34
- raise ValueError("Private key is required to fetch cheques.")
35
- sender = Web3.eth.account.from_key(private_key).address
36
-
37
- async with httpx.AsyncClient() as client:
38
- response = await client.get(
39
- __MY__CHEQUES__,
40
- params={
41
- "sender": sender
42
- }
43
- )
44
- if response.status_code == 200:
45
- return response.json()
46
- else:
47
- print(f"Failed to fetch cheques: {response.text}")
48
- return False