From 6209ee1bba127ac4facb96ceff9286c0f7e480ba Mon Sep 17 00:00:00 2001 From: Jakub Ziebinski <ziebinskijakub@gmail.com> Date: Tue, 18 Mar 2025 12:11:44 +0100 Subject: [PATCH] Implementation of the wrapper for imports from the proto --- examples/python/create_and_sign_transation.py | 2 +- examples/python/visitor_example.py | 20 ++-- python/pyproject.toml | 6 + python/tests/base_api/test_generate_assets.py | 2 +- .../test_operation_get_impacted_accounts.py | 14 +-- .../test_recurrent_transfer_operation.py | 7 +- .../base_api/test_transaction_processing.py | 6 +- .../test_update_proposal_operation.py | 3 +- .../test_abstract_operation_visitor.py | 5 +- .../test_operation_visitor.py | 17 +-- ...st_proto_account_create_with_delegation.py | 37 +++--- .../operations/test_proto_account_update.py | 23 ++-- .../operations/test_proto_account_update2.py | 24 ++-- .../test_proto_account_witness_proxy.py | 20 ++-- .../test_proto_account_witness_vote.py | 20 ++-- ...test_proto_cancel_transfer_from_savings.py | 18 +-- .../test_proto_change_recovery_account.py | 22 ++-- .../operations/test_proto_claim_account.py | 25 ++-- .../test_proto_claim_reward_balance.py | 28 ++--- .../test_proto_collateralized_convert.py | 24 ++-- python/tests/operations/test_proto_comment.py | 18 +-- .../operations/test_proto_comment_options.py | 25 ++-- python/tests/operations/test_proto_convert.py | 26 ++--- .../test_proto_create_claimed_account.py | 34 +++--- .../operations/test_proto_create_proposal.py | 24 ++-- python/tests/operations/test_proto_custom.py | 18 +-- .../operations/test_proto_custom_json.py | 18 +-- .../test_proto_decline_voting_rights.py | 18 +-- .../test_proto_delegate_vesting_shares.py | 24 ++-- .../operations/test_proto_delete_comment.py | 18 +-- .../operations/test_proto_escrow_approve.py | 18 +-- .../operations/test_proto_escrow_dispute.py | 18 +-- .../operations/test_proto_escrow_release.py | 24 ++-- .../operations/test_proto_escrow_transfer.py | 24 ++-- .../operations/test_proto_feed_publish.py | 29 +++-- .../test_proto_limit_order_cancel.py | 20 ++-- .../test_proto_limit_order_create.py | 26 ++--- .../test_proto_limit_order_create2.py | 33 +++--- python/tests/operations/test_proto_pow.py | 24 ++-- python/tests/operations/test_proto_pow2.py | 35 +++--- .../operations/test_proto_recover_account.py | 26 ++--- .../test_proto_recurrent_transfer.py | 25 ++-- .../operations/test_proto_remove_proposal.py | 20 ++-- .../test_proto_request_account_recovery.py | 26 ++--- .../test_proto_set_withdraw_vesting_route.py | 20 ++-- .../tests/operations/test_proto_transfer.py | 22 ++-- .../test_proto_transfer_from_savings.py | 25 ++-- .../test_proto_transfer_to_savings.py | 24 ++-- .../test_proto_transfer_to_vesting.py | 25 ++-- .../operations/test_proto_update_proposal.py | 29 ++--- .../test_proto_update_proposal_votes.py | 19 ++- python/tests/operations/test_proto_vote.py | 15 +-- .../operations/test_proto_withdraw_vesting.py | 25 ++-- .../test_proto_witness_block_approve.py | 21 ++-- .../test_proto_witness_set_properties.py | 18 +-- .../operations/test_proto_witness_update.py | 34 +++--- .../tests/proto-protocol/test_api_to_proto.py | 6 +- .../test_proto_to_api_to_proto.py | 59 +++++----- .../test_serialize_proto_transaction.py | 6 +- .../transactions/test_proto_transaction.py | 19 ++- .../transactions/test_transaction_creation.py | 7 +- python/tests/utils/checkers.py | 12 +- python/wax/_private/models/asset.py | 2 +- python/wax/_private/transaction.py | 2 +- python/wax/interfaces.py | 2 +- python/wax/models/asset.py | 2 +- python/wax/models/authority.py | 2 +- python/wax/proto/__init__.py | 0 python/wax/proto/asset.py | 10 ++ python/wax/proto/authority.py | 11 ++ python/wax/proto/operations.py | 110 ++++++++++++++++++ python/wax/proto/transaction.py | 10 ++ 72 files changed, 764 insertions(+), 667 deletions(-) create mode 100644 python/wax/proto/__init__.py create mode 100644 python/wax/proto/asset.py create mode 100644 python/wax/proto/authority.py create mode 100644 python/wax/proto/operations.py create mode 100644 python/wax/proto/transaction.py diff --git a/examples/python/create_and_sign_transation.py b/examples/python/create_and_sign_transation.py index 78834f894..28a37aa68 100644 --- a/examples/python/create_and_sign_transation.py +++ b/examples/python/create_and_sign_transation.py @@ -3,7 +3,7 @@ import asyncio from beekeepy import AsyncBeekeeper from beekeepy.interfaces import HttpUrl from wax import create_wax_foundation -from wax.proto.transfer_pb2 import transfer +from wax.proto.operations import transfer PASSWORD = "pass" diff --git a/examples/python/visitor_example.py b/examples/python/visitor_example.py index 42d7cf02b..401bb4f5a 100644 --- a/examples/python/visitor_example.py +++ b/examples/python/visitor_example.py @@ -1,13 +1,7 @@ from google.protobuf.json_format import ParseDict -from wax.proto import ( - comment_pb2, - limit_order_cancel_pb2, - recurrent_transfer_pb2, - operation_pb2, - transaction_pb2, - vote_pb2, -) +from wax.proto.operations import comment, limit_order_cancel, recurrent_transfer, vote +from wax.proto.transaction import transaction from wax.wax_visitor import OperationVisitor tx_json = { @@ -41,19 +35,19 @@ tx_json = { class MyOperationVisitor(OperationVisitor): - def limit_order_cancel(self, op: limit_order_cancel_pb2.limit_order_cancel): + def limit_order_cancel(self, op: limit_order_cancel): print(f"Handling limit_order_cancel operation:\n{op}") assert op.owner == "orderabc" assert op.orderid == 5 - def vote(self, op: vote_pb2.vote) -> None: + def vote(self, op: vote) -> None: print(f"Handling vote operation:\n{op}") assert op.voter == "Alice" assert op.author == "Bob" assert op.permlink == "/" assert op.weight == 11 - def comment(self, op: comment_pb2.comment) -> None: + def comment(self, op: comment) -> None: print(f"Handling comment operation:\n{op}") assert op.parent_permlink == "/" assert op.parent_author == "" @@ -63,7 +57,7 @@ class MyOperationVisitor(OperationVisitor): assert op.body == "<span>comment</span>" assert op.json_metadata == "{}" - def recurrent_transfer(self, op: recurrent_transfer_pb2.recurrent_transfer) -> None: + def recurrent_transfer(self, op: recurrent_transfer) -> None: print(f"Handling recurrent_transfer operation:\n{op}") assert op.from_account == "alice" assert op.to_account == "harry" @@ -77,7 +71,7 @@ class MyOperationVisitor(OperationVisitor): if __name__ == "__main__": - tx = ParseDict(tx_json, transaction_pb2.transaction()) + tx = ParseDict(tx_json, transaction()) visit = MyOperationVisitor() for op in tx.operations: visit.accept(op) diff --git a/python/pyproject.toml b/python/pyproject.toml index 9dad453df..911fb1284 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -77,6 +77,12 @@ strict = true disallow_untyped_decorators = false plugins = "pydantic.mypy" +[[tool.mypy.overrides]] +module = "wax._private.proto.*" +ignore_missing_imports = true +follow_imports = "skip" +ignore_errors = true + [[tool.mypy.overrides]] module = "wax.proto.*" ignore_missing_imports = true diff --git a/python/tests/base_api/test_generate_assets.py b/python/tests/base_api/test_generate_assets.py index 4b31e1219..f40f288a5 100644 --- a/python/tests/base_api/test_generate_assets.py +++ b/python/tests/base_api/test_generate_assets.py @@ -6,7 +6,7 @@ import pytest from wax._private.models.asset import Asset from wax.models.asset import AssetName -from wax.proto.asset_pb2 import asset +from wax.proto.asset import asset if TYPE_CHECKING: from wax.interfaces import IWaxBaseInterface diff --git a/python/tests/base_api/test_operation_get_impacted_accounts.py b/python/tests/base_api/test_operation_get_impacted_accounts.py index 432d64396..8563f9337 100644 --- a/python/tests/base_api/test_operation_get_impacted_accounts.py +++ b/python/tests/base_api/test_operation_get_impacted_accounts.py @@ -5,29 +5,29 @@ from typing import TYPE_CHECKING, Any, Final import pytest -from wax.proto import authority_pb2, operation_pb2, recover_account_pb2 -from wax.proto.vote_pb2 import vote +from wax.proto.authority import authority +from wax.proto.operations import operation, recover_account, vote if TYPE_CHECKING: from wax.interfaces import IWaxBaseInterface from wax.models.operations import Operation -AUTHORITY_1: Final[authority_pb2.authority] = authority_pb2.authority( +AUTHORITY_1: Final[authority] = authority( weight_threshold=1, account_auths={"account": 1, "account1": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1}, ) -AUTHORITY_2: Final[authority_pb2.authority] = authority_pb2.authority( +AUTHORITY_2: Final[authority] = authority( weight_threshold=1, account_auths={"account1": 1, "account2": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1}, ) -RECOVER_ACCOUNT: Final[recover_account_pb2.recover_account] = recover_account_pb2.recover_account( +RECOVER_ACCOUNT: Final[recover_account] = recover_account( account_to_recover="account", new_owner_authority=AUTHORITY_1, recent_owner_authority=AUTHORITY_2, extensions=[] ) -PROTO_OPERATION: Final[operation_pb2.operation] = operation_pb2.operation(recover_account=RECOVER_ACCOUNT) +PROTO_OPERATION: Final[operation] = operation(recover_account=RECOVER_ACCOUNT) API_OPERATION_DICT: Final[dict[str, Any]] = { "type": "claim_reward_balance_operation", "value": { @@ -68,7 +68,7 @@ def test_get_operation_impacted_accounts_0(wax: IWaxBaseInterface) -> None: @pytest.mark.description("Should be able to get impacted accounts from example proto operation") def test_get_operation_impacted_accounts_1(wax: IWaxBaseInterface) -> None: result = wax.get_operation_impacted_accounts( - operation=operation_pb2.operation( + operation=operation( vote=vote( author="c0ff33a", permlink="ewxhnjbj", diff --git a/python/tests/base_api/test_recurrent_transfer_operation.py b/python/tests/base_api/test_recurrent_transfer_operation.py index 50918341d..faa7ce3ca 100644 --- a/python/tests/base_api/test_recurrent_transfer_operation.py +++ b/python/tests/base_api/test_recurrent_transfer_operation.py @@ -5,11 +5,8 @@ from typing import TYPE_CHECKING, Any, Final import pytest -from wax.proto.recurrent_transfer_pb2 import ( - recurrent_transfer, - recurrent_transfer_extension, - recurrent_transfer_pair_id, -) +from wax._private.proto.recurrent_transfer_pb2 import recurrent_transfer_extension, recurrent_transfer_pair_id +from wax.proto.operations import recurrent_transfer if TYPE_CHECKING: from wax import ITransaction, IWaxBaseInterface diff --git a/python/tests/base_api/test_transaction_processing.py b/python/tests/base_api/test_transaction_processing.py index ad2362967..ab1cc6b1b 100644 --- a/python/tests/base_api/test_transaction_processing.py +++ b/python/tests/base_api/test_transaction_processing.py @@ -11,10 +11,8 @@ if TYPE_CHECKING: from wax.interfaces import IWaxBaseInterface from wax._private.models.hive_date_time import HiveDateTime -from wax.proto.operation_pb2 import operation -from wax.proto.recurrent_transfer_pb2 import recurrent_transfer -from wax.proto.transaction_pb2 import transaction -from wax.proto.vote_pb2 import vote +from wax.proto.operations import operation, recurrent_transfer, vote +from wax.proto.transaction import transaction from .templates import ( RECOVER_ACCOUNT_TRANSACTION, diff --git a/python/tests/base_api/test_update_proposal_operation.py b/python/tests/base_api/test_update_proposal_operation.py index 6d8bc9d90..ef6a58391 100644 --- a/python/tests/base_api/test_update_proposal_operation.py +++ b/python/tests/base_api/test_update_proposal_operation.py @@ -7,7 +7,8 @@ import pytest from google.protobuf.json_format import MessageToDict from wax._private.exceptions import WaxError -from wax.proto.update_proposal_pb2 import update_proposal, update_proposal_end_date, update_proposal_extension +from wax._private.proto.update_proposal_pb2 import update_proposal_end_date, update_proposal_extension +from wax.proto.operations import update_proposal if TYPE_CHECKING: from wax.interfaces import ITransaction, IWaxBaseInterface diff --git a/python/tests/operation_visitor/test_abstract_operation_visitor.py b/python/tests/operation_visitor/test_abstract_operation_visitor.py index 5c6de7bcb..d74d1d1a2 100644 --- a/python/tests/operation_visitor/test_abstract_operation_visitor.py +++ b/python/tests/operation_visitor/test_abstract_operation_visitor.py @@ -1,10 +1,11 @@ from __future__ import annotations from wax.wax_visitor import AbstractOperationVisitor -from wax.proto import vote_pb2 +from wax.proto.operations import vote + class MyOperationVisitor(AbstractOperationVisitor): - def vote(self, op: vote_pb2.vote) -> None: + def vote(self, op: vote) -> None: pass diff --git a/python/tests/operation_visitor/test_operation_visitor.py b/python/tests/operation_visitor/test_operation_visitor.py index 3a1f64f0f..b7ef828df 100644 --- a/python/tests/operation_visitor/test_operation_visitor.py +++ b/python/tests/operation_visitor/test_operation_visitor.py @@ -1,12 +1,7 @@ from google.protobuf.json_format import ParseDict -from wax.proto import ( - vote_pb2, - limit_order_cancel_pb2, - operation_pb2, - transaction_pb2 -) - +from wax.proto.operations import vote, operation +from wax.proto.transaction import transaction from wax.wax_visitor import OperationVisitor tx_json = { @@ -17,18 +12,18 @@ tx_json = { } class MyOperationVisitor(OperationVisitor): - vote_obj: vote_pb2.vote = None + vote_obj: vote = None - def vote(self, op: vote_pb2.vote) -> None: + def vote(self, op: vote) -> None: print("Processing 'vote' operation") self.vote_obj = op def test_operation_visitor(): - tx = ParseDict(tx_json, transaction_pb2.transaction()) + tx = ParseDict(tx_json, transaction()) visitor = MyOperationVisitor() for op in tx.operations: visitor.accept(op) - assert visitor.vote_obj == ParseDict(tx_json["operations"][0]["vote"], vote_pb2.vote()) + assert visitor.vote_obj == ParseDict(tx_json["operations"][0]["vote"], vote()) diff --git a/python/tests/operations/test_proto_account_create_with_delegation.py b/python/tests/operations/test_proto_account_create_with_delegation.py index e669c8d67..1cb112499 100644 --- a/python/tests/operations/test_proto_account_create_with_delegation.py +++ b/python/tests/operations/test_proto_account_create_with_delegation.py @@ -1,48 +1,45 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - account_create_with_delegation_pb2, - operation_pb2, - transaction_pb2, - future_extensions_pb2, - authority_pb2 -) +from wax.proto.operations import account_create_with_delegation, operation +from wax.proto.asset import asset +from wax.proto.transaction import transaction +from wax.proto.authority import authority +from wax._private.proto.future_extensions_pb2 import future_extensions def test_account_create_with_delegation(): - extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions() - vests: asset_pb2.asset = asset_pb2.asset( + extension: future_extensions = future_extensions() + vests: asset = asset( nai="@@000000037", precision=6, amount="10" ) - hive: asset_pb2.asset = asset_pb2.asset( + hive: asset = asset( nai="@@000000021", precision=3, amount="10" ) - authority: authority_pb2.authority = authority_pb2.authority( + proto_authority: authority = authority( weight_threshold=1, account_auths={"account": 1, "account1": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1}, ) - account_create_with_delegation: account_create_with_delegation_pb2.account_create_with_delegation = account_create_with_delegation_pb2.account_create_with_delegation( + account_create_with_delegation_proto: account_create_with_delegation = account_create_with_delegation( fee=hive, delegation=vests, creator="creator", new_account_name="account2", - owner=authority, - active=authority, - posting=authority, + owner=proto_authority, + active=proto_authority, + posting=proto_authority, memo_key="STM6FATHLohxTN8RWWkU9ZZwVywXo6MEDjHHui1jEBYkG2tTdvMYo", json_metadata="{}", extensions=[] ) - account_create_with_delegation_operation: operation_pb2.operation = operation_pb2.operation( - account_create_with_delegation=account_create_with_delegation + account_create_with_delegation_operation: operation = operation( + account_create_with_delegation=account_create_with_delegation_proto ) check_operations(account_create_with_delegation_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[account_create_with_delegation_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_account_update.py b/python/tests/operations/test_proto_account_update.py index 5ccf2e38f..774755372 100644 --- a/python/tests/operations/test_proto_account_update.py +++ b/python/tests/operations/test_proto_account_update.py @@ -1,21 +1,18 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - account_update_pb2, - authority_pb2, - operation_pb2, - transaction_pb2 -) +from wax.proto.operations import account_update, operation +from wax.proto.authority import authority +from wax.proto.transaction import transaction def test_account_update(): - posting: authority_pb2.authority = authority_pb2.authority( + posting: authority = authority( weight_threshold=1, account_auths={"account": 1, "account1": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1}, ) - account_update: account_update_pb2.account_update = ( - account_update_pb2.account_update( + account_update_proto: account_update = ( + account_update( account="theoretical", posting=posting, memo_key="STM6FATHLohxTN8RWWkU9ZZwVywXo6MEDjHHui1jEBYkG2tTdvMYo", @@ -23,14 +20,14 @@ def test_account_update(): ) ) - account_update_operation: operation_pb2.operation = operation_pb2.operation( - account_update=account_update + account_update_operation: operation = operation( + account_update=account_update_proto ) check_operations(account_update_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[account_update_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_account_update2.py b/python/tests/operations/test_proto_account_update2.py index 20aa22db6..9ccd3c1d4 100644 --- a/python/tests/operations/test_proto_account_update2.py +++ b/python/tests/operations/test_proto_account_update2.py @@ -11,17 +11,15 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - account_update2_pb2, - operation_pb2, - transaction_pb2, - future_extensions_pb2 -) +from wax.proto.operations import account_update2, operation +from wax.proto.transaction import transaction +from wax._private.proto.future_extensions_pb2 import future_extensions + def test_account_update2(): - extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions() - account_update2: account_update2_pb2.account_update2 = ( - account_update2_pb2.account_update2( + extension: future_extensions = future_extensions() + account_update2_proto: account_update2 = ( + account_update2( account="rosylisboa", json_metadata="", posting_json_metadata="{}", @@ -29,14 +27,14 @@ def test_account_update2(): ) ) - account_update2_operation: operation_pb2.operation = operation_pb2.operation( - account_update2=account_update2 + account_update2_operation: operation = operation( + account_update2=account_update2_proto ) check_operations(account_update2_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[account_update2_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_account_witness_proxy.py b/python/tests/operations/test_proto_account_witness_proxy.py index a2acef312..8ddee4997 100644 --- a/python/tests/operations/test_proto_account_witness_proxy.py +++ b/python/tests/operations/test_proto_account_witness_proxy.py @@ -8,27 +8,25 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - account_witness_proxy_pb2, - operation_pb2, - transaction_pb2 -) +from wax.proto.operations import account_witness_proxy, operation +from wax.proto.transaction import transaction + def test_account_witness_proxy(): - account_witness_proxy: account_witness_proxy_pb2.account_witness_proxy = ( - account_witness_proxy_pb2.account_witness_proxy( + account_witness_proxy_proto: account_witness_proxy = ( + account_witness_proxy( account="bunkermining", proxy="datasecuritynode" ) ) - account_witness_proxy_operation: operation_pb2.operation = ( - operation_pb2.operation(account_witness_proxy=account_witness_proxy) + account_witness_proxy_operation: operation = ( + operation(account_witness_proxy=account_witness_proxy_proto) ) check_operations(account_witness_proxy_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[account_witness_proxy_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_account_witness_vote.py b/python/tests/operations/test_proto_account_witness_vote.py index aa9db2a86..3e9451cc9 100644 --- a/python/tests/operations/test_proto_account_witness_vote.py +++ b/python/tests/operations/test_proto_account_witness_vote.py @@ -9,27 +9,27 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - account_witness_vote_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + account_witness_vote, + operation, ) +from wax.proto.transaction import transaction def test_account_witness_vote(): - account_witness_vote: account_witness_vote_pb2.account_witness_vote = ( - account_witness_vote_pb2.account_witness_vote( + account_witness_vote_proto: account_witness_vote = ( + account_witness_vote( account="donalddrumpf", witness="berniesanders", approve=True ) ) - account_witness_vote_operation: operation_pb2.operation = ( - operation_pb2.operation(account_witness_vote=account_witness_vote) + account_witness_vote_operation: operation = ( + operation(account_witness_vote=account_witness_vote_proto) ) check_operations(account_witness_vote_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[account_witness_vote_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_cancel_transfer_from_savings.py b/python/tests/operations/test_proto_cancel_transfer_from_savings.py index 7146daa55..6f603b435 100644 --- a/python/tests/operations/test_proto_cancel_transfer_from_savings.py +++ b/python/tests/operations/test_proto_cancel_transfer_from_savings.py @@ -1,25 +1,25 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - cancel_transfer_from_savings_pb2 +from wax.proto.operations import ( + operation, + cancel_transfer_from_savings, ) +from wax.proto.transaction import transaction def test_cancel_transfer_from_savings(): - cancel_transfer_from_savings: cancel_transfer_from_savings_pb2.cancel_transfer_from_savings = cancel_transfer_from_savings_pb2.cancel_transfer_from_savings( + cancel_transfer_from_savings_proto: cancel_transfer_from_savings = cancel_transfer_from_savings( from_account="faddy", request_id=3 ) - cancel_transfer_from_savings_operation: operation_pb2.operation = ( - operation_pb2.operation(cancel_transfer_from_savings=cancel_transfer_from_savings) + cancel_transfer_from_savings_operation: operation = ( + operation(cancel_transfer_from_savings=cancel_transfer_from_savings_proto) ) check_operations(cancel_transfer_from_savings_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[cancel_transfer_from_savings_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_change_recovery_account.py b/python/tests/operations/test_proto_change_recovery_account.py index f1af167ed..f26224a37 100644 --- a/python/tests/operations/test_proto_change_recovery_account.py +++ b/python/tests/operations/test_proto_change_recovery_account.py @@ -1,28 +1,28 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - change_recovery_account_pb2, - operation_pb2, - transaction_pb2, - future_extensions_pb2 +from wax.proto.operations import ( + change_recovery_account, + operation, ) +from wax.proto.transaction import transaction +from wax._private.proto.future_extensions_pb2 import future_extensions def test_change_recovery_account(): - extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions() - change_recovery_account: change_recovery_account_pb2.change_recovery_account = change_recovery_account_pb2.change_recovery_account( + extension: future_extensions = future_extensions() + change_recovery_account_proto: change_recovery_account = change_recovery_account( account_to_recover="account", new_recovery_account="account1", extensions=[] ) - change_recovery_account_operation: operation_pb2.operation = operation_pb2.operation( - change_recovery_account=change_recovery_account + change_recovery_account_operation: operation = operation( + change_recovery_account=change_recovery_account_proto ) check_operations(change_recovery_account_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[change_recovery_account_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_claim_account.py b/python/tests/operations/test_proto_claim_account.py index c968433e2..a2214606d 100644 --- a/python/tests/operations/test_proto_claim_account.py +++ b/python/tests/operations/test_proto_claim_account.py @@ -1,32 +1,29 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - claim_account_pb2, - operation_pb2, - transaction_pb2, - future_extensions_pb2, - asset_pb2 -) +from wax.proto.operations import claim_account, operation +from wax.proto.transaction import transaction +from wax.proto.asset import asset +from wax._private.proto.future_extensions_pb2 import future_extensions, void_t def test_claim_account(): - extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions(void_t=future_extensions_pb2.void_t()) - fee: asset_pb2.asset = asset_pb2.asset( + extension: future_extensions = future_extensions(void_t=void_t()) + fee: asset = asset( nai="@@000000021", precision=3, amount="10" ) - claim_account: claim_account_pb2.claim_account = claim_account_pb2.claim_account( + claim_account_proto: claim_account = claim_account( creator="rosylisboa", fee=fee, extensions=[] ) - claim_account_operation: operation_pb2.operation = operation_pb2.operation( - claim_account=claim_account + claim_account_operation: operation = operation( + claim_account=claim_account_proto ) check_operations(claim_account_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[claim_account_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_claim_reward_balance.py b/python/tests/operations/test_proto_claim_reward_balance.py index 9a388d5ac..a6d863b55 100644 --- a/python/tests/operations/test_proto_claim_reward_balance.py +++ b/python/tests/operations/test_proto_claim_reward_balance.py @@ -22,26 +22,26 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - claim_reward_balance_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + claim_reward_balance, + operation, ) +from wax.proto.transaction import transaction +from wax.proto.asset import asset def test_claim_reward_balance(): - reward_hive: asset_pb2.asset = asset_pb2.asset( + reward_hive: asset = asset( amount="0", precision=3, nai="@@000000021" ) - reward_hbd: asset_pb2.asset = asset_pb2.asset( + reward_hbd: asset = asset( amount="104", precision=3, nai="@@000000013" ) - reward_vests: asset_pb2.asset = asset_pb2.asset( + reward_vests: asset = asset( amount="531747227", precision=6, nai="@@000000037" ) - claim_reward_balance: claim_reward_balance_pb2.claim_reward_balance = ( - claim_reward_balance_pb2.claim_reward_balance( + claim_reward_balance_proto: claim_reward_balance = ( + claim_reward_balance( account="bradleyarrow", reward_hive=reward_hive, reward_hbd=reward_hbd, @@ -49,14 +49,14 @@ def test_claim_reward_balance(): ) ) - claim_reward_balance_operation: operation_pb2.operation = ( - operation_pb2.operation(claim_reward_balance=claim_reward_balance) + claim_reward_balance_operation: operation = ( + operation(claim_reward_balance=claim_reward_balance_proto) ) check_operations(claim_reward_balance_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[claim_reward_balance_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_collateralized_convert.py b/python/tests/operations/test_proto_collateralized_convert.py index f7464c870..3430da23b 100644 --- a/python/tests/operations/test_proto_collateralized_convert.py +++ b/python/tests/operations/test_proto_collateralized_convert.py @@ -13,32 +13,32 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - collateralized_convert_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + collateralized_convert, + operation, ) +from wax.proto.transaction import transaction +from wax.proto.asset import asset def test_collateralized_convert(): - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( amount="102", precision=3, nai="@@000000021" ) - collateralized_convert: collateralized_convert_pb2.collateralized_convert = ( - collateralized_convert_pb2.collateralized_convert( + collateralized_convert_proto: collateralized_convert = ( + collateralized_convert( owner="karbea", requestid=2, amount=amount ) ) - collateralized_convert_operation: operation_pb2.operation = ( - operation_pb2.operation(collateralized_convert=collateralized_convert) + collateralized_convert_operation: operation = ( + operation(collateralized_convert=collateralized_convert_proto) ) check_operations(collateralized_convert_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[collateralized_convert_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_comment.py b/python/tests/operations/test_proto_comment.py index 053dc6d41..0d70ab7c8 100644 --- a/python/tests/operations/test_proto_comment.py +++ b/python/tests/operations/test_proto_comment.py @@ -1,14 +1,14 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - comment_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + comment, + operation, ) +from wax.proto.transaction import transaction def test_comment(): - comment: comment_pb2.comment = comment_pb2.comment( + comment_proto: comment = comment( parent_permlink="/", parent_author="", author="alice", @@ -18,14 +18,14 @@ def test_comment(): json_metadata="{}", ) - comment_operation: operation_pb2.operation = operation_pb2.operation( - comment=comment + comment_operation: operation = operation( + comment=comment_proto ) check_operations(comment_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[comment_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_comment_options.py b/python/tests/operations/test_proto_comment_options.py index d12b3a6ac..67cae2cab 100644 --- a/python/tests/operations/test_proto_comment_options.py +++ b/python/tests/operations/test_proto_comment_options.py @@ -1,11 +1,12 @@ from tests.utils.checkers import check_operations, check_transaction +from wax._private.proto import comment_options_pb2 -from wax.proto import ( - asset_pb2, - comment_options_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + comment_options, + operation, ) +from wax.proto.transaction import transaction +from wax.proto.asset import asset def test_comment_options(): beneficiary_route : comment_options_pb2.beneficiary_route_type = comment_options_pb2.beneficiary_route_type(account="account", weight=10) @@ -13,27 +14,27 @@ def test_comment_options(): beneficiaries=[beneficiary_route]) comment_options_extension: comment_options_pb2.comment_options_extension = comment_options_pb2.comment_options_extension( comment_payout_beneficiaries=comment_payout_beneficiaries) - asset: asset_pb2.asset = asset_pb2.asset( + asset_proto: asset = asset( nai="@@000000013", precision=3, amount="10" ) - comment_options: comment_options_pb2.comment_options = comment_options_pb2.comment_options( + comment_options_proto: comment_options = comment_options( author="author", permlink="/", - max_accepted_payout=asset, + max_accepted_payout=asset_proto, percent_hbd=10, allow_votes=True, allow_curation_rewards=True, extensions=[comment_options_extension] ) - comment_options_operation: operation_pb2.operation = operation_pb2.operation( - comment_options=comment_options + comment_options_operation: operation = operation( + comment_options=comment_options_proto ) check_operations(comment_options_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[comment_options_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_convert.py b/python/tests/operations/test_proto_convert.py index b7481d65b..8cdd8a429 100644 --- a/python/tests/operations/test_proto_convert.py +++ b/python/tests/operations/test_proto_convert.py @@ -13,29 +13,29 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - convert_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + convert, + operation, ) +from wax.proto.transaction import transaction +from wax.proto.asset import asset def test_convert(): - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000013", precision=3, amount="5000" ) - conver: convert_pb2.convert = convert_pb2.convert( + convert_proto: convert = convert( owner="summon", requestid=1467592156, amount=amount ) - conver_operation: operation_pb2.operation = operation_pb2.operation( - convert=conver + convert_operation: operation = operation( + convert=convert_proto ) - check_operations(conver_operation) + check_operations(convert_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( - operations=[conver_operation] + transaction_proto: transaction = transaction( + operations=[convert_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_create_claimed_account.py b/python/tests/operations/test_proto_create_claimed_account.py index cfad0f52b..ac0e62d5f 100644 --- a/python/tests/operations/test_proto_create_claimed_account.py +++ b/python/tests/operations/test_proto_create_claimed_account.py @@ -1,43 +1,43 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - create_claimed_account_pb2, - operation_pb2, - transaction_pb2, - future_extensions_pb2, - authority_pb2 +from wax.proto.operations import ( + create_claimed_account, + operation, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction +from wax.proto.authority import authority +from wax._private.proto import future_extensions_pb2 def test_create_claimed_account(): extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions() - asset: asset_pb2.asset = asset_pb2.asset( + asset_proto: asset = asset( nai="@@000000021", precision=3, amount="10" ) - authority: authority_pb2.authority = authority_pb2.authority( + authority_proto: authority = authority( weight_threshold=1, account_auths={"account": 1, "account1": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1} ) - create_claimed_account: create_claimed_account_pb2.create_claimed_account = create_claimed_account_pb2.create_claimed_account( + create_claimed_account_proto: create_claimed_account = create_claimed_account( creator="creator", new_account_name="account", - owner=authority, - active=authority, - posting=authority, + owner=authority_proto, + active=authority_proto, + posting=authority_proto, memo_key="STM6FATHLohxTN8RWWkU9ZZwVywXo6MEDjHHui1jEBYkG2tTdvMYo", json_metadata="{}", extensions=[] ) - create_claimed_account_operation: operation_pb2.operation = operation_pb2.operation( - create_claimed_account=create_claimed_account + create_claimed_account_operation: operation = operation( + create_claimed_account=create_claimed_account_proto ) check_operations(create_claimed_account_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[create_claimed_account_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_create_proposal.py b/python/tests/operations/test_proto_create_proposal.py index cb15a38b4..0e9d43846 100644 --- a/python/tests/operations/test_proto_create_proposal.py +++ b/python/tests/operations/test_proto_create_proposal.py @@ -20,20 +20,20 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - create_proposal_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + create_proposal, + operation, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_create_proposal(): - daily_pay: asset_pb2.asset = asset_pb2.asset( + daily_pay: asset = asset( amount="600000", precision=3, nai="@@000000013" ) - create_proposal: create_proposal_pb2.create_proposal = ( - create_proposal_pb2.create_proposal( + create_proposal_proto: create_proposal = ( + create_proposal( creator="ecency", receiver="ecency", start_date="2022-11-30T00:00:00", @@ -44,14 +44,14 @@ def test_create_proposal(): extensions=[], ) ) - create_proposal_operation: operation_pb2.operation = operation_pb2.operation( - create_proposal=create_proposal + create_proposal_operation: operation = operation( + create_proposal=create_proposal_proto ) check_operations(create_proposal_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[create_proposal_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_custom.py b/python/tests/operations/test_proto_custom.py index b621b1865..e6048b64b 100644 --- a/python/tests/operations/test_proto_custom.py +++ b/python/tests/operations/test_proto_custom.py @@ -11,26 +11,26 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - custom_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + custom, + operation, ) +from wax.proto.transaction import transaction def test_custom(): - custom: custom_pb2.custom = custom_pb2.custom( + custom_proto: custom = custom( required_auths=["bytemaster"], id=777, data="0a627974656d617374657207737465656d697402a3d13897d82114466ad87a74b73a53292d8331d1bd1d3082da6bfbcff19ed097029db013797711c88cccca3692407f9ff9b9ce7221aaa2d797f1692be2215d0a5f6d2a8cab6832050078bc5729201e3ea24ea9f7873e6dbdc65a6bd9899053b9acda876dc69f11a13df9ca8b26b6", ) - custom_operation: operation_pb2.operation = operation_pb2.operation( - custom=custom + custom_operation: operation = operation( + custom=custom_proto ) check_operations(custom_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[custom_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_custom_json.py b/python/tests/operations/test_proto_custom_json.py index 6d4a0812b..6c34a6a20 100644 --- a/python/tests/operations/test_proto_custom_json.py +++ b/python/tests/operations/test_proto_custom_json.py @@ -1,10 +1,10 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - custom_json_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + custom_json, + operation, ) +from wax.proto.transaction import transaction ''' required_auths: collections.abc.Iterable[builtins.str] | None = ..., @@ -14,20 +14,20 @@ from wax.proto import ( ''' def test_custom_json(): - custom_json: custom_json_pb2.custom_json = custom_json_pb2.custom_json( + custom_json_proto: custom_json = custom_json( required_auths=["bytemaster"], required_posting_auths=["other"], id="666", json="{}" ) - custom_json_operation: operation_pb2.operation = operation_pb2.operation( - custom_json=custom_json + custom_json_operation: operation = operation( + custom_json=custom_json_proto ) check_operations(custom_json_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[custom_json_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_decline_voting_rights.py b/python/tests/operations/test_proto_decline_voting_rights.py index abfcab4ba..76372dcc6 100644 --- a/python/tests/operations/test_proto_decline_voting_rights.py +++ b/python/tests/operations/test_proto_decline_voting_rights.py @@ -1,25 +1,25 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - decline_voting_rights_pb2 +from wax.proto.operations import ( + operation, + decline_voting_rights, ) +from wax.proto.transaction import transaction def test_decline_voting_rights(): - decline_voting_rights: decline_voting_rights_pb2.decline_voting_rights = decline_voting_rights_pb2.decline_voting_rights( + decline_voting_rights_proto: decline_voting_rights = decline_voting_rights( account="faddy", decline=True ) - decline_voting_rights_operation: operation_pb2.operation = ( - operation_pb2.operation(decline_voting_rights=decline_voting_rights) + decline_voting_rights_operation: operation = ( + operation(decline_voting_rights=decline_voting_rights_proto) ) check_operations(decline_voting_rights_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[decline_voting_rights_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_delegate_vesting_shares.py b/python/tests/operations/test_proto_delegate_vesting_shares.py index d8f8636a5..ebe11076f 100644 --- a/python/tests/operations/test_proto_delegate_vesting_shares.py +++ b/python/tests/operations/test_proto_delegate_vesting_shares.py @@ -13,31 +13,31 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - delegate_vesting_shares_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + delegate_vesting_shares, + operation, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_delegate_vesting_shares(): - vesting_shares: asset_pb2.asset = asset_pb2.asset( + vesting_shares: asset = asset( amount="90111193694", precision=6, nai="@@000000037" ) - delegate_vesting_shares: delegate_vesting_shares_pb2.delegate_vesting_shares = ( - delegate_vesting_shares_pb2.delegate_vesting_shares( + delegate_vesting_shares_proto: delegate_vesting_shares = ( + delegate_vesting_shares( delegator="elamaria", delegatee="music1sound", vesting_shares=vesting_shares ) ) - delegate_vesting_shares_operation: operation_pb2.operation = ( - operation_pb2.operation(delegate_vesting_shares=delegate_vesting_shares) + delegate_vesting_shares_operation: operation = ( + operation(delegate_vesting_shares=delegate_vesting_shares_proto) ) check_operations(delegate_vesting_shares_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[delegate_vesting_shares_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_delete_comment.py b/python/tests/operations/test_proto_delete_comment.py index 157090ed6..b56f04a82 100644 --- a/python/tests/operations/test_proto_delete_comment.py +++ b/python/tests/operations/test_proto_delete_comment.py @@ -1,25 +1,25 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - delete_comment_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + delete_comment, + operation, ) +from wax.proto.transaction import transaction def test_delete_comment(): - delete_comment: delete_comment_pb2.delete_comment = delete_comment_pb2.delete_comment( + delete_comment_proto: delete_comment = delete_comment( author="alice", permlink="/", ) - delete_comment_operation: operation_pb2.operation = operation_pb2.operation( - delete_comment=delete_comment + delete_comment_operation: operation = operation( + delete_comment=delete_comment_proto ) check_operations(delete_comment_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[delete_comment_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_escrow_approve.py b/python/tests/operations/test_proto_escrow_approve.py index 5d90fe341..fced84c9d 100644 --- a/python/tests/operations/test_proto_escrow_approve.py +++ b/python/tests/operations/test_proto_escrow_approve.py @@ -1,13 +1,13 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - escrow_approve_pb2 +from wax.proto.operations import ( + operation, + escrow_approve ) +from wax.proto.transaction import transaction def test_escrow_approve(): - escrow_approve: escrow_approve_pb2.escrow_approve = escrow_approve_pb2.escrow_approve( + escrow_approve_proto: escrow_approve = escrow_approve( from_account="faddy", to_account="daddy", agent="agent", @@ -16,14 +16,14 @@ def test_escrow_approve(): approve=True ) - escrow_approve_operation: operation_pb2.operation = ( - operation_pb2.operation(escrow_approve=escrow_approve) + escrow_approve_operation: operation = ( + operation(escrow_approve=escrow_approve_proto) ) check_operations(escrow_approve_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction =transaction( operations=[escrow_approve_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_escrow_dispute.py b/python/tests/operations/test_proto_escrow_dispute.py index 009f0b8a3..afd551bf3 100644 --- a/python/tests/operations/test_proto_escrow_dispute.py +++ b/python/tests/operations/test_proto_escrow_dispute.py @@ -1,13 +1,13 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - escrow_dispute_pb2 +from wax.proto.operations import ( + operation, + escrow_dispute ) +from wax.proto.transaction import transaction def test_escrow_dispute(): - escrow_dispute: escrow_dispute_pb2.escrow_dispute = escrow_dispute_pb2.escrow_dispute( + escrow_dispute_proto: escrow_dispute = escrow_dispute( from_account="faddy", to_account="daddy", agent="agent", @@ -15,14 +15,14 @@ def test_escrow_dispute(): escrow_id=1 ) - escrow_dispute_operation: operation_pb2.operation = ( - operation_pb2.operation(escrow_dispute=escrow_dispute) + escrow_dispute_operation: operation = ( + operation(escrow_dispute=escrow_dispute_proto) ) check_operations(escrow_dispute_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[escrow_dispute_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_escrow_release.py b/python/tests/operations/test_proto_escrow_release.py index 229e95638..eebf0eeb3 100644 --- a/python/tests/operations/test_proto_escrow_release.py +++ b/python/tests/operations/test_proto_escrow_release.py @@ -1,21 +1,21 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - escrow_release_pb2 +from wax.proto.operations import ( + operation, + escrow_release ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_escrow_release(): - hbd_amount: asset_pb2.asset = asset_pb2.asset( + hbd_amount: asset = asset( nai="@@000000013", precision=3, amount="357000" ) - hive_amount: asset_pb2.asset = asset_pb2.asset( + hive_amount: asset = asset( nai="@@000000021", precision=3, amount="357000" ) - escrow_release: escrow_release_pb2.escrow_release = escrow_release_pb2.escrow_release( + escrow_release_proto: escrow_release = escrow_release( from_account="faddy", to_account="daddy", agent="agent", @@ -26,14 +26,14 @@ def test_escrow_release(): hive_amount=hive_amount ) - escrow_release_operation: operation_pb2.operation = ( - operation_pb2.operation(escrow_release=escrow_release) + escrow_release_operation: operation = ( + operation(escrow_release=escrow_release_proto) ) check_operations(escrow_release_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[escrow_release_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_escrow_transfer.py b/python/tests/operations/test_proto_escrow_transfer.py index 2e1fdec74..8f53616c3 100644 --- a/python/tests/operations/test_proto_escrow_transfer.py +++ b/python/tests/operations/test_proto_escrow_transfer.py @@ -1,21 +1,21 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - escrow_transfer_pb2 +from wax.proto.operations import ( + operation, + escrow_transfer ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_escrow_transfer(): - hbd_amount: asset_pb2.asset = asset_pb2.asset( + hbd_amount: asset = asset( nai="@@000000013", precision=3, amount="357000" ) - hive_amount: asset_pb2.asset = asset_pb2.asset( + hive_amount: asset = asset( nai="@@000000021", precision=3, amount="357000" ) - escrow_transfer: escrow_transfer_pb2.escrow_transfer = escrow_transfer_pb2.escrow_transfer( + escrow_transfer_proto: escrow_transfer = escrow_transfer( from_account="faddy", to_account="daddy", agent="agent", @@ -28,14 +28,14 @@ def test_escrow_transfer(): json_meta="{}" ) - escrow_transfer_operation: operation_pb2.operation = ( - operation_pb2.operation(escrow_transfer=escrow_transfer) + escrow_transfer_operation: operation = ( + operation(escrow_transfer=escrow_transfer_proto) ) check_operations(escrow_transfer_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[escrow_transfer_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_feed_publish.py b/python/tests/operations/test_proto_feed_publish.py index f71c8d430..8f1816d35 100644 --- a/python/tests/operations/test_proto_feed_publish.py +++ b/python/tests/operations/test_proto_feed_publish.py @@ -1,37 +1,34 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - feed_publish_pb2, - price_pb2, - operation_pb2, - transaction_pb2 -) +from wax.proto.operations import feed_publish, operation +from wax.proto.asset import asset +from wax.proto.transaction import transaction +from wax._private.proto.price_pb2 import price def test_feed_publish(): - base: asset_pb2.asset = asset_pb2.asset( + base: asset = asset( nai="@@000000021", precision=3, amount="1000" ) - quote: asset_pb2.asset = asset_pb2.asset( + quote: asset = asset( nai="@@000000013", precision=3, amount="1000000" ) - price: price_pb2.price = price_pb2.price(base=base, quote=quote) + price_proto: price = price(base=base, quote=quote) - feed_publish: feed_publish_pb2.feed_publish = feed_publish_pb2.feed_publish( + feed_publish_proto: feed_publish = feed_publish( publisher="abit", - exchange_rate=price, + exchange_rate=price_proto, ) - feed_publish_operation: operation_pb2.operation = operation_pb2.operation( - feed_publish=feed_publish + feed_publish_operation: operation =operation( + feed_publish=feed_publish_proto ) check_operations(feed_publish_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[feed_publish_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_limit_order_cancel.py b/python/tests/operations/test_proto_limit_order_cancel.py index f09ea6ab9..82da87d56 100644 --- a/python/tests/operations/test_proto_limit_order_cancel.py +++ b/python/tests/operations/test_proto_limit_order_cancel.py @@ -1,24 +1,24 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - limit_order_cancel_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + limit_order_cancel, + operation, ) +from wax.proto.transaction import transaction def test_limit_order_cancel(): - limit_order_cancel: limit_order_cancel_pb2.limit_order_cancel = ( - limit_order_cancel_pb2.limit_order_cancel(owner="adm", orderid=1) + limit_order_cancel_proto: limit_order_cancel = ( + limit_order_cancel(owner="adm", orderid=1) ) - limit_order_cancel_operation: operation_pb2.operation = operation_pb2.operation( - limit_order_cancel=limit_order_cancel + limit_order_cancel_operation: operation = operation( + limit_order_cancel=limit_order_cancel_proto ) check_operations(limit_order_cancel_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[limit_order_cancel_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_limit_order_create.py b/python/tests/operations/test_proto_limit_order_create.py index d1ac11dad..f341a43e0 100644 --- a/python/tests/operations/test_proto_limit_order_create.py +++ b/python/tests/operations/test_proto_limit_order_create.py @@ -20,23 +20,23 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - limit_order_create_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + limit_order_create, + operation, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_limit_order_create(): - amount_to_sell: asset_pb2.asset = asset_pb2.asset( + amount_to_sell: asset =asset( nai="@@000000021", precision=3, amount="1000" ) - min_to_receive: asset_pb2.asset = asset_pb2.asset( + min_to_receive: asset = asset( nai="@@000000013", precision=3, amount="3500" ) - limit_order_create: limit_order_create_pb2.limit_order_create = ( - limit_order_create_pb2.limit_order_create( + limit_order_create_proto: limit_order_create = ( + limit_order_create( owner="linouxis9", orderid=10, amount_to_sell=amount_to_sell, @@ -46,14 +46,14 @@ def test_limit_order_create(): ) ) - limit_order_create_operation: operation_pb2.operation = operation_pb2.operation( - limit_order_create=limit_order_create + limit_order_create_operation: operation = operation( + limit_order_create=limit_order_create_proto ) check_operations(limit_order_create_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[limit_order_create_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_limit_order_create2.py b/python/tests/operations/test_proto_limit_order_create2.py index a8d11430b..33dff0a26 100644 --- a/python/tests/operations/test_proto_limit_order_create2.py +++ b/python/tests/operations/test_proto_limit_order_create2.py @@ -1,43 +1,44 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - price_pb2, - limit_order_create2_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + limit_order_create2, + operation, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction +from wax._private.proto.price_pb2 import price + def test_limit_order_create2(): - amount_to_sell: asset_pb2.asset = asset_pb2.asset( + amount_to_sell: asset = asset( nai="@@000000021", precision=3, amount="1000" ) - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset =asset( nai="@@000000013", precision=3, amount="3500" ) - price: price_pb2.price = price_pb2.price( + price_proto: price = price( base=amount_to_sell, quote=amount ) - limit_order_create2: limit_order_create2_pb2.limit_order_create2 = ( - limit_order_create2_pb2.limit_order_create2( + limit_order_create2_proto: limit_order_create2 = ( + limit_order_create2( owner="linouxis9", orderid=10, amount_to_sell=amount_to_sell, fill_or_kill=False, - exchange_rate=price, + exchange_rate=price_proto, expiration="2035-10-29T06:32:22" ) ) - limit_order_create2_operation: operation_pb2.operation = operation_pb2.operation( - limit_order_create2=limit_order_create2 + limit_order_create2_operation: operation = operation( + limit_order_create2=limit_order_create2_proto ) check_operations(limit_order_create2_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[limit_order_create2_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_pow.py b/python/tests/operations/test_proto_pow.py index 3b16d789c..e8480f0d2 100644 --- a/python/tests/operations/test_proto_pow.py +++ b/python/tests/operations/test_proto_pow.py @@ -1,12 +1,12 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - asset_pb2, - legacy_chain_properties_pb2, - pow_pb2 +from wax._private.proto import pow_pb2, legacy_chain_properties_pb2 +from wax.proto.operations import ( + operation, + pow, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_pow(): pow_work: pow_pb2.pow_work = pow_pb2.pow_work( @@ -15,7 +15,7 @@ def test_pow(): signature="20e04849e13ab128d7d32e68f6989b95a0c7a2b0f9efac2a0ebb65ef649506af0d5b9fa80555116880348e99b0947c30af612750fe4c09d829c0947ed8eb4ee2fc", work="000000026fadb7729a31f60d04bb8a8e83707fd3a108e75d4881c14410f4024b" ) - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="3000" ) legacy_chain_properties: legacy_chain_properties_pb2.legacy_chain_properties = legacy_chain_properties_pb2.legacy_chain_properties( @@ -24,7 +24,7 @@ def test_pow(): hbd_interest_rate=66, ) - pow: pow_pb2.pow = pow_pb2.pow( + pow_proto: pow = pow( worker_account="steemit15", block_id="0031078448f8b2ceffc5052d9f9dd32951a184a4", nonce=17268219029926207870, @@ -32,14 +32,14 @@ def test_pow(): props=legacy_chain_properties ) - pow_operation: operation_pb2.operation = operation_pb2.operation( - pow=pow + pow_operation: operation = operation( + pow=pow_proto ) check_operations(pow_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[pow_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_pow2.py b/python/tests/operations/test_proto_pow2.py index bc4e83afd..5eaf370db 100644 --- a/python/tests/operations/test_proto_pow2.py +++ b/python/tests/operations/test_proto_pow2.py @@ -1,12 +1,9 @@ from tests.utils.checkers import check_operations, check_transaction +from wax._private.proto import pow2_pb2, legacy_chain_properties_pb2 -from wax.proto import ( - operation_pb2, - transaction_pb2, - asset_pb2, - legacy_chain_properties_pb2, - pow2_pb2 -) +from wax.proto.operations import operation, pow2 +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_pow2_1(): pow2_input: pow2_pb2.pow2_input = pow2_pb2.pow2_input( @@ -33,7 +30,7 @@ def test_pow2_1(): pow2_work: pow2_pb2.pow2_work = pow2_pb2.pow2_work( equihash_pow=equihash_pow ) - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="1" ) legacy_chain_properties: legacy_chain_properties_pb2.legacy_chain_properties = legacy_chain_properties_pb2.legacy_chain_properties( @@ -42,22 +39,22 @@ def test_pow2_1(): hbd_interest_rate=1000 ) - pow2: pow2_pb2.pow2 = pow2_pb2.pow2( + pow2_proto: pow2 = pow2( work=pow2_work, props=legacy_chain_properties ) - pow2_operation: operation_pb2.operation = operation_pb2.operation( - pow2=pow2 + pow2_operation: operation = operation( + pow2=pow2_proto ) check_operations(pow2_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[pow2_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) def test_pow2_2(): pow2_input: pow2_pb2.pow2_input = pow2_pb2.pow2_input( @@ -72,7 +69,7 @@ def test_pow2_2(): pow2_work: pow2_pb2.pow2_work = pow2_pb2.pow2_work( pow2=pow2_pow ) - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="1" ) legacy_chain_properties: legacy_chain_properties_pb2.legacy_chain_properties = legacy_chain_properties_pb2.legacy_chain_properties( @@ -81,19 +78,19 @@ def test_pow2_2(): hbd_interest_rate=1000 ) - pow2: pow2_pb2.pow2 = pow2_pb2.pow2( + pow2_proto: pow2 = pow2( work=pow2_work, props=legacy_chain_properties ) - pow2_operation: operation_pb2.operation = operation_pb2.operation( - pow2=pow2 + pow2_operation: operation = operation( + pow2=pow2_proto ) check_operations(pow2_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[pow2_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_recover_account.py b/python/tests/operations/test_proto_recover_account.py index 111404986..f8272b7a0 100644 --- a/python/tests/operations/test_proto_recover_account.py +++ b/python/tests/operations/test_proto_recover_account.py @@ -1,40 +1,40 @@ from tests.utils.checkers import check_operations, check_transaction +from wax._private.proto import future_extensions_pb2 -from wax.proto import ( - recover_account_pb2, - operation_pb2, - transaction_pb2, - future_extensions_pb2, - authority_pb2 +from wax.proto.operations import ( + recover_account, + operation, ) +from wax.proto.transaction import transaction +from wax.proto.authority import authority def test_recover_account(): extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions() - authority1: authority_pb2.authority = authority_pb2.authority( + authority1: authority = authority( weight_threshold=1, account_auths={"account": 1, "account1": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1} ) - authority2: authority_pb2.authority = authority_pb2.authority( + authority2: authority = authority( weight_threshold=1, account_auths={"account1": 1, "account2": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1} ) - recover_account: recover_account_pb2.recover_account = recover_account_pb2.recover_account( + recover_account_proto: recover_account = recover_account( account_to_recover="account", new_owner_authority=authority1, recent_owner_authority=authority2, extensions=[] ) - recover_account_operation: operation_pb2.operation = operation_pb2.operation( - recover_account=recover_account + recover_account_operation: operation = operation( + recover_account=recover_account_proto ) check_operations(recover_account_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[recover_account_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_recurrent_transfer.py b/python/tests/operations/test_proto_recurrent_transfer.py index 5a8d2e843..9b093a4dc 100644 --- a/python/tests/operations/test_proto_recurrent_transfer.py +++ b/python/tests/operations/test_proto_recurrent_transfer.py @@ -1,14 +1,15 @@ from tests.utils.checkers import check_operations, check_transaction +from wax._private.proto import recurrent_transfer_pb2 -from wax.proto import ( - asset_pb2, - recurrent_transfer_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + recurrent_transfer, + operation, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_recurrent_transfer(): - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="10" ) recurrent_transfer_pair_id: recurrent_transfer_pb2.recurrent_transfer_pair_id = ( @@ -19,8 +20,8 @@ def test_recurrent_transfer(): recurrent_transfer_pair_id=recurrent_transfer_pair_id ) ) - recurrent_transfer: recurrent_transfer_pb2.recurrent_transfer = ( - recurrent_transfer_pb2.recurrent_transfer( + recurrent_transfer_proto: recurrent_transfer = ( + recurrent_transfer( from_account="alice", to_account="harry", amount=amount, @@ -30,14 +31,14 @@ def test_recurrent_transfer(): extensions=[extensions], ) ) - recurrent_transfer_operation: operation_pb2.operation = operation_pb2.operation( - recurrent_transfer=recurrent_transfer + recurrent_transfer_operation: operation = operation( + recurrent_transfer=recurrent_transfer_proto ) check_operations(recurrent_transfer_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction =transaction( operations=[recurrent_transfer_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_remove_proposal.py b/python/tests/operations/test_proto_remove_proposal.py index 337276d34..826c3bc67 100644 --- a/python/tests/operations/test_proto_remove_proposal.py +++ b/python/tests/operations/test_proto_remove_proposal.py @@ -5,27 +5,27 @@ remove_proposal_operation = { from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - remove_proposal_pb2, - operation_pb2, - transaction_pb2 +from wax.proto.operations import ( + remove_proposal, + operation, ) +from wax.proto.transaction import transaction def test_remove_proposal(): - remove_proposal: remove_proposal_pb2.remove_proposal = ( - remove_proposal_pb2.remove_proposal( + remove_proposal_proto: remove_proposal = ( + remove_proposal( proposal_owner="doze", proposal_ids=[225], extensions=[] ) ) - remove_proposal_operation: operation_pb2.operation = operation_pb2.operation( - remove_proposal=remove_proposal + remove_proposal_operation: operation = operation( + remove_proposal=remove_proposal_proto ) check_operations(remove_proposal_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[remove_proposal_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_request_account_recovery.py b/python/tests/operations/test_proto_request_account_recovery.py index 7583fdeae..4b4ceae95 100644 --- a/python/tests/operations/test_proto_request_account_recovery.py +++ b/python/tests/operations/test_proto_request_account_recovery.py @@ -1,36 +1,36 @@ from tests.utils.checkers import check_operations, check_transaction +from wax._private.proto import future_extensions_pb2 -from wax.proto import ( - request_account_recovery_pb2, - operation_pb2, - transaction_pb2, - future_extensions_pb2, - authority_pb2 +from wax.proto.operations import ( + request_account_recovery, + operation, ) +from wax.proto.authority import authority +from wax.proto.transaction import transaction def test_request_account_recovery(): extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions() - authority: authority_pb2.authority = authority_pb2.authority( + authority_proto: authority = authority( weight_threshold=1, account_auths={"account": 1, "account1": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1} ) - request_account_recovery: request_account_recovery_pb2.request_account_recovery = request_account_recovery_pb2.request_account_recovery( + request_account_recovery_proto: request_account_recovery = request_account_recovery( recovery_account="account", account_to_recover="account1", - new_owner_authority=authority, + new_owner_authority=authority_proto, extensions=[] ) - request_account_recovery_operation: operation_pb2.operation = operation_pb2.operation( - request_account_recovery=request_account_recovery + request_account_recovery_operation: operation = operation( + request_account_recovery=request_account_recovery_proto ) check_operations(request_account_recovery_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[request_account_recovery_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_set_withdraw_vesting_route.py b/python/tests/operations/test_proto_set_withdraw_vesting_route.py index 5e4fc7802..99d8e27bb 100644 --- a/python/tests/operations/test_proto_set_withdraw_vesting_route.py +++ b/python/tests/operations/test_proto_set_withdraw_vesting_route.py @@ -1,14 +1,14 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - set_withdraw_vesting_route_pb2 +from wax.proto.operations import ( + operation, + set_withdraw_vesting_route, ) +from wax.proto.transaction import transaction def test_set_withdraw_vesting_route(): - set_withdraw_vesting_route: set_withdraw_vesting_route_pb2.set_withdraw_vesting_route = ( - set_withdraw_vesting_route_pb2.set_withdraw_vesting_route( + set_withdraw_vesting_route_proto: set_withdraw_vesting_route = ( + set_withdraw_vesting_route( from_account="faddy", to_account="faddy", percent=10, @@ -16,14 +16,14 @@ def test_set_withdraw_vesting_route(): ) ) - set_withdraw_vesting_route_opertaion: operation_pb2.operation = ( - operation_pb2.operation(set_withdraw_vesting_route=set_withdraw_vesting_route) + set_withdraw_vesting_route_opertaion: operation = ( + operation(set_withdraw_vesting_route=set_withdraw_vesting_route_proto) ) check_operations(set_withdraw_vesting_route_opertaion) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[set_withdraw_vesting_route_opertaion] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_transfer.py b/python/tests/operations/test_proto_transfer.py index c9d1ef5f6..b96f6e187 100644 --- a/python/tests/operations/test_proto_transfer.py +++ b/python/tests/operations/test_proto_transfer.py @@ -1,32 +1,32 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - transfer_pb2 +from wax.proto.operations import ( + operation, + transfer, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_transfer(): - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="357000" ) - transfer: transfer_pb2.transfer = transfer_pb2.transfer( + transfer_proto: transfer = transfer( from_account="faddy", to_account="daddy", amount=amount, memo="memo" ) - transfer_operation: operation_pb2.operation = ( - operation_pb2.operation(transfer=transfer) + transfer_operation: operation = ( + operation(transfer=transfer_proto) ) check_operations(transfer_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[transfer_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_transfer_from_savings.py b/python/tests/operations/test_proto_transfer_from_savings.py index 37d991a01..ae92dad1b 100644 --- a/python/tests/operations/test_proto_transfer_from_savings.py +++ b/python/tests/operations/test_proto_transfer_from_savings.py @@ -1,19 +1,20 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - transfer_from_savings_pb2 +from wax.proto.operations import ( + operation, + transfer_from_savings, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction + def test_transfer_from_savings(): - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="7000" ) - transfer_from_savings: transfer_from_savings_pb2.transfer_from_savings = ( - transfer_from_savings_pb2.transfer_from_savings( + transfer_from_savings_proto: transfer_from_savings = ( + transfer_from_savings( from_account="abcde", request_id=3, to_account="abcdef", @@ -22,14 +23,14 @@ def test_transfer_from_savings(): ) ) - transfer_from_savings_operation: operation_pb2.operation = ( - operation_pb2.operation(transfer_from_savings=transfer_from_savings) + transfer_from_savings_operation: operation = ( + operation(transfer_from_savings=transfer_from_savings_proto) ) check_operations(transfer_from_savings_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[transfer_from_savings_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_transfer_to_savings.py b/python/tests/operations/test_proto_transfer_to_savings.py index 26ed98624..aa4743ce6 100644 --- a/python/tests/operations/test_proto_transfer_to_savings.py +++ b/python/tests/operations/test_proto_transfer_to_savings.py @@ -1,19 +1,19 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - transfer_to_savings_pb2 +from wax.proto.operations import ( + operation, + transfer_to_savings, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction def test_transfer_to_savings(): - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="7000" ) - transfer_to_savings: transfer_to_savings_pb2.transfer_to_savings = ( - transfer_to_savings_pb2.transfer_to_savings( + transfer_to_savings_proto: transfer_to_savings = ( + transfer_to_savings( from_account="faddy", to_account="daddy", amount=amount, @@ -21,14 +21,14 @@ def test_transfer_to_savings(): ) ) - transfer_to_savings_operation: operation_pb2.operation = ( - operation_pb2.operation(transfer_to_savings=transfer_to_savings) + transfer_to_savings_operation: operation = ( + operation(transfer_to_savings=transfer_to_savings_proto) ) check_operations(transfer_to_savings_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[transfer_to_savings_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_transfer_to_vesting.py b/python/tests/operations/test_proto_transfer_to_vesting.py index a2b94e99e..17195e20f 100644 --- a/python/tests/operations/test_proto_transfer_to_vesting.py +++ b/python/tests/operations/test_proto_transfer_to_vesting.py @@ -13,32 +13,29 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - transfer_to_vesting_pb2 -) +from wax.proto.operations import operation, transfer_to_vesting +from wax.proto.transaction import transaction +from wax.proto.asset import asset def test_transfer_to_vesting(): - amount: asset_pb2.asset = asset_pb2.asset( + proto_asset: asset = asset( nai="@@000000021", precision=3, amount="357000" ) - transfer_to_vesting: transfer_to_vesting_pb2.transfer_to_vesting = ( - transfer_to_vesting_pb2.transfer_to_vesting( - from_account="faddy", to_account="", amount=amount + transfer_to_vesting_proto: transfer_to_vesting = ( + transfer_to_vesting( + from_account="faddy", to_account="", amount=proto_asset ) ) - transfer_to_vesting_operation: operation_pb2.operation = ( - operation_pb2.operation(transfer_to_vesting=transfer_to_vesting) + transfer_to_vesting_operation: operation = ( + operation(transfer_to_vesting=transfer_to_vesting_proto) ) check_operations(transfer_to_vesting_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[transfer_to_vesting_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_update_proposal.py b/python/tests/operations/test_proto_update_proposal.py index 037403315..c5d0aa2f1 100644 --- a/python/tests/operations/test_proto_update_proposal.py +++ b/python/tests/operations/test_proto_update_proposal.py @@ -16,22 +16,23 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - update_proposal_pb2 +from wax.proto.operations import ( + operation, + update_proposal, ) +from wax.proto.transaction import transaction +from wax.proto.asset import asset +from wax._private.proto.update_proposal_pb2 import update_proposal_end_date, update_proposal_extension def test_update_proposal(): - daily_pay: asset_pb2.asset = asset_pb2.asset( + daily_pay: asset = asset( amount="135000", precision=3, nai="@@000000013" ) - update_proposal_end_date: update_proposal_pb2.update_proposal_end_date = update_proposal_pb2.update_proposal_end_date(end_date="2035-10-29T06:32:22") - extension: update_proposal_pb2.update_proposal_extension = update_proposal_pb2.update_proposal_extension(update_proposal_end_date=update_proposal_end_date) + update_proposal_end_date_proto: update_proposal_end_date = update_proposal_end_date(end_date="2035-10-29T06:32:22") + extension: update_proposal_extension =update_proposal_extension(update_proposal_end_date=update_proposal_end_date_proto) - update_proposal: update_proposal_pb2.update_proposal = ( - update_proposal_pb2.update_proposal( + update_proposal_proto: update_proposal = ( + update_proposal( proposal_id=247, creator="arcange", daily_pay=daily_pay, @@ -41,14 +42,14 @@ def test_update_proposal(): ) ) - update_proposal_operation: operation_pb2.operation = operation_pb2.operation( - update_proposal=update_proposal + update_proposal_operation: operation = operation( + update_proposal=update_proposal_proto ) check_operations(update_proposal_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[update_proposal_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_update_proposal_votes.py b/python/tests/operations/test_proto_update_proposal_votes.py index 2e2afc203..ff0d82052 100644 --- a/python/tests/operations/test_proto_update_proposal_votes.py +++ b/python/tests/operations/test_proto_update_proposal_votes.py @@ -12,26 +12,23 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - update_proposal_votes_pb2 -) +from wax.proto.operations import operation, update_proposal_votes +from wax.proto.transaction import transaction def test_update_proposal_votes(): - update_proposal_votes: update_proposal_votes_pb2.update_proposal_votes = ( - update_proposal_votes_pb2.update_proposal_votes( + update_proposal_votes_proto: update_proposal_votes = ( + update_proposal_votes( voter="ballenaprepago", proposal_ids=[0], approve=True, extensions=[] ) ) - update_proposal_votes_operations: operation_pb2.operation = ( - operation_pb2.operation(update_proposal_votes=update_proposal_votes) + update_proposal_votes_operations: operation = ( + operation(update_proposal_votes=update_proposal_votes_proto) ) check_operations(update_proposal_votes_operations) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[update_proposal_votes_operations] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_vote.py b/python/tests/operations/test_proto_vote.py index 512658238..3bd0c340f 100644 --- a/python/tests/operations/test_proto_vote.py +++ b/python/tests/operations/test_proto_vote.py @@ -1,21 +1,18 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - vote_pb2 -) +from wax.proto.operations import operation, vote +from wax.proto.transaction import transaction def test_vote(): - vote: vote_pb2.vote = vote_pb2.vote( + proto_vote: vote = vote( voter="alice", author="author", permlink="/", weight=11 ) - vote_operation: operation_pb2.operation = operation_pb2.operation(vote=vote) + vote_operation: operation = operation(vote=proto_vote) check_operations(vote_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[vote_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_withdraw_vesting.py b/python/tests/operations/test_proto_withdraw_vesting.py index 2c1053d38..3e5c9220e 100644 --- a/python/tests/operations/test_proto_withdraw_vesting.py +++ b/python/tests/operations/test_proto_withdraw_vesting.py @@ -12,32 +12,27 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - operation_pb2, - transaction_pb2, - withdraw_vesting_pb2 -) +from wax.proto.asset import asset +from wax.proto.transaction import transaction +from wax.proto.operations import operation, withdraw_vesting + def test_withdraw_vesting(): - vesting_shares: asset_pb2.asset = asset_pb2.asset( + vesting_shares: asset = asset( nai="@@000000037", precision=6, amount="200000000000" ) - withdraw_vesting: withdraw_vesting_pb2.withdraw_vesting = ( - withdraw_vesting_pb2.withdraw_vesting( + withdraw_vesting_proto: withdraw_vesting = ( + withdraw_vesting( account="steemit", vesting_shares=vesting_shares ) ) - withdraw_vesting_operation: operation_pb2.operation = operation_pb2.operation( - withdraw_vesting=withdraw_vesting - ) - + withdraw_vesting_operation: operation = operation(withdraw_vesting=withdraw_vesting_proto) check_operations(withdraw_vesting_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[withdraw_vesting_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_witness_block_approve.py b/python/tests/operations/test_proto_witness_block_approve.py index caddea039..0a1dd5014 100644 --- a/python/tests/operations/test_proto_witness_block_approve.py +++ b/python/tests/operations/test_proto_witness_block_approve.py @@ -1,26 +1,27 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - witness_block_approve_pb2 +from wax.proto.operations import ( + operation, + witness_block_approve ) +from wax.proto.transaction import transaction + def test_witness_block_approve(): - witness_block_approve: witness_block_approve_pb2.witness_block_approve = ( - witness_block_approve_pb2.witness_block_approve( + witness_block_approve_proto: witness_block_approve = ( + witness_block_approve( witness="gtg", block_id="000004433bd4602cf5f74dbb564183837df9cef8" ) ) - witness_block_approve_operation: operation_pb2.operation = ( - operation_pb2.operation(witness_block_approve=witness_block_approve) + witness_block_approve_operation: operation = ( + operation(witness_block_approve=witness_block_approve_proto) ) check_operations(witness_block_approve_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[witness_block_approve_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/operations/test_proto_witness_set_properties.py b/python/tests/operations/test_proto_witness_set_properties.py index 7313e786d..cc58131d8 100644 --- a/python/tests/operations/test_proto_witness_set_properties.py +++ b/python/tests/operations/test_proto_witness_set_properties.py @@ -18,15 +18,15 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - operation_pb2, - transaction_pb2, - witness_set_properties_pb2 +from wax.proto.operations import ( + operation, + witness_set_properties ) +from wax.proto.transaction import transaction def test_witness_set_properties(): - witness_set_properties: witness_set_properties_pb2.witness_set_properties = witness_set_properties_pb2.witness_set_properties( + witness_set_properties_proto: witness_set_properties = witness_set_properties( owner="alloyxuast", props=[ [ @@ -41,14 +41,14 @@ def test_witness_set_properties(): extensions=[], ) - witness_set_properties_operation: operation_pb2.operation = ( - operation_pb2.operation(witness_set_properties=witness_set_properties) + witness_set_properties_operation: operation = ( + operation(witness_set_properties=witness_set_properties_proto) ) check_operations(witness_set_properties_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + transaction_proto: transaction = transaction( operations=[witness_set_properties_operation] ) - check_transaction(transaction) + check_transaction(transaction_proto) diff --git a/python/tests/operations/test_proto_witness_update.py b/python/tests/operations/test_proto_witness_update.py index 75fe25f6e..d6da7090c 100644 --- a/python/tests/operations/test_proto_witness_update.py +++ b/python/tests/operations/test_proto_witness_update.py @@ -23,49 +23,49 @@ from tests.utils.checkers import check_operations, check_transaction -from wax.proto import ( - asset_pb2, - legacy_chain_properties_pb2, - operation_pb2, - transaction_pb2, - witness_update_pb2, +from wax.proto.operations import ( + operation, + witness_update, ) +from wax.proto.asset import asset +from wax.proto.transaction import transaction +from wax._private.proto.legacy_chain_properties_pb2 import legacy_chain_properties def test_witness_update(): - account_creation_fee: asset_pb2.asset = asset_pb2.asset( + account_creation_fee: asset = asset( amount="100000", precision=3, nai="@@000000021" ) - fee: asset_pb2.asset = asset_pb2.asset( + fee: asset = asset( amount="100000", precision=3, nai="@@000000021" ) - legacy_chain_properties: legacy_chain_properties_pb2.legacy_chain_properties = ( - legacy_chain_properties_pb2.legacy_chain_properties( + legacy_chain_properties_proto: legacy_chain_properties = ( + legacy_chain_properties( account_creation_fee=account_creation_fee, maximum_block_size=131072, hbd_interest_rate=1000, ) ) - witness_update: witness_update_pb2.witness_update = ( - witness_update_pb2.witness_update( + witness_update_proto: witness_update = ( + witness_update( owner="steempty", url="fmooo/steemd-docker", block_signing_key="STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD", - props=legacy_chain_properties, + props=legacy_chain_properties_proto, fee=fee, ) ) - witness_update_operation: operation_pb2.operation = operation_pb2.operation( - witness_update=witness_update + witness_update_operation: operation = operation( + witness_update=witness_update_proto ) check_operations(witness_update_operation) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( + proto_transaction: transaction = transaction( operations=[witness_update_operation] ) - check_transaction(transaction) + check_transaction(proto_transaction) diff --git a/python/tests/proto-protocol/test_api_to_proto.py b/python/tests/proto-protocol/test_api_to_proto.py index afd2fa539..794660631 100644 --- a/python/tests/proto-protocol/test_api_to_proto.py +++ b/python/tests/proto-protocol/test_api_to_proto.py @@ -17,19 +17,19 @@ from tests.utils.refs import ( from wax import api_to_proto -from wax.proto import transaction_pb2 +from wax.proto.transaction import transaction @pytest.mark.skip(reason="block.proto definition is ignored") def test_api_to_proto(): # moved here since code generation for block.proto is skipped - from wax.proto import block_pb2 + from wax._private.proto import block_pb2 api_str = json.dumps(API_REF_TRANSACTION) proto = api_to_proto(api_str.encode()) assert proto.status == proto.status.ok assert proto.exception_message == b'' assert proto.result.decode() == json.dumps(PROTO_REF_TRANSACTION, separators=(',', ':')) - transaction: transaction_pb2.transaction = ParseDict(json.loads(proto.result.decode()), transaction_pb2.transaction()) + transaction_proto: transaction = ParseDict(json.loads(proto.result.decode()), transaction()) # Negative test api_str = json.dumps(PROTO_REF_TRANSACTION) diff --git a/python/tests/proto-protocol/test_proto_to_api_to_proto.py b/python/tests/proto-protocol/test_proto_to_api_to_proto.py index 946122e05..6897a759f 100644 --- a/python/tests/proto-protocol/test_proto_to_api_to_proto.py +++ b/python/tests/proto-protocol/test_proto_to_api_to_proto.py @@ -4,17 +4,12 @@ from google.protobuf.json_format import MessageToJson from tests.utils.refs import API_REF_TRANSACTION, PROTO_REF_TRANSACTION from wax import api_to_proto, proto_to_api -from wax.proto import ( - operation_pb2, - transaction_pb2, - asset_pb2, - legacy_chain_properties_pb2, - pow2_pb2, - recover_account_pb2, - future_extensions_pb2, - authority_pb2, - witness_set_properties_pb2 -) +from wax.proto.operations import operation, pow2, recover_account, witness_set_properties +from wax.proto.asset import asset +from wax.proto.authority import authority +from wax._private.proto.pow2_pb2 import pow2_input, pow2_pow, pow2_work +from wax._private.proto.legacy_chain_properties_pb2 import legacy_chain_properties +from wax._private.proto.future_extensions_pb2 import future_extensions def test_proto_to_api_to_proto(): @@ -32,34 +27,34 @@ def test_proto_to_api_to_proto(): assert proto.result.decode() == json.dumps(PROTO_REF_TRANSACTION).replace(" ", "") # Test special case: pow2 operation - pow2_input: pow2_pb2.pow2_input = pow2_pb2.pow2_input( + pow2_input_proto: pow2_input = pow2_input( worker_account="aizen06", prev_block="003ea604345523c344fbadab605073ea712dd76f", nonce=1052853013628665497 ) - pow2_pow: pow2_pb2.pow2_pow = pow2_pb2.pow2_pow( - input=pow2_input, + pow2_pow_proto: pow2_pow = pow2_pow( + input=pow2_input_proto, pow_summary=3817904373 ) - pow2_work: pow2_pb2.pow2_work = pow2_pb2.pow2_work( - pow2=pow2_pow + pow2_work_proto: pow2_work = pow2_work( + pow2=pow2_pow_proto ) - amount: asset_pb2.asset = asset_pb2.asset( + amount: asset = asset( nai="@@000000021", precision=3, amount="1" ) - legacy_chain_properties: legacy_chain_properties_pb2.legacy_chain_properties = legacy_chain_properties_pb2.legacy_chain_properties( + legacy_chain_properties_proto: legacy_chain_properties = legacy_chain_properties( account_creation_fee=amount, maximum_block_size=131072, hbd_interest_rate=1000 ) - pow2: pow2_pb2.pow2 = pow2_pb2.pow2( - work=pow2_work, - props=legacy_chain_properties + pow2_proto: pow2 = pow2( + work=pow2_work_proto, + props=legacy_chain_properties_proto ) - pow2_operation: operation_pb2.operation = operation_pb2.operation( - pow2=pow2 + pow2_operation: operation = operation( + pow2=pow2_proto ) proto_json = MessageToJson(pow2_operation) @@ -78,26 +73,26 @@ def test_proto_to_api_to_proto(): assert proto_result.result.decode() == proto_json.replace(" ", "").replace("\n", "") # Test special case: recover_account operation - extension: future_extensions_pb2.future_extensions = future_extensions_pb2.future_extensions() - authority1: authority_pb2.authority = authority_pb2.authority( + extension: future_extensions = future_extensions() + authority1: authority = authority( weight_threshold=1, account_auths={"account": 1, "account1": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1} ) - authority2: authority_pb2.authority = authority_pb2.authority( + authority2: authority = authority( weight_threshold=1, account_auths={"account1": 1, "account2": 2}, key_auths={"STM76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76": 1} ) - recover_account: recover_account_pb2.recover_account = recover_account_pb2.recover_account( + recover_account_proto: recover_account = recover_account( account_to_recover="account", new_owner_authority=authority1, recent_owner_authority=authority2, extensions=[] ) - recover_account_operation: operation_pb2.operation = operation_pb2.operation( - recover_account=recover_account + recover_account_operation: operation = operation( + recover_account=recover_account_proto ) proto_json = MessageToJson(recover_account_operation) @@ -116,7 +111,7 @@ def test_proto_to_api_to_proto(): assert proto_result.result.decode() == proto_json.replace(" ", "").replace("\n", "") # Test special case: witness_set_properties operation - witness_set_properties: witness_set_properties_pb2.witness_set_properties = witness_set_properties_pb2.witness_set_properties( + witness_set_properties_proto: witness_set_properties = witness_set_properties( owner="alloyxuast", props=[ [ @@ -131,8 +126,8 @@ def test_proto_to_api_to_proto(): extensions=[], ) - witness_set_properties_operation: operation_pb2.operation = ( - operation_pb2.operation(witness_set_properties=witness_set_properties) + witness_set_properties_operation: operation = ( + operation(witness_set_properties=witness_set_properties_proto) ) proto_json = MessageToJson(witness_set_properties_operation) diff --git a/python/tests/proto-protocol/test_serialize_proto_transaction.py b/python/tests/proto-protocol/test_serialize_proto_transaction.py index 0e498632c..111264747 100644 --- a/python/tests/proto-protocol/test_serialize_proto_transaction.py +++ b/python/tests/proto-protocol/test_serialize_proto_transaction.py @@ -6,7 +6,7 @@ from tests.utils.refs import PROTO_REF_TRANSACTION, API_REF_TRANSACTION from wax import serialize_proto_transaction, deserialize_proto_transaction -from wax.proto import transaction_pb2 +from wax.proto.transaction import transaction def test_serialize_proto_transaction(): @@ -29,8 +29,8 @@ def test_serialize_proto_transaction(): assert result.exception_message == b'' assert result.result.decode() == tx_str.replace(" ", "").replace("\n","") - tx_ref = ParseDict(PROTO_REF_TRANSACTION, transaction_pb2.transaction()) - tx = ParseDict(json.loads(result.result.decode()), transaction_pb2.transaction()) + tx_ref = ParseDict(PROTO_REF_TRANSACTION, transaction()) + tx = ParseDict(json.loads(result.result.decode()), transaction()) assert(tx_ref == tx) # Negative test diff --git a/python/tests/transactions/test_proto_transaction.py b/python/tests/transactions/test_proto_transaction.py index 8faab7587..848da2dea 100644 --- a/python/tests/transactions/test_proto_transaction.py +++ b/python/tests/transactions/test_proto_transaction.py @@ -1,12 +1,13 @@ from tests.utils.checkers import check_transaction -from wax.proto import comment_pb2, operation_pb2, transaction_pb2, vote_pb2 +from wax.proto.operations import comment, operation, vote +from wax.proto.transaction import transaction def test_transaction() -> None: - vote: vote_pb2.vote = vote_pb2.vote(voter="alice", author="author", permlink="/", weight=11) - vote_operation: operation_pb2.operation = operation_pb2.operation(vote=vote) + vote_proto: vote = vote(voter="alice", author="author", permlink="/", weight=11) + vote_operation: operation = operation(vote=vote_proto) - comment: comment_pb2.comment = comment_pb2.comment( + comment_proto: comment = comment( parent_permlink="/", parent_author="", author="alice", @@ -15,11 +16,9 @@ def test_transaction() -> None: body="<span>comment</span>", json_metadata="{}", ) - comment_operation: operation_pb2.operation = operation_pb2.operation(comment=comment) + comment_operation: operation = operation(comment=comment_proto) - transaction: transaction_pb2.transaction = transaction_pb2.transaction( - operations=[vote_operation, comment_operation] - ) + transaction_proto: transaction = transaction(operations=[vote_operation, comment_operation]) - check_transaction(transaction) - check_transaction(transaction) + check_transaction(transaction_proto) + check_transaction(transaction_proto) diff --git a/python/tests/transactions/test_transaction_creation.py b/python/tests/transactions/test_transaction_creation.py index 5a58b38e3..5efb8fc6a 100644 --- a/python/tests/transactions/test_transaction_creation.py +++ b/python/tests/transactions/test_transaction_creation.py @@ -6,11 +6,8 @@ from typing import Final from beekeepy import AsyncBeekeeper from tests.utils.refs import PROTO_REF_TRANSACTION from wax import create_wax_foundation -from wax.proto.comment_pb2 import comment -from wax.proto.operation_pb2 import operation -from wax.proto.transaction_pb2 import transaction as proto_transaction -from wax.proto.transfer_pb2 import transfer -from wax.proto.vote_pb2 import vote +from wax.proto.operations import comment, operation, transfer, vote +from wax.proto.transaction import transaction as proto_transaction WALLET_NAME: Final[str] = "alice" WALLET_PASSWORD: Final[str] = "password" diff --git a/python/tests/utils/checkers.py b/python/tests/utils/checkers.py index 3f0584511..fbcdf19d7 100644 --- a/python/tests/utils/checkers.py +++ b/python/tests/utils/checkers.py @@ -1,11 +1,11 @@ from google.protobuf.json_format import MessageToJson from wax.cpp_python_bridge import validate_proto_operation, validate_proto_transaction, proto_to_api -from wax.proto import operation_pb2, transaction_pb2 +from wax.proto.operations import operation +from wax.proto.transaction import transaction - -def check_operations(operation: operation_pb2.operation) -> None: - operation_json = MessageToJson(operation) +def check_operations(operation_proto: operation) -> None: + operation_json = MessageToJson(operation_proto) print(operation_json) result = proto_to_api(operation_json.encode()) print(result) @@ -14,8 +14,8 @@ def check_operations(operation: operation_pb2.operation) -> None: assert result.status == result.status.ok -def check_transaction(transaction: transaction_pb2.transaction) -> None: - transaction_json = MessageToJson(transaction) +def check_transaction(transaction_proto: transaction) -> None: + transaction_json = MessageToJson(transaction_proto) result = validate_proto_transaction(transaction_json.encode()) print(result) assert result.status == result.status.ok diff --git a/python/wax/_private/models/asset.py b/python/wax/_private/models/asset.py index f24080eb3..33dbda110 100644 --- a/python/wax/_private/models/asset.py +++ b/python/wax/_private/models/asset.py @@ -12,7 +12,7 @@ from wax._private.exceptions import ( from wax._private.result_tools import to_python_string from wax.cpp_python_bridge import hbd, hive, vests from wax.models.asset import AnyNaiAssetConvertible, AssetAmount, AssetFactory, AssetInfo, AssetName, NaiAsset -from wax.proto.asset_pb2 import asset as proto_asset +from wax.proto.asset import asset as proto_asset if TYPE_CHECKING: from wax.wax_result import python_json_asset diff --git a/python/wax/_private/transaction.py b/python/wax/_private/transaction.py index 7e36a4b93..0bfdf7eae 100644 --- a/python/wax/_private/transaction.py +++ b/python/wax/_private/transaction.py @@ -30,7 +30,7 @@ from wax.cpp_python_bridge import ( # type: ignore[attr-defined] validate_proto_transaction, ) from wax.interfaces import ITransaction, JsonTransaction, ProtoTransaction -from wax.proto.transaction_pb2 import transaction as proto_transaction +from wax.proto.transaction import transaction as proto_transaction if TYPE_CHECKING: from datetime import timedelta diff --git a/python/wax/interfaces.py b/python/wax/interfaces.py index 5c0ed2d18..26599e6ed 100644 --- a/python/wax/interfaces.py +++ b/python/wax/interfaces.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, TypeAlias from typing_extensions import Self -from wax.proto.transaction_pb2 import transaction as proto_transaction +from wax.proto.transaction import transaction as proto_transaction if TYPE_CHECKING: from decimal import Decimal diff --git a/python/wax/models/asset.py b/python/wax/models/asset.py index 6a0dcb515..7f6059046 100644 --- a/python/wax/models/asset.py +++ b/python/wax/models/asset.py @@ -5,7 +5,7 @@ from decimal import Decimal from enum import Enum from typing import Protocol, TypeAlias -from wax.proto.asset_pb2 import asset as proto_asset +from wax.proto.asset import asset as proto_asset AssetAmount = int | float | Decimal NaiAsset: TypeAlias = proto_asset diff --git a/python/wax/models/authority.py b/python/wax/models/authority.py index 612836d4d..428ceb910 100644 --- a/python/wax/models/authority.py +++ b/python/wax/models/authority.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from typing import TypeAlias from wax.models.basic import AccountName, PublicKey -from wax.proto.authority_pb2 import authority as proto_authority +from wax.proto.authority import authority as proto_authority WaxAuthority: TypeAlias = proto_authority KeyAuths: TypeAlias = dict[PublicKey, int] diff --git a/python/wax/proto/__init__.py b/python/wax/proto/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/python/wax/proto/asset.py b/python/wax/proto/asset.py new file mode 100644 index 000000000..b10175dd9 --- /dev/null +++ b/python/wax/proto/asset.py @@ -0,0 +1,10 @@ +from wax._private.exceptions import WaxImportProtoBeforeCompileError + +try: + from wax._private.proto.asset_pb2 import asset +except (ImportError, ModuleNotFoundError) as error: + raise WaxImportProtoBeforeCompileError from error + +__all__ = [ + "asset", +] diff --git a/python/wax/proto/authority.py b/python/wax/proto/authority.py new file mode 100644 index 000000000..080dca70b --- /dev/null +++ b/python/wax/proto/authority.py @@ -0,0 +1,11 @@ +from wax._private.exceptions import WaxImportProtoBeforeCompileError + +try: + from wax._private.proto.authority_pb2 import authority +except (ImportError, ModuleNotFoundError) as error: + raise WaxImportProtoBeforeCompileError from error + + +__all__ = [ + "authority", +] \ No newline at end of file diff --git a/python/wax/proto/operations.py b/python/wax/proto/operations.py new file mode 100644 index 000000000..fa6fef88b --- /dev/null +++ b/python/wax/proto/operations.py @@ -0,0 +1,110 @@ +from wax._private.exceptions import WaxImportProtoBeforeCompileError + +try: + from wax._private.proto.transfer_pb2 import transfer + from wax._private.proto.recurrent_transfer_pb2 import recurrent_transfer + from wax._private.proto.transfer_to_savings_pb2 import transfer_to_savings + from wax._private.proto.transfer_from_savings_pb2 import transfer_from_savings + from wax._private.proto.cancel_transfer_from_savings_pb2 import cancel_transfer_from_savings + from wax._private.proto.transfer_to_vesting_pb2 import transfer_to_vesting + from wax._private.proto.withdraw_vesting_pb2 import withdraw_vesting + from wax._private.proto.delegate_vesting_shares_pb2 import delegate_vesting_shares + from wax._private.proto.set_withdraw_vesting_route_pb2 import set_withdraw_vesting_route + from wax._private.proto.create_proposal_pb2 import create_proposal + from wax._private.proto.remove_proposal_pb2 import remove_proposal + from wax._private.proto.update_proposal_pb2 import update_proposal + from wax._private.proto.update_proposal_votes_pb2 import update_proposal_votes + from wax._private.proto.account_witness_proxy_pb2 import account_witness_proxy + from wax._private.proto.account_witness_vote_pb2 import account_witness_vote + from wax._private.proto.witness_set_properties_pb2 import witness_set_properties + from wax._private.proto.witness_update_pb2 import witness_update + from wax._private.proto.witness_block_approve_pb2 import witness_block_approve + from wax._private.proto.custom_pb2 import custom + from wax._private.proto.custom_json_pb2 import custom_json + from wax._private.proto.convert_pb2 import convert + from wax._private.proto.collateralized_convert_pb2 import collateralized_convert + from wax._private.proto.collateralized_convert_immediate_conversion_pb2 import collateralized_convert_immediate_conversion + from wax._private.proto.comment_pb2 import comment + from wax._private.proto.comment_options_pb2 import comment_options + from wax._private.proto.delete_comment_pb2 import delete_comment + from wax._private.proto.effective_comment_vote_pb2 import effective_comment_vote + from wax._private.proto.vote_pb2 import vote + from wax._private.proto.create_claimed_account_pb2 import create_claimed_account + from wax._private.proto.account_create_pb2 import account_create + from wax._private.proto.account_create_with_delegation_pb2 import account_create_with_delegation + from wax._private.proto.account_update_pb2 import account_update + from wax._private.proto.account_update2_pb2 import account_update2 + from wax._private.proto.recover_account_pb2 import recover_account + from wax._private.proto.request_account_recovery_pb2 import request_account_recovery + from wax._private.proto.change_recovery_account_pb2 import change_recovery_account + from wax._private.proto.pow_pb2 import pow + from wax._private.proto.pow2_pb2 import pow2 + from wax._private.proto.limit_order_create_pb2 import limit_order_create + from wax._private.proto.limit_order_create2_pb2 import limit_order_create2 + from wax._private.proto.limit_order_cancel_pb2 import limit_order_cancel + from wax._private.proto.feed_publish_pb2 import feed_publish + from wax._private.proto.decline_voting_rights_pb2 import decline_voting_rights + from wax._private.proto.claim_account_pb2 import claim_account + from wax._private.proto.claim_reward_balance_pb2 import claim_reward_balance + from wax._private.proto.escrow_approve_pb2 import escrow_approve + from wax._private.proto.escrow_transfer_pb2 import escrow_transfer + from wax._private.proto.escrow_release_pb2 import escrow_release + from wax._private.proto.escrow_rejected_pb2 import escrow_rejected + from wax._private.proto.escrow_dispute_pb2 import escrow_dispute + from wax._private.proto.operation_pb2 import operation +except (ImportError, ModuleNotFoundError) as error: + raise WaxImportProtoBeforeCompileError from error + +__all__ = [ + "transfer", + "recurrent_transfer", + "transfer_to_savings", + "transfer_from_savings", + "cancel_transfer_from_savings", + "transfer_to_vesting", + "withdraw_vesting", + "delegate_vesting_shares", + "set_withdraw_vesting_route", + "create_proposal", + "remove_proposal", + "update_proposal", + "update_proposal_votes", + "account_witness_proxy", + "account_witness_vote", + "witness_set_properties", + "witness_update", + "witness_block_approve", + "custom", + "custom_json", + "convert", + "collateralized_convert", + "collateralized_convert_immediate_conversion", + "comment", + "comment_options", + "delete_comment", + "effective_comment_vote", + "vote", + "create_claimed_account", + "account_create", + "account_create_with_delegation", + "account_update", + "account_update2", + "recover_account", + "request_account_recovery", + "change_recovery_account", + "pow", + "pow2", + "limit_order_create", + "limit_order_create2", + "limit_order_cancel", + "feed_publish", + "decline_voting_rights", + "claim_account", + "claim_reward_balance", + "escrow_approve", + "escrow_transfer", + "escrow_release", + "escrow_rejected", + "escrow_dispute", + "operation", +] diff --git a/python/wax/proto/transaction.py b/python/wax/proto/transaction.py new file mode 100644 index 000000000..6dbbb2340 --- /dev/null +++ b/python/wax/proto/transaction.py @@ -0,0 +1,10 @@ +from wax._private.exceptions import WaxImportProtoBeforeCompileError + +try: + from wax._private.proto.transaction_pb2 import transaction +except (ImportError, ModuleNotFoundError) as error: + raise WaxImportProtoBeforeCompileError from error + +__all__ = [ + "transaction", +] -- GitLab