From 446f3ad102944a780720aaf8d123450874e889a5 Mon Sep 17 00:00:00 2001 From: Mirella de Medeiros Date: Tue, 9 Apr 2024 15:29:53 -0300 Subject: [PATCH] CU-86dt50abt - Error when compiling using union type notation with | (bitwise or) in Event argument type --- boa3/builtin/contract/__init__.py | 12 ++-- boa3/internal/analyser/moduleanalyser.py | 40 ++++++++---- .../model/builtin/method/createeventmethod.py | 10 ++- .../auxiliary_contracts/update_contract.py | 6 +- boa3_test/examples/nep11_non_divisible.py | 6 +- boa3_test/examples/update_contract.py | 6 +- .../event_test/EventNep17TransferBuilt.py | 6 +- .../ManifestOptionalUnionEvent.py | 3 +- ...InfoSupportedStandardsByteStringAsBytes.py | 6 +- ...taInfoSupportedStandardsByteStringAsStr.py | 6 +- .../aux_package/internal_package/__init__.py | 8 +-- boa3_test/tests/compiler_tests/test_event.py | 4 +- .../compiler_tests/test_file_generation.py | 63 ++++++++++--------- 13 files changed, 102 insertions(+), 74 deletions(-) diff --git a/boa3/builtin/contract/__init__.py b/boa3/builtin/contract/__init__.py index 55ea472d1..60e83c967 100644 --- a/boa3/builtin/contract/__init__.py +++ b/boa3/builtin/contract/__init__.py @@ -8,7 +8,7 @@ 'to_script_hash', ] -from typing import Any, Union +from typing import Any from boa3.builtin.compile_time import CreateNewEvent from boa3.builtin.contract.Nep17Contract import Nep17Contract @@ -16,10 +16,10 @@ Nep11TransferEvent: Event = CreateNewEvent( [ - ('from', Union[UInt160, None]), - ('to', Union[UInt160, None]), + ('from', UInt160 | None), + ('to', UInt160 | None), ('amount', int), - ('tokenId', Union[str, bytes]) + ('tokenId', str | bytes) ], 'Transfer' ) @@ -49,8 +49,8 @@ Nep17TransferEvent: Event = CreateNewEvent( [ - ('from', Union[UInt160, None]), - ('to', Union[UInt160, None]), + ('from', UInt160 | None), + ('to', UInt160 | None), ('amount', int) ], 'Transfer' diff --git a/boa3/internal/analyser/moduleanalyser.py b/boa3/internal/analyser/moduleanalyser.py index 242ec1d7a..2bd9fa6c0 100644 --- a/boa3/internal/analyser/moduleanalyser.py +++ b/boa3/internal/analyser/moduleanalyser.py @@ -1259,6 +1259,25 @@ def get_values_type(self, value: ast.AST) -> Iterable[IType | None]: return types + def visit_BinOp(self, bin_op: ast.BinOp) -> IType | None: + left = self.visit(bin_op.left) + if isinstance(left, str): + left = self.get_symbol(left) + elif isinstance(bin_op.left, ast.Constant) and left is None: + left = self.get_type(left) + + right = self.visit(bin_op.right) + if isinstance(right, str): + right = self.get_symbol(right) + elif isinstance(bin_op.right, ast.Constant) and right is None: + right = self.get_type(right) + + # only validate type1 | type2, other binary operations are evaluated on TypeAnalyser + if isinstance(bin_op.op, ast.BitOr) and isinstance(left, IType) and isinstance(right, IType): + return left.union_type(right) + + return self.generic_visit(bin_op) + def visit_Call(self, call: ast.Call) -> IType | None: """ Visitor of a function call node @@ -1319,25 +1338,24 @@ def create_new_event(self, create_call: ast.Call) -> Event: ) elif len(event_args) > 0: args_type = self.get_type(event_args[0]) + expected_type = Builtin.NewEvent.arguments_type if not Type.list.is_type_of(args_type): self._log_error( CompilerError.MismatchedTypes(line=event_args[0].lineno, col=event_args[0].col_offset, - expected_type_id=Type.list.identifier, + expected_type_id=expected_type.identifier, actual_type_id=args_type.identifier) ) else: + expected_type = expected_type.value_type for value in event_args[0].elts: - if not isinstance(value, ast.Tuple): - CompilerError.MismatchedTypes(line=value.lineno, - col=value.col_offset, - expected_type_id=Type.tuple.identifier, - actual_type_id=self.get_type(value).identifier) - elif len(value.elts) < 2: + if not isinstance(value, ast.Tuple) or len(value.elts) < 2: + actual_type = self.get_type(value) self._log_error( - CompilerError.UnfilledArgument(line=value.lineno, - col=value.col_offset, - param=list(Builtin.NewEvent.args)[0]) + CompilerError.MismatchedTypes(line=value.lineno, + col=value.col_offset, + expected_type_id=expected_type.identifier, + actual_type_id=actual_type.identifier) ) else: event_arg_name, event_arg_type = value.elts @@ -1365,7 +1383,7 @@ def create_new_event(self, create_call: ast.Call) -> Event: self._log_error( CompilerError.MismatchedTypes(line=value.lineno, col=value.col_offset, - expected_type_id=Type.tuple.identifier, + expected_type_id=expected_type.identifier, actual_type_id=self.get_type(value).identifier) ) else: diff --git a/boa3/internal/model/builtin/method/createeventmethod.py b/boa3/internal/model/builtin/method/createeventmethod.py index d9fdff3ba..c1229c62b 100644 --- a/boa3/internal/model/builtin/method/createeventmethod.py +++ b/boa3/internal/model/builtin/method/createeventmethod.py @@ -2,6 +2,7 @@ from boa3.internal.model.builtin.method.builtinmethod import IBuiltinMethod from boa3.internal.model.expression import IExpression +from boa3.internal.model.type.collection.sequence.mutable.listtype import ListType from boa3.internal.model.type.itype import IType from boa3.internal.model.variable import Variable from boa3.internal.neo.vm.type.AbiType import AbiType @@ -11,15 +12,22 @@ class CreateEventMethod(IBuiltinMethod): def __init__(self): import ast from boa3.internal.model.type.type import Type + from boa3.internal.model.type.typeutils import TypeUtils identifier = 'CreateNewEvent' args = { - 'arguments': Variable(Type.list.build(Type.tuple)), + 'arguments': Variable(Type.list.build( + Type.tuple.build_collection((Type.str, TypeUtils.type)) + )), 'event_name': Variable(Type.str) } event_name_default = ast.parse("'{0}'".format(Type.str.default_value) ).body[0].value super().__init__(identifier, args, defaults=[event_name_default], return_type=EventType) + @property + def arguments_type(self) -> ListType: + return self.args['arguments'].type + def validate_parameters(self, *params: IExpression) -> bool: return len(params) == len(self.args) diff --git a/boa3_test/examples/auxiliary_contracts/update_contract.py b/boa3_test/examples/auxiliary_contracts/update_contract.py index fce2bdf2f..1436b08cd 100644 --- a/boa3_test/examples/auxiliary_contracts/update_contract.py +++ b/boa3_test/examples/auxiliary_contracts/update_contract.py @@ -1,4 +1,4 @@ -from typing import Any, Union +from typing import Any from boa3.builtin.compile_time import CreateNewEvent, NeoMetadata, public from boa3.builtin.interop import storage, runtime @@ -42,8 +42,8 @@ def manifest_metadata() -> NeoMetadata: on_transfer = CreateNewEvent( [ - ('from_addr', Union[UInt160, None]), - ('to_addr', Union[UInt160, None]), + ('from_addr', UInt160 | None), + ('to_addr', UInt160 | None), ('amount', int) ], 'Transfer' diff --git a/boa3_test/examples/nep11_non_divisible.py b/boa3_test/examples/nep11_non_divisible.py index d3fa367aa..ac32afa09 100644 --- a/boa3_test/examples/nep11_non_divisible.py +++ b/boa3_test/examples/nep11_non_divisible.py @@ -7,13 +7,13 @@ from boa3.builtin.compile_time import CreateNewEvent, NeoMetadata, public from boa3.builtin.contract import abort +from boa3.builtin.interop import storage from boa3.builtin.interop.blockchain import get_contract from boa3.builtin.interop.contract import CallFlags, call_contract, destroy_contract, get_call_flags, update_contract from boa3.builtin.interop.iterator import Iterator from boa3.builtin.interop.json import json_deserialize from boa3.builtin.interop.runtime import check_witness, get_network, script_container from boa3.builtin.interop.stdlib import deserialize, serialize -from boa3.builtin.interop import storage from boa3.builtin.interop.storage.findoptions import FindOptions from boa3.builtin.type import UInt160, helper as type_helper @@ -80,8 +80,8 @@ def gm_manifest() -> NeoMetadata: on_transfer = CreateNewEvent( # trigger when tokens are transferred, including zero value transfers. [ - ('from_addr', Union[UInt160, None]), - ('to_addr', Union[UInt160, None]), + ('from_addr', UInt160 | None), + ('to_addr', UInt160 | None), ('amount', int), ('tokenId', bytes) ], diff --git a/boa3_test/examples/update_contract.py b/boa3_test/examples/update_contract.py index 69624ab9b..70f63708b 100644 --- a/boa3_test/examples/update_contract.py +++ b/boa3_test/examples/update_contract.py @@ -1,4 +1,4 @@ -from typing import Any, Union +from typing import Any from boa3.builtin.compile_time import CreateNewEvent, NeoMetadata, public from boa3.builtin.interop import storage, runtime @@ -46,8 +46,8 @@ def manifest_metadata() -> NeoMetadata: on_transfer = CreateNewEvent( [ - ('from_addr', Union[UInt160, None]), - ('to_addr', Union[UInt160, None]), + ('from_addr', UInt160 | None), + ('to_addr', UInt160 | None), ('amount', int) ], 'Transfer' diff --git a/boa3_test/test_sc/event_test/EventNep17TransferBuilt.py b/boa3_test/test_sc/event_test/EventNep17TransferBuilt.py index b66cc433e..bd58fb746 100644 --- a/boa3_test/test_sc/event_test/EventNep17TransferBuilt.py +++ b/boa3_test/test_sc/event_test/EventNep17TransferBuilt.py @@ -1,12 +1,10 @@ -from typing import Union - from boa3.builtin.compile_time import public, CreateNewEvent from boa3.builtin.type import UInt160 transfer = CreateNewEvent( [ - ('from', Union[UInt160, None]), - ('to', Union[UInt160, None]), + ('from', UInt160 | None), + ('to', UInt160 | None), ('amount', int) ], 'Transfer' diff --git a/boa3_test/test_sc/generation_test/ManifestOptionalUnionEvent.py b/boa3_test/test_sc/generation_test/ManifestOptionalUnionEvent.py index 8ecfd80f8..a4c6f56b9 100644 --- a/boa3_test/test_sc/generation_test/ManifestOptionalUnionEvent.py +++ b/boa3_test/test_sc/generation_test/ManifestOptionalUnionEvent.py @@ -6,6 +6,7 @@ [ ('optional', Optional[str]), ('union', Union[int, None]), + ('union2', bool | None) ], 'event' ) @@ -13,4 +14,4 @@ @public def main(): - event('foo', 1) + event('foo', 1, True) diff --git a/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsBytes.py b/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsBytes.py index f735a08c9..7e9077a59 100644 --- a/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsBytes.py +++ b/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsBytes.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Union +from typing import Any, Dict from boa3.builtin.compile_time import CreateNewEvent, NeoMetadata, public from boa3.builtin.interop.iterator import Iterator @@ -7,8 +7,8 @@ on_transfer = CreateNewEvent( # trigger when tokens are transferred, including zero value transfers. [ - ('from_addr', Union[UInt160, None]), - ('to_addr', Union[UInt160, None]), + ('from_addr', UInt160 | None), + ('to_addr', UInt160 | None), ('amount', int), ('tokenId', bytes) ], diff --git a/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsStr.py b/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsStr.py index d47b3cf08..92d03f0f2 100644 --- a/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsStr.py +++ b/boa3_test/test_sc/metadata_test/MetadataInfoSupportedStandardsByteStringAsStr.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Union +from typing import Any, Dict from boa3.builtin.compile_time import CreateNewEvent, NeoMetadata, public from boa3.builtin.interop.iterator import Iterator @@ -7,8 +7,8 @@ on_transfer = CreateNewEvent( # trigger when tokens are transferred, including zero value transfers. [ - ('from_addr', Union[UInt160, None]), - ('to_addr', Union[UInt160, None]), + ('from_addr', UInt160 | None), + ('to_addr', UInt160 | None), ('amount', int), ('tokenId', str) ], diff --git a/boa3_test/test_sc/metadata_test/aux_package/internal_package/__init__.py b/boa3_test/test_sc/metadata_test/aux_package/internal_package/__init__.py index cd496243d..46ecddceb 100644 --- a/boa3_test/test_sc/metadata_test/aux_package/internal_package/__init__.py +++ b/boa3_test/test_sc/metadata_test/aux_package/internal_package/__init__.py @@ -1,12 +1,12 @@ -from boa3.builtin.compile_time import CreateNewEvent - from typing import Union + +from boa3.builtin.compile_time import CreateNewEvent from boa3.builtin.type import UInt160 on_transfer = CreateNewEvent( [ - ('from_addr', Union[UInt160, None]), - ('to_addr', Union[UInt160, None]), + ('from_addr', UInt160 | None), + ('to_addr', UInt160 | None), ('amount', int), ], 'Transfer' diff --git a/boa3_test/tests/compiler_tests/test_event.py b/boa3_test/tests/compiler_tests/test_event.py index fd99edce1..2e5ace85d 100644 --- a/boa3_test/tests/compiler_tests/test_event.py +++ b/boa3_test/tests/compiler_tests/test_event.py @@ -222,9 +222,9 @@ async def test_event_nep11_transfer_run(self): event = boatestcase.BoaTestEvent.from_notification(events[0], bytes, bytes, int, bytes) self.assertEqual(transfer_args, event.state) - def test_event_with_return(self): + def test_event_without_types(self): path = self.get_contract_path('EventWithoutTypes.py') - self.assertCompilerLogs(CompilerError.UnfilledArgument, path) + self.assertCompilerLogs(CompilerError.MismatchedTypes, path) async def test_event_with_duplicated_name(self): await self.set_up_contract('EventWithDuplicatedName.py') diff --git a/boa3_test/tests/compiler_tests/test_file_generation.py b/boa3_test/tests/compiler_tests/test_file_generation.py index 166cfd066..318177c8e 100644 --- a/boa3_test/tests/compiler_tests/test_file_generation.py +++ b/boa3_test/tests/compiler_tests/test_file_generation.py @@ -320,9 +320,9 @@ def test_generate_manifest_file_with_unused_event(self): self.assertIn('parameters', event) self.assertEqual(3, len(event['parameters'])) parameters = event['parameters'] - self.assertEqual(('var4', 'Integer'), (parameters[0]['name'], parameters[0]['type'])) - self.assertEqual(('var5', 'String'), (parameters[1]['name'], parameters[1]['type'])) - self.assertEqual(('var6', 'ByteArray'), (parameters[2]['name'], parameters[2]['type'])) + self.assertEqual(('var4', AbiType.Integer), (parameters[0]['name'], parameters[0]['type'])) + self.assertEqual(('var5', AbiType.String), (parameters[1]['name'], parameters[1]['type'])) + self.assertEqual(('var6', AbiType.ByteArray), (parameters[2]['name'], parameters[2]['type'])) def test_metadata_abi_method_safe_mismatched_type(self): path = self.get_contract_path('MetadataMethodSafeMismatchedType.py') @@ -795,10 +795,10 @@ def test_generate_manifest_file_with_type_hint_list(self): _, abi_methods = self.verify_parameters_and_return_manifest(path) # type: dict, list abi_method_main = abi_methods[0] - self.assertEqual('Array', abi_method_main['returntype']) + self.assertEqual(AbiType.Array, abi_method_main['returntype']) self.assertIn('returngeneric', abi_method_main) self.assertIn('type', abi_method_main['returngeneric']) - self.assertEqual('Array', abi_method_main['returngeneric']['type']) + self.assertEqual(AbiType.Array, abi_method_main['returngeneric']['type']) self.assertIn('generic', abi_method_main['returngeneric']) self.assertIn('type', abi_method_main['returngeneric']['generic']) @@ -811,7 +811,7 @@ def test_generate_manifest_file_with_type_hint_dict(self): _, abi_methods = self.verify_parameters_and_return_manifest(path) # type: dict, list abi_method_main = abi_methods[0] - self.assertEqual('Map', abi_method_main['returntype']) + self.assertEqual(AbiType.Map, abi_method_main['returntype']) self.assertIn('returngenerickey', abi_method_main) self.assertIn('type', abi_method_main['returngenerickey']) self.assertIn('returngenericitem', abi_method_main) @@ -828,7 +828,7 @@ def test_generate_manifest_file_with_type_hint_union_return(self): _, abi_methods = self.verify_parameters_and_return_manifest(path) # type: dict, list abi_method_main = abi_methods[0] - self.assertEqual('Any', abi_method_main['returntype']) + self.assertEqual(AbiType.Any, abi_method_main['returntype']) self.assertIn('returnunion', abi_method_main) self.assertIsInstance(abi_method_main['returnunion'], list) for union_type in abi_method_main['returnunion']: @@ -850,7 +850,7 @@ def test_generate_manifest_file_with_type_hint_optional(self): _, abi_methods = self.verify_parameters_and_return_manifest(path) # type: dict, list abi_method_main = abi_methods[0] - self.assertEqual('Integer', abi_method_main['returntype']) + self.assertEqual(AbiType.Integer, abi_method_main['returntype']) self.assertIn('returnnullable', abi_method_main) abi_method_main_parameters = abi_method_main['parameters'] @@ -865,7 +865,7 @@ def test_generate_manifest_file_with_type_hint_storage_context(self): _, abi_methods = self.verify_parameters_and_return_manifest(path) # type: dict, list abi_method_main = abi_methods[0] - self.assertEqual('InteropInterface', abi_method_main['returntype']) + self.assertEqual(AbiType.InteropInterface, abi_method_main['returntype']) self.assertIn('returnhint', abi_method_main) self.assertEqual(abi_method_main['returnhint'], 'StorageContext') @@ -874,7 +874,7 @@ def test_generate_manifest_file_with_type_hint_iterator(self): _, abi_methods = self.verify_parameters_and_return_manifest(path) # type: dict, list abi_method_main = abi_methods[0] - self.assertEqual('InteropInterface', abi_method_main['returntype']) + self.assertEqual(AbiType.InteropInterface, abi_method_main['returntype']) self.assertIn('returnhint', abi_method_main) self.assertEqual(abi_method_main['returnhint'], 'Iterator') @@ -888,7 +888,7 @@ def test_generate_manifest_file_with_type_hint_address(self): self.assertIsInstance(method_main.return_type, AddressType) abi_method_main = abi_methods[0] - self.assertEqual(abi_method_main['returntype'], 'String') + self.assertEqual(abi_method_main['returntype'], AbiType.String) self.assertIn('returnhint', abi_method_main) self.assertEqual(abi_method_main['returnhint'], 'Address') @@ -911,7 +911,7 @@ def test_generate_manifest_file_with_type_hint_blockhash(self): self.assertIsInstance(method_main.return_type, BlockHashType) abi_method_main = abi_methods[0] - self.assertEqual(abi_method_main['returntype'], 'Hash256') + self.assertEqual(abi_method_main['returntype'], AbiType.Hash256) self.assertIn('returnhint', abi_method_main) self.assertEqual(abi_method_main['returnhint'], 'BlockHash') @@ -934,7 +934,7 @@ def test_generate_manifest_file_with_type_hint_publickey(self): self.assertIsInstance(method_main.return_type, PublicKeyType) abi_method_main = abi_methods[0] - self.assertEqual(abi_method_main['returntype'], 'PublicKey') + self.assertEqual(abi_method_main['returntype'], AbiType.PublicKey) # 'PublicKey' already is a abi type, so there is no need to use a 'returnhint' self.assertNotIn('returnhint', abi_method_main) @@ -957,7 +957,7 @@ def test_generate_manifest_file_with_type_hint_scripthash(self): self.assertIsInstance(method_main.return_type, ScriptHashType) abi_method_main = abi_methods[0] - self.assertEqual(abi_method_main['returntype'], 'Hash160') + self.assertEqual(abi_method_main['returntype'], AbiType.Hash160) self.assertIn('returnhint', abi_method_main) self.assertEqual(abi_method_main['returnhint'], 'ScriptHash') @@ -980,7 +980,7 @@ def test_generate_manifest_file_with_type_hint_scripthashlittleendian(self): self.assertIsInstance(method_main.return_type, ScriptHashLittleEndianType) abi_method_main = abi_methods[0] - self.assertEqual(abi_method_main['returntype'], 'Hash160') + self.assertEqual(abi_method_main['returntype'], AbiType.Hash160) self.assertIn('returnhint', abi_method_main) self.assertEqual(abi_method_main['returnhint'], 'ScriptHashLittleEndian') @@ -1003,7 +1003,7 @@ def test_generate_manifest_file_with_type_hint_transactionid(self): self.assertIsInstance(method_main.return_type, TransactionIdType) abi_method_main = abi_methods[0] - self.assertEqual(abi_method_main['returntype'], 'Hash256') + self.assertEqual(abi_method_main['returntype'], AbiType.Hash256) self.assertIn('returnhint', abi_method_main) self.assertEqual(abi_method_main['returnhint'], 'TransactionId') @@ -1021,7 +1021,7 @@ def test_generate_manifest_file_with_type_hint_any(self): _, abi_methods = self.verify_parameters_and_return_manifest(path) # type: dict, list abi_method_main = abi_methods[0] - self.assertEqual(abi_method_main['returntype'], 'Any') + self.assertEqual(abi_method_main['returntype'], AbiType.Any) # verifying if 'returnunion' was not wrongfully added to the manifest self.assertNotIn('returnunion', abi_method_main) @@ -1033,25 +1033,25 @@ def test_generate_manifest_file_with_type_hint_maps_array_union_hint(self): abi_method_main_parameter = abi_method_main['parameters'][0] # verifying arg type - self.assertEqual('Map', abi_method_main_parameter['type']) + self.assertEqual(AbiType.Map, abi_method_main_parameter['type']) self.assertIn('generickey', abi_method_main_parameter) self.assertIn('type', abi_method_main_parameter['generickey']) - self.assertEqual('String', abi_method_main_parameter['generickey']['type']) + self.assertEqual(AbiType.String, abi_method_main_parameter['generickey']['type']) self.assertIn('genericitem', abi_method_main_parameter) self.assertIn('type', abi_method_main_parameter['genericitem']) - self.assertEqual('Array', abi_method_main_parameter['genericitem']['type']) + self.assertEqual(AbiType.Array, abi_method_main_parameter['genericitem']['type']) self.assertIn('generic', abi_method_main_parameter['genericitem']) self.assertIn('type', abi_method_main_parameter['genericitem']['generic']) # verifying return type - self.assertEqual('Array', abi_method_main['returntype']) + self.assertEqual(AbiType.Array, abi_method_main['returntype']) self.assertIn('returngeneric', abi_method_main) self.assertIn('type', abi_method_main['returngeneric']) - self.assertEqual('Any', abi_method_main['returngeneric']['type']) + self.assertEqual(AbiType.Any, abi_method_main['returngeneric']['type']) self.assertIn('union', abi_method_main['returngeneric']) self.assertEqual(3, len(abi_method_main['returngeneric']['union'])) self.assertTrue(any( - union_type['type'] == 'Map' and 'generickey' in union_type and 'genericitem' in union_type + union_type['type'] == AbiType.Map and 'generickey' in union_type and 'genericitem' in union_type for union_type in abi_method_main['returngeneric']['union'] )) @@ -1063,19 +1063,19 @@ def test_generate_manifest_file_with_type_hint_list_and_dict_not_from_typing(sel abi_method_main_parameter = abi_method_main['parameters'][0] # verifying arg type - self.assertEqual('Map', abi_method_main_parameter['type']) + self.assertEqual(AbiType.Map, abi_method_main_parameter['type']) self.assertIn('generickey', abi_method_main_parameter) self.assertIn('type', abi_method_main_parameter['generickey']) - self.assertEqual('Any', abi_method_main_parameter['generickey']['type']) + self.assertEqual(AbiType.Any, abi_method_main_parameter['generickey']['type']) self.assertIn('genericitem', abi_method_main_parameter) self.assertIn('type', abi_method_main_parameter['genericitem']) - self.assertEqual('Any', abi_method_main_parameter['genericitem']['type']) + self.assertEqual(AbiType.Any, abi_method_main_parameter['genericitem']['type']) # verifying return type - self.assertEqual('Array', abi_method_main['returntype']) + self.assertEqual(AbiType.Array, abi_method_main['returntype']) self.assertIn('returngeneric', abi_method_main) self.assertIn('type', abi_method_main['returngeneric']) - self.assertEqual('Any', abi_method_main['returngeneric']['type']) + self.assertEqual(AbiType.Any, abi_method_main['returngeneric']['type']) def verify_parameters_and_return_manifest(self, path: str) -> tuple[dict, list]: nef_output, expected_manifest_output = self.get_deploy_file_paths_without_compiling(path) @@ -1125,5 +1125,8 @@ def test_manifest_optional_union_eventsd(self): compiler.compile_and_save(path, nef_output) _, manifest = self.get_output(nef_output) - self.assertEqual(manifest['abi']['events'][0]['parameters'][0]['type'], 'String') - self.assertEqual(manifest['abi']['events'][0]['parameters'][1]['type'], 'Integer') + events_parameters = manifest['abi']['events'][0]['parameters'] + self.assertEqual(3, len(events_parameters)) + self.assertEqual(events_parameters[0]['type'], AbiType.String) + self.assertEqual(events_parameters[1]['type'], AbiType.Integer) + self.assertEqual(events_parameters[2]['type'], AbiType.Boolean)