forked from neonevm/neon-evm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolana-py.patch
58 lines (47 loc) · 2.48 KB
/
solana-py.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- solana/rpc/api.py 2021-05-25 13:08:52.430148672 +0300
+++ solana/rpc/api.py 2021-05-25 13:08:43.102202173 +0300
@@ -14,7 +14,7 @@
from solana.publickey import PublicKey
from solana.transaction import Transaction
-from .commitment import Commitment, Max
+from .commitment import Commitment, Max, Confirmed
from .providers import http
@@ -33,6 +33,11 @@
return types.MemcmpOpts(*args, **kwargs)
+class SendTransactionError(Exception):
+ def __init__(self, result):
+ super().__init__(result['message'])
+ self.result=result
+
class Client: # pylint: disable=too-many-public-methods
"""Client class."""
@@ -284,7 +289,7 @@
return self._provider.make_request(types.RPCMethod("getConfirmedSignaturesForAddress2"), account, opts)
- def get_confirmed_transaction(self, tx_sig: str, encoding: str = "json") -> types.RPCResponse:
+ def get_confirmed_transaction(self, tx_sig: str, encoding: str = "json", commitment : Commitment = Confirmed) -> types.RPCResponse:
"""Returns transaction details for a confirmed transaction.
:param tx_sig: Transaction signature as base-58 encoded string N encoding attempts to use program-specific
@@ -315,7 +320,7 @@
'signatures': ['3PtGYH77LhhQqTXP4SmDVJ85hmDieWsgXCUbn14v7gYyVYPjZzygUQhTk3bSTYnfA48vCM1rmWY7zWL3j1EVKmEy']}},
'id': 4}
""" # noqa: E501 # pylint: disable=line-too-long
- return self._provider.make_request(types.RPCMethod("getConfirmedTransaction"), tx_sig, encoding)
+ return self._provider.make_request(types.RPCMethod("getConfirmedTransaction"), tx_sig, {self._comm_key: commitment, self._encoding_key: encoding})
def get_epoch_info(self, commitment: Commitment = Max) -> types.RPCResponse:
"""Returns information about the current epoch.
@@ -1039,6 +1044,7 @@
def __post_send(self, resp: types.RPCResponse, skip_confirm: bool, conf_comm: Commitment) -> types.RPCResponse:
if resp.get("error"):
self._provider.logger.error(resp.get("error"))
+ raise SendTransactionError(resp.get("error"))
if not resp.get("result"):
raise Exception("Failed to send transaction")
if skip_confirm:
--- solana/rpc/commitment.py 2021-05-25 13:09:06.898065852 +0300
+++ solana/rpc/commitment.py 2021-05-25 13:08:43.102202173 +0300
@@ -26,3 +26,5 @@
Recent = Commitment("recent")
"""The node will query its most recent bank."""
+
+Confirmed = Commitment("confirmed")
\ No newline at end of file