Skip to content

Conversation

@Pranay22077
Copy link
Contributor

Description:

Related issue(s):

Fixes #727

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@Pranay22077 Pranay22077 mentioned this pull request Nov 4, 2025
Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check this again, you are passing the same enum literal [0,1] which means the error is not resolved - to see that, please install Pylance reading pylance.md

initialSupply=self._token_params.initial_supply,
tokenType=token_type_value,
supplyType=supply_type_value,
tokenType=self._token_params.token_type.value,
Copy link
Contributor

@exploreriii exploreriii Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In lines 490 to 494 you see we have a function that attempts to resolve
token_type_value to be like the proto --

see:
token_type_value = (
self._token_params.token_type.value
if isinstance(self._token_params.token_type, TokenType)
else int(self._token_params.token_type or 0)
)

so when you suggest

tokenType=self_token_params.token_type.value
Its doing very similar thing

Current type error:
Argument of type "int" cannot be assigned to parameter "tokenType" of type "TokenType | str | None" in function "init"
  Type "int" is not assignable to type "TokenType | str | None"
    "int" is not assignable to "TokenType"
    "int" is not assignable to "str"
    "int" is not assignable to "None"

The reason this errors is because either the type checker is not able to pick up on the correct type in the proto, or the underlying protobuf expects tokenType: TokenType | str | None

Currently, it thinks we are passing ints, even if you delete the int normalisation (lines 490 to 494, and just provide your idea, it will still conflict as it would be type Literal[0,1]

SOLUTION
the solution is to cast the the token type to the proto value

This was per my original suggestion:
tokenType=basic_types_pb2.TokenType(self._token_params.token_type.value)

This works because its taken the token type enum Literal of [0,1] and wrapping it into the proto token type.

or
you can change lines 490 to 494, which in hindsight probably makes more sense
and do

    token_type_value = (
        self._token_params.token_type.value
        if isinstance(self._token_params.token_type, TokenType)
        else int(self._token_params.token_type or 0)
    )
    proto_token_type = basic_types_pb2.TokenType(token_type_value)

so it takes that token type literal and wraps it to proto friendly term

the underlying issue is we lack an easy to proto method for token type and supply type that would mean we can avoid writing all this custom conversions, and probably the type checker is not picking up on the type inference

Then we could just do
tokenType=self._token_params.token_type._to_proto()
and both the code will work (as it currently does) but the type checker will be happy too

Copy link
Contributor

@exploreriii exploreriii Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently testing if this would work,
My suggestion probably won't work
TypeError: 'EnumTypeWrapper' object is not callable
Not yet sure how to fix underlying issue, which seems to be caused by the type checker

@Pranay22077 can't find a way to fix the issue, let me know if you do! else feel free to start a new issue. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @exploreriii
That's becoming a little too complex
Will update you about it in some time, after trying other steps

@exploreriii
Copy link
Contributor

Please join our office hour happenign now if you have any questions :)
https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Token type

2 participants