software-mansion / starknet.py

✨ 🐍 Python SDK for Starknet.
https://starknetpy.rtfd.io/
MIT License
253 stars 62 forks source link

Type 'core::integer::i128' is not defined. #1366

Open Ophiase opened 2 weeks ago

Ophiase commented 2 weeks ago

Feature Request

This type is properly defined in Cairo. I have a contract that use it, but its not recognized by starknet.py.

Ophiase commented 2 weeks ago

I'm going to replace every occurrences of i128 in the ABI with u128 and see what happens.

contract = Contract(address=DEPLOYED_CONTRACT, abi=abi, provider=account)
Ophiase commented 2 weeks ago
def replace_i128_with_u128(data):
    if isinstance(data, dict):
        return {key: replace_i128_with_u128(value) for key, value in data.items()}
    elif isinstance(data, list):
        return [replace_i128_with_u128(item) for item in data]
    elif isinstance(data, str):
        return data.replace('i128', 'u128')
    else:
        return data

abi_as_u128 = replace_i128_with_u128(abi)

contract = Contract(address=DEPLOYED_CONTRACT, abi=abi_as_u128, provider=accounts)

Result : ValueError: Make sure valid ABI is used to create a Contract instance

franciszekjob commented 1 week ago

Hi @Ophiase, replacing i128 with u128 in contract ABI may lead to potential issues. Could you please provide us with your contract address? This way we can help you and indicate source of the problem.