Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Change Log
## v0.2.6-beta - December XX, 2024
* Added a check function to verify and validate the wallet ID before making a call to the Qubic network
* Optimized network calls by preventing invalid requests
* Added input validation to enhance security and reliability

## v0.2.5-beta - December 22, 2024
* Added new advanced code examples
* Reorganized documentation structure
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Currently, QubiPy is in a very early development phase, so please take this into

Please visit the [Change log](https://github.com/QubiPy-Labs/QubiPy/blob/main/docs/changelog.md) to see all changes.

![release](https://img.shields.io/badge/release-v0.2.5--beta-blue)
![release](https://img.shields.io/badge/release-v0.2.6--beta-blue)
![python](https://img.shields.io/badge/python-3.10_%7C_3.11_%7C_3.12-blue)
![Python Package](https://github.com/QubiPy-Labs/QubiPy/actions/workflows/python-package.yml/badge.svg)
![Code Quality](https://github.com/QubiPy-Labs/QubiPy/actions/workflows/pylint.yml/badge.svg)
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Change Log
## v0.2.6-beta - December XX, 2024
* Added a check function to verify and validate the wallet ID before making a call to the Qubic network
* Optimized network calls by preventing invalid requests
* Added input validation to enhance security and reliability

## v0.2.5-beta - December 22, 2024
* Added new advanced code examples
* Reorganized documentation structure
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Welcome to the **QubiPy** official documentation, a Python Library for the QUBIC RPC API

!!! note "Beta Version: 0.2.5"
!!! note "Beta Version: 0.2.6"
QubiPy is currently in beta. While functional, some features might change before the stable release.

**QubiPy** is a Python library that provides RPC and Core client functionality. You can interact quickly and easily with the Qubic RPC API using the different methods offered by this library.

![release](https://img.shields.io/badge/release-v0.2.5--beta-blue)
![release](https://img.shields.io/badge/release-v0.2.6--beta-blue)
![python](https://img.shields.io/badge/python-3.10_%7C_3.11_%7C_3.12-blue)
![Python Package](https://github.com/QubiPy-Labs/QubiPy/actions/workflows/python-package.yml/badge.svg)
![Code Quality](https://github.com/QubiPy-Labs/QubiPy/actions/workflows/pylint.yml/badge.svg)
Expand Down
15 changes: 8 additions & 7 deletions qubipy/rpc/rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,10 @@ def get_balance(self, wallet_id: str | None = None) -> Dict[str, Any]:
QubiPy_Exceptions: If there is an issue with the API request (e.g., network error, invalid response, or timeout).
"""

if not wallet_id:
if not wallet_id or is_wallet_id_invalid(wallet_id):
raise QubiPy_Exceptions(QubiPy_Exceptions.INVALID_ADDRESS_ID)


endpoint = WALLET_BALANCE.format(id = wallet_id)
endpoint = WALLET_BALANCE.format(id = wallet_id.upper())

try:
response = requests.get(f'{self.rpc_url}{endpoint}', headers=HEADERS, timeout=self.timeout)
Expand Down Expand Up @@ -355,7 +354,7 @@ def get_transfer_transactions_per_tick(self, identity: str | None = None, start_
QubiPy_Exceptions: If there is an issue with the API request (e.g., network error, invalid response, or timeout).
"""

if not identity:
if not identity or is_wallet_id_invalid(identity):
raise QubiPy_Exceptions(QubiPy_Exceptions.INVALID_ADDRESS_ID)


Expand Down Expand Up @@ -508,7 +507,7 @@ def get_issued_assets(self, identity: str | None = None) -> Dict[str, Any]:
QubiPy_Exceptions: If there is an issue with the API request (e.g., network error, invalid response, or timeout).
"""

if not identity:
if not identity or is_wallet_id_invalid(identity):
raise QubiPy_Exceptions(QubiPy_Exceptions.INVALID_ADDRESS_ID)

endpoint = ISSUED_ASSETS.format(identity = identity)
Expand Down Expand Up @@ -537,9 +536,10 @@ def get_owned_assets(self, identity: str | None = None) -> Dict[str, Any]:
QubiPy_Exceptions: If there is an issue with the API request (e.g., network error, invalid response, or timeout).
"""

if not identity:
if not identity or is_wallet_id_invalid(identity):
raise QubiPy_Exceptions(QubiPy_Exceptions.INVALID_ADDRESS_ID)


endpoint = OWNED_ASSETS.format(identity = identity)

try:
Expand All @@ -566,9 +566,10 @@ def get_possessed_assets(self, identity: str | None = None) -> Dict[str, Any]:
QubiPy_Exceptions: If there is an issue with the API request (e.g., network error, invalid response, or timeout).
"""

if not identity:
if not identity or is_wallet_id_invalid(identity):
raise QubiPy_Exceptions(QubiPy_Exceptions.INVALID_ADDRESS_ID)


endpoint = POSSESSED_ASSETS.format(identity = identity)

try:
Expand Down
13 changes: 13 additions & 0 deletions qubipy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,16 @@ def check_bytes(tx: bytes):

if not isinstance(tx, (bytes, bytearray)):
raise QubiPy_Exceptions(QubiPy_Exceptions.INVALID_TX_BYTES)


def is_wallet_id_invalid(wallet_id: str) -> bool:
"""
Checks if the provided wallet ID is invalid.

Args:
wallet_id (str): The wallet ID to validate. Must be exactly 60 characters long.

Returns:
bool: True if the wallet ID is invalid, False if valid
"""
return not isinstance(wallet_id, str) or len(wallet_id) != 60 or not wallet_id.isalpha()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

__version__ = '0.2.5'
__version__ = '0.2.6'


with open("README.md", "r", encoding="utf-8") as fh:
Expand Down