diff --git a/hathor/nanocontracts/resources/blueprint.py b/hathor/nanocontracts/resources/blueprint.py index bf6f9d5ed..f2626cb94 100644 --- a/hathor/nanocontracts/resources/blueprint.py +++ b/hathor/nanocontracts/resources/blueprint.py @@ -18,6 +18,7 @@ import typing from typing import TYPE_CHECKING, Any, Optional +import hathor from hathor._openapi.register import register_resource from hathor.api_util import Resource, set_cors from hathor.nanocontracts import types as nc_types @@ -66,6 +67,8 @@ def get_type_name(self, type_: type) -> str: match args: case (_subtype, types.NoneType) | (types.NoneType, _subtype): return self._get_optional_type_name(_subtype) + case (hathor.Address, hathor.ContractId) | (hathor.ContractId, hathor.Address): + return 'CallerId' return self._get_composed_type_name('union', args) case nc_types.SignedData: return self._get_composed_type_name('SignedData', args) diff --git a/hathor_tests/resources/nanocontracts/my_blueprint.py b/hathor_tests/resources/nanocontracts/my_blueprint.py index e98e56a8e..a8d614711 100644 --- a/hathor_tests/resources/nanocontracts/my_blueprint.py +++ b/hathor_tests/resources/nanocontracts/my_blueprint.py @@ -4,6 +4,7 @@ Address, Amount, Blueprint, + CallerId, Context, SignedData, Timestamp, @@ -30,6 +31,7 @@ class MyBlueprint(Blueprint): a_tuple: tuple[str, int, bool] a_dict_dict_tuple: dict[str, tuple[str, int]] a_optional_int: Optional[int] + a_caller_id: CallerId @public def initialize(self, ctx: Context, arg1: int) -> None: diff --git a/hathor_tests/resources/nanocontracts/test_blueprint.py b/hathor_tests/resources/nanocontracts/test_blueprint.py index 7ed434c9c..71d55945c 100644 --- a/hathor_tests/resources/nanocontracts/test_blueprint.py +++ b/hathor_tests/resources/nanocontracts/test_blueprint.py @@ -71,6 +71,7 @@ def test_success(self) -> Generator[Deferred[Any], Any, None]: 'a_tuple': 'tuple[str, int, bool]', 'a_dict_dict_tuple': 'dict[str, tuple[str, int]]', 'a_optional_int': 'int?', + 'a_caller_id': 'CallerId', }) self.assertEqual(data['public_methods'], { 'initialize': {