shadowPaySDK 16.7.2025__py3-none-any.whl → 16.7.2025.5__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.
shadowPaySDK/const.py CHANGED
@@ -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("""[
@@ -53,13 +53,13 @@ class ERC20Token:
53
53
  ).call()
54
54
  return raw / (10 ** self.get_decimals())
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()
@@ -87,7 +87,7 @@ class ERC20Token:
87
87
  tx_hash = self.web3.eth.send_raw_transaction(signed.raw_transaction)
88
88
  return self._format_tx(self.web3.to_hex(tx_hash))
89
89
 
90
- def approve(self, spender: str, amount: float,address:Optional[str] = None, private_key: Optional[str] = None, build_tx: bool = False) -> str:
90
+ def approve(self, spender: str, amount: float,address:Optional[str] = None, private_key: Optional[str] = None, conveted_amount: bool = True) -> str:
91
91
 
92
92
  self._ensure_contract()
93
93
  key = private_key
@@ -99,10 +99,10 @@ class ERC20Token:
99
99
  address = Web3.to_checksum_address(self.address)
100
100
  else:
101
101
  raise ValueError("No private key or address provided")
102
-
103
- decimals = self.get_decimals()
104
- amount = int(amount * (10 ** decimals))
105
-
102
+ if conveted_amount:
103
+ decimals = self.get_decimals()
104
+ amount = int(amount * (10 ** decimals))
105
+
106
106
  txn = self.contract.functions.approve(
107
107
  Web3.to_checksum_address(spender),
108
108
  amount
@@ -113,8 +113,7 @@ class ERC20Token:
113
113
 
114
114
  'gasPrice': self.web3.eth.gas_price,
115
115
  })
116
- if build_tx:
117
- return txn
116
+
118
117
 
119
118
  signed = self.web3.eth.account.sign_transaction(txn, key)
120
119
  tx_hash = self.web3.eth.send_raw_transaction(signed.raw_transaction)
@@ -54,7 +54,14 @@ class Cheque:
54
54
  self.contract = contract
55
55
  return contract
56
56
  raise ValueError(f"Chain {chain_id} is not supported. Supported chains are: {list(__SHADOWPAY_CONTRACT_ADDRESS__ERC20__.keys())}")
57
-
57
+ async def get_address(self):
58
+ if self.address:
59
+ return self.address
60
+ elif self.w3:
61
+ return self.w3.eth.default_account
62
+ else:
63
+ raise ValueError("No address provided or Web3 instance is not set")
64
+
58
65
  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
66
  if w3:
60
67
  self.w3 = w3
@@ -63,6 +70,7 @@ class Cheque:
63
70
  self.amount = amount
64
71
  if private_key:
65
72
  self.private_key = private_key
73
+ self.address = Web3.to_checksum_address(self.w3.eth.account.from_key(private_key).address)
66
74
  if token:
67
75
  self.token = token
68
76
  if address:
@@ -167,8 +175,8 @@ class Cheque:
167
175
  return False
168
176
  return {
169
177
  "hash": tx_hash.hex()
170
- }
171
-
178
+ }
179
+
172
180
  async def InitTokenCheque(self, token_address:str, amount, reciver:str, private_key:Optional[str] = None):
173
181
  key = private_key or self.private_key
174
182
 
@@ -333,11 +341,19 @@ class Cheque:
333
341
  amount_out = swapDetail["amountOut"]
334
342
  erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
335
343
  erc20.set_params(token_address=token_out)
336
- encure_allowance = erc20.ensure_allowance(
337
- private_key=private_key,
344
+ encure_allowance = erc20.allowance(
338
345
  spender=self.contract.address,
339
- amount=amount_out,
346
+ owner=self.address,
340
347
  )
348
+ if encure_allowance < amount_out:
349
+ approve = erc20.approve(
350
+ spender=self.contract.address,
351
+ amount=amount_out,
352
+ private_key=private_key,
353
+ conveted_amount=False
354
+ )
355
+ if not approve:
356
+ return False
341
357
  estimated_gas = self.contract.functions.CashOutSwapCheque(
342
358
  Web3.to_bytes(hexstr=cheque_id)
343
359
  ).estimate_gas({
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 16.7.2025
3
+ Version: 16.7.2025.5
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,17 +1,17 @@
1
1
  shadowPaySDK/__init__.py,sha256=CMwAuP_6hJN-WueU-XlTNta9Oyd28sFo8OojdgD_pxA,681
2
2
  shadowPaySDK/api.py,sha256=cv5Z171cOh-Idi-lMA4AORzeGDPPrk8BCQ9e5V9MAaM,1461
3
- shadowPaySDK/const.py,sha256=dIifSDi2SEW7W3e-Z1nG3TwpAqPNnXvnFipGP0cgPwE,10318
3
+ shadowPaySDK/const.py,sha256=E-w8fivcd-yeHmpOpDAwTIP5FvsArFBHNWbhJ5K01yw,10386
4
4
  shadowPaySDK/interface/__init__.py,sha256=ggSZCV22udnzXm_Wv_3x6VN3hNIAEiwgwHZc2Jwc688,146
5
- shadowPaySDK/interface/erc20.py,sha256=7p8eU5LzhI2MsH80PZhq6IRhbfMGlNYucGl3OtyS9SI,4669
5
+ shadowPaySDK/interface/erc20.py,sha256=R5i8EQ5CVydd8qZq4h4WS5BclntTd6-AOmdyJLePNKU,4745
6
6
  shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
7
7
  shadowPaySDK/interface/sol.py,sha256=TDp62OtQkR8Wy9I4UBVmL_K_FQeMVS--Lojgbvq5T2E,8146
8
- shadowPaySDK/types/EVMcheque.py,sha256=8M1EzpZGqf4uidrd9yDKiR7BvIl85p93A_9AMZtshSs,14570
8
+ shadowPaySDK/types/EVMcheque.py,sha256=KRhf4DtscDI2kJ2V5qnAv-lQDUrGzt3FvjWsgfr0vuU,15186
9
9
  shadowPaySDK/types/SOLcheque.py,sha256=h1u-VaIhdb5hFWScdePCQDeDhIyyFhKgtZWmZ8vckh4,11991
10
10
  shadowPaySDK/types/__init__.py,sha256=sG6pNZfKGvENXqsnv6MrQtKrJ898fAXkMvAZY1k1-Qg,97
11
11
  shadowPaySDK/utils/__init__.py,sha256=aja3iYO4rT-ptMM-pzw0GRFTziBdXdcEi-4kE84zH64,61
12
12
  shadowPaySDK/utils/utils.py,sha256=g4bGvLDdjhNGsAj1eaZnNWFNaiN-cVhhM-5PrnG5aIQ,720
13
- shadowpaysdk-16.7.2025.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
- shadowpaysdk-16.7.2025.dist-info/METADATA,sha256=tQhhhmL8EhfnqO_BkjBfAGFmKVccigApYJaVNJ8wZL8,1044
15
- shadowpaysdk-16.7.2025.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- shadowpaysdk-16.7.2025.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
- shadowpaysdk-16.7.2025.dist-info/RECORD,,
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,,