From a60027742b2668a71ad9c0955e7a3381e2f90dfd Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:18:44 +0000 Subject: [PATCH 1/3] chore: update dependencies mainsail --- .github/workflows/test.yml | 6 ++--- README.md | 10 ++------ requirements.txt | 50 +++++++++++++++++++------------------- setup.cfg | 3 --- setup.py | 28 +++++++++------------ 5 files changed, 42 insertions(+), 55 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45a2d13..c937bb1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,12 +14,12 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: install dependencies diff --git a/README.md b/README.md index 2622cab..692b001 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ If you have any questions, requests or ideas open an issue or ask us in #python ### Prerequisites -- Python >= 3.8 +- Python >= 3.11 ### Setup @@ -74,19 +74,13 @@ pip install -r requirements.txt Run the following command to install the package in development mode: ```bash -python setup.py develop +pip install -e . ``` 6. Run the tests Use pytest to run the tests and ensure everything is working correctly: -```bash -python setup.py test -``` - -Or directly with pytest: - ```bash pytest ``` diff --git a/requirements.txt b/requirements.txt index c7f3ce8..3cd220e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,26 +1,26 @@ backoff==2.2.1 -certifi==2024.6.2 -chardet==3.0.4 -charset-normalizer==3.3.2 -coverage==7.5.3 -flake8==3.5.0 -flake8-import-order==0.17.1 -flake8-print==3.1.0 -flake8-quotes==1.0.0 -flatten-dict==0.4.2 -idna==2.7 -iniconfig==2.0.0 -mccabe==0.6.1 -packaging==24.1 -pluggy==1.5.0 -pycodestyle==2.3.1 -pyflakes==1.6.0 -pytest==8.2.2 -pytest-cov==2.5.1 -pytest-mock==1.10.0 -pytest-responses==0.5.1 -requests==2.32.3 -responses==0.10.15 -setuptools==70.1.0 -six==1.16.0 -urllib3==2.2.2 +certifi==2026.11.20 +charset-normalizer==3.5.3 +coverage==7.18.0 +flake8==7.5.0 +flake8-import-order==0.19.2 +flake8-print==5.0.0 +flake8-quotes==3.4.0 +flatten-dict==0.6.0 +idna==3.20 +iniconfig==2.3.1 +mccabe==0.7.0 +packaging==26.4 +pluggy==1.7.0 +pycodestyle==2.15.0 +pyflakes==4.1.0 +pygments==2.21.0 +pytest==9.2.0 +pytest-cov==7.1.0 +pytest-mock==3.17.0 +pytest-responses==0.6.0 +pyyaml==6.0.4 +requests==2.34.2 +responses==0.26.3 +setuptools==84.2.1 +urllib3==2.8.0 diff --git a/setup.cfg b/setup.cfg index 36dfa98..dded69d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[aliases] -test=pytest - [flake8] max-line-length = 100 application-import-names = client diff --git a/setup.py b/setup.py index 46100de..0f2c100 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,21 @@ -import sys - import setuptools requires = [ - 'requests==2.32.3', 'backoff==2.2.1', - 'flatten-dict==0.4.2', + 'flatten-dict==0.6.0', + 'requests==2.34.2', ] tests_require = [ - 'pytest==8.2.2', - 'pytest-cov==2.5.1', - 'pytest-mock==1.10.0', - 'pytest-responses==0.5.1', - 'flake8==3.5.0', - 'flake8-import-order==0.17.1', - 'flake8-print==3.1.0', - 'flake8-quotes==1.0.0', + 'flake8==7.5.0', + 'flake8-import-order==0.19.2', + 'flake8-print==5.0.0', + 'flake8-quotes==3.4.0', + 'pytest==9.2.0', + 'pytest-cov==7.1.0', + 'pytest-mock==3.17.0', + 'pytest-responses==0.6.0', + 'responses==0.26.3', ] extras_require = { @@ -24,8 +23,6 @@ 'dev': requires + tests_require } -setup_requires = ['pytest-runner'] if {'pytest', 'test', 'ptr'}.intersection(sys.argv) else [] - setuptools.setup( name='arkecosystem-client', description='A simple Python API client for the ARK Blockchain.', @@ -34,8 +31,7 @@ author_email='info@client.io', url='https://github.com/ArkEcosystem/python-client', packages=setuptools.find_packages(exclude=['tests', 'tests.*']), + python_requires='>=3.11', install_requires=requires, extras_require=extras_require, - tests_require=tests_require, - setup_requires=setup_requires, ) From 7659e0f5f9141718808bb8f8f2f0bf4f1b9f8def Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Tue, 1 Dec 2026 15:47:19 +0000 Subject: [PATCH 2/3] style: fix lint errors --- client/api/evm.py | 2 +- client/api/receipts.py | 12 ++++++++++-- client/api/tokens.py | 15 ++++++++++++--- client/api/transactions.py | 5 ++++- client/api/wallets.py | 14 +++++++++++--- client/client.py | 8 +++++--- client/connection.py | 4 ++++ client/resource.py | 2 ++ client/types/blocks.py | 3 ++- client/types/evm.py | 2 +- client/types/validators.py | 3 ++- client/types/wallets.py | 3 ++- tests/api/test_api_nodes.py | 1 + tests/api/test_blockchain.py | 1 + tests/api/test_commits.py | 1 + tests/api/test_contracts.py | 5 ++++- tests/api/test_evm.py | 5 +++-- tests/api/test_receipts.py | 1 + tests/api/test_rounds.py | 1 + tests/test_client.py | 28 +++++++++++++--------------- tests/test_connection.py | 6 +++--- tests/test_resource.py | 1 - 22 files changed, 84 insertions(+), 39 deletions(-) diff --git a/client/api/evm.py b/client/api/evm.py index c8189c3..c76aaad 100644 --- a/client/api/evm.py +++ b/client/api/evm.py @@ -5,6 +5,6 @@ class EVM(Resource): def call(self, payload: EvmBodyPartialParams): return self.with_endpoint('evm').request_post('', { - 'jsonrpc': "2.0", + 'jsonrpc': '2.0', **payload, }) diff --git a/client/api/receipts.py b/client/api/receipts.py index 765e39d..811185b 100644 --- a/client/api/receipts.py +++ b/client/api/receipts.py @@ -2,7 +2,12 @@ from client.resource import Resource from client.types import PaginatedResponse, Response -from client.types.receipts import ReceiptContractsQuery, ReceiptQuery, ReceiptResponse, ReceiptsQuery +from client.types.receipts import ( + ReceiptContractsQuery, + ReceiptQuery, + ReceiptResponse, + ReceiptsQuery, +) class Receipts(Resource): @@ -19,7 +24,10 @@ def get( f'receipts/{transaction_hash}', query ) - def contracts(self, query: Optional[ReceiptContractsQuery] = None) -> PaginatedResponse[ReceiptResponse]: + def contracts( + self, + query: Optional[ReceiptContractsQuery] = None, + ) -> PaginatedResponse[ReceiptResponse]: return self.with_endpoint('api').request_get( 'receipts/contracts', query ) diff --git a/client/api/tokens.py b/client/api/tokens.py index 93f5285..01885a0 100644 --- a/client/api/tokens.py +++ b/client/api/tokens.py @@ -21,17 +21,26 @@ class Tokens(Resource): def all(self, query: Optional[TokensQuery] = None) -> PaginatedResponse[TokenResponse]: return self.with_endpoint('api').request_get('tokens', query) - def transfers(self, query: Optional[TokenTransfersQuery] = None) -> TokenPaginatedResponseResults[TokenActionsResponse]: + def transfers( + self, + query: Optional[TokenTransfersQuery] = None, + ) -> TokenPaginatedResponseResults[TokenActionsResponse]: return self.with_endpoint('api').request_get( 'tokens/transfers', query ) - def approvals(self, query: Optional[TokenApprovalsQuery] = None) -> TokenPaginatedResponseResults[TokenActionsResponse]: + def approvals( + self, + query: Optional[TokenApprovalsQuery] = None, + ) -> TokenPaginatedResponseResults[TokenActionsResponse]: return self.with_endpoint('api').request_get( 'tokens/approvals', query ) - def whitelist(self, query: Optional[PaginatedQuery] = None) -> PaginatedResponse[TokenWhitelistResponse]: + def whitelist( + self, + query: Optional[PaginatedQuery] = None, + ) -> PaginatedResponse[TokenWhitelistResponse]: return self.with_endpoint('api').request_get( 'tokens/whitelist', query ) diff --git a/client/api/transactions.py b/client/api/transactions.py index ab6d8d3..2ce8bb6 100644 --- a/client/api/transactions.py +++ b/client/api/transactions.py @@ -14,7 +14,10 @@ class Transactions(Resource): - def all(self, query: Optional[TransactionsQuery] = None) -> PaginatedResponse[TransactionResponse]: + def all( + self, + query: Optional[TransactionsQuery] = None, + ) -> PaginatedResponse[TransactionResponse]: return self.with_endpoint('api').request_get( 'transactions', query ) diff --git a/client/api/wallets.py b/client/api/wallets.py index 9f1e648..1045f78 100644 --- a/client/api/wallets.py +++ b/client/api/wallets.py @@ -2,9 +2,14 @@ from client.resource import Resource from client.types import PaginatedResponse, Response -from client.types.transactions import TransactionResponse, TransactionsQuery -from client.types.wallets import WalletResponse, WalletTokensForQuery, WalletTokensQuery, WalletsQuery from client.types.tokens import TokenActionsResponse, TokenPaginatedResponseResults +from client.types.transactions import TransactionResponse, TransactionsQuery +from client.types.wallets import ( + WalletResponse, + WalletTokensForQuery, + WalletTokensQuery, + WalletsQuery, +) class Wallets(Resource): @@ -65,7 +70,10 @@ def tokens_for( f'wallets/{address}/tokens', query ) - def tokens(self, query: Optional[WalletTokensQuery] = None) -> TokenPaginatedResponseResults[TokenActionsResponse]: + def tokens( + self, + query: Optional[WalletTokensQuery] = None, + ) -> TokenPaginatedResponseResults[TokenActionsResponse]: return self.with_endpoint('api').request_get( 'wallets/tokens', query ) diff --git a/client/client.py b/client/client.py index 86c8353..492f5b8 100644 --- a/client/client.py +++ b/client/client.py @@ -1,11 +1,10 @@ from typing import Union -from client.api.contracts import Contracts -from client.connection import ClientHosts, Connection + from client.api.api_nodes import ApiNodes from client.api.blockchain import Blockchain from client.api.blocks import Blocks from client.api.commits import Commits -from client.api.validators import Validators +from client.api.contracts import Contracts from client.api.evm import EVM from client.api.node import Node from client.api.peers import Peers @@ -13,8 +12,11 @@ from client.api.rounds import Rounds from client.api.tokens import Tokens from client.api.transactions import Transactions +from client.api.validators import Validators from client.api.votes import Votes from client.api.wallets import Wallets +from client.connection import ClientHosts, Connection + class Client(object): diff --git a/client/connection.py b/client/connection.py index 1fd1f35..6567c2c 100644 --- a/client/connection.py +++ b/client/connection.py @@ -1,6 +1,8 @@ from typing import Literal, Optional, TypedDict, Union + import backoff + import requests from client.exceptions import ArkHTTPException @@ -22,6 +24,7 @@ class ClientHosts(TypedDict): transactions: Optional[str] evm: Optional[str] + class Session(requests.Session): def __init__(self, *args, **kwargs): @@ -44,6 +47,7 @@ def prepare_request(self, request): return super().prepare_request(request) + class Connection(object): session: Session hosts: ClientHosts diff --git a/client/resource.py b/client/resource.py index 2a5afb6..a7754e2 100644 --- a/client/resource.py +++ b/client/resource.py @@ -1,8 +1,10 @@ from typing import Literal + from flatten_dict import flatten from client.connection import Connection + class Resource(object): def __init__(self, connection: Connection): diff --git a/client/types/blocks.py b/client/types/blocks.py index 85192a2..2133e7f 100644 --- a/client/types/blocks.py +++ b/client/types/blocks.py @@ -44,7 +44,8 @@ class BlockResponse(TypedDict, total=False): version: int -# Functional form required: keys contain dots (e.g. 'height.from') which are not valid Python identifiers +# Functional form required: keys contain dots (e.g. 'height.from') which are not +# valid Python identifiers BlocksQuery = TypedDict( 'BlocksQuery', { diff --git a/client/types/evm.py b/client/types/evm.py index 14f170e..3ba0f98 100644 --- a/client/types/evm.py +++ b/client/types/evm.py @@ -3,7 +3,7 @@ PayloadData = dict[str, str | int | float] -BlockParameter = Literal["earliest", "latest", "safe", "finalized", "pending"] +BlockParameter = Literal['earliest', 'latest', 'safe', 'finalized', 'pending'] class EvmBodyPartialParams(TypedDict, total=False): diff --git a/client/types/validators.py b/client/types/validators.py index 59f2abd..4999b06 100644 --- a/client/types/validators.py +++ b/client/types/validators.py @@ -1,7 +1,8 @@ from typing import TypedDict -# Functional form required: keys contain dots (e.g. 'blocks.last.hash') which are not valid Python identifiers +# Functional form required: keys contain dots (e.g. 'blocks.last.hash') which are not +# valid Python identifiers ValidatorsQuery = TypedDict( 'ValidatorsQuery', { diff --git a/client/types/wallets.py b/client/types/wallets.py index 2d29f5b..096c42a 100644 --- a/client/types/wallets.py +++ b/client/types/wallets.py @@ -35,7 +35,8 @@ class WalletResponse(TypedDict): tokenCount: int -# Functional form required: keys contain dots (e.g. 'balance.from') which are not valid Python identifiers +# Functional form required: keys contain dots (e.g. 'balance.from') which are not +# valid Python identifiers WalletsQuery = TypedDict( 'WalletsQuery', { diff --git a/tests/api/test_api_nodes.py b/tests/api/test_api_nodes.py index c3be92f..8ccdf37 100644 --- a/tests/api/test_api_nodes.py +++ b/tests/api/test_api_nodes.py @@ -1,4 +1,5 @@ import responses + from client import Client diff --git a/tests/api/test_blockchain.py b/tests/api/test_blockchain.py index 345175c..5bb3916 100644 --- a/tests/api/test_blockchain.py +++ b/tests/api/test_blockchain.py @@ -1,4 +1,5 @@ import responses + from client import Client diff --git a/tests/api/test_commits.py b/tests/api/test_commits.py index fe6a884..19d10a4 100644 --- a/tests/api/test_commits.py +++ b/tests/api/test_commits.py @@ -1,4 +1,5 @@ import responses + from client import Client diff --git a/tests/api/test_contracts.py b/tests/api/test_contracts.py index 5aefbae..c173676 100644 --- a/tests/api/test_contracts.py +++ b/tests/api/test_contracts.py @@ -1,4 +1,5 @@ import responses + from client import Client @@ -27,4 +28,6 @@ def test_abi_calls_correct_url(): client = Client('http://127.0.0.1:4002/api') client.contracts.abi('consensus', 'some-address') assert len(responses.calls) == 1 - assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/contracts/consensus/some-address/abi' + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/contracts/consensus/some-address/abi' + ) diff --git a/tests/api/test_evm.py b/tests/api/test_evm.py index a3d1876..11591a4 100644 --- a/tests/api/test_evm.py +++ b/tests/api/test_evm.py @@ -1,4 +1,5 @@ import json + import responses from client import Client @@ -15,7 +16,7 @@ def test_eth_call_methods_correct_url(): client = Client('http://127.0.0.1:4002/evm/api') client.evm.call({ 'method': 'eth_call', - 'params': [[{ 'random': 'data' }], 'latest'], + 'params': [[{'random': 'data'}], 'latest'], 'id': None, }) assert len(responses.calls) == 1 @@ -23,6 +24,6 @@ def test_eth_call_methods_correct_url(): assert json.loads(responses.calls[0].request.body.decode()) == { 'jsonrpc': '2.0', 'method': 'eth_call', - 'params': [[{ 'random': 'data' }], 'latest'], + 'params': [[{'random': 'data'}], 'latest'], 'id': None, } diff --git a/tests/api/test_receipts.py b/tests/api/test_receipts.py index b739b09..4cef9ff 100644 --- a/tests/api/test_receipts.py +++ b/tests/api/test_receipts.py @@ -1,4 +1,5 @@ import responses + from client import Client diff --git a/tests/api/test_rounds.py b/tests/api/test_rounds.py index b8b860b..c7e409e 100644 --- a/tests/api/test_rounds.py +++ b/tests/api/test_rounds.py @@ -1,4 +1,5 @@ import responses + from client import Client diff --git a/tests/test_client.py b/tests/test_client.py index 4543f27..9e33d35 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,21 +1,19 @@ -import pytest - from client.client import Client def test_client(): client = Client('http://127.0.0.1:4002') - assert hasattr(client, 'connection') == True - assert hasattr(client, 'api_nodes') == True - assert hasattr(client, 'blockchain') == True - assert hasattr(client, 'blocks') == True - assert hasattr(client, 'commits') == True - assert hasattr(client, 'evm') == True - assert hasattr(client, 'node') == True - assert hasattr(client, 'peers') == True - assert hasattr(client, 'rounds') == True - assert hasattr(client, 'transactions') == True - assert hasattr(client, 'validators') == True - assert hasattr(client, 'votes') == True - assert hasattr(client, 'wallets') == True + assert hasattr(client, 'connection') + assert hasattr(client, 'api_nodes') + assert hasattr(client, 'blockchain') + assert hasattr(client, 'blocks') + assert hasattr(client, 'commits') + assert hasattr(client, 'evm') + assert hasattr(client, 'node') + assert hasattr(client, 'peers') + assert hasattr(client, 'rounds') + assert hasattr(client, 'transactions') + assert hasattr(client, 'validators') + assert hasattr(client, 'votes') + assert hasattr(client, 'wallets') diff --git a/tests/test_connection.py b/tests/test_connection.py index 26dbf07..f427c56 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -165,8 +165,8 @@ def test_http_methods_call_correct_url_with_params_and_return_correct_response(m def test_session_detects_hostname_correctly(): - session = Session(hostname="test.com") - assert session.hostname == "test.com" + session = Session(hostname='test.com') + assert session.hostname == 'test.com' assert isinstance(session, requests.Session) @@ -185,7 +185,7 @@ def test_session_prepends_hostname_to_url(): status=200 ) - session = Session(hostname="http://test.com") + session = Session(hostname='http://test.com') session.get('spongebob') assert len(responses.calls) == 1 diff --git a/tests/test_resource.py b/tests/test_resource.py index 8b22eec..264d933 100644 --- a/tests/test_resource.py +++ b/tests/test_resource.py @@ -20,4 +20,3 @@ def test_request_post_calls_connection_post_with_correct_params(mocker): resource.request_post('spongebob', data={'one': 'two'}, params={'foo': 'bar'}) post_mock.assert_called_once_with('spongebob', data={'one': 'two'}, params={'foo': 'bar'}) - From c8434c3535b13676c056d6e34cade461ede42c83 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Tue, 1 Dec 2026 15:47:19 +0000 Subject: [PATCH 3/3] ci: add lint workflow --- .github/workflows/lint.yml | 29 +++++++++++++++++++++++++++++ setup.cfg | 1 + 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4d93d50 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,29 @@ +name: Lint + +on: + push: + branches: + - "master" + - "develop" + pull_request: + types: [ready_for_review, synchronize, opened] + +jobs: + flake8: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v7 + - name: Set up Python + uses: actions/setup-python@v7 + with: + python-version: "3.14" + - name: install dependencies + run: | + python3 -m venv venv + . venv/bin/activate + pip install .[test] + - name: run linter + run: | + . venv/bin/activate + make lint diff --git a/setup.cfg b/setup.cfg index dded69d..412908a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,7 @@ [flake8] max-line-length = 100 application-import-names = client +extend-exclude = .venv,venv,build,dist [tool:pytest] addopts = --verbose -s