shadowPaySDK 0.2.0.14__tar.gz → 0.2.0.16__tar.gz

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.
Files changed (22) hide show
  1. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/PKG-INFO +1 -1
  2. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/setup.py +1 -1
  3. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/interface/erc20.py +18 -6
  4. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/types/EVMcheque.py +7 -0
  5. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK.egg-info/PKG-INFO +1 -1
  6. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/LICENSE +0 -0
  7. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/README.md +0 -0
  8. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/setup.cfg +0 -0
  9. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/__init__.py +0 -0
  10. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/api.py +0 -0
  11. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/const.py +0 -0
  12. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/interface/__init__.py +0 -0
  13. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/interface/erc721.py +0 -0
  14. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/interface/sol.py +0 -0
  15. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/types/SOLcheque.py +0 -0
  16. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/types/__init__.py +0 -0
  17. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/utils/__init__.py +0 -0
  18. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK/utils/utils.py +0 -0
  19. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK.egg-info/SOURCES.txt +0 -0
  20. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
  21. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK.egg-info/requires.txt +0 -0
  22. {shadowpaysdk-0.2.0.14 → shadowpaysdk-0.2.0.16}/shadowPaySDK.egg-info/top_level.txt +0 -0
@@ -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,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='shadowPaySDK',
5
- version='0.2.0.14',
5
+ version='0.2.0.16',
6
6
  description='ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction',
7
7
  long_description=open('README.md').read(),
8
8
  long_description_content_type='text/markdown',
@@ -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
File without changes