shadowPaySDK 0.2.0.3__py3-none-any.whl → 0.2.0.4__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/interface/erc20.py +8 -7
- {shadowpaysdk-0.2.0.3.dist-info → shadowpaysdk-0.2.0.4.dist-info}/METADATA +1 -1
- {shadowpaysdk-0.2.0.3.dist-info → shadowpaysdk-0.2.0.4.dist-info}/RECORD +6 -6
- {shadowpaysdk-0.2.0.3.dist-info → shadowpaysdk-0.2.0.4.dist-info}/WHEEL +0 -0
- {shadowpaysdk-0.2.0.3.dist-info → shadowpaysdk-0.2.0.4.dist-info}/licenses/LICENSE +0 -0
- {shadowpaysdk-0.2.0.3.dist-info → shadowpaysdk-0.2.0.4.dist-info}/top_level.txt +0 -0
shadowPaySDK/interface/erc20.py
CHANGED
@@ -9,6 +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
|
self.address = None
|
13
14
|
self.contract = None
|
14
15
|
|
@@ -21,7 +22,7 @@ class ERC20Token:
|
|
21
22
|
|
22
23
|
def _ensure_contract(self):
|
23
24
|
if not self.contract:
|
24
|
-
raise ValueError("Token address is not set. Use
|
25
|
+
raise ValueError("Token address is not set. Use set_params first.")
|
25
26
|
|
26
27
|
def _format_tx(self, tx_hash: str) -> str:
|
27
28
|
if self.explorer:
|
@@ -44,7 +45,7 @@ class ERC20Token:
|
|
44
45
|
raw = self.contract.functions.balanceOf(Web3.to_checksum_address(wallet_address)).call()
|
45
46
|
return raw / (10 ** self.get_decimals())
|
46
47
|
|
47
|
-
def allowance(self, owner: str, spender: str
|
48
|
+
def allowance(self, owner: str, spender: str) -> float:
|
48
49
|
self._ensure_contract()
|
49
50
|
raw = self.contract.functions.allowance(
|
50
51
|
Web3.to_checksum_address(owner),
|
@@ -52,13 +53,13 @@ class ERC20Token:
|
|
52
53
|
).call()
|
53
54
|
return raw / (10 ** self.get_decimals())
|
54
55
|
|
55
|
-
def ensure_allowance(self, private_key: str, spender: str, amount
|
56
|
+
def ensure_allowance(self, private_key: str, spender: str, amount) -> Union[bool, str]:
|
56
57
|
self._ensure_contract()
|
57
58
|
account = self.web3.eth.account.from_key(private_key)
|
58
|
-
current = self.allowance(account.address, spender
|
59
|
+
current = self.allowance(account.address, spender)
|
59
60
|
if current == amount:
|
60
61
|
return True
|
61
|
-
return self.approve(private_key, spender, amount
|
62
|
+
return self.approve(private_key, spender, amount)
|
62
63
|
|
63
64
|
def transfer(self, private_key: str, to: str, amount: float) -> str:
|
64
65
|
self._ensure_contract()
|
@@ -86,10 +87,10 @@ class ERC20Token:
|
|
86
87
|
tx_hash = self.web3.eth.send_raw_transaction(signed.raw_transaction)
|
87
88
|
return self._format_tx(self.web3.to_hex(tx_hash))
|
88
89
|
|
89
|
-
def approve(self, private_key: str, spender: str, amount: float
|
90
|
+
def approve(self, private_key: str, spender: str, amount: float) -> str:
|
90
91
|
self._ensure_contract()
|
91
92
|
account = self.web3.eth.account.from_key(private_key)
|
92
|
-
decimals = self.get_decimals(
|
93
|
+
decimals = self.get_decimals()
|
93
94
|
amount = int(amount * (10 ** decimals))
|
94
95
|
|
95
96
|
txn = self.contract.functions.approve(
|
@@ -2,7 +2,7 @@ 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=
|
5
|
+
shadowPaySDK/interface/erc20.py,sha256=FJa0HPylM9YhToFnWdKw4Bfv2vv0U0C9rhOG0CZfR3Y,4315
|
6
6
|
shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
|
7
7
|
shadowPaySDK/interface/sol.py,sha256=xgJZsg4xE-_dRctGUW_mHuGj_o_0OlKNp4Gr7IXvTEc,5586
|
8
8
|
shadowPaySDK/types/EVMcheque.py,sha256=S1ZioFeRisSvw42LYaA3_uWEqaTqz6jIxf45EFVrrnQ,11999
|
@@ -10,8 +10,8 @@ shadowPaySDK/types/SOLcheque.py,sha256=gmivsCK4hm_6pzQ9whPGuQ_f7qfcUfiJfQgb5ZsJY
|
|
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
|
-
shadowpaysdk-0.2.0.
|
15
|
-
shadowpaysdk-0.2.0.
|
16
|
-
shadowpaysdk-0.2.0.
|
17
|
-
shadowpaysdk-0.2.0.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|