shadowPaySDK 16.7.2025.5__py3-none-any.whl → 16.7.2025.6__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.
@@ -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,7 +51,7 @@ 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
56
  def ensure_allowance(self, private_key: str, spender: str, amount, converted_amount: bool = False) -> Union[bool, str]:
57
57
  self._ensure_contract()
@@ -64,18 +64,17 @@ class ERC20Token:
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),
@@ -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
- if conveted_amount:
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
@@ -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,13 +47,16 @@ 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):
58
62
  if self.address:
@@ -141,41 +145,54 @@ class Cheque:
141
145
  async def CashOutCheque(
142
146
  self,
143
147
  private_key: str,
144
- cheque_id: str # hex-строка типа "0xabc..."
148
+ cheque_id: str
145
149
  ):
146
150
  if not private_key:
147
151
  private_key = self.private_key
148
152
 
149
-
150
153
  account = self.w3.eth.account.from_key(private_key)
151
154
  sender_address = account.address or self.address
152
-
153
-
154
155
  nonce = self.w3.eth.get_transaction_count(sender_address)
155
156
 
156
- txn = self.contract.functions.CashOutCheque(
157
- 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 = {
158
161
  'from': sender_address,
159
162
  'nonce': nonce,
160
163
  'gas': 300_000,
161
- 'gasPrice': self.w3.to_wei('5', 'gwei'),
162
- })
163
- if self.return_build_tx:
164
- return {
165
- "build_tx": txn
166
- }
164
+ }
167
165
 
168
- 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
169
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
+ })
170
181
 
171
- 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)
185
+
186
+ if self.return_build_tx:
187
+ return {"build_tx": txn}
172
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)
173
191
  receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
192
+
174
193
  if receipt.status != 1:
175
194
  return False
176
- return {
177
- "hash": tx_hash.hex()
178
- }
195
+ return {"hash": tx_hash.hex()}
179
196
 
180
197
  async def InitTokenCheque(self, token_address:str, amount, reciver:str, private_key:Optional[str] = None):
181
198
  key = private_key or self.private_key
@@ -385,8 +402,7 @@ class Cheque:
385
402
 
386
403
 
387
404
  async def getComunityPool(self):
388
- # fee = self.contract.functions.getCollectedFee().call()
389
- fee = 50000000000000
405
+ fee = self.contract.functions.getCollectedFee().call()
390
406
  half_fee_eth = self.w3.from_wei(fee // 2, 'ether')
391
407
  return half_fee_eth
392
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.5
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
@@ -0,0 +1,16 @@
1
+ shadowPaySDK/__init__.py,sha256=CMwAuP_6hJN-WueU-XlTNta9Oyd28sFo8OojdgD_pxA,681
2
+ shadowPaySDK/const.py,sha256=E-w8fivcd-yeHmpOpDAwTIP5FvsArFBHNWbhJ5K01yw,10386
3
+ shadowPaySDK/interface/__init__.py,sha256=ggSZCV22udnzXm_Wv_3x6VN3hNIAEiwgwHZc2Jwc688,146
4
+ shadowPaySDK/interface/erc20.py,sha256=NlnPyR2xrzfDQ4ejd-cMl4bpO97JcCTpT04Yu2Zq1ZI,4476
5
+ shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
6
+ shadowPaySDK/interface/sol.py,sha256=LsgwE8BzCstsVAxgcbKcYiXAORYMBHcQmNZdzsNkaLQ,7998
7
+ shadowPaySDK/types/EVMcheque.py,sha256=BdDeI05BdHhIeyDThRAj6pfLn-Gd_tMTWAZ6h3q-BLU,15841
8
+ shadowPaySDK/types/SOLcheque.py,sha256=ZzQgQXBerwa9lelbV8O6JBr1nevCAmJDxrdo8FtKT-4,11795
9
+ shadowPaySDK/types/__init__.py,sha256=sG6pNZfKGvENXqsnv6MrQtKrJ898fAXkMvAZY1k1-Qg,97
10
+ shadowPaySDK/utils/__init__.py,sha256=aja3iYO4rT-ptMM-pzw0GRFTziBdXdcEi-4kE84zH64,61
11
+ shadowPaySDK/utils/utils.py,sha256=g4bGvLDdjhNGsAj1eaZnNWFNaiN-cVhhM-5PrnG5aIQ,720
12
+ shadowpaysdk-16.7.2025.6.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
13
+ shadowpaysdk-16.7.2025.6.dist-info/METADATA,sha256=BqT8OKm2hWPzoOi8c906o4ibmI-DG1XiDxoo_K7y_qo,1045
14
+ shadowpaysdk-16.7.2025.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ shadowpaysdk-16.7.2025.6.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
16
+ shadowpaysdk-16.7.2025.6.dist-info/RECORD,,
shadowPaySDK/api.py DELETED
@@ -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
@@ -1,17 +0,0 @@
1
- shadowPaySDK/__init__.py,sha256=CMwAuP_6hJN-WueU-XlTNta9Oyd28sFo8OojdgD_pxA,681
2
- shadowPaySDK/api.py,sha256=cv5Z171cOh-Idi-lMA4AORzeGDPPrk8BCQ9e5V9MAaM,1461
3
- shadowPaySDK/const.py,sha256=E-w8fivcd-yeHmpOpDAwTIP5FvsArFBHNWbhJ5K01yw,10386
4
- shadowPaySDK/interface/__init__.py,sha256=ggSZCV22udnzXm_Wv_3x6VN3hNIAEiwgwHZc2Jwc688,146
5
- shadowPaySDK/interface/erc20.py,sha256=R5i8EQ5CVydd8qZq4h4WS5BclntTd6-AOmdyJLePNKU,4745
6
- shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
7
- shadowPaySDK/interface/sol.py,sha256=TDp62OtQkR8Wy9I4UBVmL_K_FQeMVS--Lojgbvq5T2E,8146
8
- shadowPaySDK/types/EVMcheque.py,sha256=KRhf4DtscDI2kJ2V5qnAv-lQDUrGzt3FvjWsgfr0vuU,15186
9
- shadowPaySDK/types/SOLcheque.py,sha256=h1u-VaIhdb5hFWScdePCQDeDhIyyFhKgtZWmZ8vckh4,11991
10
- shadowPaySDK/types/__init__.py,sha256=sG6pNZfKGvENXqsnv6MrQtKrJ898fAXkMvAZY1k1-Qg,97
11
- shadowPaySDK/utils/__init__.py,sha256=aja3iYO4rT-ptMM-pzw0GRFTziBdXdcEi-4kE84zH64,61
12
- shadowPaySDK/utils/utils.py,sha256=g4bGvLDdjhNGsAj1eaZnNWFNaiN-cVhhM-5PrnG5aIQ,720
13
- shadowpaysdk-16.7.2025.5.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
- shadowpaysdk-16.7.2025.5.dist-info/METADATA,sha256=vFglFPN39_474TJjm-HZm2kOT_MZAfUzDf5XR4Z2gIc,1046
15
- shadowpaysdk-16.7.2025.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- shadowpaysdk-16.7.2025.5.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
- shadowpaysdk-16.7.2025.5.dist-info/RECORD,,