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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hathor/nanocontracts/resources/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions hathor_tests/resources/nanocontracts/my_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Address,
Amount,
Blueprint,
CallerId,
Context,
SignedData,
Timestamp,
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions hathor_tests/resources/nanocontracts/test_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down
Loading