shadowPaySDK 0.2.0.16__py3-none-any.whl → 0.2.0.18__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
@@ -30,7 +30,7 @@ __ERC20_ABI__ = json.loads("""[
30
30
  ]""")
31
31
 
32
32
  __SHADOWPAY_CONTRACT_ADDRESS__ERC20__ = {
33
- 97: "0x17a82E53a3b3f2acA7ceae8CA6B6b3B8F14e4441"
33
+ 97: "0x5487C0DdCbD5465F26B446c6CAB88D8d6F7DF23b"
34
34
  }
35
35
 
36
36
  __SHADOWPAY_ABI__ERC20__= json.loads("""[
@@ -20,7 +20,7 @@ class Cheque:
20
20
  if self.w3 != None:
21
21
  self.__allow__()
22
22
 
23
- def __get__id(self, tx):
23
+ def get_id(self, tx):
24
24
  if isinstance(tx, str):
25
25
  try:
26
26
  tx = self.w3.eth.get_transaction_receipt(tx)
@@ -111,11 +111,11 @@ class Cheque:
111
111
  "build_tx": txn
112
112
  }
113
113
 
114
- signed_txn = self.w3.eth.account.sign_transaction(txn, private_key or self.private_key)
114
+ signed_txn = self.w3.eth.account.sign_transaction(txn, key)
115
115
  txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
116
116
  txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
117
117
  insert_to_dn = None
118
- logs = self.__get__id(txn_receipt)
118
+ logs = self.get_id(txn_receipt)
119
119
  if logs:
120
120
  cheque_id = logs
121
121
  else:
@@ -170,22 +170,33 @@ class Cheque:
170
170
  }
171
171
 
172
172
  async def InitTokenCheque(self, token_address:str, amount, reciver:str, private_key:Optional[str] = None):
173
+ key = private_key or self.private_key
174
+
175
+ if key:
176
+ address = Web3.to_checksum_address(self.w3.eth.account.from_key(key).address)
173
177
 
178
+ elif self.address:
179
+ address = Web3.to_checksum_address(self.address)
180
+ else:
181
+ raise ValueError("No private key or address provided")
182
+
183
+
184
+
185
+
174
186
 
175
187
  erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
176
188
  erc20.set_params(token_address=token_address)
177
189
  decimals = erc20.get_decimals()
178
- erc20.ensure_allowance(
179
- private_key=self.private_key,
190
+ erc20.allowance(
180
191
  spender=self.contract.address,
181
- amount=amount,
192
+ owner=address,
182
193
  )
183
194
  estimated_gas = self.contract.functions.InitTokenCheque(
184
195
  Web3.to_checksum_address(token_address),
185
196
  int(amount * (10 ** decimals)),
186
197
  Web3.to_checksum_address(reciver)
187
198
  ).estimate_gas({
188
- 'from': self.w3.eth.account.from_key(self.private_key).address,
199
+ 'from': address,
189
200
  'gasPrice': self.w3.eth.gas_price
190
201
  })
191
202
  txn = self.contract.functions.InitTokenCheque(
@@ -193,8 +204,8 @@ class Cheque:
193
204
  int(amount * (10 ** decimals)),
194
205
  Web3.to_checksum_address(reciver)
195
206
  ).build_transaction({
196
- 'from': self.w3.eth.account.from_key(self.private_key).address,
197
- 'nonce': self.w3.eth.get_transaction_count(self.w3.eth.account.from_key(self.private_key).address),
207
+ 'from': address,
208
+ 'nonce': self.w3.eth.get_transaction_count(address),
198
209
  'gas': estimated_gas,
199
210
  'gasPrice': self.w3.eth.gas_price
200
211
  })
@@ -202,11 +213,11 @@ class Cheque:
202
213
  return {
203
214
  "build_tx": txn
204
215
  }
205
- signed_txn = self.w3.eth.account.sign_transaction(txn, self.private_key)
216
+ signed_txn = self.w3.eth.account.sign_transaction(txn, key)
206
217
  txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
207
218
  txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
208
219
 
209
- logs = self.__get__id(txn_receipt)
220
+ logs = self.get_id(txn_receipt)
210
221
  if logs:
211
222
  cheque_id = logs
212
223
  else:
@@ -257,10 +268,14 @@ class Cheque:
257
268
  "status": receipt.status # 1 = success, 0 = fail
258
269
  }
259
270
  async def InitTokenChequeSwap(self, token_in:str, amount_in,token_out:str, amount_out, reciver:str, private_key:Optional[str] = None):
260
-
271
+ key = private_key or self.private_key
272
+ if key:
273
+ address = Web3.to_checksum_address(self.w3.eth.account.from_key(key).address)
274
+ elif self.address:
275
+ address = Web3.to_checksum_address(self.address)
261
276
  erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
262
277
  erc20.set_params(token_address=token_in)
263
- approve = erc20.approve(
278
+ approve = erc20.allowance(
264
279
  private_key=self.private_key,
265
280
  spender=self.contract.address,
266
281
  amount=amount_in,
@@ -298,7 +313,7 @@ class Cheque:
298
313
  txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
299
314
  txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
300
315
 
301
- logs = self.__get__id(txn_receipt)
316
+ logs = self.get_id(txn_receipt)
302
317
  if logs:
303
318
  cheque_id = logs
304
319
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 0.2.0.16
3
+ Version: 0.2.0.18
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
5
  Author: 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=T7TJPKFLqCtxwpUYO1AOryGMr65G-vVuotxfL8gWcME,9898
3
+ shadowPaySDK/const.py,sha256=uUkzYTm-12iK3IsnQICnoT9tpmZ9aYh3pqXbSd-GNh8,9898
4
4
  shadowPaySDK/interface/__init__.py,sha256=ggSZCV22udnzXm_Wv_3x6VN3hNIAEiwgwHZc2Jwc688,146
5
5
  shadowPaySDK/interface/erc20.py,sha256=7p8eU5LzhI2MsH80PZhq6IRhbfMGlNYucGl3OtyS9SI,4669
6
6
  shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
7
7
  shadowPaySDK/interface/sol.py,sha256=flMfmW14J4ybfVshUUTw6iklKa5x-zJzjxRi011XKXA,7230
8
- shadowPaySDK/types/EVMcheque.py,sha256=aomYsyQdvLMGEc3VHppVaBABQR55lQYUc0OoHgW81OE,14449
8
+ shadowPaySDK/types/EVMcheque.py,sha256=3Nzj-61dWKWG_6lcqR1n24gVqhDb3qt-e_jZ_UceWrg,14765
9
9
  shadowPaySDK/types/SOLcheque.py,sha256=S6LnKxiWDj1KGRgFFAaHy03c7mxv4msaR-2cfVIhD2Y,818
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.16.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
- shadowpaysdk-0.2.0.16.dist-info/METADATA,sha256=_ejaWKCyHhZz8tQ7X99KuAMjjbo8CbY0f8z_GREBoGo,840
15
- shadowpaysdk-0.2.0.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- shadowpaysdk-0.2.0.16.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
- shadowpaysdk-0.2.0.16.dist-info/RECORD,,
13
+ shadowpaysdk-0.2.0.18.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
+ shadowpaysdk-0.2.0.18.dist-info/METADATA,sha256=7n5ROtuI7gEUvNAHnlkQKxtux-owZebiyzFWjTKV6x8,840
15
+ shadowpaysdk-0.2.0.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ shadowpaysdk-0.2.0.18.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
+ shadowpaysdk-0.2.0.18.dist-info/RECORD,,