shadowPaySDK 0.1.2__py3-none-any.whl → 0.2.0.1__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/__init__.py CHANGED
@@ -1,2 +1,29 @@
1
- from .interface import ERC20Token as ERC20
2
- from .interface import ERC721Token as ERC721
1
+ import json
2
+ from shadowPaySDK.interface.erc20 import ERC20Token
3
+ from shadowPaySDK.interface.erc721 import ERC721Token
4
+ from shadowPaySDK.interface.sol import SolTokens
5
+ from shadowPaySDK.interface.sol import SOL
6
+ from shadowPaySDK.types.EVMcheque import Cheque
7
+ from shadowPaySDK.types.SOLcheque import SOLCheque
8
+ from shadowPaySDK.const import __ERC20_ABI__, __SHADOWPAY_ABI__ERC20__,__ALLOW_CHAINS__, __SHADOWPAY_CONTRACT_ADDRESS__ERC20__
9
+ from shadowPaySDK.api import __MAIN__URL__, __CREATE__CHEQUE__, get_my_cheques, create_cheque
10
+
11
+
12
+ # from shadowPaySDK.utils import parse_tx as PARSE_TX
13
+
14
+ __all__ = [
15
+ "ERC20",
16
+ "ERC721",
17
+ "PARSE_TX",
18
+ "Cheque",
19
+ "SOLCheque",
20
+ "SOL",
21
+ "SolTokens",
22
+ "__SHADOWPAY_ABI__ERC20__",
23
+ "__ERC20_ABI__ ",
24
+ "create_cheque",
25
+ "get_my_cheques"
26
+
27
+ ]
28
+
29
+
shadowPaySDK/api.py ADDED
@@ -0,0 +1,48 @@
1
+ import httpx
2
+ import json
3
+ from typing import Optional
4
+ from web3 import Web3
5
+
6
+ __MAIN__URL__= "http://0.0.0.0:8000"
7
+ __CREATE__CHEQUE__ = f"{__MAIN__URL__}/validate"
8
+ __MY__CHEQUES__ = f"{__MAIN__URL__}/mycheque"
9
+
10
+
11
+
12
+ async def __validate__cheque__(id, sender,action, receiver:Optional[str] = None, chain_id: Optional[int] = None, type:Optional[str] = None):
13
+ async with httpx.AsyncClient() as client:
14
+ response = await client.post(
15
+ __CREATE__CHEQUE__,
16
+ json={
17
+ "cheque_id": id,
18
+ "chain_id":chain_id,
19
+ "receiver": receiver,
20
+ "type": type,
21
+ "sender":sender,
22
+ "action": action
23
+ }
24
+ )
25
+ if response.status_code == 200:
26
+ return response.json()
27
+ else:
28
+ print(f"Failed to create cheque: {response.text}")
29
+ return False
30
+
31
+
32
+ async def get_my_cheques(private_key):
33
+ if not private_key:
34
+ raise ValueError("Private key is required to fetch cheques.")
35
+ sender = Web3.eth.account.from_key(private_key).address
36
+
37
+ async with httpx.AsyncClient() as client:
38
+ response = await client.get(
39
+ __MY__CHEQUES__,
40
+ params={
41
+ "sender": sender
42
+ }
43
+ )
44
+ if response.status_code == 200:
45
+ return response.json()
46
+ else:
47
+ print(f"Failed to fetch cheques: {response.text}")
48
+ return False
shadowPaySDK/const.py ADDED
@@ -0,0 +1,550 @@
1
+ import json
2
+
3
+ __ALLOW_CHAINS__ = [
4
+ 56, # BSC Mainnet
5
+ 97, # BSC Testnet
6
+ 0x1,
7
+ 0x1f984,
8
+ 0x38,
9
+ 0x66eed,
10
+ 0x89,
11
+ 0xa
12
+ ]
13
+
14
+
15
+
16
+
17
+ __VERSION__ = "0.1.2"
18
+
19
+
20
+ __ERC20_ABI__ = json.loads("""[
21
+ {"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"type":"function"},
22
+ {"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"type":"function"},
23
+ {"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},
24
+ {"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},
25
+ {"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"type":"function"},
26
+ {"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"type":"function"},
27
+ {"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"type":"function"},
28
+ {"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"type":"function"},
29
+ {"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"", "type":"bool"}],"type":"function"}
30
+ ]""")
31
+
32
+ __SHADOWPAY_CONTRACT_ADDRESS__ERC20__ = {
33
+ 97: "0x17a82E53a3b3f2acA7ceae8CA6B6b3B8F14e4441"
34
+ }
35
+
36
+ __SHADOWPAY_ABI__ERC20__= json.loads("""[
37
+ {
38
+ "inputs": [
39
+ {
40
+ "internalType": "bytes32",
41
+ "name": "groupIdv1",
42
+ "type": "bytes32"
43
+ }
44
+ ],
45
+ "name": "CashOutCheque",
46
+ "outputs": [],
47
+ "stateMutability": "nonpayable",
48
+ "type": "function"
49
+ },
50
+ {
51
+ "inputs": [
52
+ {
53
+ "internalType": "bytes32",
54
+ "name": "_id",
55
+ "type": "bytes32"
56
+ }
57
+ ],
58
+ "name": "CashOutSwapCheque",
59
+ "outputs": [],
60
+ "stateMutability": "nonpayable",
61
+ "type": "function"
62
+ },
63
+ {
64
+ "inputs": [
65
+ {
66
+ "internalType": "bytes32",
67
+ "name": "id",
68
+ "type": "bytes32"
69
+ }
70
+ ],
71
+ "name": "CashOutTokenCheque",
72
+ "outputs": [],
73
+ "stateMutability": "nonpayable",
74
+ "type": "function"
75
+ },
76
+ {
77
+ "inputs": [
78
+ {
79
+ "internalType": "address",
80
+ "name": "newOwner",
81
+ "type": "address"
82
+ }
83
+ ],
84
+ "name": "changeOwner",
85
+ "outputs": [],
86
+ "stateMutability": "nonpayable",
87
+ "type": "function"
88
+ },
89
+ {
90
+ "inputs": [
91
+ {
92
+ "internalType": "address payable[]",
93
+ "name": "_to",
94
+ "type": "address[]"
95
+ }
96
+ ],
97
+ "name": "InitCheque",
98
+ "outputs": [
99
+ {
100
+ "internalType": "bytes32",
101
+ "name": "groupIdv1",
102
+ "type": "bytes32"
103
+ }
104
+ ],
105
+ "stateMutability": "payable",
106
+ "type": "function"
107
+ },
108
+ {
109
+ "inputs": [
110
+ {
111
+ "internalType": "address",
112
+ "name": "_reciever",
113
+ "type": "address"
114
+ },
115
+ {
116
+ "internalType": "address",
117
+ "name": "_tokenIn",
118
+ "type": "address"
119
+ },
120
+ {
121
+ "internalType": "uint256",
122
+ "name": "_amountIn",
123
+ "type": "uint256"
124
+ },
125
+ {
126
+ "internalType": "address",
127
+ "name": "_tokenOut",
128
+ "type": "address"
129
+ },
130
+ {
131
+ "internalType": "uint256",
132
+ "name": "_amountOut",
133
+ "type": "uint256"
134
+ }
135
+ ],
136
+ "name": "InitSwapCheque",
137
+ "outputs": [
138
+ {
139
+ "internalType": "bytes32",
140
+ "name": "chequeId",
141
+ "type": "bytes32"
142
+ }
143
+ ],
144
+ "stateMutability": "nonpayable",
145
+ "type": "function"
146
+ },
147
+ {
148
+ "inputs": [
149
+ {
150
+ "internalType": "address",
151
+ "name": "_treaseryAddress",
152
+ "type": "address"
153
+ }
154
+ ],
155
+ "name": "setTreasery",
156
+ "outputs": [],
157
+ "stateMutability": "nonpayable",
158
+ "type": "function"
159
+ },
160
+ {
161
+ "inputs": [
162
+ {
163
+ "internalType": "address",
164
+ "name": "_trassary",
165
+ "type": "address"
166
+ }
167
+ ],
168
+ "stateMutability": "nonpayable",
169
+ "type": "constructor"
170
+ },
171
+ {
172
+ "anonymous": false,
173
+ "inputs": [
174
+ {
175
+ "indexed": false,
176
+ "internalType": "bytes32",
177
+ "name": "id",
178
+ "type": "bytes32"
179
+ }
180
+ ],
181
+ "name": "ChequeCreated",
182
+ "type": "event"
183
+ },
184
+ {
185
+ "inputs": [
186
+ {
187
+ "internalType": "address",
188
+ "name": "tokenAddrr",
189
+ "type": "address"
190
+ },
191
+ {
192
+ "internalType": "uint256",
193
+ "name": "amount",
194
+ "type": "uint256"
195
+ },
196
+ {
197
+ "internalType": "address payable",
198
+ "name": "to",
199
+ "type": "address"
200
+ }
201
+ ],
202
+ "name": "InitTokenCheque",
203
+ "outputs": [
204
+ {
205
+ "internalType": "bytes32",
206
+ "name": "",
207
+ "type": "bytes32"
208
+ }
209
+ ],
210
+ "stateMutability": "payable",
211
+ "type": "function"
212
+ },
213
+ {
214
+ "anonymous": false,
215
+ "inputs": [
216
+ {
217
+ "indexed": true,
218
+ "internalType": "bytes32",
219
+ "name": "id",
220
+ "type": "bytes32"
221
+ }
222
+ ],
223
+ "name": "redeem",
224
+ "type": "event"
225
+ },
226
+ {
227
+ "inputs": [
228
+ {
229
+ "internalType": "uint256",
230
+ "name": "_minFee",
231
+ "type": "uint256"
232
+ },
233
+ {
234
+ "internalType": "uint256",
235
+ "name": "_maxFees",
236
+ "type": "uint256"
237
+ },
238
+ {
239
+ "internalType": "uint256",
240
+ "name": "_minEth",
241
+ "type": "uint256"
242
+ },
243
+ {
244
+ "internalType": "uint256",
245
+ "name": "_baseFee",
246
+ "type": "uint256"
247
+ }
248
+ ],
249
+ "name": "setFees",
250
+ "outputs": [],
251
+ "stateMutability": "nonpayable",
252
+ "type": "function"
253
+ },
254
+ {
255
+ "inputs": [
256
+ {
257
+ "internalType": "uint256",
258
+ "name": "amount",
259
+ "type": "uint256"
260
+ },
261
+ {
262
+ "internalType": "address",
263
+ "name": "_to",
264
+ "type": "address"
265
+ }
266
+ ],
267
+ "name": "withdrawAmount",
268
+ "outputs": [],
269
+ "stateMutability": "nonpayable",
270
+ "type": "function"
271
+ },
272
+ {
273
+ "inputs": [],
274
+ "name": "withdrawFees",
275
+ "outputs": [],
276
+ "stateMutability": "nonpayable",
277
+ "type": "function"
278
+ },
279
+ {
280
+ "inputs": [],
281
+ "name": "collectedFees",
282
+ "outputs": [
283
+ {
284
+ "internalType": "uint256",
285
+ "name": "",
286
+ "type": "uint256"
287
+ }
288
+ ],
289
+ "stateMutability": "view",
290
+ "type": "function"
291
+ },
292
+ {
293
+ "inputs": [],
294
+ "name": "FEE_DENOMINATOR",
295
+ "outputs": [
296
+ {
297
+ "internalType": "uint256",
298
+ "name": "",
299
+ "type": "uint256"
300
+ }
301
+ ],
302
+ "stateMutability": "view",
303
+ "type": "function"
304
+ },
305
+ {
306
+ "inputs": [],
307
+ "name": "feeBasisPoints",
308
+ "outputs": [
309
+ {
310
+ "internalType": "uint256",
311
+ "name": "",
312
+ "type": "uint256"
313
+ }
314
+ ],
315
+ "stateMutability": "view",
316
+ "type": "function"
317
+ },
318
+ {
319
+ "inputs": [],
320
+ "name": "getBalance",
321
+ "outputs": [
322
+ {
323
+ "internalType": "uint256",
324
+ "name": "",
325
+ "type": "uint256"
326
+ }
327
+ ],
328
+ "stateMutability": "view",
329
+ "type": "function"
330
+ },
331
+ {
332
+ "inputs": [
333
+ {
334
+ "internalType": "bytes32",
335
+ "name": "id",
336
+ "type": "bytes32"
337
+ }
338
+ ],
339
+ "name": "getChequeInfo",
340
+ "outputs": [
341
+ {
342
+ "internalType": "uint256",
343
+ "name": "amount",
344
+ "type": "uint256"
345
+ },
346
+ {
347
+ "internalType": "address payable[]",
348
+ "name": "to",
349
+ "type": "address[]"
350
+ }
351
+ ],
352
+ "stateMutability": "view",
353
+ "type": "function"
354
+ },
355
+ {
356
+ "inputs": [],
357
+ "name": "getCollectedFee",
358
+ "outputs": [
359
+ {
360
+ "internalType": "uint256",
361
+ "name": "",
362
+ "type": "uint256"
363
+ }
364
+ ],
365
+ "stateMutability": "view",
366
+ "type": "function"
367
+ },
368
+ {
369
+ "inputs": [],
370
+ "name": "getOwner",
371
+ "outputs": [
372
+ {
373
+ "internalType": "address",
374
+ "name": "",
375
+ "type": "address"
376
+ }
377
+ ],
378
+ "stateMutability": "view",
379
+ "type": "function"
380
+ },
381
+ {
382
+ "inputs": [
383
+ {
384
+ "internalType": "bytes32",
385
+ "name": "id",
386
+ "type": "bytes32"
387
+ }
388
+ ],
389
+ "name": "getSwapDetail",
390
+ "outputs": [
391
+ {
392
+ "internalType": "address",
393
+ "name": "tokenOut",
394
+ "type": "address"
395
+ },
396
+ {
397
+ "internalType": "uint256",
398
+ "name": "amountOut",
399
+ "type": "uint256"
400
+ }
401
+ ],
402
+ "stateMutability": "view",
403
+ "type": "function"
404
+ },
405
+ {
406
+ "inputs": [],
407
+ "name": "getTreasery",
408
+ "outputs": [
409
+ {
410
+ "internalType": "address",
411
+ "name": "",
412
+ "type": "address"
413
+ }
414
+ ],
415
+ "stateMutability": "view",
416
+ "type": "function"
417
+ },
418
+ {
419
+ "inputs": [
420
+ {
421
+ "internalType": "address",
422
+ "name": "_addrr",
423
+ "type": "address"
424
+ }
425
+ ],
426
+ "name": "getUserChequeCount",
427
+ "outputs": [
428
+ {
429
+ "internalType": "uint256",
430
+ "name": "",
431
+ "type": "uint256"
432
+ }
433
+ ],
434
+ "stateMutability": "view",
435
+ "type": "function"
436
+ },
437
+ {
438
+ "inputs": [],
439
+ "name": "nextAvailableWithdraw",
440
+ "outputs": [
441
+ {
442
+ "internalType": "uint256",
443
+ "name": "timestamp",
444
+ "type": "uint256"
445
+ }
446
+ ],
447
+ "stateMutability": "view",
448
+ "type": "function"
449
+ },
450
+ {
451
+ "inputs": [
452
+ {
453
+ "internalType": "address",
454
+ "name": "",
455
+ "type": "address"
456
+ }
457
+ ],
458
+ "name": "nonces",
459
+ "outputs": [
460
+ {
461
+ "internalType": "uint256",
462
+ "name": "",
463
+ "type": "uint256"
464
+ }
465
+ ],
466
+ "stateMutability": "view",
467
+ "type": "function"
468
+ },
469
+ {
470
+ "inputs": [],
471
+ "name": "owner",
472
+ "outputs": [
473
+ {
474
+ "internalType": "address",
475
+ "name": "",
476
+ "type": "address"
477
+ }
478
+ ],
479
+ "stateMutability": "view",
480
+ "type": "function"
481
+ },
482
+ {
483
+ "inputs": [
484
+ {
485
+ "internalType": "bytes32",
486
+ "name": "",
487
+ "type": "bytes32"
488
+ }
489
+ ],
490
+ "name": "swapCheques",
491
+ "outputs": [
492
+ {
493
+ "internalType": "address",
494
+ "name": "spender",
495
+ "type": "address"
496
+ },
497
+ {
498
+ "internalType": "address",
499
+ "name": "receiver",
500
+ "type": "address"
501
+ },
502
+ {
503
+ "internalType": "address",
504
+ "name": "tokenIn",
505
+ "type": "address"
506
+ },
507
+ {
508
+ "internalType": "uint256",
509
+ "name": "amountIn",
510
+ "type": "uint256"
511
+ },
512
+ {
513
+ "internalType": "address",
514
+ "name": "tokenOut",
515
+ "type": "address"
516
+ },
517
+ {
518
+ "internalType": "uint256",
519
+ "name": "amountOut",
520
+ "type": "uint256"
521
+ },
522
+ {
523
+ "internalType": "bool",
524
+ "name": "claimed",
525
+ "type": "bool"
526
+ }
527
+ ],
528
+ "stateMutability": "view",
529
+ "type": "function"
530
+ },
531
+ {
532
+ "inputs": [],
533
+ "name": "treasery",
534
+ "outputs": [
535
+ {
536
+ "internalType": "address",
537
+ "name": "",
538
+ "type": "address"
539
+ }
540
+ ],
541
+ "stateMutability": "view",
542
+ "type": "function"
543
+ }
544
+ ]""")
545
+
546
+ __SHADOWPAY_ABI__ERC721__ = json.loads("""[]""")
547
+ __SHADOWPAY_CONTRACT_ADDRESS__ERC721__ = {
548
+ "0x1": "0x3c5b8d6f2e"
549
+ }
550
+
@@ -1,4 +1,4 @@
1
- from .erc20 import ERC20Token
2
- from .erc721 import ERC721Token
3
-
4
- __all__ = ["ERC20Token", "ERC721Token"]
1
+ from .erc20 import ERC20Token as ERC20
2
+ from .erc721 import ERC721Token as ERC721
3
+ from .sol import SolTokens as SPL
4
+ __all__ = ["ERC20", "ERC721", "SPL"]