shadowPaySDK 0.2.0.4__py3-none-any.whl → 0.2.0.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.
@@ -9,7 +9,7 @@ class ERC20Token:
9
9
  def __init__(self, w3:Web3, explorer: Optional[str] = None):
10
10
  self.web3 = w3
11
11
  self.explorer = explorer
12
-
12
+
13
13
  self.address = None
14
14
  self.contract = None
15
15
 
@@ -109,5 +109,5 @@ class ERC20Token:
109
109
  tx_receipt = self.web3.eth.wait_for_transaction_receipt(tx_hash)
110
110
  if tx_receipt.status != 1:
111
111
  raise ValueError(f"aaprove fail.\n {self._format_tx(self.web3.to_hex(tx_hash))}")
112
- return f"approve: {self._format_tx(self.web3.to_hex(tx_hash))}"
112
+ return f"{self._format_tx(self.web3.to_hex(tx_hash))}"
113
113
 
@@ -139,14 +139,11 @@ class Cheque:
139
139
 
140
140
  erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
141
141
  erc20.set_params(token_address=token_address)
142
- decimals = erc20.get_decimals(
143
- token_address
144
- )
142
+ decimals = erc20.get_decimals()
145
143
  erc20.ensure_allowance(
146
144
  private_key=self.private_key,
147
145
  spender=self.contract.address,
148
146
  amount=amount,
149
- token=token_address
150
147
  )
151
148
  estimated_gas = self.contract.functions.InitTokenCheque(
152
149
  Web3.to_checksum_address(token_address),
@@ -224,10 +221,10 @@ class Cheque:
224
221
  private_key=self.private_key,
225
222
  spender=self.contract.address,
226
223
  amount=amount_in,
227
- token=token_in
228
224
  )
229
- decimals = erc20.get_decimals(token_in)
230
- token_out_decinals = erc20.get_decimals(token_out)
225
+ decimals = erc20.get_decimals()
226
+ erc20.set_params(token_address=token_out)
227
+ token_out_decinals = erc20.get_decimals()
231
228
  estimated_gas = self.contract.functions.InitSwapCheque(
232
229
  Web3.to_checksum_address(reciver),
233
230
  Web3.to_checksum_address(token_in),
@@ -265,6 +262,47 @@ class Cheque:
265
262
  "hash": txn_hash.hex(),
266
263
  "chequeId": cheque_id
267
264
  }
265
+
266
+ async def CashOutSwapCheque(self, cheque_id: str, private_key: Optional[str] = None):
267
+ swapDetail = await self.getSwaoDetail(cheque_id)
268
+ print(swapDetail)
269
+ if private_key is None:
270
+ private_key = self.private_key
271
+ token_out = swapDetail["tokenOut"]
272
+ amount_out = swapDetail["amountOut"]
273
+ erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
274
+ erc20.set_params(token_address=token_out)
275
+ encure_allowance = erc20.ensure_allowance(
276
+ private_key=private_key,
277
+ spender=self.contract.address,
278
+ amount=amount_out,
279
+ )
280
+ estimated_gas = self.contract.functions.CashOutSwapCheque(
281
+ Web3.to_bytes(hexstr=cheque_id)
282
+ ).estimate_gas({
283
+ 'from': self.w3.eth.account.from_key(private_key).address,
284
+ 'gasPrice': self.w3.eth.gas_price
285
+ })
286
+ swa = self.contract.functions.CashOutSwapCheque(
287
+ Web3.to_bytes(hexstr=cheque_id)
288
+ ).build_transaction({
289
+ 'from': self.w3.eth.account.from_key(private_key).address,
290
+ 'nonce': self.w3.eth.get_transaction_count(self.w3.eth.account.from_key(private_key).address),
291
+ 'gas': 300_000,
292
+ 'gasPrice': self.w3.eth.gas_price
293
+ })
294
+ signed_txn = self.w3.eth.account.sign_transaction(swa, private_key=private_key)
295
+ tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
296
+ receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
297
+ if receipt.status != 1:
298
+ return False
299
+ return {
300
+ "hash": tx_hash.hex(),
301
+ }
302
+
303
+
304
+
305
+
268
306
  async def getComunityPool(self):
269
307
  # fee = self.contract.functions.getCollectedFee().call()
270
308
  fee = 50000000000000
@@ -276,7 +314,11 @@ class Cheque:
276
314
  return self.contract.functions.getTreasery().call()
277
315
  async def getSwaoDetail(self, cheque_id: str):
278
316
  cheque_id_bytes = Web3.to_bytes(hexstr=cheque_id)
279
- return self.contract.functions.getSwapDetail(cheque_id_bytes).call()
317
+ s = self.contract.functions.getSwapDetail(cheque_id_bytes).call()
318
+ return{
319
+ "tokenOut": s[0],
320
+ "amountOut": s[1],
321
+ }
280
322
  class NFTcheque:
281
323
  def __init__(self, w3:Web3, token:str, amount:int, spender:str):
282
324
  self.w3 = w3
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 0.2.0.4
3
+ Version: 0.2.0.6
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=FJa0HPylM9YhToFnWdKw4Bfv2vv0U0C9rhOG0CZfR3Y,4315
5
+ shadowPaySDK/interface/erc20.py,sha256=TIsek7ykuYsLMj5no-uastA5gYsIbk-F_Dq-5XPk_6w,4298
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=S1ZioFeRisSvw42LYaA3_uWEqaTqz6jIxf45EFVrrnQ,11999
8
+ shadowPaySDK/types/EVMcheque.py,sha256=QjWuIKztb7MqnzFT82L6kWcxDgAkBxpSMrZ2a2Voa34,13676
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.4.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
- shadowpaysdk-0.2.0.4.dist-info/METADATA,sha256=qrwJ82WymBrNjso33bbegjd0w-C1Ks-f88AW_Ozi3IY,839
15
- shadowpaysdk-0.2.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- shadowpaysdk-0.2.0.4.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
- shadowpaysdk-0.2.0.4.dist-info/RECORD,,
13
+ shadowpaysdk-0.2.0.6.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
+ shadowpaysdk-0.2.0.6.dist-info/METADATA,sha256=8wEskwIkgX06ppdMN2eOifUcgaVG0bhwbiT3VCqwZbM,839
15
+ shadowpaysdk-0.2.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ shadowpaysdk-0.2.0.6.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
+ shadowpaysdk-0.2.0.6.dist-info/RECORD,,