shadowPaySDK 0.2.0.2__tar.gz → 0.2.0.3__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.
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/PKG-INFO +1 -1
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/setup.py +1 -1
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/interface/erc20.py +3 -4
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/types/EVMcheque.py +14 -18
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK.egg-info/PKG-INFO +1 -1
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/LICENSE +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/README.md +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/setup.cfg +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/__init__.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/api.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/const.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/interface/__init__.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/interface/erc721.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/interface/sol.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/types/SOLcheque.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/types/__init__.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/utils/__init__.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK/utils/utils.py +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK.egg-info/SOURCES.txt +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK.egg-info/requires.txt +0 -0
- {shadowpaysdk-0.2.0.2 → shadowpaysdk-0.2.0.3}/shadowPaySDK.egg-info/top_level.txt +0 -0
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='shadowPaySDK',
|
5
|
-
version='0.2.0.
|
5
|
+
version='0.2.0.3',
|
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',
|
@@ -30,10 +30,9 @@ class ERC20Token:
|
|
30
30
|
def gen_wallet(self) -> str:
|
31
31
|
account = self.web3.eth.account.create()
|
32
32
|
return account
|
33
|
-
def get_decimals(self
|
33
|
+
def get_decimals(self) -> int:
|
34
34
|
self._ensure_contract()
|
35
|
-
|
36
|
-
self.set_params(token_address=token)
|
35
|
+
|
37
36
|
return self.contract.functions.decimals().call()
|
38
37
|
|
39
38
|
def get_symbol(self) -> str:
|
@@ -51,7 +50,7 @@ class ERC20Token:
|
|
51
50
|
Web3.to_checksum_address(owner),
|
52
51
|
Web3.to_checksum_address(spender)
|
53
52
|
).call()
|
54
|
-
return raw / (10 ** self.get_decimals(
|
53
|
+
return raw / (10 ** self.get_decimals())
|
55
54
|
|
56
55
|
def ensure_allowance(self, private_key: str, spender: str, amount, token) -> Union[bool, str]:
|
57
56
|
self._ensure_contract()
|
@@ -112,42 +112,42 @@ class Cheque:
|
|
112
112
|
sender_address = account.address
|
113
113
|
|
114
114
|
|
115
|
-
|
116
|
-
nonce = self.eth.get_transaction_count(sender_address)
|
115
|
+
nonce = self.w3.eth.get_transaction_count(sender_address)
|
117
116
|
|
118
117
|
txn = self.contract.functions.CashOutCheque(
|
119
118
|
Web3.to_bytes(hexstr=cheque_id)).build_transaction({
|
120
119
|
'from': sender_address,
|
121
120
|
'nonce': nonce,
|
122
|
-
'gas': 300_000,
|
121
|
+
'gas': 300_000,
|
123
122
|
'gasPrice': self.w3.to_wei('5', 'gwei'),
|
124
123
|
})
|
125
124
|
|
126
|
-
# подписываем
|
127
125
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
|
128
126
|
|
129
|
-
|
127
|
+
|
130
128
|
tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
131
129
|
|
132
|
-
print(f"⏳ Transaction sent: {tx_hash.hex()}")
|
133
130
|
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
|
134
|
-
print(f"✅ Transaction confirmed in block {receipt.blockNumber}")
|
135
131
|
if receipt.status != 1:
|
136
132
|
return False
|
137
|
-
return
|
133
|
+
return {
|
134
|
+
"hash": tx_hash.hex()
|
135
|
+
}
|
138
136
|
|
139
137
|
async def InitTokenCheque(self, token_address:str, amount, reciver:str, private_key:Optional[str] = None):
|
140
138
|
|
141
139
|
|
142
140
|
erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
|
143
141
|
erc20.set_params(token_address=token_address)
|
144
|
-
|
142
|
+
decimals = erc20.get_decimals(
|
143
|
+
token_address
|
144
|
+
)
|
145
|
+
erc20.ensure_allowance(
|
145
146
|
private_key=self.private_key,
|
146
147
|
spender=self.contract.address,
|
147
|
-
amount=amount
|
148
|
+
amount=amount,
|
149
|
+
token=token_address
|
148
150
|
)
|
149
|
-
print(f"Ensure allowance: {ensure_allowance}")
|
150
|
-
decimals = erc20.get_decimals()
|
151
151
|
estimated_gas = self.contract.functions.InitTokenCheque(
|
152
152
|
Web3.to_checksum_address(token_address),
|
153
153
|
int(amount * (10 ** decimals)),
|
@@ -190,9 +190,8 @@ class Cheque:
|
|
190
190
|
|
191
191
|
|
192
192
|
|
193
|
-
# Строим транзакцию
|
194
193
|
estimated_gas = self.contract.functions.CashOutTokenCheque(
|
195
|
-
Web3.to_bytes(hexstr=cheque_id)
|
194
|
+
Web3.to_bytes(hexstr=cheque_id)
|
196
195
|
).estimate_gas({
|
197
196
|
'from': account.address,
|
198
197
|
'gasPrice': self.w3.eth.gas_price
|
@@ -206,11 +205,9 @@ class Cheque:
|
|
206
205
|
'gasPrice': self.w3.eth.gas_price,
|
207
206
|
})
|
208
207
|
|
209
|
-
# Подписываем и отправляем транзакцию
|
210
208
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
|
211
209
|
tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
212
210
|
|
213
|
-
# Получаем подтверждение
|
214
211
|
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
|
215
212
|
|
216
213
|
if receipt.status != 1:
|
@@ -223,13 +220,12 @@ class Cheque:
|
|
223
220
|
|
224
221
|
erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
|
225
222
|
erc20.set_params(token_address=token_in)
|
226
|
-
|
223
|
+
approve = erc20.approve(
|
227
224
|
private_key=self.private_key,
|
228
225
|
spender=self.contract.address,
|
229
226
|
amount=amount_in,
|
230
227
|
token=token_in
|
231
228
|
)
|
232
|
-
print(f"Ensure allowance: {ensure_allowance}")
|
233
229
|
decimals = erc20.get_decimals(token_in)
|
234
230
|
token_out_decinals = erc20.get_decimals(token_out)
|
235
231
|
estimated_gas = self.contract.functions.InitSwapCheque(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|