shadowPaySDK 0.2.0.2__py3-none-any.whl → 0.2.0.3__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.
@@ -30,10 +30,9 @@ class ERC20Token:
30
30
  def gen_wallet(self) -> str:
31
31
  account = self.web3.eth.account.create()
32
32
  return account
33
- def get_decimals(self, token) -> int:
33
+ def get_decimals(self) -> int:
34
34
  self._ensure_contract()
35
- if token:
36
- self.set_params(token_address=token)
35
+
37
36
  return self.contract.functions.decimals().call()
38
37
 
39
38
  def get_symbol(self) -> str:
@@ -51,7 +50,7 @@ class ERC20Token:
51
50
  Web3.to_checksum_address(owner),
52
51
  Web3.to_checksum_address(spender)
53
52
  ).call()
54
- return raw / (10 ** self.get_decimals(token))
53
+ return raw / (10 ** self.get_decimals())
55
54
 
56
55
  def ensure_allowance(self, private_key: str, spender: str, amount, token) -> Union[bool, str]:
57
56
  self._ensure_contract()
@@ -112,42 +112,42 @@ class Cheque:
112
112
  sender_address = account.address
113
113
 
114
114
 
115
- # подготовка транзакции
116
- nonce = self.eth.get_transaction_count(sender_address)
115
+ nonce = self.w3.eth.get_transaction_count(sender_address)
117
116
 
118
117
  txn = self.contract.functions.CashOutCheque(
119
118
  Web3.to_bytes(hexstr=cheque_id)).build_transaction({
120
119
  'from': sender_address,
121
120
  'nonce': nonce,
122
- 'gas': 300_000, # пример
121
+ 'gas': 300_000,
123
122
  'gasPrice': self.w3.to_wei('5', 'gwei'),
124
123
  })
125
124
 
126
- # подписываем
127
125
  signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
128
126
 
129
- # отправляем
127
+
130
128
  tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
131
129
 
132
- print(f"⏳ Transaction sent: {tx_hash.hex()}")
133
130
  receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
134
- print(f"✅ Transaction confirmed in block {receipt.blockNumber}")
135
131
  if receipt.status != 1:
136
132
  return False
137
- return receipt
133
+ return {
134
+ "hash": tx_hash.hex()
135
+ }
138
136
 
139
137
  async def InitTokenCheque(self, token_address:str, amount, reciver:str, private_key:Optional[str] = None):
140
138
 
141
139
 
142
140
  erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
143
141
  erc20.set_params(token_address=token_address)
144
- ensure_allowance = erc20.ensure_allowance(
142
+ decimals = erc20.get_decimals(
143
+ token_address
144
+ )
145
+ erc20.ensure_allowance(
145
146
  private_key=self.private_key,
146
147
  spender=self.contract.address,
147
- amount=amount
148
+ amount=amount,
149
+ token=token_address
148
150
  )
149
- print(f"Ensure allowance: {ensure_allowance}")
150
- decimals = erc20.get_decimals()
151
151
  estimated_gas = self.contract.functions.InitTokenCheque(
152
152
  Web3.to_checksum_address(token_address),
153
153
  int(amount * (10 ** decimals)),
@@ -190,9 +190,8 @@ class Cheque:
190
190
 
191
191
 
192
192
 
193
- # Строим транзакцию
194
193
  estimated_gas = self.contract.functions.CashOutTokenCheque(
195
- Web3.to_bytes(hexstr=cheque_id) # Преобразуем строку в bytes32
194
+ Web3.to_bytes(hexstr=cheque_id)
196
195
  ).estimate_gas({
197
196
  'from': account.address,
198
197
  'gasPrice': self.w3.eth.gas_price
@@ -206,11 +205,9 @@ class Cheque:
206
205
  'gasPrice': self.w3.eth.gas_price,
207
206
  })
208
207
 
209
- # Подписываем и отправляем транзакцию
210
208
  signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
211
209
  tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
212
210
 
213
- # Получаем подтверждение
214
211
  receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
215
212
 
216
213
  if receipt.status != 1:
@@ -223,13 +220,12 @@ class Cheque:
223
220
 
224
221
  erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
225
222
  erc20.set_params(token_address=token_in)
226
- ensure_allowance = erc20.approve(
223
+ approve = erc20.approve(
227
224
  private_key=self.private_key,
228
225
  spender=self.contract.address,
229
226
  amount=amount_in,
230
227
  token=token_in
231
228
  )
232
- print(f"Ensure allowance: {ensure_allowance}")
233
229
  decimals = erc20.get_decimals(token_in)
234
230
  token_out_decinals = erc20.get_decimals(token_out)
235
231
  estimated_gas = self.contract.functions.InitSwapCheque(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 0.2.0.2
3
+ Version: 0.2.0.3
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
5
  Author: dazarius_
6
6
  Author-email: your@email.com
@@ -2,16 +2,16 @@ shadowPaySDK/__init__.py,sha256=lV_L5SuQMPAt5XDkeZScJqLo43gtP-pNbsuErOSNOVw,727
2
2
  shadowPaySDK/api.py,sha256=cv5Z171cOh-Idi-lMA4AORzeGDPPrk8BCQ9e5V9MAaM,1461
3
3
  shadowPaySDK/const.py,sha256=T7TJPKFLqCtxwpUYO1AOryGMr65G-vVuotxfL8gWcME,9898
4
4
  shadowPaySDK/interface/__init__.py,sha256=QceU3dWteSgwvMnR3JDVdmS8OgdRPjvl9JzRs7IsA74,152
5
- shadowPaySDK/interface/erc20.py,sha256=UpmO8OVkXS5zUPB002KT2bbsuTO8GwGTlusw1aTYNtg,4444
5
+ shadowPaySDK/interface/erc20.py,sha256=2U-1Kp13D4wcl4WucgI0X8ujBu7hWx9nuQsRzqqn2ZY,4366
6
6
  shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
7
7
  shadowPaySDK/interface/sol.py,sha256=xgJZsg4xE-_dRctGUW_mHuGj_o_0OlKNp4Gr7IXvTEc,5586
8
- shadowPaySDK/types/EVMcheque.py,sha256=7GXS0oPG6xIDLz-Uuzkub-Uv0oLbOeVFLiVtFflcUgc,12514
8
+ shadowPaySDK/types/EVMcheque.py,sha256=S1ZioFeRisSvw42LYaA3_uWEqaTqz6jIxf45EFVrrnQ,11999
9
9
  shadowPaySDK/types/SOLcheque.py,sha256=gmivsCK4hm_6pzQ9whPGuQ_f7qfcUfiJfQgb5ZsJYDo,884
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-0.2.0.2.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
- shadowpaysdk-0.2.0.2.dist-info/METADATA,sha256=GkNvFIwdkxvr9CWQNVyzYgd2Q-aNzU9OwiitCGY5MSE,839
15
- shadowpaysdk-0.2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- shadowpaysdk-0.2.0.2.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
- shadowpaysdk-0.2.0.2.dist-info/RECORD,,
13
+ shadowpaysdk-0.2.0.3.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
+ shadowpaysdk-0.2.0.3.dist-info/METADATA,sha256=g1KOjBBVHg1QRtpPfAxj03UsNvGgdUnNVFnuExd6O58,839
15
+ shadowpaysdk-0.2.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ shadowpaysdk-0.2.0.3.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
+ shadowpaysdk-0.2.0.3.dist-info/RECORD,,