shadowPaySDK 16.7.2025.1__tar.gz → 16.7.2025.1.1__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-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/PKG-INFO +3 -3
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/setup.py +3 -3
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/const.py +207 -126
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/interface/erc20.py +10 -15
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/interface/sol.py +0 -5
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/types/EVMcheque.py +97 -42
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/types/SOLcheque.py +0 -2
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK.egg-info/PKG-INFO +3 -3
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK.egg-info/SOURCES.txt +0 -1
- shadowpaysdk-16.7.2025.1/shadowPaySDK/api.py +0 -48
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/LICENSE +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/README.md +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/setup.cfg +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/__init__.py +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/interface/__init__.py +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/interface/erc721.py +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/types/__init__.py +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/utils/__init__.py +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK/utils/utils.py +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK.egg-info/requires.txt +0 -0
- {shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK.egg-info/top_level.txt +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: shadowPaySDK
|
3
|
-
Version: 16.7.2025.1
|
3
|
+
Version: 16.7.2025.1.1
|
4
4
|
Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
|
5
|
-
Author: dazay
|
6
|
-
Author-email:
|
5
|
+
Author: dazay
|
6
|
+
Author-email: shadowpay.protocol@gmail.com
|
7
7
|
License: MIT
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -2,12 +2,12 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='shadowPaySDK',
|
5
|
-
version='16.07.2025.1',
|
5
|
+
version='16.07.2025.1.1',
|
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',
|
9
|
-
author='dazay
|
10
|
-
author_email='
|
9
|
+
author='dazay',
|
10
|
+
author_email='shadowpay.protocol@gmail.com',
|
11
11
|
license='MIT',
|
12
12
|
packages=find_packages(),
|
13
13
|
classifiers=[
|
@@ -3,6 +3,7 @@ from solders.pubkey import Pubkey
|
|
3
3
|
__ALLOW_CHAINS__ = [
|
4
4
|
56, # BSC Mainnet
|
5
5
|
97, # BSC Testnet
|
6
|
+
10143,
|
6
7
|
0x1,
|
7
8
|
0x1f984,
|
8
9
|
0x38,
|
@@ -30,10 +31,61 @@ __ERC20_ABI__ = json.loads("""[
|
|
30
31
|
]""")
|
31
32
|
|
32
33
|
__SHADOWPAY_CONTRACT_ADDRESS__ERC20__ = {
|
33
|
-
97: "0x5487C0DdCbD5465F26B446c6CAB88D8d6F7DF23b"
|
34
|
+
97: "0x5487C0DdCbD5465F26B446c6CAB88D8d6F7DF23b",
|
35
|
+
10143: "0x1d856f2eA4738d1a89E27dbfc8950a4976Db41a5"
|
34
36
|
}
|
35
37
|
|
36
38
|
__SHADOWPAY_ABI__ERC20__= json.loads("""[
|
39
|
+
{
|
40
|
+
"inputs": [
|
41
|
+
{
|
42
|
+
"internalType": "address",
|
43
|
+
"name": "_trassary",
|
44
|
+
"type": "address"
|
45
|
+
}
|
46
|
+
],
|
47
|
+
"stateMutability": "nonpayable",
|
48
|
+
"type": "constructor"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"anonymous": false,
|
52
|
+
"inputs": [
|
53
|
+
{
|
54
|
+
"indexed": false,
|
55
|
+
"internalType": "bytes32",
|
56
|
+
"name": "id",
|
57
|
+
"type": "bytes32"
|
58
|
+
}
|
59
|
+
],
|
60
|
+
"name": "ChequeClaimed",
|
61
|
+
"type": "event"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"anonymous": false,
|
65
|
+
"inputs": [
|
66
|
+
{
|
67
|
+
"indexed": false,
|
68
|
+
"internalType": "bytes32",
|
69
|
+
"name": "id",
|
70
|
+
"type": "bytes32"
|
71
|
+
}
|
72
|
+
],
|
73
|
+
"name": "ChequeCreated",
|
74
|
+
"type": "event"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"anonymous": false,
|
78
|
+
"inputs": [
|
79
|
+
{
|
80
|
+
"indexed": true,
|
81
|
+
"internalType": "bytes32",
|
82
|
+
"name": "id",
|
83
|
+
"type": "bytes32"
|
84
|
+
}
|
85
|
+
],
|
86
|
+
"name": "redeem",
|
87
|
+
"type": "event"
|
88
|
+
},
|
37
89
|
{
|
38
90
|
"inputs": [
|
39
91
|
{
|
@@ -74,16 +126,16 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
74
126
|
"type": "function"
|
75
127
|
},
|
76
128
|
{
|
77
|
-
"inputs": [
|
129
|
+
"inputs": [],
|
130
|
+
"name": "FEE_DENOMINATOR",
|
131
|
+
"outputs": [
|
78
132
|
{
|
79
|
-
"internalType": "
|
80
|
-
"name": "
|
81
|
-
"type": "
|
133
|
+
"internalType": "uint256",
|
134
|
+
"name": "",
|
135
|
+
"type": "uint256"
|
82
136
|
}
|
83
137
|
],
|
84
|
-
"
|
85
|
-
"outputs": [],
|
86
|
-
"stateMutability": "nonpayable",
|
138
|
+
"stateMutability": "view",
|
87
139
|
"type": "function"
|
88
140
|
},
|
89
141
|
{
|
@@ -144,43 +196,6 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
144
196
|
"stateMutability": "nonpayable",
|
145
197
|
"type": "function"
|
146
198
|
},
|
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
199
|
{
|
185
200
|
"inputs": [
|
186
201
|
{
|
@@ -210,68 +225,15 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
210
225
|
"stateMutability": "payable",
|
211
226
|
"type": "function"
|
212
227
|
},
|
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
228
|
{
|
255
229
|
"inputs": [
|
256
|
-
{
|
257
|
-
"internalType": "uint256",
|
258
|
-
"name": "amount",
|
259
|
-
"type": "uint256"
|
260
|
-
},
|
261
230
|
{
|
262
231
|
"internalType": "address",
|
263
|
-
"name": "
|
232
|
+
"name": "newOwner",
|
264
233
|
"type": "address"
|
265
234
|
}
|
266
235
|
],
|
267
|
-
"name": "
|
268
|
-
"outputs": [],
|
269
|
-
"stateMutability": "nonpayable",
|
270
|
-
"type": "function"
|
271
|
-
},
|
272
|
-
{
|
273
|
-
"inputs": [],
|
274
|
-
"name": "withdrawFees",
|
236
|
+
"name": "changeOwner",
|
275
237
|
"outputs": [],
|
276
238
|
"stateMutability": "nonpayable",
|
277
239
|
"type": "function"
|
@@ -289,19 +251,6 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
289
251
|
"stateMutability": "view",
|
290
252
|
"type": "function"
|
291
253
|
},
|
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
254
|
{
|
306
255
|
"inputs": [],
|
307
256
|
"name": "feeBasisPoints",
|
@@ -334,6 +283,11 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
334
283
|
"internalType": "bytes32",
|
335
284
|
"name": "id",
|
336
285
|
"type": "bytes32"
|
286
|
+
},
|
287
|
+
{
|
288
|
+
"internalType": "address",
|
289
|
+
"name": "from",
|
290
|
+
"type": "address"
|
337
291
|
}
|
338
292
|
],
|
339
293
|
"name": "getChequeInfo",
|
@@ -347,6 +301,11 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
347
301
|
"internalType": "address payable[]",
|
348
302
|
"name": "to",
|
349
303
|
"type": "address[]"
|
304
|
+
},
|
305
|
+
{
|
306
|
+
"internalType": "bool",
|
307
|
+
"name": "claimed",
|
308
|
+
"type": "bool"
|
350
309
|
}
|
351
310
|
],
|
352
311
|
"stateMutability": "view",
|
@@ -397,38 +356,63 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
397
356
|
"internalType": "uint256",
|
398
357
|
"name": "amountOut",
|
399
358
|
"type": "uint256"
|
359
|
+
},
|
360
|
+
{
|
361
|
+
"internalType": "address",
|
362
|
+
"name": "spender",
|
363
|
+
"type": "address"
|
364
|
+
},
|
365
|
+
{
|
366
|
+
"internalType": "address",
|
367
|
+
"name": "receiver",
|
368
|
+
"type": "address"
|
369
|
+
},
|
370
|
+
{
|
371
|
+
"internalType": "bool",
|
372
|
+
"name": "claimed",
|
373
|
+
"type": "bool"
|
400
374
|
}
|
401
375
|
],
|
402
376
|
"stateMutability": "view",
|
403
377
|
"type": "function"
|
404
378
|
},
|
405
379
|
{
|
406
|
-
"inputs": [
|
407
|
-
|
380
|
+
"inputs": [
|
381
|
+
{
|
382
|
+
"internalType": "bytes32",
|
383
|
+
"name": "id",
|
384
|
+
"type": "bytes32"
|
385
|
+
}
|
386
|
+
],
|
387
|
+
"name": "getTokenChequeDetail",
|
408
388
|
"outputs": [
|
409
389
|
{
|
410
390
|
"internalType": "address",
|
411
|
-
"name": "",
|
391
|
+
"name": "spender",
|
392
|
+
"type": "address"
|
393
|
+
},
|
394
|
+
{
|
395
|
+
"internalType": "address",
|
396
|
+
"name": "receiver",
|
412
397
|
"type": "address"
|
398
|
+
},
|
399
|
+
{
|
400
|
+
"internalType": "bool",
|
401
|
+
"name": "claimed",
|
402
|
+
"type": "bool"
|
413
403
|
}
|
414
404
|
],
|
415
405
|
"stateMutability": "view",
|
416
406
|
"type": "function"
|
417
407
|
},
|
418
408
|
{
|
419
|
-
"inputs": [
|
420
|
-
|
421
|
-
"internalType": "address",
|
422
|
-
"name": "_addrr",
|
423
|
-
"type": "address"
|
424
|
-
}
|
425
|
-
],
|
426
|
-
"name": "getUserChequeCount",
|
409
|
+
"inputs": [],
|
410
|
+
"name": "getTreasery",
|
427
411
|
"outputs": [
|
428
412
|
{
|
429
|
-
"internalType": "
|
413
|
+
"internalType": "address",
|
430
414
|
"name": "",
|
431
|
-
"type": "
|
415
|
+
"type": "address"
|
432
416
|
}
|
433
417
|
],
|
434
418
|
"stateMutability": "view",
|
@@ -479,6 +463,78 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
479
463
|
"stateMutability": "view",
|
480
464
|
"type": "function"
|
481
465
|
},
|
466
|
+
{
|
467
|
+
"inputs": [
|
468
|
+
{
|
469
|
+
"internalType": "uint256",
|
470
|
+
"name": "_minFee",
|
471
|
+
"type": "uint256"
|
472
|
+
},
|
473
|
+
{
|
474
|
+
"internalType": "uint256",
|
475
|
+
"name": "_maxFees",
|
476
|
+
"type": "uint256"
|
477
|
+
},
|
478
|
+
{
|
479
|
+
"internalType": "uint256",
|
480
|
+
"name": "_minEth",
|
481
|
+
"type": "uint256"
|
482
|
+
},
|
483
|
+
{
|
484
|
+
"internalType": "uint256",
|
485
|
+
"name": "_baseFee",
|
486
|
+
"type": "uint256"
|
487
|
+
}
|
488
|
+
],
|
489
|
+
"name": "setFees",
|
490
|
+
"outputs": [],
|
491
|
+
"stateMutability": "nonpayable",
|
492
|
+
"type": "function"
|
493
|
+
},
|
494
|
+
{
|
495
|
+
"inputs": [
|
496
|
+
{
|
497
|
+
"internalType": "uint256",
|
498
|
+
"name": "_TokenChequepercentage",
|
499
|
+
"type": "uint256"
|
500
|
+
},
|
501
|
+
{
|
502
|
+
"internalType": "uint256",
|
503
|
+
"name": "_SwapTokenChequepercentage",
|
504
|
+
"type": "uint256"
|
505
|
+
}
|
506
|
+
],
|
507
|
+
"name": "setTokenFees",
|
508
|
+
"outputs": [],
|
509
|
+
"stateMutability": "nonpayable",
|
510
|
+
"type": "function"
|
511
|
+
},
|
512
|
+
{
|
513
|
+
"inputs": [
|
514
|
+
{
|
515
|
+
"internalType": "address",
|
516
|
+
"name": "_treaseryAddress",
|
517
|
+
"type": "address"
|
518
|
+
}
|
519
|
+
],
|
520
|
+
"name": "setTreasery",
|
521
|
+
"outputs": [],
|
522
|
+
"stateMutability": "nonpayable",
|
523
|
+
"type": "function"
|
524
|
+
},
|
525
|
+
{
|
526
|
+
"inputs": [],
|
527
|
+
"name": "swapBasicPoints",
|
528
|
+
"outputs": [
|
529
|
+
{
|
530
|
+
"internalType": "uint256",
|
531
|
+
"name": "",
|
532
|
+
"type": "uint256"
|
533
|
+
}
|
534
|
+
],
|
535
|
+
"stateMutability": "view",
|
536
|
+
"type": "function"
|
537
|
+
},
|
482
538
|
{
|
483
539
|
"inputs": [
|
484
540
|
{
|
@@ -540,6 +596,31 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
540
596
|
],
|
541
597
|
"stateMutability": "view",
|
542
598
|
"type": "function"
|
599
|
+
},
|
600
|
+
{
|
601
|
+
"inputs": [
|
602
|
+
{
|
603
|
+
"internalType": "uint256",
|
604
|
+
"name": "amount",
|
605
|
+
"type": "uint256"
|
606
|
+
},
|
607
|
+
{
|
608
|
+
"internalType": "address",
|
609
|
+
"name": "_to",
|
610
|
+
"type": "address"
|
611
|
+
}
|
612
|
+
],
|
613
|
+
"name": "withdrawAmount",
|
614
|
+
"outputs": [],
|
615
|
+
"stateMutability": "nonpayable",
|
616
|
+
"type": "function"
|
617
|
+
},
|
618
|
+
{
|
619
|
+
"inputs": [],
|
620
|
+
"name": "withdrawFees",
|
621
|
+
"outputs": [],
|
622
|
+
"stateMutability": "nonpayable",
|
623
|
+
"type": "function"
|
543
624
|
}
|
544
625
|
]""")
|
545
626
|
|
@@ -43,7 +43,8 @@ class ERC20Token:
|
|
43
43
|
def get_balance(self, wallet_address: str) -> float:
|
44
44
|
self._ensure_contract()
|
45
45
|
raw = self.contract.functions.balanceOf(Web3.to_checksum_address(wallet_address)).call()
|
46
|
-
return raw
|
46
|
+
return raw
|
47
|
+
|
47
48
|
|
48
49
|
def allowance(self, owner: str, spender: str) -> float:
|
49
50
|
self._ensure_contract()
|
@@ -51,31 +52,30 @@ class ERC20Token:
|
|
51
52
|
Web3.to_checksum_address(owner),
|
52
53
|
Web3.to_checksum_address(spender)
|
53
54
|
).call()
|
54
|
-
return raw
|
55
|
+
return raw
|
55
56
|
|
56
|
-
def ensure_allowance(self, private_key: str, spender: str, amount) -> Union[bool, str]:
|
57
|
+
def ensure_allowance(self, private_key: str, spender: str, amount, converted_amount: bool = False) -> Union[bool, str]:
|
57
58
|
self._ensure_contract()
|
58
59
|
account = self.web3.eth.account.from_key(private_key)
|
59
60
|
current = self.allowance(account.address, spender)
|
60
61
|
if current == amount:
|
61
62
|
return True
|
62
|
-
return self.approve(private_key, spender, amount)
|
63
|
+
return self.approve(private_key, spender, amount, conveted_amount=converted_amount)
|
63
64
|
|
64
65
|
def transfer(self, private_key: str, to: str, amount: float) -> str:
|
65
66
|
self._ensure_contract()
|
66
67
|
account = self.web3.eth.account.from_key(private_key)
|
67
|
-
|
68
|
-
value = int(amount * (10 ** decimals))
|
68
|
+
|
69
69
|
estimated_gas = self.contract.functions.transfer(
|
70
70
|
Web3.to_checksum_address(to),
|
71
|
-
|
71
|
+
amount
|
72
72
|
).estimate_gas({
|
73
73
|
'from': account.address,
|
74
74
|
'gasPrice': self.web3.to_wei('5', 'gwei'),
|
75
75
|
})
|
76
76
|
txn = self.contract.functions.transfer(
|
77
77
|
Web3.to_checksum_address(to),
|
78
|
-
|
78
|
+
amount
|
79
79
|
).build_transaction({
|
80
80
|
'from': account.address,
|
81
81
|
'nonce': self.web3.eth.get_transaction_count(account.address),
|
@@ -87,7 +87,7 @@ 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, spender: str, amount: float,address:Optional[str] = None, private_key: Optional[str] = None,
|
90
|
+
def approve(self, spender: str, amount: float,address:Optional[str] = None, private_key: Optional[str] = None, conveted_amount: bool = True) -> str:
|
91
91
|
|
92
92
|
self._ensure_contract()
|
93
93
|
key = private_key
|
@@ -99,10 +99,6 @@ class ERC20Token:
|
|
99
99
|
address = Web3.to_checksum_address(self.address)
|
100
100
|
else:
|
101
101
|
raise ValueError("No private key or address provided")
|
102
|
-
|
103
|
-
decimals = self.get_decimals()
|
104
|
-
amount = int(amount * (10 ** decimals))
|
105
|
-
|
106
102
|
txn = self.contract.functions.approve(
|
107
103
|
Web3.to_checksum_address(spender),
|
108
104
|
amount
|
@@ -113,8 +109,7 @@ class ERC20Token:
|
|
113
109
|
|
114
110
|
'gasPrice': self.web3.eth.gas_price,
|
115
111
|
})
|
116
|
-
|
117
|
-
return txn
|
112
|
+
|
118
113
|
|
119
114
|
signed = self.web3.eth.account.sign_transaction(txn, key)
|
120
115
|
tx_hash = self.web3.eth.send_raw_transaction(signed.raw_transaction)
|
@@ -118,12 +118,7 @@ class SOL:
|
|
118
118
|
|
119
119
|
|
120
120
|
return token_data
|
121
|
-
async def is_connected(self):
|
122
|
-
return await self.client.is_connected()
|
123
121
|
|
124
|
-
async def close(self):
|
125
|
-
await self.client.close()
|
126
|
-
|
127
122
|
async def fetch_metadata_raw(self,mint_address: str):
|
128
123
|
METADATA_PROGRAM_ID = solders.pubkey.Pubkey.from_string("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
|
129
124
|
mint = solders.pubkey.Pubkey.from_string(mint_address)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import shadowPaySDK
|
2
2
|
from shadowPaySDK.const import __SHADOWPAY_ABI__ERC20__, __ALLOW_CHAINS__, __SHADOWPAY_CONTRACT_ADDRESS__ERC20__
|
3
|
-
from shadowPaySDK.api import __CREATE__CHEQUE__
|
4
3
|
from web3 import Web3
|
5
4
|
from typing import Optional
|
6
5
|
import httpx
|
@@ -36,6 +35,7 @@ class Cheque:
|
|
36
35
|
print(f"Failed to get cheque ID from transaction receipt: {str(e)}")
|
37
36
|
return False
|
38
37
|
def __allow__(self):
|
38
|
+
print("Checking if chain is allowed", self.w3.eth.chain_id)
|
39
39
|
for chain in self.allowed_chains:
|
40
40
|
|
41
41
|
if chain == self.w3.eth.chain_id:
|
@@ -46,15 +46,25 @@ class Cheque:
|
|
46
46
|
raise ValueError(f"Chain {str(self.w3.eth.chain_id)} is not allowed. Allowed chains are: {self.allowed_chains}")
|
47
47
|
def get_contract_for_chain(self,chain_id: str):
|
48
48
|
c = None
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
chain_id = int(chain_id)
|
50
|
+
|
51
|
+
for key,value in __SHADOWPAY_CONTRACT_ADDRESS__ERC20__.items():
|
52
|
+
print("Checking address", value, "for chain_id", chain_id)
|
53
|
+
if key == chain_id:
|
54
|
+
c = value
|
55
|
+
contract_address = Web3.to_checksum_address(c)
|
56
|
+
contract = self.w3.eth.contract(address=contract_address, abi=__SHADOWPAY_ABI__ERC20__)
|
57
|
+
self.contract = contract
|
58
|
+
return contract
|
56
59
|
raise ValueError(f"Chain {chain_id} is not supported. Supported chains are: {list(__SHADOWPAY_CONTRACT_ADDRESS__ERC20__.keys())}")
|
57
|
-
|
60
|
+
async def get_address(self):
|
61
|
+
if self.address:
|
62
|
+
return self.address
|
63
|
+
elif self.w3:
|
64
|
+
return self.w3.eth.default_account
|
65
|
+
else:
|
66
|
+
raise ValueError("No address provided or Web3 instance is not set")
|
67
|
+
|
58
68
|
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):
|
59
69
|
if w3:
|
60
70
|
self.w3 = w3
|
@@ -63,6 +73,7 @@ class Cheque:
|
|
63
73
|
self.amount = amount
|
64
74
|
if private_key:
|
65
75
|
self.private_key = private_key
|
76
|
+
self.address = Web3.to_checksum_address(self.w3.eth.account.from_key(private_key).address)
|
66
77
|
if token:
|
67
78
|
self.token = token
|
68
79
|
if address:
|
@@ -70,7 +81,7 @@ class Cheque:
|
|
70
81
|
|
71
82
|
def __convert__(self):
|
72
83
|
return self.w3.to_wei(self.amount, 'ether')
|
73
|
-
|
84
|
+
|
74
85
|
async def InitCheque(self, amount, receiver:list, private_key:Optional[str] = None):
|
75
86
|
if not isinstance(receiver,list):
|
76
87
|
raise ValueError("Receiver must be a list of addresses, [""0x1234...5678", "0x2345...6789""]")
|
@@ -133,42 +144,55 @@ class Cheque:
|
|
133
144
|
async def CashOutCheque(
|
134
145
|
self,
|
135
146
|
private_key: str,
|
136
|
-
cheque_id: str
|
147
|
+
cheque_id: str
|
137
148
|
):
|
138
149
|
if not private_key:
|
139
150
|
private_key = self.private_key
|
140
151
|
|
141
|
-
|
142
152
|
account = self.w3.eth.account.from_key(private_key)
|
143
153
|
sender_address = account.address or self.address
|
144
|
-
|
145
|
-
|
146
154
|
nonce = self.w3.eth.get_transaction_count(sender_address)
|
147
155
|
|
148
|
-
|
149
|
-
|
156
|
+
latest_block = self.w3.eth.get_block('latest')
|
157
|
+
supports_eip1559 = 'baseFeePerGas' in latest_block
|
158
|
+
|
159
|
+
tx_common = {
|
150
160
|
'from': sender_address,
|
151
161
|
'nonce': nonce,
|
152
162
|
'gas': 300_000,
|
153
|
-
|
154
|
-
})
|
155
|
-
if self.return_build_tx:
|
156
|
-
return {
|
157
|
-
"build_tx": txn
|
158
|
-
}
|
163
|
+
}
|
159
164
|
|
160
|
-
|
165
|
+
if supports_eip1559:
|
166
|
+
# EIP-1559 style
|
167
|
+
base_fee = latest_block['baseFeePerGas']
|
168
|
+
priority_fee = self.w3.to_wei(2, 'gwei') # можно поднять до 5
|
169
|
+
max_fee = base_fee + priority_fee * 2
|
170
|
+
|
171
|
+
tx_common.update({
|
172
|
+
'maxFeePerGas': max_fee,
|
173
|
+
'maxPriorityFeePerGas': priority_fee
|
174
|
+
})
|
175
|
+
else:
|
176
|
+
# Legacy gas price style
|
177
|
+
tx_common.update({
|
178
|
+
'gasPrice': self.w3.to_wei('5', 'gwei')
|
179
|
+
})
|
161
180
|
|
181
|
+
txn = self.contract.functions.CashOutCheque(
|
182
|
+
Web3.to_bytes(hexstr=cheque_id)
|
183
|
+
).build_transaction(tx_common)
|
162
184
|
|
163
|
-
|
185
|
+
if self.return_build_tx:
|
186
|
+
return {"build_tx": txn}
|
164
187
|
|
188
|
+
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
|
189
|
+
tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
165
190
|
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
|
191
|
+
|
166
192
|
if receipt.status != 1:
|
167
193
|
return False
|
168
|
-
return {
|
169
|
-
|
170
|
-
}
|
171
|
-
|
194
|
+
return {"hash": tx_hash.hex()}
|
195
|
+
|
172
196
|
async def InitTokenCheque(self, token_address:str, amount, reciver:str, private_key:Optional[str] = None):
|
173
197
|
key = private_key or self.private_key
|
174
198
|
|
@@ -193,7 +217,7 @@ class Cheque:
|
|
193
217
|
)
|
194
218
|
estimated_gas = self.contract.functions.InitTokenCheque(
|
195
219
|
Web3.to_checksum_address(token_address),
|
196
|
-
|
220
|
+
amount,
|
197
221
|
Web3.to_checksum_address(reciver)
|
198
222
|
).estimate_gas({
|
199
223
|
'from': address,
|
@@ -201,7 +225,7 @@ class Cheque:
|
|
201
225
|
})
|
202
226
|
txn = self.contract.functions.InitTokenCheque(
|
203
227
|
Web3.to_checksum_address(token_address),
|
204
|
-
|
228
|
+
amount,
|
205
229
|
Web3.to_checksum_address(reciver)
|
206
230
|
).build_transaction({
|
207
231
|
'from': address,
|
@@ -285,9 +309,9 @@ class Cheque:
|
|
285
309
|
estimated_gas = self.contract.functions.InitSwapCheque(
|
286
310
|
Web3.to_checksum_address(reciver),
|
287
311
|
Web3.to_checksum_address(token_in),
|
288
|
-
|
312
|
+
amount_in,
|
289
313
|
Web3.to_checksum_address(token_out),
|
290
|
-
|
314
|
+
amount_out,
|
291
315
|
).estimate_gas({
|
292
316
|
'from': address,
|
293
317
|
'gasPrice': self.w3.eth.gas_price
|
@@ -295,9 +319,9 @@ class Cheque:
|
|
295
319
|
txn = self.contract.functions.InitSwapCheque(
|
296
320
|
Web3.to_checksum_address(reciver),
|
297
321
|
Web3.to_checksum_address(token_in),
|
298
|
-
|
322
|
+
amount_in,
|
299
323
|
Web3.to_checksum_address(token_out),
|
300
|
-
|
324
|
+
amount_out
|
301
325
|
).build_transaction({
|
302
326
|
'from': address,
|
303
327
|
'nonce': self.w3.eth.get_transaction_count(address),
|
@@ -333,11 +357,20 @@ class Cheque:
|
|
333
357
|
amount_out = swapDetail["amountOut"]
|
334
358
|
erc20 = shadowPaySDK.ERC20Token(w3=self.w3)
|
335
359
|
erc20.set_params(token_address=token_out)
|
336
|
-
encure_allowance = erc20.
|
337
|
-
private_key=private_key,
|
360
|
+
encure_allowance = erc20.allowance(
|
338
361
|
spender=self.contract.address,
|
339
|
-
|
362
|
+
owner=self.address,
|
340
363
|
)
|
364
|
+
if encure_allowance < amount_out:
|
365
|
+
approve = erc20.approve(
|
366
|
+
spender=self.contract.address,
|
367
|
+
amount=amount_out,
|
368
|
+
private_key=private_key,
|
369
|
+
conveted_amount=False
|
370
|
+
)
|
371
|
+
if not approve:
|
372
|
+
return False
|
373
|
+
print(f"contract balance: {erc20.get_balance(wallet_address=self.contract.address)}")
|
341
374
|
estimated_gas = self.contract.functions.CashOutSwapCheque(
|
342
375
|
Web3.to_bytes(hexstr=cheque_id)
|
343
376
|
).estimate_gas({
|
@@ -369,21 +402,43 @@ class Cheque:
|
|
369
402
|
|
370
403
|
|
371
404
|
async def getComunityPool(self):
|
372
|
-
|
373
|
-
fee = 50000000000000
|
405
|
+
fee = self.contract.functions.getCollectedFee().call()
|
374
406
|
half_fee_eth = self.w3.from_wei(fee // 2, 'ether')
|
375
407
|
return half_fee_eth
|
376
408
|
async def getOwner(self):
|
377
409
|
return self.contract.functions.getOwner().call()
|
378
410
|
async def getTreasery(self):
|
379
411
|
return self.contract.functions.getTreasery().call()
|
412
|
+
def getChequeInfo(self, cheque_id: str, address: Optional[str] = None):
|
413
|
+
if not cheque_id:
|
414
|
+
raise ValueError("Cheque ID is required")
|
415
|
+
if address:
|
416
|
+
address = Web3.to_checksum_address(address)
|
417
|
+
|
418
|
+
cheque_id_bytes32 = Web3.to_bytes(hexstr=cheque_id).rjust(32, b'\x00')
|
419
|
+
cheque_info = self.contract.functions.getChequeInfo(cheque_id_bytes32).call({
|
420
|
+
cheque_id_bytes32,
|
421
|
+
address or self.address
|
422
|
+
|
423
|
+
})
|
424
|
+
return cheque_info
|
425
|
+
def getTokenChequeInfo(self, cheque_id: str):
|
426
|
+
if not cheque_id:
|
427
|
+
raise ValueError("Cheque ID is required")
|
428
|
+
|
429
|
+
cheque_id_bytes32 = Web3.to_bytes(hexstr=cheque_id).rjust(32, b'\x00')
|
430
|
+
cheque_info = self.contract.functions.getTokenChequeInfo(cheque_id_bytes32).call({
|
431
|
+
cheque_id_bytes32
|
432
|
+
})
|
433
|
+
return cheque_info
|
380
434
|
async def getSwaoDetail(self, cheque_id: str):
|
381
|
-
|
382
|
-
s =
|
383
|
-
return{
|
435
|
+
cheque_id_bytes32 = Web3.to_bytes(hexstr=cheque_id).rjust(32, b'\x00') # паддинг до bytes32
|
436
|
+
s = self.contract.functions.getSwapDetail(cheque_id_bytes32).call()
|
437
|
+
return {
|
384
438
|
"tokenOut": s[0],
|
385
439
|
"amountOut": s[1],
|
386
440
|
}
|
441
|
+
|
387
442
|
class NFTcheque:
|
388
443
|
def __init__(self, w3:Web3, token:str, amount:int, spender:str):
|
389
444
|
self.w3 = w3
|
@@ -71,7 +71,6 @@ class SOLCheque:
|
|
71
71
|
print("❌ Config PDA not found.")
|
72
72
|
return None
|
73
73
|
|
74
|
-
# 🧠 У тебя data — это list[int], его нужно превратить в bytes
|
75
74
|
raw = bytes(response.value.data)
|
76
75
|
|
77
76
|
if len(raw) < 89:
|
@@ -263,7 +262,6 @@ class SOLCheque:
|
|
263
262
|
]
|
264
263
|
)
|
265
264
|
|
266
|
-
# === 6. Собираем и отправляем всё в одном tx ===
|
267
265
|
print("Accounts (ix_program):")
|
268
266
|
for i, acc in enumerate(ix_program.accounts):
|
269
267
|
print(f"[{i}] {acc.pubkey} | signer={acc.is_signer} | writable={acc.is_writable}")
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: shadowPaySDK
|
3
|
-
Version: 16.7.2025.1
|
3
|
+
Version: 16.7.2025.1.1
|
4
4
|
Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
|
5
|
-
Author: dazay
|
6
|
-
Author-email:
|
5
|
+
Author: dazay
|
6
|
+
Author-email: shadowpay.protocol@gmail.com
|
7
7
|
License: MIT
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -1,48 +0,0 @@
|
|
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
|
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
|
{shadowpaysdk-16.7.2025.1 → shadowpaysdk-16.7.2025.1.1}/shadowPaySDK.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|