shadowPaySDK 0.2.0.9__tar.gz → 0.2.0.11__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.9 → shadowpaysdk-0.2.0.11}/PKG-INFO +1 -1
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/setup.py +1 -1
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/interface/sol.py +2 -4
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/types/EVMcheque.py +39 -27
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK.egg-info/PKG-INFO +1 -1
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/LICENSE +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/README.md +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/setup.cfg +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/__init__.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/api.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/const.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/interface/__init__.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/interface/erc20.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/interface/erc721.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/types/SOLcheque.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/types/__init__.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/utils/__init__.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK/utils/utils.py +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK.egg-info/SOURCES.txt +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/shadowPaySDK.egg-info/requires.txt +0 -0
- {shadowpaysdk-0.2.0.9 → shadowpaysdk-0.2.0.11}/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.11',
|
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',
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import asyncio
|
2
|
+
import solana
|
2
3
|
from solana.rpc.async_api import AsyncClient, GetTokenAccountsByOwnerResp
|
3
|
-
from
|
4
|
+
from solders.transaction import Transaction
|
4
5
|
from solders.system_program import TransferParams as p
|
5
6
|
import spl
|
6
7
|
import spl.token
|
@@ -203,6 +204,3 @@ class SOL:
|
|
203
204
|
|
204
205
|
|
205
206
|
|
206
|
-
if __name__ == "__main__":
|
207
|
-
newKeypair = solders.keypair.Keypair()
|
208
|
-
print("New Keypair:", newKeypair)
|
@@ -7,18 +7,19 @@ import httpx
|
|
7
7
|
|
8
8
|
|
9
9
|
class Cheque:
|
10
|
-
def __init__(self, w3:Optional[Web3] = None,private_key:Optional[str] = None, ABI = __SHADOWPAY_ABI__ERC20__, allowed_chains = __ALLOW_CHAINS__):
|
10
|
+
def __init__(self, w3:Optional[Web3] = None,private_key:Optional[str] = None, ABI = __SHADOWPAY_ABI__ERC20__, allowed_chains = __ALLOW_CHAINS__, retunrn_build_tx:bool = False,address:Optional[str] = None):
|
11
11
|
self.w3 = w3
|
12
12
|
|
13
13
|
self.amount = None
|
14
14
|
self.token = None
|
15
15
|
self.private_key = private_key
|
16
16
|
self.ABI = ABI
|
17
|
-
|
17
|
+
self.address = address
|
18
|
+
self.return_build_tx = retunrn_build_tx
|
18
19
|
self.allowed_chains = allowed_chains
|
19
20
|
if self.w3 != None:
|
20
21
|
self.__allow__()
|
21
|
-
|
22
|
+
|
22
23
|
def __get__id(self, tx):
|
23
24
|
try:
|
24
25
|
logs = self.contract.events.ChequeCreated().process_receipt(tx)
|
@@ -47,7 +48,7 @@ class Cheque:
|
|
47
48
|
return contract
|
48
49
|
raise ValueError(f"Chain {chain_id} is not supported. Supported chains are: {list(__SHADOWPAY_CONTRACT_ADDRESS__ERC20__.keys())}")
|
49
50
|
|
50
|
-
def set_parameters(self,chain_id: Optional[str] = None, w3:Optional[Web3] = None, amount:Optional[int] = None, private_key:Optional[str] = None, token:Optional[str] = None):
|
51
|
+
def set_parameters(self,chain_id: Optional[str] = None, w3:Optional[Web3] = None, amount:Optional[int] = None, private_key:Optional[str] = None, token:Optional[str] = None,address:Optional[str] = None):
|
51
52
|
if w3:
|
52
53
|
self.w3 = w3
|
53
54
|
self.get_contract_for_chain(chain_id=chain_id or self.w3.eth.chain_id)
|
@@ -57,6 +58,9 @@ class Cheque:
|
|
57
58
|
self.private_key = private_key
|
58
59
|
if token:
|
59
60
|
self.token = token
|
61
|
+
if address:
|
62
|
+
self.address = address
|
63
|
+
|
60
64
|
def __convert__(self):
|
61
65
|
return self.w3.to_wei(self.amount, 'ether')
|
62
66
|
|
@@ -71,15 +75,20 @@ class Cheque:
|
|
71
75
|
'gasPrice': self.w3.eth.gas_price
|
72
76
|
})
|
73
77
|
txn = self.contract.functions.InitCheque(receiver).build_transaction({
|
74
|
-
'from': self.w3.eth.account.from_key(private_key or self.private_key).address,
|
78
|
+
'from': self.w3.eth.account.from_key(private_key or self.private_key).address or self.address,
|
75
79
|
'value': self.w3.to_wei(amount, 'ether'),
|
76
80
|
'nonce': self.w3.eth.get_transaction_count(
|
77
|
-
self.w3.eth.account.from_key(private_key or self.private_key).address
|
81
|
+
self.w3.eth.account.from_key(private_key or self.private_key).address or self.address
|
78
82
|
),
|
79
83
|
'gas': estimated_gas,
|
80
84
|
'gasPrice': self.w3.eth.gas_price,
|
81
85
|
'chainId': self.w3.eth.chain_id
|
82
86
|
})
|
87
|
+
if self.return_build_tx:
|
88
|
+
return {
|
89
|
+
"build_tx": txn
|
90
|
+
}
|
91
|
+
|
83
92
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key or self.private_key)
|
84
93
|
txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
85
94
|
txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
|
@@ -109,7 +118,7 @@ class Cheque:
|
|
109
118
|
|
110
119
|
|
111
120
|
account = self.w3.eth.account.from_key(private_key)
|
112
|
-
sender_address = account.address
|
121
|
+
sender_address = account.address or self.address
|
113
122
|
|
114
123
|
|
115
124
|
nonce = self.w3.eth.get_transaction_count(sender_address)
|
@@ -121,6 +130,10 @@ class Cheque:
|
|
121
130
|
'gas': 300_000,
|
122
131
|
'gasPrice': self.w3.to_wei('5', 'gwei'),
|
123
132
|
})
|
133
|
+
if self.return_build_tx:
|
134
|
+
return {
|
135
|
+
"build_tx": txn
|
136
|
+
}
|
124
137
|
|
125
138
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
|
126
139
|
|
@@ -163,6 +176,10 @@ class Cheque:
|
|
163
176
|
'gas': estimated_gas,
|
164
177
|
'gasPrice': self.w3.eth.gas_price
|
165
178
|
})
|
179
|
+
if self.return_build_tx:
|
180
|
+
return {
|
181
|
+
"build_tx": txn
|
182
|
+
}
|
166
183
|
signed_txn = self.w3.eth.account.sign_transaction(txn, self.private_key)
|
167
184
|
txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
168
185
|
txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
|
@@ -190,17 +207,21 @@ class Cheque:
|
|
190
207
|
estimated_gas = self.contract.functions.CashOutTokenCheque(
|
191
208
|
Web3.to_bytes(hexstr=cheque_id)
|
192
209
|
).estimate_gas({
|
193
|
-
'from': account.address,
|
210
|
+
'from': account.address or self.address,
|
194
211
|
'gasPrice': self.w3.eth.gas_price
|
195
212
|
})
|
196
213
|
txn = self.contract.functions.CashOutTokenCheque(
|
197
214
|
Web3.to_bytes(hexstr=cheque_id)
|
198
215
|
).build_transaction({
|
199
|
-
'from': account.address,
|
200
|
-
'nonce': self.w3.eth.get_transaction_count(account.address),
|
216
|
+
'from': account.address or self.address,
|
217
|
+
'nonce': self.w3.eth.get_transaction_count(account.address or self.address),
|
201
218
|
'gas': estimated_gas,
|
202
219
|
'gasPrice': self.w3.eth.gas_price,
|
203
220
|
})
|
221
|
+
if self.return_build_tx:
|
222
|
+
return {
|
223
|
+
"build_tx": txn
|
224
|
+
}
|
204
225
|
|
205
226
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
|
206
227
|
tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
@@ -247,6 +268,10 @@ class Cheque:
|
|
247
268
|
'gas': estimated_gas,
|
248
269
|
'gasPrice': self.w3.eth.gas_price
|
249
270
|
})
|
271
|
+
if self.return_build_tx:
|
272
|
+
return {
|
273
|
+
"build_tx": txn
|
274
|
+
}
|
250
275
|
signed_txn = self.w3.eth.account.sign_transaction(txn, self.private_key)
|
251
276
|
txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
252
277
|
txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
|
@@ -291,6 +316,10 @@ class Cheque:
|
|
291
316
|
'gas': 300_000,
|
292
317
|
'gasPrice': self.w3.eth.gas_price
|
293
318
|
})
|
319
|
+
if self.return_build_tx:
|
320
|
+
return {
|
321
|
+
"build_tx": swa
|
322
|
+
}
|
294
323
|
signed_txn = self.w3.eth.account.sign_transaction(swa, private_key=private_key)
|
295
324
|
tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
296
325
|
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
|
@@ -350,20 +379,3 @@ class NFTcheque:
|
|
350
379
|
|
351
380
|
|
352
381
|
|
353
|
-
async def create_cheque(id, type, chain_id, receiver, sender):
|
354
|
-
async with httpx.AsyncClient() as client:
|
355
|
-
response = await client.post(
|
356
|
-
__CREATE__CHEQUE__,
|
357
|
-
json={
|
358
|
-
"cheque_id": id,
|
359
|
-
"chain_id":chain_id,
|
360
|
-
"receiver": receiver,
|
361
|
-
"type": type,
|
362
|
-
"sender":sender
|
363
|
-
}
|
364
|
-
)
|
365
|
-
if response.status_code == 200:
|
366
|
-
return response.json()
|
367
|
-
else:
|
368
|
-
print(f"Failed to create cheque: {response.text}")
|
369
|
-
return False
|
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
|