# TVM value types
Telegram Open Network Virtual Machine has 7 value types:
1. Integer
2. Cell
3. Tuple
4. Null
5. Slice
6. Builder
7. Continuation
This library is collection of utilits for handling those types.
# Cell and Slice
`tvm_valuetypes.cell` has class `Cell` and functions to work with cells:
`deserialize_boc`, `cell.serialize_boc`, `cell.serialize_to_object`, `cell.serialize_to_json`, `deserialize_cell_from_json`
```
from tvm_valuertypes.cell import Cell, deserialize_boc
serialized_cell = bytes.fromhex("B5EE9C72410102010007000102000100024995C5FE15")
cell1 = deserialize_boc(serialized_c1)
cell1
serialization_with_index = cell1.serialize_boc(has_idx=True, hash_crc32=True, has_cache_bits=False, flags=0 )
serialization_with_index
cell2 = deserialize_boc(serialized_c2)
cell2 == cell1
cell2.serialize_to_object()
```
## HashMaps (Dictionaries)
Cell may represent special 'virtual' value type, HashMap, which can be used for storing key-value container in the Cell.
`tvm_valuetypes.dict_utils` has special method `parse_hashmap` for dealing with hashmaps. Note the difference between `Hashmap` and `HashmapE`.
```
from tvm_valuertypes.cell import Cell
from tvm_valuertypes.dict_utils import parse_hashmap
test_dict = bytes.fromhex("B5EE9C7241010A01002D00020120010202014803040003FC0202014805060003F5FE02014807080003DB24020120090900035FF800030020CB8CA892")
dict_cell = deserialize_boc(test_dict)
parsed_dict = {}
parse_hashmap(dict_cell, 8, parsed_dict)
parsed_dict
```
Raw data
{
"_id": null,
"home_page": "https://github.com/EmelyanenkoK/tvm_valuetypes",
"name": "tvm-valuetypes",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Emelyanenko Kirill",
"author_email": "emelyanenko.kirill@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/96/8c/6e856cf86ab94363333d3e3e1a3754f0c56694fab7a7c8b328493eaef00d/tvm_valuetypes-0.0.12.tar.gz",
"platform": null,
"description": "# TVM value types\nTelegram Open Network Virtual Machine has 7 value types:\n1. Integer\n2. Cell\n3. Tuple\n4. Null\n5. Slice\n6. Builder\n7. Continuation\n\nThis library is collection of utilits for handling those types.\n\n# Cell and Slice\n`tvm_valuetypes.cell` has class `Cell` and functions to work with cells:\n`deserialize_boc`, `cell.serialize_boc`, `cell.serialize_to_object`, `cell.serialize_to_json`, `deserialize_cell_from_json`\n```\nfrom tvm_valuertypes.cell import Cell, deserialize_boc\nserialized_cell = bytes.fromhex(\"B5EE9C72410102010007000102000100024995C5FE15\")\ncell1 = deserialize_boc(serialized_c1)\ncell1\nserialization_with_index = cell1.serialize_boc(has_idx=True, hash_crc32=True, has_cache_bits=False, flags=0 )\nserialization_with_index\ncell2 = deserialize_boc(serialized_c2)\ncell2 == cell1\ncell2.serialize_to_object()\n```\n## HashMaps (Dictionaries)\nCell may represent special 'virtual' value type, HashMap, which can be used for storing key-value container in the Cell.\n\n`tvm_valuetypes.dict_utils` has special method `parse_hashmap` for dealing with hashmaps. Note the difference between `Hashmap` and `HashmapE`.\n\n```\nfrom tvm_valuertypes.cell import Cell\nfrom tvm_valuertypes.dict_utils import parse_hashmap\ntest_dict = bytes.fromhex(\"B5EE9C7241010A01002D00020120010202014803040003FC0202014805060003F5FE02014807080003DB24020120090900035FF800030020CB8CA892\")\ndict_cell = deserialize_boc(test_dict)\nparsed_dict = {}\nparse_hashmap(dict_cell, 8, parsed_dict)\nparsed_dict\n```\n\n\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Collection of utils for handling Telegram Open Network Virtual Machine value types",
"version": "0.0.12",
"project_urls": {
"Homepage": "https://github.com/EmelyanenkoK/tvm_valuetypes"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0c58d98de1ffd588dcf5cda8c9d105b5949aa66c69cb3af7d0a25bae679536c1",
"md5": "43291f5673bb851aa350d69950cc4bca",
"sha256": "e4af62baebdcc8864a1f4aac40082f3221f1e4232f79b8dfb7411d7c78856880"
},
"downloads": -1,
"filename": "tvm_valuetypes-0.0.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "43291f5673bb851aa350d69950cc4bca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9471,
"upload_time": "2023-07-18T19:28:36",
"upload_time_iso_8601": "2023-07-18T19:28:36.304523Z",
"url": "https://files.pythonhosted.org/packages/0c/58/d98de1ffd588dcf5cda8c9d105b5949aa66c69cb3af7d0a25bae679536c1/tvm_valuetypes-0.0.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "968c6e856cf86ab94363333d3e3e1a3754f0c56694fab7a7c8b328493eaef00d",
"md5": "852615315ff4bbea413112edc809cb47",
"sha256": "1f9304126be99e30ecb827e68e6e36e1620b8dc6a781dca1b0fdcc1e31d70983"
},
"downloads": -1,
"filename": "tvm_valuetypes-0.0.12.tar.gz",
"has_sig": false,
"md5_digest": "852615315ff4bbea413112edc809cb47",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9044,
"upload_time": "2023-07-18T19:28:37",
"upload_time_iso_8601": "2023-07-18T19:28:37.890384Z",
"url": "https://files.pythonhosted.org/packages/96/8c/6e856cf86ab94363333d3e3e1a3754f0c56694fab7a7c8b328493eaef00d/tvm_valuetypes-0.0.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-18 19:28:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "EmelyanenkoK",
"github_project": "tvm_valuetypes",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "crc32c",
"specs": []
},
{
"name": "bitarray",
"specs": []
}
],
"lcname": "tvm-valuetypes"
}