[solved] Typechecking for run_contract_function in python is wrong

Hello!

I tried to use the function run_contract_function in python. With the following code

from frozendict import frozendict
from moralis import evm_api


abi = {
    "inputs": [],
    "name": "getRound",
    "outputs": [
        {
            "internalType": "int256",
            "name": "",
            "type": "int256",
        },
    ],
    "stateMutability": "view",
    "type": "function",
}

params = {
    "address": "0xD91212683F8F7e3010dAaa9E29031A518453ebd9",
    "function_name": "getRound",
    "chain": "0x13881",
}
body = {"abi": [frozendict(abi)], "params": {}, "functionName": "getRound"}

result = evm_api.utils.run_contract_function(
    api_key=api_key,
    params=params,
    body=body,
)

print(result)

But then I get the following error back from the typechecking done in schemas.py

openapi_evm_api.exceptions.ApiTypeError: Invalid type. Required value type is frozendict and passed type was tuple at ['args[0]']['abi']

However the abi should be a list of frozendicts. So by commenting out the type checking in _validate_oapg I get the code run with no issues.

# if base_class not in cls._types:
#     raise cls.__get_type_error(
#         arg,
#         validation_metadata.path_to_item,
#         cls._types,
#         key_type=False,
#     )

I will check later to see what happens.

1 Like

it is fixed now in the latest version of moralis python sdk

Thanks for the quick support!

1 Like

I think this error is still in the current version of Moralis moralis 0.1.14

we will check again, thanks for reporting

it works now in latest version that is 0.1.16

Ok, thanks for the update

2 Likes