shadowPaySDK 0.2.0.14__py3-none-any.whl → 0.2.0.16__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.
@@ -6,7 +6,7 @@ from shadowPaySDK.const import __ERC20_ABI__
6
6
 
7
7
 
8
8
  class ERC20Token:
9
- def __init__(self, w3:Web3, explorer: Optional[str] = None):
9
+ def __init__(self, w3: Optional[Web3] = None, explorer: Optional[str] = None):
10
10
  self.web3 = w3
11
11
  self.explorer = explorer
12
12
 
@@ -87,9 +87,19 @@ 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, private_key: str, spender: str, amount: float) -> str:
90
+ def approve(self, spender: str, amount: float,address:Optional[str] = None, private_key: Optional[str] = None, build_tx: bool = False) -> str:
91
+
91
92
  self._ensure_contract()
92
- account = self.web3.eth.account.from_key(private_key)
93
+ key = private_key
94
+
95
+ if key:
96
+ address = Web3.to_checksum_address(self.web3.eth.account.from_key(key).address)
97
+
98
+ elif self.address:
99
+ address = Web3.to_checksum_address(self.address)
100
+ else:
101
+ raise ValueError("No private key or address provided")
102
+
93
103
  decimals = self.get_decimals()
94
104
  amount = int(amount * (10 ** decimals))
95
105
 
@@ -97,14 +107,16 @@ class ERC20Token:
97
107
  Web3.to_checksum_address(spender),
98
108
  amount
99
109
  ).build_transaction({
100
- 'from': account.address,
101
- 'nonce': self.web3.eth.get_transaction_count(account.address),
110
+ 'from': address,
111
+ 'nonce': self.web3.eth.get_transaction_count(address),
102
112
  'gas': 60000,
103
113
 
104
114
  'gasPrice': self.web3.eth.gas_price,
105
115
  })
116
+ if build_tx:
117
+ return txn
106
118
 
107
- signed = self.web3.eth.account.sign_transaction(txn, private_key)
119
+ signed = self.web3.eth.account.sign_transaction(txn, key)
108
120
  tx_hash = self.web3.eth.send_raw_transaction(signed.raw_transaction)
109
121
  tx_receipt = self.web3.eth.wait_for_transaction_receipt(tx_hash)
110
122
  if tx_receipt.status != 1:
@@ -21,6 +21,13 @@ class Cheque:
21
21
  self.__allow__()
22
22
 
23
23
  def __get__id(self, tx):
24
+ if isinstance(tx, str):
25
+ try:
26
+ tx = self.w3.eth.get_transaction_receipt(tx)
27
+ except Exception as e:
28
+ print(f"Failed to get transaction receipt: {str(e)}")
29
+ return False
30
+
24
31
  try:
25
32
  logs = self.contract.events.ChequeCreated().process_receipt(tx)
26
33
  cheque_id = logs[0]["args"]["id"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 0.2.0.14
3
+ Version: 0.2.0.16
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=CMwAuP_6hJN-WueU-XlTNta9Oyd28sFo8OojdgD_pxA,681
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=ggSZCV22udnzXm_Wv_3x6VN3hNIAEiwgwHZc2Jwc688,146
5
- shadowPaySDK/interface/erc20.py,sha256=TIsek7ykuYsLMj5no-uastA5gYsIbk-F_Dq-5XPk_6w,4298
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=mRbMGdOiCmOrdJRSOfr-Nzxx79zJbgZON1_bXPm5Ufk,14204
8
+ shadowPaySDK/types/EVMcheque.py,sha256=aomYsyQdvLMGEc3VHppVaBABQR55lQYUc0OoHgW81OE,14449
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.14.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
- shadowpaysdk-0.2.0.14.dist-info/METADATA,sha256=m1FKgVr6Msedt4GRI0k4CdhAqClxVPAa7fgtSOI5zj4,840
15
- shadowpaysdk-0.2.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- shadowpaysdk-0.2.0.14.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
- shadowpaysdk-0.2.0.14.dist-info/RECORD,,
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,,