From 3d99ba8c72702f8d6b49c2e213bfb9169ad23a76 Mon Sep 17 00:00:00 2001 From: Jakub Ziebinski Date: Thu, 11 Sep 2025 13:37:00 +0000 Subject: [PATCH 1/3] Bump hive submodule. Version with completely filled swagger. --- hive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hive b/hive index 624834c24..1f85c3ac0 160000 --- a/hive +++ b/hive @@ -1 +1 @@ -Subproject commit 624834c24c599365187b77a9a2fbae651e6be0ae +Subproject commit 1f85c3ac0ff69b067ea41b93bdd5169e6eff17cb -- GitLab From e67036ed870e646baf8cebc21ddc4bdfd71c4950 Mon Sep 17 00:00:00 2001 From: Jakub Ziebinski Date: Fri, 12 Sep 2025 08:02:05 +0000 Subject: [PATCH 2/3] Handle flattened openapi description in wax --- python/docker/wax-python-builder.dockerfile | 9 ++++++++- python/scripts/build_api_packages.sh | 13 +++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/python/docker/wax-python-builder.dockerfile b/python/docker/wax-python-builder.dockerfile index b5c9aa7c3..7cf9128d7 100644 --- a/python/docker/wax-python-builder.dockerfile +++ b/python/docker/wax-python-builder.dockerfile @@ -10,7 +10,14 @@ USER root RUN groupadd -g $GROUP_ID usergroup && \ useradd -m -s /bin/bash -u $USER_ID -g $GROUP_ID ${USER_NAME} && \ usermod -a -G $(id -g hived_admin) ${USER_NAME} && \ - DEBIAN_FRONTEND=noninteractive apt update && DEBIAN_FRONTEND=noninteractive apt install -y gdb python3.12-dbg + DEBIAN_FRONTEND=noninteractive apt update && DEBIAN_FRONTEND=noninteractive apt install -y gdb python3.12-dbg && \ + apt update && apt install -y curl && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && \ + export NVM_DIR="/root/.nvm" && \ + . "$NVM_DIR/nvm.sh" && \ + nvm install --lts && \ + nvm use --lts + # Switch to created user USER ${USER_NAME} diff --git a/python/scripts/build_api_packages.sh b/python/scripts/build_api_packages.sh index 8546c4797..9b73cb8ab 100755 --- a/python/scripts/build_api_packages.sh +++ b/python/scripts/build_api_packages.sh @@ -4,11 +4,17 @@ set -xeuo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" WAX_PROJECT_DIR="$(dirname "$SCRIPT_DIR")/.." -API_GENERATION_DIR="${WAX_PROJECT_DIR}/hive/libraries/plugins/apis/api_generation" +APIS_DIR="${WAX_PROJECT_DIR}/hive/libraries/plugins/apis" +API_GENERATION_DIR="${APIS_DIR}/api_generation" cd "${API_GENERATION_DIR}/api_generation" poetry install -${API_GENERATION_DIR}/generate_api_packages.sh database_api network_broadcast_api + +cd "${API_GENERATION_DIR}" +npm install @apidevtools/json-schema-ref-parser@14.2.1 json-schema-merge-allof@0.8.1 # Install dependencies for flatten_swagger.js +node "${API_GENERATION_DIR}/flatten_swagger.js" "${APIS_DIR}/documentation/openapi.json" > "${APIS_DIR}/documentation/openapi_flattened.json" + +"${API_GENERATION_DIR}/generate_api_packages.sh" database_api network_broadcast_api poetry -C "${API_GENERATION_DIR}/database_api" build --format wheel poetry -C "${API_GENERATION_DIR}/network_broadcast_api" build --format wheel @@ -18,3 +24,6 @@ NETWORK_BROADCAST_API_WHEEL_BUILD_VERSION=$(poetry -C "${API_GENERATION_DIR}/net echo "DATABASE_API_WHEEL_BUILD_VERSION=${DATABASE_API_WHEEL_BUILD_VERSION}" >> "${SCRIPT_DIR}/../../build_wheel.env" echo "NETWORK_BROADCAST_API_WHEEL_BUILD_VERSION=${NETWORK_BROADCAST_API_WHEEL_BUILD_VERSION}" >> "${SCRIPT_DIR}/../../build_wheel.env" + +echo "Clean up generated flattened openapi_flattened.json." +rm -f "${APIS_DIR}/documentation/openapi_flattened.json" -- GitLab From cf6629178c3051100485f546cc338134a2930668 Mon Sep 17 00:00:00 2001 From: Jakub Ziebinski Date: Fri, 12 Sep 2025 08:23:16 +0000 Subject: [PATCH 3/3] Improve type hints after bumping API packages --- python/wax/_private/api/models.py | 6 ++++-- python/wax/_private/chain_api.py | 11 ++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/python/wax/_private/api/models.py b/python/wax/_private/api/models.py index 1c6402eaf..e20798212 100644 --- a/python/wax/_private/api/models.py +++ b/python/wax/_private/api/models.py @@ -1,7 +1,9 @@ from __future__ import annotations -from database_api.database_api_description import Auths as ApiAuthority +from database_api.database_api_description import Active, Owner, Posting from database_api.database_api_description import FindAccountsResponse as FindAccountsApiResponse from network_broadcast_api.network_broadcast_api_description import Transaction as ApiTransaction -__all__ = ["ApiAuthority", "ApiTransaction", "FindAccountsApiResponse"] +PossibleAuthorityApi = Active | Owner | Posting + +__all__ = ["PossibleAuthorityApi", "ApiTransaction", "FindAccountsApiResponse"] diff --git a/python/wax/_private/chain_api.py b/python/wax/_private/chain_api.py index 3674169d6..27e55bd34 100644 --- a/python/wax/_private/chain_api.py +++ b/python/wax/_private/chain_api.py @@ -20,7 +20,7 @@ if TYPE_CHECKING: from datetime import datetime, timedelta from beekeepy.interfaces import HttpUrl - from wax._private.api.models import ApiAuthority, FindAccountsApiResponse + from wax._private.api.models import FindAccountsApiResponse, PossibleAuthorityApi from wax.interfaces import ITransaction from wax.models.basic import AccountName, ChainId @@ -130,7 +130,7 @@ class HiveChainApi(IHiveChainInterface, WaxBaseApi, Generic[ApiCollectionT]): return self._tapos_cache - def _transform_api_authority(self, api_authority: ApiAuthority) -> WaxAuthority | None: + def _transform_api_authority(self, api_authority: PossibleAuthorityApi) -> WaxAuthority | None: if not api_authority: return None @@ -139,11 +139,8 @@ class HiveChainApi(IHiveChainInterface, WaxBaseApi, Generic[ApiCollectionT]): return WaxAuthority( weight_threshold=api_authority.weight_threshold, - account_auths={ - cast(str, account[entity_index]): cast(int, account[weight_index]) - for account in api_authority.account_auths - }, - key_auths={cast(str, key[entity_index]): cast(int, key[weight_index]) for key in api_authority.key_auths}, + account_auths={account[entity_index]: account[weight_index] for account in api_authority.account_auths}, + key_auths={key[entity_index]: cast(int, key[weight_index]) for key in api_authority.key_auths}, ) def _extract_authority_from_find_accounts_response( -- GitLab