Skip to content

Commit

Permalink
fix: type issues, update: dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
GitBolt committed Nov 16, 2024
1 parent 28753dd commit 65d06c9
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 212 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env/
venv/
env3/
.ipynb_checkpoints

package_test/
.history/*


Expand Down
2 changes: 1 addition & 1 deletion docs/pages/models/transaction/instructions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ This is a named tuple representing an instruction object. Here keys are `Account
<Code>
```python
class Instruction(NamedTuple):
keys: list[AccountMeta]
keys: List[AccountMeta]
program_id: PublicKey
data: bytes = bytes(0)
```
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/utility/functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The message argument is optional, when not provided the public key itself is use
```python
def verify_signature(
public_key: PublicKey | str,
signature: list[int],
signature: List[int],
message: str | bytes | None = None
)
```
Expand All @@ -50,7 +50,7 @@ from nacl.exceptions import BadSignatureError

# Getting the public key and the signature array
public_key: str = request.headers.get("public_key")
signature_array: list[int] = request.headers.get("signature")
signature_array: List[int] = request.headers.get("signature")

try:
verify_signature(public_key, signature_array)
Expand Down
199 changes: 44 additions & 155 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "solathon"
version = "1.0.4"
version = "1.0.5"
description = "High performance, easy to use and feature-rich Solana SDK for Python."
license = "MIT"
authors = ["GitBolt"]
Expand All @@ -22,13 +22,13 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.8"
httpx = "^0.22.0"
PyNaCl = "^1.5.0"
base58 = "^2.1.1"
construct = "^2.10.67"
typing-extensions = { version = "^4.1.1", python = "3.10" }
qrcode = "^7.4.2"
pillow = "^10.2.0"
httpx = "^0.27.2"

[tool.poetry.dev-dependencies]
jedi = "^0.18.1"
Expand Down
2 changes: 1 addition & 1 deletion solathon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.0.4"
__version__ = "1.0.5"

from .client import Client
from .async_client import AsyncClient
Expand Down
8 changes: 4 additions & 4 deletions solathon/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ async def get_inflation_reward(self, addresses: List[Text]) -> RPCResponse:
Get the inflation reward for a list of addresses.
Args:
addresses (list[Text]): A list of addresses to get the inflation reward for.
addresses (List[Text]): A list of addresses to get the inflation reward for.
Returns:
RPCResponse: The response from the RPC server.
Expand Down Expand Up @@ -362,12 +362,12 @@ async def get_signatures_for_address(self, acct_address: Text) -> RPCResponse:
"getSignaturesForAddress", [acct_address]
)

async def get_signature_statuses(self, transaction_sigs: list[Text]) -> RPCResponse:
async def get_signature_statuses(self, transaction_sigs: List[Text]) -> RPCResponse:
"""
Returns the current status of a list of signatures.
Args:
transaction_sigs (list[str]): List of transaction signatures to check status for.
transaction_sigs (List[str]): List of transaction signatures to check status for.
Returns:
RPCResponse: Response object containing the status of the signatures.
Expand Down Expand Up @@ -518,6 +518,6 @@ async def build_and_send_request_async(
Returns:
RPCResponse: The response from the server.
"""
data: dict[Text, Any] = self.http.build_data(method=method, params=params)
data: Dict[Text, Any] = self.http.build_data(method=method, params=params)
res: RPCResponse = await self.http.send(data)
return res
10 changes: 5 additions & 5 deletions solathon/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def get_inflation_reward(
Returns the inflation reward for the specified addresses.
Args:
addresses (list[str]): The addresses.
addresses (List[str]): The addresses.
commitment (Commitment, optional): The level of commitment desired when querying state.
Returns:
Expand Down Expand Up @@ -419,7 +419,7 @@ def get_largest_accounts(
def get_leader_schedule(
self,
) -> (
RPCResponse[dict[str, Union[List[int], Any]]] | dict[str, Union[List[int], Any]]
RPCResponse[Dict[str, Union[List[int], Any]]] | Dict[str, Union[List[int], Any]]
):
"""
Returns the leader schedule.
Expand Down Expand Up @@ -580,7 +580,7 @@ def get_signature_statuses(
Returns the signature statuses for the specified transaction signatures.
Args:
transaction_sigs (list[str]): The transaction signatures.
transaction_sigs (List[str]): The transaction signatures.
Returns:
RPCResponse: The response from the RPC endpoint.
Expand Down Expand Up @@ -715,7 +715,7 @@ def get_transaction(

def build_and_send_request(
self, method, params: List[Any]
) -> RPCResponse | dict[str, Any] | List[dict[str, Any]]:
) -> RPCResponse | Dict[str, Any] | List[Dict[str, Any]]:
"""
Builds and sends an RPC request to the server.
Expand All @@ -726,7 +726,7 @@ def build_and_send_request(
Returns:
RPCResponse: The response from the server.
"""
data: dict[str, Any] = self.http.build_data(method=method, params=params)
data: Dict[str, Any] = self.http.build_data(method=method, params=params)
res: RPCResponse = self.http.send(data)
if self.clean_response:
if "error" in res:
Expand Down
14 changes: 7 additions & 7 deletions solathon/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asyncio
import base64
import httpx
from typing import Any
from typing import Any, List, Dict


from .. import __version__
Expand All @@ -27,14 +27,14 @@ def __init__(self, endpoint: str):
self.request_id = 0
self.client = httpx.Client()

def send(self, data: dict[str, Any]) -> RPCResponse:
def send(self, data: Dict[str, Any]) -> RPCResponse:
res = self.client.post(
url=self.endpoint, headers=self.headers, json=data)
return res.json()

def build_data(self, method: str, params: list[Any]) -> dict[str, Any]:
def build_data(self, method: str, params: List[Any]) -> Dict[str, Any]:
self.request_id += 1
params: list[Any] = [
params: List[Any] = [
str(i) if isinstance(i, PublicKey) else i for i in params
]

Expand Down Expand Up @@ -72,14 +72,14 @@ def __init__(self, endpoint: str):
self.client = httpx.AsyncClient()


async def send(self, data: dict[str, Any]) -> RPCResponse:
async def send(self, data: Dict[str, Any]) -> RPCResponse:
res = await self.client.post(
url=self.endpoint, headers=self.headers, json=data)
return res.json()

def build_data(self, method: str, params: list[Any]) -> dict[str, Any]:
def build_data(self, method: str, params: List[Any]) -> Dict[str, Any]:
self.request_id += 1
params: list[Any] = [
params: List[Any] = [
str(i) if isinstance(i, PublicKey) else i for i in params
]

Expand Down
10 changes: 5 additions & 5 deletions solathon/core/instructions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Developer reference: https://github.com/solana-labs/solana/blob/master/sdk/program/src/system_instruction.rs
from __future__ import annotations

from typing import NamedTuple
from typing import NamedTuple, List
from dataclasses import dataclass
from ..publickey import PublicKey
from ..core.layouts import (
Expand All @@ -19,7 +19,7 @@ class AccountMeta:


class Instruction(NamedTuple):
keys: list[AccountMeta]
keys: List[AccountMeta]
program_id: PublicKey
data: bytes = bytes(0)

Expand All @@ -31,7 +31,7 @@ def create_account(
space: int,
program_id: PublicKey
) -> Instruction:
account_metas: list[AccountMeta] = [
account_metas: List[AccountMeta] = [
AccountMeta(
public_key=from_public_key,
is_signer=True,
Expand Down Expand Up @@ -68,7 +68,7 @@ def create_account_with_seed(
space: int,
program_id: PublicKey
) -> Instruction:
account_metas: list[AccountMeta] = [
account_metas: List[AccountMeta] = [
AccountMeta(
public_key=from_public_key,
is_signer=True,
Expand Down Expand Up @@ -136,7 +136,7 @@ def transfer(
to_public_key: PublicKey | str,
lamports: int
) -> Instruction:
account_metas: list[AccountMeta] = [
account_metas: List[AccountMeta] = [
AccountMeta(
public_key=from_public_key,
is_signer=True,
Expand Down
6 changes: 3 additions & 3 deletions solathon/core/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def to_uint8_bytes(val: int) -> bytes:


class CompiledInstruction(NamedTuple):
accounts: bytes | list[int]
accounts: bytes | List[int]
program_id_index: int
data: bytes

Expand All @@ -52,8 +52,8 @@ class Message:
def __init__(
self,
header: MessageHeader,
account_keys: list[str],
instructions: list[CompiledInstruction],
account_keys: List[str],
instructions: List[CompiledInstruction],
recent_blockhash: str
):
self.header = header
Expand Down
2 changes: 1 addition & 1 deletion solathon/core/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Result(TypedDict):
class RPCResponse(TypedDict):
jsonrpc: Literal["2.0"]
id: int
result: Union[Result[T], T]
result: Any
error: RPCErrorType

Commitment = Literal["processed", "confirmed", "finalized", "recent", "single", "singleGossip", "root", "max"]
Expand Down
4 changes: 2 additions & 2 deletions solathon/core/types/account_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, TypedDict, Union
from typing import Any, TypedDict, Union, Dict

class AccountInfoType(TypedDict):
'''
Expand All @@ -9,7 +9,7 @@ class AccountInfoType(TypedDict):
executable: bool
rentEpoch: int
size: Union[int, None]
data: Union[str, dict[str, Any]]
data: Union[str, Dict[str, Any]]

def __repr__(self) -> str:
return f"AccountInfoType(owner={self.owner!r})"
Expand Down
4 changes: 2 additions & 2 deletions solathon/core/types/block.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from solathon.core.message import Message as CoreMessage, MessageHeader
from typing import Any, List, TypedDict, Union
from typing import Any, List, TypedDict, Union, Dict


class HeaderType(TypedDict):
Expand Down Expand Up @@ -214,7 +214,7 @@ class BlockProductionType(TypedDict):
'''
JSON Response type of Block Production Information received by RPC
'''
byIdentity: dict[str, Any]
byIdentity: Dict[str, Any]
range: RangeType


Expand Down
4 changes: 2 additions & 2 deletions solathon/publickey.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

import base58

from typing import List

class PublicKey:
LENGTH = 32

def __init__(self, value: bytes | int | str | list[int] | bytearray):
def __init__(self, value: bytes | int | str | List[int] | bytearray):
if isinstance(value, str):
try:
self.byte_value = base58.b58decode(value)
Expand Down
Loading

0 comments on commit 65d06c9

Please sign in to comment.