shadowPaySDK 0.2.0.7__tar.gz → 0.2.0.10__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.7 → shadowpaysdk-0.2.0.10}/PKG-INFO +1 -1
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/setup.py +1 -1
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/interface/sol.py +29 -29
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/types/EVMcheque.py +28 -20
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/types/SOLcheque.py +3 -4
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK.egg-info/PKG-INFO +1 -1
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/LICENSE +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/README.md +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/setup.cfg +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/__init__.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/api.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/const.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/interface/__init__.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/interface/erc20.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/interface/erc721.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/types/__init__.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/utils/__init__.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK/utils/utils.py +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK.egg-info/SOURCES.txt +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK.egg-info/dependency_links.txt +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/shadowPaySDK.egg-info/requires.txt +0 -0
- {shadowpaysdk-0.2.0.7 → shadowpaysdk-0.2.0.10}/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.10',
|
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,18 +1,20 @@
|
|
1
1
|
import asyncio
|
2
|
+
import solana
|
2
3
|
from solana.rpc.async_api import AsyncClient, GetTokenAccountsByOwnerResp
|
4
|
+
from solders.transaction import Transaction
|
5
|
+
from solders.system_program import TransferParams as p
|
3
6
|
import spl
|
4
7
|
import spl.token
|
5
8
|
import spl.token.constants
|
6
|
-
from spl.token.instructions import get_associated_token_address, create_associated_token_account, transfer, close_account
|
9
|
+
from spl.token.instructions import get_associated_token_address, create_associated_token_account, transfer, close_account, TransferParams
|
7
10
|
from spl.token.constants import TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID
|
8
|
-
from solana.constants import *
|
9
11
|
from solana.rpc.types import TxOpts, TokenAccountOpts
|
10
12
|
from solana.rpc.types import TxOpts
|
11
13
|
import solders
|
12
|
-
from solders.pubkey import Pubkey
|
13
|
-
from solders.keypair import Keypair
|
14
|
-
from solders.signature import Signature
|
15
|
-
from solders.transaction import Transaction
|
14
|
+
# from solders.pubkey import Pubkey
|
15
|
+
# from solders.keypair import Keypair
|
16
|
+
# from solders.signature import Signature
|
17
|
+
# from solders.transaction import Transaction
|
16
18
|
from spl.token.async_client import AsyncToken
|
17
19
|
|
18
20
|
|
@@ -27,9 +29,11 @@ import base64
|
|
27
29
|
import re
|
28
30
|
|
29
31
|
|
32
|
+
LAMPORTS_PER_SOL = 1_000_000_000 # 1 SOL = 1,000,000,000 lamports
|
33
|
+
|
30
34
|
class SOL:
|
31
35
|
|
32
|
-
def __init__(self, rpc_url = "https://api.mainnet-beta.solana.com", KEYPAIR: Optional[Union[str, Keypair]] = None,TOKEN_MINT: Optional[str] = None):
|
36
|
+
def __init__(self, rpc_url = "https://api.mainnet-beta.solana.com", KEYPAIR: Optional[Union[str, solders.keypair.Keypair]] = None,TOKEN_MINT: Optional[str] = None):
|
33
37
|
self.rpc_url = rpc_url
|
34
38
|
self.client = AsyncClient(rpc_url)
|
35
39
|
self.KEYPAIR = None
|
@@ -39,18 +43,18 @@ class SOL:
|
|
39
43
|
if KEYPAIR:
|
40
44
|
self.set_keypair(KEYPAIR)
|
41
45
|
|
42
|
-
def set_keypair(self, KEYPAIR: Union[str, Keypair]):
|
46
|
+
def set_keypair(self, KEYPAIR: Union[str, solders.keypair.Keypair]):
|
43
47
|
if isinstance(KEYPAIR, str):
|
44
48
|
try:
|
45
|
-
self.KEYPAIR = Keypair.from_base58_string(KEYPAIR)
|
49
|
+
self.KEYPAIR = solders.keypair.Keypair.from_base58_string(KEYPAIR)
|
46
50
|
except Exception as e:
|
47
51
|
raise ValueError(f"Invalid Keypair string: {e}")
|
48
|
-
elif isinstance(KEYPAIR, Keypair):
|
52
|
+
elif isinstance(KEYPAIR, solders.keypair.Keypair):
|
49
53
|
self.KEYPAIR = KEYPAIR
|
50
54
|
else:
|
51
55
|
raise ValueError("KEYPAIR must be a Keypair instance or a base58 encoded string.")
|
52
56
|
|
53
|
-
def set_params(self, rpc_url: Optional[str] = None, KEYPAIR: Optional[Union[str, Keypair]] = None,TOKEN_MINT: Optional[str] = None):
|
57
|
+
def set_params(self, rpc_url: Optional[str] = None, KEYPAIR: Optional[Union[str, solders.keypair.Keypair]] = None,TOKEN_MINT: Optional[str] = None):
|
54
58
|
if rpc_url:
|
55
59
|
self.rpc_url = rpc_url
|
56
60
|
self.client = AsyncClient(rpc_url)
|
@@ -72,7 +76,7 @@ class SOL:
|
|
72
76
|
raise ValueError("Keypair not set")
|
73
77
|
|
74
78
|
def gen_wallet(self):
|
75
|
-
return Keypair()
|
79
|
+
return solders.keypair.Keypair()
|
76
80
|
async def get_balance(self):
|
77
81
|
resp = await self.client.get_balance(self.get_pubkey())
|
78
82
|
lamports = resp.value
|
@@ -117,14 +121,14 @@ class SOL:
|
|
117
121
|
await self.client.close()
|
118
122
|
|
119
123
|
async def fetch_metadata_raw(self,mint_address: str):
|
120
|
-
METADATA_PROGRAM_ID = Pubkey.from_string("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
|
121
|
-
mint = Pubkey.from_string(mint_address)
|
124
|
+
METADATA_PROGRAM_ID = solders.pubkey.Pubkey.from_string("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
|
125
|
+
mint = solders.pubkey.Pubkey.from_string(mint_address)
|
122
126
|
seeds = [
|
123
127
|
b"metadata",
|
124
128
|
bytes(METADATA_PROGRAM_ID),
|
125
129
|
bytes(mint),
|
126
130
|
]
|
127
|
-
pda, _ = Pubkey.find_program_address(seeds, METADATA_PROGRAM_ID)
|
131
|
+
pda, _ = solders.pubkey.Pubkey.find_program_address(seeds, METADATA_PROGRAM_ID)
|
128
132
|
|
129
133
|
payload = {
|
130
134
|
"jsonrpc": "2.0",
|
@@ -162,8 +166,8 @@ class SOL:
|
|
162
166
|
raise ValueError("not set KEYPAIR.")
|
163
167
|
|
164
168
|
sender_pubkey = self.get_pubkey()
|
165
|
-
receiver_pubkey = Pubkey.from_string(to)
|
166
|
-
token_pubkey = Pubkey.from_string(self.TOKEN_MINT)
|
169
|
+
receiver_pubkey = solders.pubkey.Pubkey.from_string(to)
|
170
|
+
token_pubkey = solders.pubkey.Pubkey.from_string(self.TOKEN_MINT)
|
167
171
|
|
168
172
|
token = AsyncToken(self.client, token_pubkey, TOKEN_PROGRAM_ID, self.KEYPAIR)
|
169
173
|
sender_ata = get_associated_token_address(sender_pubkey, token_pubkey)
|
@@ -183,17 +187,16 @@ class SOL:
|
|
183
187
|
|
184
188
|
decimals = (await token.get_mint_info()).decimals
|
185
189
|
real_amount = int(amount * (10 ** decimals))
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
amount=real_amount,
|
193
|
-
program_id=TOKEN_PROGRAM_ID,
|
194
|
-
)
|
190
|
+
params = TransferParams(
|
191
|
+
program_id=TOKEN_PROGRAM_ID,
|
192
|
+
source=sender_ata,
|
193
|
+
dest=receiver_ata,
|
194
|
+
owner=sender_pubkey,
|
195
|
+
amount=real_amount
|
195
196
|
)
|
196
197
|
|
198
|
+
tx.add(transfer(params))
|
199
|
+
|
197
200
|
resp = await self.client.send_transaction(tx, self.KEYPAIR, opts=TxOpts(skip_preflight=True, preflight_commitment=Confirmed))
|
198
201
|
return resp.value
|
199
202
|
|
@@ -201,6 +204,3 @@ class SOL:
|
|
201
204
|
|
202
205
|
|
203
206
|
|
204
|
-
if __name__ == "__main__":
|
205
|
-
newKeypair = Keypair()
|
206
|
-
print("New Keypair:", newKeypair)
|
@@ -7,18 +7,18 @@ 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):
|
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.return_build_tx = retunrn_build_tx
|
18
18
|
self.allowed_chains = allowed_chains
|
19
19
|
if self.w3 != None:
|
20
20
|
self.__allow__()
|
21
|
-
|
21
|
+
|
22
22
|
def __get__id(self, tx):
|
23
23
|
try:
|
24
24
|
logs = self.contract.events.ChequeCreated().process_receipt(tx)
|
@@ -80,6 +80,11 @@ class Cheque:
|
|
80
80
|
'gasPrice': self.w3.eth.gas_price,
|
81
81
|
'chainId': self.w3.eth.chain_id
|
82
82
|
})
|
83
|
+
if self.return_build_tx:
|
84
|
+
return {
|
85
|
+
"build_tx": txn
|
86
|
+
}
|
87
|
+
|
83
88
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key or self.private_key)
|
84
89
|
txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
85
90
|
txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
|
@@ -121,6 +126,10 @@ class Cheque:
|
|
121
126
|
'gas': 300_000,
|
122
127
|
'gasPrice': self.w3.to_wei('5', 'gwei'),
|
123
128
|
})
|
129
|
+
if self.return_build_tx:
|
130
|
+
return {
|
131
|
+
"build_tx": txn
|
132
|
+
}
|
124
133
|
|
125
134
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
|
126
135
|
|
@@ -163,6 +172,10 @@ class Cheque:
|
|
163
172
|
'gas': estimated_gas,
|
164
173
|
'gasPrice': self.w3.eth.gas_price
|
165
174
|
})
|
175
|
+
if self.return_build_tx:
|
176
|
+
return {
|
177
|
+
"build_tx": txn
|
178
|
+
}
|
166
179
|
signed_txn = self.w3.eth.account.sign_transaction(txn, self.private_key)
|
167
180
|
txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
168
181
|
txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
|
@@ -201,6 +214,10 @@ class Cheque:
|
|
201
214
|
'gas': estimated_gas,
|
202
215
|
'gasPrice': self.w3.eth.gas_price,
|
203
216
|
})
|
217
|
+
if self.return_build_tx:
|
218
|
+
return {
|
219
|
+
"build_tx": txn
|
220
|
+
}
|
204
221
|
|
205
222
|
signed_txn = self.w3.eth.account.sign_transaction(txn, private_key=private_key)
|
206
223
|
tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
@@ -247,6 +264,10 @@ class Cheque:
|
|
247
264
|
'gas': estimated_gas,
|
248
265
|
'gasPrice': self.w3.eth.gas_price
|
249
266
|
})
|
267
|
+
if self.return_build_tx:
|
268
|
+
return {
|
269
|
+
"build_tx": txn
|
270
|
+
}
|
250
271
|
signed_txn = self.w3.eth.account.sign_transaction(txn, self.private_key)
|
251
272
|
txn_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
252
273
|
txn_receipt = self.w3.eth.wait_for_transaction_receipt(txn_hash)
|
@@ -291,6 +312,10 @@ class Cheque:
|
|
291
312
|
'gas': 300_000,
|
292
313
|
'gasPrice': self.w3.eth.gas_price
|
293
314
|
})
|
315
|
+
if self.return_build_tx:
|
316
|
+
return {
|
317
|
+
"build_tx": swa
|
318
|
+
}
|
294
319
|
signed_txn = self.w3.eth.account.sign_transaction(swa, private_key=private_key)
|
295
320
|
tx_hash = self.w3.eth.send_raw_transaction(signed_txn.raw_transaction)
|
296
321
|
receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash)
|
@@ -350,20 +375,3 @@ class NFTcheque:
|
|
350
375
|
|
351
376
|
|
352
377
|
|
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
|
@@ -1,10 +1,9 @@
|
|
1
1
|
|
2
2
|
import anchorpy
|
3
3
|
from anchorpy import Idl, Provider, Wallet
|
4
|
+
import solders
|
4
5
|
from shadowPaySDK.interface.sol import SOL
|
5
|
-
|
6
|
-
import solana.constants as constants
|
7
|
-
import solana.constants as sol_constants
|
6
|
+
import solders
|
8
7
|
import spl.token.constants as spl_constants
|
9
8
|
|
10
9
|
|
@@ -17,7 +16,7 @@ class SOLCheque:
|
|
17
16
|
self.WRAPED_SOL = spl_constants.WRAPPED_SOL_MINT # wrapped SOL token mint address
|
18
17
|
# self.idl = Idl.from_json(sol_interface.Idl) # Load the IDL for the program
|
19
18
|
def get(self, keypair = None):
|
20
|
-
pubkey = SOL.get_pubkey(KEYPAIR=Keypair.from_base58_string(self.keystore))
|
19
|
+
pubkey = SOL.get_pubkey(KEYPAIR=solders.keypair.Keypair.from_base58_string(self.keystore))
|
21
20
|
|
22
21
|
return pubkey
|
23
22
|
|
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
|