helius-python 0.3.1__py3-none-any.whl → 0.3.3__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.
- helius/laserstream/websockets.py +2 -1
- helius/solana_rpc/client.py +85 -0
- helius/solana_rpc/models.py +98 -0
- {helius_python-0.3.1.dist-info → helius_python-0.3.3.dist-info}/METADATA +9 -6
- {helius_python-0.3.1.dist-info → helius_python-0.3.3.dist-info}/RECORD +7 -7
- {helius_python-0.3.1.dist-info → helius_python-0.3.3.dist-info}/WHEEL +0 -0
- {helius_python-0.3.1.dist-info → helius_python-0.3.3.dist-info}/licenses/LICENSE +0 -0
helius/laserstream/websockets.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from os import environ
|
|
3
|
-
from typing import Annotated, Literal
|
|
3
|
+
from typing import Annotated, Literal
|
|
4
4
|
|
|
5
5
|
import httpx
|
|
6
6
|
from dotenv import dotenv_values
|
|
7
7
|
from pydantic import AliasGenerator, BaseModel, ConfigDict, Field, model_validator
|
|
8
8
|
from pydantic.alias_generators import to_camel
|
|
9
|
+
from typing_extensions import TypedDict
|
|
9
10
|
from websockets.sync.client import connect
|
|
10
11
|
|
|
11
12
|
from helius.rpc import JsonRpcRequest
|
helius/solana_rpc/client.py
CHANGED
|
@@ -25,7 +25,12 @@ from helius.solana_rpc.models import (
|
|
|
25
25
|
TokenAccountBalance,
|
|
26
26
|
TokenSupply,
|
|
27
27
|
Transaction,
|
|
28
|
+
TransactionFilters,
|
|
29
|
+
TransactionFullDetail,
|
|
28
30
|
TransactionSignature,
|
|
31
|
+
TransactionSignaturesDetail,
|
|
32
|
+
Transfer,
|
|
33
|
+
TransferFilters,
|
|
29
34
|
VotingAccount,
|
|
30
35
|
)
|
|
31
36
|
|
|
@@ -983,3 +988,83 @@ class SolanaRpcClient:
|
|
|
983
988
|
)
|
|
984
989
|
response = self._send(request)
|
|
985
990
|
return response["result"]
|
|
991
|
+
|
|
992
|
+
@validate_call
|
|
993
|
+
def get_transactions_for_address(
|
|
994
|
+
self,
|
|
995
|
+
*,
|
|
996
|
+
address: str,
|
|
997
|
+
transaction_details: Literal["signatures", "full"] | None = None,
|
|
998
|
+
sort_order: Literal["asc", "desc"] | None = None,
|
|
999
|
+
commitment: Literal["confirmed", "finalized"] | None = None,
|
|
1000
|
+
min_context_slot: int | None = None,
|
|
1001
|
+
limit: Annotated[int, Field(ge=1, le=1000)] | None = None,
|
|
1002
|
+
pagination_token: str | None = None,
|
|
1003
|
+
encoding: Literal["json", "jsonParsed", "base58", "base64"] | None = None,
|
|
1004
|
+
max_supported_transaction_version: int | None = None,
|
|
1005
|
+
filters: TransactionFilters | None = None,
|
|
1006
|
+
) -> tuple[
|
|
1007
|
+
list[TransactionSignaturesDetail] | list[TransactionFullDetail], str | None
|
|
1008
|
+
]:
|
|
1009
|
+
request = (
|
|
1010
|
+
JsonRpcRequest(method="getTransactionsForAddress")
|
|
1011
|
+
.add(address)
|
|
1012
|
+
.set("transactionDetails", transaction_details)
|
|
1013
|
+
.set("sortOrder", sort_order)
|
|
1014
|
+
.set("commitment", commitment)
|
|
1015
|
+
.set("minContextSlot", min_context_slot)
|
|
1016
|
+
.set("limit", limit)
|
|
1017
|
+
.set("paginationToken", pagination_token)
|
|
1018
|
+
.set("encoding", encoding)
|
|
1019
|
+
.set("maxSupportedTransactionVersion", max_supported_transaction_version)
|
|
1020
|
+
.set("filters", filters)
|
|
1021
|
+
.build()
|
|
1022
|
+
)
|
|
1023
|
+
response = self._send(request)
|
|
1024
|
+
pagination_token = response["result"]["paginationToken"]
|
|
1025
|
+
data = response["result"]["data"]
|
|
1026
|
+
ta = TypeAdapter(
|
|
1027
|
+
list[TransactionSignaturesDetail]
|
|
1028
|
+
if transaction_details == "signatures"
|
|
1029
|
+
else list[TransactionFullDetail]
|
|
1030
|
+
)
|
|
1031
|
+
transactions = ta.validate_python(data)
|
|
1032
|
+
return transactions, pagination_token
|
|
1033
|
+
|
|
1034
|
+
@validate_call
|
|
1035
|
+
def get_transfers_by_address(
|
|
1036
|
+
self,
|
|
1037
|
+
*,
|
|
1038
|
+
address: str,
|
|
1039
|
+
with_address: str | None = None,
|
|
1040
|
+
direction: Literal["in", "out", "any"] | None = None,
|
|
1041
|
+
mint: str | None = None,
|
|
1042
|
+
sol_mode: Literal["merged", "separate"] | None = None,
|
|
1043
|
+
filters: TransferFilters | None = None,
|
|
1044
|
+
limit: Annotated[int, Field(ge=1, le=100)] | None = None,
|
|
1045
|
+
pagination_token: str | None = None,
|
|
1046
|
+
commitment: Literal["finalized", "confirmed"] | None = None,
|
|
1047
|
+
min_context_slot: int | None = None,
|
|
1048
|
+
sort_order: Literal["asc", "desc"] | None = None,
|
|
1049
|
+
) -> tuple[list[Transfer], str | None]:
|
|
1050
|
+
request = (
|
|
1051
|
+
JsonRpcRequest(method="getTransfersByAddress")
|
|
1052
|
+
.add(address)
|
|
1053
|
+
.set("with", with_address)
|
|
1054
|
+
.set("direction", direction)
|
|
1055
|
+
.set("mint", mint)
|
|
1056
|
+
.set("solMode", sol_mode)
|
|
1057
|
+
.set("filters", filters)
|
|
1058
|
+
.set("limit", limit)
|
|
1059
|
+
.set("paginationToken", pagination_token)
|
|
1060
|
+
.set("commitment", commitment)
|
|
1061
|
+
.set("minContextSlot", min_context_slot)
|
|
1062
|
+
.set("sortOrder", sort_order)
|
|
1063
|
+
.build()
|
|
1064
|
+
)
|
|
1065
|
+
response = self._send(request)
|
|
1066
|
+
pagination_token = response["result"]["paginationToken"]
|
|
1067
|
+
data = response["result"]["data"]
|
|
1068
|
+
ta = TypeAdapter(list[Transfer])
|
|
1069
|
+
transfers = ta.validate_python(data)
|
|
1070
|
+
return transfers, pagination_token
|
helius/solana_rpc/models.py
CHANGED
|
@@ -2,6 +2,9 @@ from typing import Literal
|
|
|
2
2
|
|
|
3
3
|
from pydantic import AliasGenerator, BaseModel, ConfigDict
|
|
4
4
|
from pydantic.alias_generators import to_camel
|
|
5
|
+
from typing_extensions import TypedDict
|
|
6
|
+
|
|
7
|
+
# TODO: Improve camelCase <-> snake_case
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
class Account(BaseModel):
|
|
@@ -221,3 +224,98 @@ class Transaction(BaseModel):
|
|
|
221
224
|
meta: TransactionMetadata | None
|
|
222
225
|
transaction: dict | list
|
|
223
226
|
version: Literal["legacy"] | int | None = None
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class RangeFilter(TypedDict, total=False):
|
|
230
|
+
gt: int
|
|
231
|
+
gte: int
|
|
232
|
+
lt: int
|
|
233
|
+
lte: int
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class ComparisonFilter(TypedDict, total=False):
|
|
237
|
+
gte: int
|
|
238
|
+
gt: int
|
|
239
|
+
lte: int
|
|
240
|
+
lt: int
|
|
241
|
+
eq: int
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
TokenTransferFilter = TypedDict(
|
|
245
|
+
"TokenTransferFilter",
|
|
246
|
+
{
|
|
247
|
+
"with": str,
|
|
248
|
+
"direction": Literal["in", "out", "any"],
|
|
249
|
+
"mint": str,
|
|
250
|
+
"amount": RangeFilter,
|
|
251
|
+
},
|
|
252
|
+
total=False,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class TransactionFilters(TypedDict, total=False):
|
|
257
|
+
slot: RangeFilter
|
|
258
|
+
blockTime: ComparisonFilter
|
|
259
|
+
signature: RangeFilter
|
|
260
|
+
status: Literal["succeeded", "failed", "any"]
|
|
261
|
+
tokenAccounts: Literal["none", "balanceChanged", "all"]
|
|
262
|
+
tokenTransfer: TokenTransferFilter
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class TransferFilters(TypedDict, total=False):
|
|
266
|
+
amount: RangeFilter
|
|
267
|
+
blockTime: RangeFilter
|
|
268
|
+
slot: RangeFilter
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class Transfer(BaseModel):
|
|
272
|
+
model_config = ConfigDict(alias_generator=AliasGenerator(validation_alias=to_camel))
|
|
273
|
+
|
|
274
|
+
signature: str
|
|
275
|
+
slot: int
|
|
276
|
+
block_time: int
|
|
277
|
+
type: Literal[
|
|
278
|
+
"transfer",
|
|
279
|
+
"mint",
|
|
280
|
+
"burn",
|
|
281
|
+
"wrap",
|
|
282
|
+
"unwrap",
|
|
283
|
+
"changeOwner",
|
|
284
|
+
"withdrawWithheldFee",
|
|
285
|
+
]
|
|
286
|
+
from_user_account: str | None
|
|
287
|
+
to_user_account: str | None
|
|
288
|
+
mint: str
|
|
289
|
+
amount: str
|
|
290
|
+
decimals: int
|
|
291
|
+
ui_amount: str
|
|
292
|
+
confirmation_status: Literal["finalized", "confirmed"]
|
|
293
|
+
transaction_idx: int
|
|
294
|
+
instruction_idx: int
|
|
295
|
+
inner_instruction_idx: int
|
|
296
|
+
from_token_account: str | None = None
|
|
297
|
+
to_token_account: str | None = None
|
|
298
|
+
fee_amount: str | None = None
|
|
299
|
+
fee_ui_amount: str | None = None
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class TransactionSignaturesDetail(BaseModel):
|
|
303
|
+
model_config = ConfigDict(alias_generator=AliasGenerator(validation_alias=to_camel))
|
|
304
|
+
|
|
305
|
+
signature: str
|
|
306
|
+
slot: int
|
|
307
|
+
transaction_index: int
|
|
308
|
+
err: dict | None
|
|
309
|
+
memo: str | None
|
|
310
|
+
block_time: int | None
|
|
311
|
+
confirmation_status: Literal["finalized", "confirmed"] | None
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class TransactionFullDetail(BaseModel):
|
|
315
|
+
model_config = ConfigDict(alias_generator=AliasGenerator(validation_alias=to_camel))
|
|
316
|
+
|
|
317
|
+
slot: int
|
|
318
|
+
transaction_index: int
|
|
319
|
+
transaction: dict
|
|
320
|
+
meta: dict | list
|
|
321
|
+
block_time: int | None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: helius-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Typed Python client for the Helius API
|
|
5
5
|
Project-URL: Homepage, https://github.com/markosnarinian/helius-python
|
|
6
6
|
Project-URL: Issues, https://github.com/markosnarinian/helius-python/issues
|
|
@@ -13,6 +13,7 @@ Requires-Python: >=3.10
|
|
|
13
13
|
Requires-Dist: httpx
|
|
14
14
|
Requires-Dist: pydantic
|
|
15
15
|
Requires-Dist: python-dotenv
|
|
16
|
+
Requires-Dist: typing-extensions
|
|
16
17
|
Requires-Dist: websockets
|
|
17
18
|
Provides-Extra: dev
|
|
18
19
|
Requires-Dist: pytest; extra == 'dev'
|
|
@@ -143,11 +144,11 @@ wraps it.
|
|
|
143
144
|
`programSubscribe`, and the rest) is **supported today**; other
|
|
144
145
|
platform features are **in progress**.
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
**Current status:** the standard Solana JSON-RPC surface, the
|
|
148
|
+
WebSocket subscription surface, and the Admin (account management)
|
|
149
|
+
usage endpoint are implemented today. Support for Helius RPC
|
|
150
|
+
extensions and the remaining REST endpoints is actively being worked
|
|
151
|
+
on.
|
|
151
152
|
|
|
152
153
|
## Goals
|
|
153
154
|
|
|
@@ -322,6 +323,8 @@ continuously.
|
|
|
322
323
|
| `minimumLedgerSlot` | `minimum_ledger_slot()` | [guide](https://www.helius.dev/docs/rpc/guides/minimumledgerslot), [reference](https://www.helius.dev/docs/api-reference/rpc/http/minimumledgerslot) |
|
|
323
324
|
| `requestAirdrop` | `request_airdrop(...)` | [guide](https://www.helius.dev/docs/rpc/guides/requestairdrop), [reference](https://www.helius.dev/docs/api-reference/rpc/http/requestairdrop) |
|
|
324
325
|
| `sendTransaction` | `send_transaction(...)` | [guide](https://www.helius.dev/docs/rpc/guides/sendtransaction), [reference](https://www.helius.dev/docs/api-reference/rpc/http/sendtransaction) |
|
|
326
|
+
| `getTransactionsForAddress` | `get_transactions_for_address(...)` | [reference](https://www.helius.dev/docs/api-reference/rpc/http/gettransactionsforaddress) |
|
|
327
|
+
| `getTransfersByAddress` | `get_transfers_by_address(...)` | [guide](https://www.helius.dev/docs/rpc/gettransfersbyaddress), [reference](https://www.helius.dev/docs/api-reference/rpc/http/gettransfersbyaddress) |
|
|
325
328
|
|
|
326
329
|
## WebSocket subscriptions
|
|
327
330
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
helius/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
helius/admin/__init__.py,sha256=HboRJXZNzuDAc6r3kj2QZtEcu2U3EWJHv81dYDJGjaA,262
|
|
3
3
|
helius/admin/admin.py,sha256=dcmOgeu10Q43QZC8K-a25vp2JNAb4hs5gu3YWaovV4Y,2541
|
|
4
|
-
helius/laserstream/websockets.py,sha256=
|
|
4
|
+
helius/laserstream/websockets.py,sha256=MX_3stOzo6EyYJVSlE_zHFNesZkQIfAv2R1e5qdr9b0,12446
|
|
5
5
|
helius/rpc/__init__.py,sha256=ciwM1KfBNyZwCeqOmlWTcSrUD03cbrzgeeEZsn9msi0,85
|
|
6
6
|
helius/rpc/json_rpc_request.py,sha256=hm7WkPo0CnwMnuHE4qR-d93wGArZRPRm-B3uueykL3E,1479
|
|
7
7
|
helius/solana_rpc/__init__.py,sha256=Mfhb6ibrCqAX6AchtL3ViBlpCi9RKP8uhT9e_S5_Wb0,1006
|
|
8
|
-
helius/solana_rpc/client.py,sha256=
|
|
9
|
-
helius/solana_rpc/models.py,sha256=
|
|
10
|
-
helius_python-0.3.
|
|
11
|
-
helius_python-0.3.
|
|
12
|
-
helius_python-0.3.
|
|
13
|
-
helius_python-0.3.
|
|
8
|
+
helius/solana_rpc/client.py,sha256=dNB5rrOPF1O-wwxmDe3dfjLNSTxB_TT8RUNw-g0XRIQ,37503
|
|
9
|
+
helius/solana_rpc/models.py,sha256=tQmuWi1frDxvQeBSG2ald6Ze2KsaUQQOry45L41MbnQ,7724
|
|
10
|
+
helius_python-0.3.3.dist-info/METADATA,sha256=1ig_sGPRg_mu8adNqPAbBDeiHOe4cOYMFKBjEoz8lMc,34957
|
|
11
|
+
helius_python-0.3.3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
12
|
+
helius_python-0.3.3.dist-info/licenses/LICENSE,sha256=bZc2EDmq_GsWH77uK8LBn1kqqrOPcp2f9p-ys9bYa1E,1072
|
|
13
|
+
helius_python-0.3.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|