Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Type 'felt252' is not defined error when using starknet.py #1436

Closed
1 task done
otatataata opened this issue Aug 11, 2024 · 1 comment
Closed
1 task done

[BUG] Type 'felt252' is not defined error when using starknet.py #1436

otatataata opened this issue Aug 11, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@otatataata
Copy link

What happened

Hello,

I am encountering an issue when trying to use the starknet.py library with a smart contract that utilizes the felt252 type.

API I'm using: https://github.com/influenceth/sdk/blob/master/src/contracts/starknet_events.json

With the function ExtractResourceFinish

     function_name = "ExtractResourceFinish"
        call_data = [
            5,  # extractor (Entity converti en felt)
            5,  # extractor_slot (u64)
            6410  # caller_crew (Entity converti en felt)
        ]

Stack trace

Erreur lors de l'exécution de la transaction : Type 'felt252' is not defined. Please report this issue at https://github.com/software-mansion/starknet.py/issues
Traceback complet de l'erreur :
Traceback (most recent call last):
File "path/to/my/script.py", line 106, in main
contract = Contract(
^^^^^^^^^
File "path/to/starknet_py/contract.py", line 746, in init
self._functions = self._make_functions(
^^^^^^^^^^^^^^^^^^^^^
File "path/to/starknet_py/contract.py", line 1075, in _make_functions
repository[name] = ContractFunction(
^^^^^^^^^^^^^^^^^
File "path/to/starknet_py/contract.py", line 543, in init
function = contract_data.parsed_abi.functions.get(name)
^^^^^^^^^^^^^^^^^^^^^^^^
File "path/to/functools.py", line 995, in get
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "path/to/starknet_py/contract.py", line 74, in parsed_abi
return AbiParserV1(self.abi).parse()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/to/starknet_py/abi/v1/parser.py", line 89, in parse
name: self._parse_function(entry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/to/starknet_py/abi/v1/parser.py", line 173, in _parse_function
inputs=self._parse_members(function["inputs"], function["name"]),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/to/starknet_py/abi/v1/parser.py", line 191, in _parse_members
return OrderedDict(
^^^^^^^^^^^^
File "path/to/starknet_py/abi/v1/parser.py", line 192, in
(name, self.type_parser.parse_inline_type(param["type"]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/to/starknet_py/cairo/v1/type_parser.py", line 57, in parse_inline_type
raise UnknownCairoTypeError(parsed.name)
starknet_py.cairo.v1.type_parser.UnknownCairoTypeError: Type 'felt252' is not defined. Please report this issue at https://github.com/software-mansion/starknet.py/issues

Steps to reproduce

from starknet_py.contract import Contract

Assuming ABI data is loaded from a source, here represented as a dictionary

abi_data = {
'name': 'ExampleFunction',
'type': 'function',
'inputs': [{'name': 'example_input', 'type': 'felt252'}],
'outputs': [],
'stateMutability': 'external'
}

contract = Contract(address="0x0422d33a3638dcc4c62e72e1d6942cd31eb643ef596ccac2351e0e21f6cd4bf4", abi=[abi_data])

SDK Version

SDK Version: starknet.py version 0.4.7

Python version

3.9

What operating system are you using?

Windows

Is there an existing issue for this?

  • I have searched the existing issues and verified no issue exits for this problem.
@otatataata otatataata added the bug Something isn't working label Aug 11, 2024
@franciszekjob franciszekjob self-assigned this Aug 12, 2024
@franciszekjob
Copy link
Collaborator

franciszekjob commented Aug 12, 2024

Hey @otatataata, thanks for report. Could you please provide full code sample? This way I will be able to reproduce the error. Also, v0.4.7 is a very old version of the SDK. Did you try to use a newer version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants