Skip to content

Commit c83d82f

Browse files
committed
Proper codegen for single default entrypoint
1 parent 70b60fe commit c83d82f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/dipdup/codegen.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ async def init(self, overwrite_types: bool = False, keep_schemas: bool = False)
148148
await self.cleanup()
149149
await self.verify_package()
150150

151+
@staticmethod
152+
def __match_entrypoint_schema(entrypoint_name, entrypoint_schemas) -> dict:
153+
if entrypoint_name == 'default' and len(entrypoint_schemas) == 1:
154+
return entrypoint_schemas[0]['parameterSchema']
155+
156+
return next(ep['parameterSchema'] for ep in entrypoint_schemas if ep['name'] == entrypoint_name)
157+
151158
async def _fetch_operation_pattern_schema(
152159
self,
153160
operation_pattern_config: PatternConfigU,
@@ -195,8 +202,9 @@ async def _fetch_operation_pattern_schema(
195202
entrypoint = cast(str, operation_pattern_config.entrypoint)
196203

197204
try:
198-
entrypoint_schema = next(
199-
ep['parameterSchema'] for ep in contract_schemas['entrypoints'] if ep['name'] == entrypoint
205+
entrypoint_schema = self.__match_entrypoint_schema(
206+
entrypoint,
207+
contract_schemas['entrypoints'],
200208
)
201209
except StopIteration as e:
202210
raise ConfigurationError(f'Contract `{contract_config.address}` has no entrypoint `{entrypoint}`') from e

0 commit comments

Comments
 (0)