shadowPaySDK 0.2.0.9__py3-none-any.whl → 0.2.0.11__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.
@@ -1,6 +1,7 @@
1
1
  import asyncio
2
+ import solana
2
3
  from solana.rpc.async_api import AsyncClient, GetTokenAccountsByOwnerResp
3
- from solana.transaction import Transaction
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowPaySDK
3
- Version: 0.2.0.9
3
+ Version: 0.2.0.11
4
4
  Summary: ShadowPay SDK for ERC20/ERC721 and P2P smart contract interaction
5
5
  Author: dazarius_
6
6
  Author-email: your@email.com
@@ -4,14 +4,14 @@ shadowPaySDK/const.py,sha256=T7TJPKFLqCtxwpUYO1AOryGMr65G-vVuotxfL8gWcME,9898
4
4
  shadowPaySDK/interface/__init__.py,sha256=ggSZCV22udnzXm_Wv_3x6VN3hNIAEiwgwHZc2Jwc688,146
5
5
  shadowPaySDK/interface/erc20.py,sha256=TIsek7ykuYsLMj5no-uastA5gYsIbk-F_Dq-5XPk_6w,4298
6
6
  shadowPaySDK/interface/erc721.py,sha256=4AlWfDjrvl85wFocnN93j-oM54kTsLLwv9SdtcLj4eM,3094
7
- shadowPaySDK/interface/sol.py,sha256=IKzG9b-XwMgCCH2GdmbVrNXvhwTJ0iUqlziFlQBQmKc,7322
8
- shadowPaySDK/types/EVMcheque.py,sha256=QjWuIKztb7MqnzFT82L6kWcxDgAkBxpSMrZ2a2Voa34,13676
7
+ shadowPaySDK/interface/sol.py,sha256=flMfmW14J4ybfVshUUTw6iklKa5x-zJzjxRi011XKXA,7230
8
+ shadowPaySDK/types/EVMcheque.py,sha256=xhiJsTQVECr8gCcL0J5jI0cV3ZUgZbKW0bPtOjYdCMw,14039
9
9
  shadowPaySDK/types/SOLcheque.py,sha256=S6LnKxiWDj1KGRgFFAaHy03c7mxv4msaR-2cfVIhD2Y,818
10
10
  shadowPaySDK/types/__init__.py,sha256=sG6pNZfKGvENXqsnv6MrQtKrJ898fAXkMvAZY1k1-Qg,97
11
11
  shadowPaySDK/utils/__init__.py,sha256=aja3iYO4rT-ptMM-pzw0GRFTziBdXdcEi-4kE84zH64,61
12
12
  shadowPaySDK/utils/utils.py,sha256=g4bGvLDdjhNGsAj1eaZnNWFNaiN-cVhhM-5PrnG5aIQ,720
13
- shadowpaysdk-0.2.0.9.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
- shadowpaysdk-0.2.0.9.dist-info/METADATA,sha256=OMBbMZ95ekjJNO8_7JyW5VQtNBUWgN-szVIWs7PjnOw,839
15
- shadowpaysdk-0.2.0.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- shadowpaysdk-0.2.0.9.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
- shadowpaysdk-0.2.0.9.dist-info/RECORD,,
13
+ shadowpaysdk-0.2.0.11.dist-info/licenses/LICENSE,sha256=EG13vNmyBfkG3oKj40oOYfUGLKko8OouU6PfO6MlAk4,1066
14
+ shadowpaysdk-0.2.0.11.dist-info/METADATA,sha256=T0f21bjsGbrLuMq8eS1Y5KozgqXp0TuvxVVsKMoyZuc,840
15
+ shadowpaysdk-0.2.0.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ shadowpaysdk-0.2.0.11.dist-info/top_level.txt,sha256=RSJc73GEf31NMdZp9KovEduzfhm10eQ2t5GTZ44aN1U,13
17
+ shadowpaysdk-0.2.0.11.dist-info/RECORD,,