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

Tonclient and LiteserverClient return different data format for run_get_method #10

Open
sann05 opened this issue Sep 27, 2024 · 1 comment

Comments

@sann05
Copy link

sann05 commented Sep 27, 2024

Package            Version   Editable project location
------------------ --------- -------------------------------
aiohttp            3.9.5
aiosignal          1.3.1
attrs              24.2.0
bitarray           2.9.2
certifi            2024.8.30
cffi               1.17.1
charset-normalizer 3.3.2
frozenlist         1.4.1
idna               3.10
multidict          6.1.0
pip                22.3.1
pycparser          2.22
pycryptodomex      3.20.0
PyNaCl             1.5.0
pytoniq            0.1.39
pytoniq-core       0.1.39
requests           2.32.3
setuptools         65.5.1
tonutils           0.1.1     commit hash: 97561e241e13fc3d8bb744f5cd3a68bcf97e472a
urllib3            2.2.3
wheel              0.38.4
x25519             0.0.2
yarl               1.12.1

Code to reproduce the issue:

import asyncio
from typing import Any

from tonutils.client import TonapiClient, LiteserverClient, Client

API_KEY = ""

# The address of the recipient
SMART_CONTRACT_ADDRESS = "kQAYdbm4IMz9PzCi8D164t1dskUQa1T110SAfYcBxSVXG6Fq"
GET_METHOD_NAME = "get_contract_storage_data"
INCREMENT_OPERATION_CODE = 1

# This contract is only deployed in the testnet
IS_TESTNET = True

async def get_contract_storage_data(client: Client) -> Any:
    result = await client.run_get_method(
        address=SMART_CONTRACT_ADDRESS,
        method_name=GET_METHOD_NAME,
        stack=[],
    )
    return result


async def main() -> None:
    tonapi_client = TonapiClient(api_key=API_KEY, is_testnet=IS_TESTNET)
    tonapi_client_result = await get_contract_storage_data(tonapi_client)
    print(f"Tonapi client result: {tonapi_client_result}")

    liteserver_client = LiteserverClient(is_testnet=IS_TESTNET)
    liteserver_client_result = await get_contract_storage_data(liteserver_client)
    print(f"Liteserver client result: {liteserver_client_result}")


if __name__ == '__main__':
    asyncio.run(main())


The output:

Tonapi client result: {'success': True, 'exit_code': 0, 'stack': [{'type': 'num', 'num': '0x71'}, {'type': 'cell', 'cell': 'b5ee9c720101010100240000438008df7a6ed3406bd9702ac79a1777a6fb9f4ee5626ae7b709ee539a71203f5955d0'}, {'type': 'cell', 'cell': 'b5ee9c720101010100240000438008df7a6ed3406bd9702ac79a1777a6fb9f4ee5626ae7b709ee539a71203f5955d0'}]}
Liteserver client result: [113, <Slice 267[8008DF7A6ED3406BD9702AC79A1777A6FB9F4EE5626AE7B709EE539A71203F5955C0] -> 0 refs>, <Slice 267[8008DF7A6ED3406BD9702AC79A1777A6FB9F4EE5626AE7B709EE539A71203F5955C0] -> 0 refs>]
@sann05 sann05 changed the title Tonclient and LiteserverClient returns different data format for run_get_method Tonclient and LiteserverClient return different data format for run_get_method Sep 27, 2024
@nessshon
Copy link
Owner

@sann05 Yes, currently the output format for the "run_get_method" is different across all three clients. As a result, I've had to manually process the data from each client separately. For now, you'll need to handle them according to your specific needs on a case-by-case basis. In the future, I may implement a unified output format at the response stage in "run_get_method."

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

No branches or pull requests

2 participants