shadowPaySDK 16.7.2025__tar.gz → 16.7.2025.1.0__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 → shadowpaysdk-16.7.2025.1.0}/PKG-INFO +3 -3
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/setup.py +3 -3
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/const.py +202 -126
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/interface/erc20.py +10 -15
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/interface/sol.py +0 -5
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/types/EVMcheque.py +94 -41
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/types/SOLcheque.py +0 -2
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK.egg-info/PKG-INFO +3 -3
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK.egg-info/SOURCES.txt +0 -1
- shadowpaysdk-16.7.2025/shadowPaySDK/api.py +0 -48
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/LICENSE +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/README.md +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/setup.cfg +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/__init__.py +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/interface/__init__.py +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/interface/erc721.py +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/types/__init__.py +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/utils/__init__.py +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK/utils/utils.py +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK.egg-info/requires.txt +0 -0
- {shadowpaysdk-16.7.2025 → shadowpaysdk-16.7.2025.1.0}/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
|
3
|
+
Version: 16.7.2025.1.0
|
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',
|
5
|
+
version='16.07.2025.1.0',
|
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: "0x4C57988fa6641FAE69bBD5Ed679b14004aE88164"
|
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
228
|
{
|
227
229
|
"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
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",
|
@@ -347,6 +296,11 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
347
296
|
"internalType": "address payable[]",
|
348
297
|
"name": "to",
|
349
298
|
"type": "address[]"
|
299
|
+
},
|
300
|
+
{
|
301
|
+
"internalType": "bool",
|
302
|
+
"name": "claimed",
|
303
|
+
"type": "bool"
|
350
304
|
}
|
351
305
|
],
|
352
306
|
"stateMutability": "view",
|
@@ -397,38 +351,63 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
397
351
|
"internalType": "uint256",
|
398
352
|
"name": "amountOut",
|
399
353
|
"type": "uint256"
|
354
|
+
},
|
355
|
+
{
|
356
|
+
"internalType": "address",
|
357
|
+
"name": "spender",
|
358
|
+
"type": "address"
|
359
|
+
},
|
360
|
+
{
|
361
|
+
"internalType": "address",
|
362
|
+
"name": "receiver",
|
363
|
+
"type": "address"
|
364
|
+
},
|
365
|
+
{
|
366
|
+
"internalType": "bool",
|
367
|
+
"name": "claimed",
|
368
|
+
"type": "bool"
|
400
369
|
}
|
401
370
|
],
|
402
371
|
"stateMutability": "view",
|
403
372
|
"type": "function"
|
404
373
|
},
|
405
374
|
{
|
406
|
-
"inputs": [
|
407
|
-
|
375
|
+
"inputs": [
|
376
|
+
{
|
377
|
+
"internalType": "bytes32",
|
378
|
+
"name": "id",
|
379
|
+
"type": "bytes32"
|
380
|
+
}
|
381
|
+
],
|
382
|
+
"name": "getTokenChequeDetail",
|
408
383
|
"outputs": [
|
409
384
|
{
|
410
385
|
"internalType": "address",
|
411
|
-
"name": "",
|
386
|
+
"name": "spender",
|
387
|
+
"type": "address"
|
388
|
+
},
|
389
|
+
{
|
390
|
+
"internalType": "address",
|
391
|
+
"name": "receiver",
|
412
392
|
"type": "address"
|
393
|
+
},
|
394
|
+
{
|
395
|
+
"internalType": "bool",
|
396
|
+
"name": "claimed",
|
397
|
+
"type": "bool"
|
413
398
|
}
|
414
399
|
],
|
415
400
|
"stateMutability": "view",
|
416
401
|
"type": "function"
|
417
402
|
},
|
418
403
|
{
|
419
|
-
"inputs": [
|
420
|
-
|
421
|
-
"internalType": "address",
|
422
|
-
"name": "_addrr",
|
423
|
-
"type": "address"
|
424
|
-
}
|
425
|
-
],
|
426
|
-
"name": "getUserChequeCount",
|
404
|
+
"inputs": [],
|
405
|
+
"name": "getTreasery",
|
427
406
|
"outputs": [
|
428
407
|
{
|
429
|
-
"internalType": "
|
408
|
+
"internalType": "address",
|
430
409
|
"name": "",
|
431
|
-
"type": "
|
410
|
+
"type": "address"
|
432
411
|
}
|
433
412
|
],
|
434
413
|
"stateMutability": "view",
|
@@ -479,6 +458,78 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
479
458
|
"stateMutability": "view",
|
480
459
|
"type": "function"
|
481
460
|
},
|
461
|
+
{
|
462
|
+
"inputs": [
|
463
|
+
{
|
464
|
+
"internalType": "uint256",
|
465
|
+
"name": "_minFee",
|
466
|
+
"type": "uint256"
|
467
|
+
},
|
468
|
+
{
|
469
|
+
"internalType": "uint256",
|
470
|
+
"name": "_maxFees",
|
471
|
+
"type": "uint256"
|
472
|
+
},
|
473
|
+
{
|
474
|
+
"internalType": "uint256",
|
475
|
+
"name": "_minEth",
|
476
|
+
"type": "uint256"
|
477
|
+
},
|
478
|
+
{
|
479
|
+
"internalType": "uint256",
|
480
|
+
"name": "_baseFee",
|
481
|
+
"type": "uint256"
|
482
|
+
}
|
483
|
+
],
|
484
|
+
"name": "setFees",
|
485
|
+
"outputs": [],
|
486
|
+
"stateMutability": "nonpayable",
|
487
|
+
"type": "function"
|
488
|
+
},
|
489
|
+
{
|
490
|
+
"inputs": [
|
491
|
+
{
|
492
|
+
"internalType": "uint256",
|
493
|
+
"name": "_TokenChequepercentage",
|
494
|
+
"type": "uint256"
|
495
|
+
},
|
496
|
+
{
|
497
|
+
"internalType": "uint256",
|
498
|
+
"name": "_SwapTokenChequepercentage",
|
499
|
+
"type": "uint256"
|
500
|
+
}
|
501
|
+
],
|
502
|
+
"name": "setTokenFees",
|
503
|
+
"outputs": [],
|
504
|
+
"stateMutability": "nonpayable",
|
505
|
+
"type": "function"
|
506
|
+
},
|
507
|
+
{
|
508
|
+
"inputs": [
|
509
|
+
{
|
510
|
+
"internalType": "address",
|
511
|
+
"name": "_treaseryAddress",
|
512
|
+
"type": "address"
|
513
|
+
}
|
514
|
+
],
|
515
|
+
"name": "setTreasery",
|
516
|
+
"outputs": [],
|
517
|
+
"stateMutability": "nonpayable",
|
518
|
+
"type": "function"
|
519
|
+
},
|
520
|
+
{
|
521
|
+
"inputs": [],
|
522
|
+
"name": "swapBasicPoints",
|
523
|
+
"outputs": [
|
524
|
+
{
|
525
|
+
"internalType": "uint256",
|
526
|
+
"name": "",
|
527
|
+
"type": "uint256"
|
528
|
+
}
|
529
|
+
],
|
530
|
+
"stateMutability": "view",
|
531
|
+
"type": "function"
|
532
|
+
},
|
482
533
|
{
|
483
534
|
"inputs": [
|
484
535
|
{
|
@@ -540,6 +591,31 @@ __SHADOWPAY_ABI__ERC20__= json.loads("""[
|
|
540
591
|
],
|
541
592
|
"stateMutability": "view",
|
542
593
|
"type": "function"
|
594
|
+
},
|
595
|
+
{
|
596
|
+
"inputs": [
|
597
|
+
{
|
598
|
+
"internalType": "uint256",
|
599
|
+
"name": "amount",
|
600
|
+
"type": "uint256"
|
601
|
+
},
|
602
|
+
{
|
603
|
+
"internalType": "address",
|
604
|
+
"name": "_to",
|
605
|
+
"type": "address"
|
606
|
+
}
|
607
|
+
],
|
608
|
+
"name": "withdrawAmount",
|
609
|
+
"outputs": [],
|
610
|
+
"stateMutability": "nonpayable",
|
611
|
+
"type": "function"
|
612
|
+
},
|
613
|
+
{
|
614
|
+
"inputs": [],
|
615
|
+
"name": "withdrawFees",
|
616
|
+
"outputs": [],
|
617
|
+
"stateMutability": "nonpayable",
|
618
|
+
"type": "function"
|
543
619
|
}
|
544
620
|
]""")
|
545
621
|
|
@@ -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:
|
@@ -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
|
161
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
|
+
})
|
162
180
|
|
163
|
-
|
181
|
+
txn = self.contract.functions.CashOutCheque(
|
182
|
+
Web3.to_bytes(hexstr=cheque_id)
|
183
|
+
).build_transaction(tx_common)
|
164
184
|
|
185
|
+
if self.return_build_tx:
|
186
|
+
return {"build_tx": txn}
|
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,8 +402,7 @@ 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):
|
@@ -378,12 +410,33 @@ class Cheque:
|
|
378
410
|
async def getTreasery(self):
|
379
411
|
return self.contract.functions.getTreasery().call()
|
380
412
|
async def getSwaoDetail(self, cheque_id: str):
|
381
|
-
|
382
|
-
s =
|
383
|
-
return{
|
413
|
+
cheque_id_bytes32 = Web3.to_bytes(hexstr=cheque_id).rjust(32, b'\x00') # паддинг до bytes32
|
414
|
+
s = self.contract.functions.getSwapDetail(cheque_id_bytes32).call()
|
415
|
+
return {
|
384
416
|
"tokenOut": s[0],
|
385
417
|
"amountOut": s[1],
|
386
418
|
}
|
419
|
+
async def getNativeChequeDetail(self,id, address:Optional[str] = None):
|
420
|
+
if not address:
|
421
|
+
address = self.w3.eth.default_account or self.w3.eth.account.from_key(self.private_key).address
|
422
|
+
address = Web3.to_checksum_address(address)
|
423
|
+
cheque_id_bytes32 = Web3.to_bytes(hexstr=id).rjust(32, b'\x00') # паддинг до bytes32
|
424
|
+
|
425
|
+
data = self.contract.functions.getChequeInfo(cheque_id_bytes32, address).call()
|
426
|
+
return {
|
427
|
+
"amount":data[0],
|
428
|
+
"reciver": data[1],
|
429
|
+
"status": data[2],
|
430
|
+
}
|
431
|
+
async def getTokenChequeDetail(self,id):
|
432
|
+
cheque_id_bytes32 = Web3.to_bytes(hexstr=id).rjust(32, b'\x00')
|
433
|
+
data = self.contract.functions.getTokenChequeInfo(cheque_id_bytes32).call()
|
434
|
+
return{
|
435
|
+
"from":data[0],
|
436
|
+
"to":data[1],
|
437
|
+
"claimed":data[2],
|
438
|
+
}
|
439
|
+
|
387
440
|
class NFTcheque:
|
388
441
|
def __init__(self, w3:Web3, token:str, amount:int, spender:str):
|
389
442
|
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
|
3
|
+
Version: 16.7.2025.1.0
|
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 → shadowpaysdk-16.7.2025.1.0}/shadowPaySDK.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|