ton-http-api 2.0.58__tar.gz → 2.0.60__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/PKG-INFO +1 -1
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/main.py +36 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/manager.py +7 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/ton_http_api.egg-info/PKG-INFO +1 -1
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/README.md +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/__init__.py +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/__main__.py +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/cache.py +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/models.py +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/settings.py +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/pyTON/worker.py +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/setup.cfg +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/setup.py +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/ton_http_api.egg-info/SOURCES.txt +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/ton_http_api.egg-info/dependency_links.txt +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/ton_http_api.egg-info/entry_points.txt +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/ton_http_api.egg-info/requires.txt +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/ton_http_api.egg-info/top_level.txt +0 -0
- {ton_http_api-2.0.58 → ton_http_api-2.0.60}/ton_http_api.egg-info/zip-safe +0 -0
@@ -29,6 +29,7 @@ from pyTON.settings import Settings, RedisCacheSettings
|
|
29
29
|
|
30
30
|
from pytonlib.utils.address import detect_address as __detect_address, prepare_address as _prepare_address
|
31
31
|
from pytonlib.utils.wallet import wallets as known_wallets, sha256
|
32
|
+
from pytonlib.utils.common import hash_to_hex, hex_to_b64str
|
32
33
|
from pytonlib import TonlibException
|
33
34
|
|
34
35
|
from loguru import logger
|
@@ -181,6 +182,20 @@ def prepare_address(address):
|
|
181
182
|
except:
|
182
183
|
raise HTTPException(status_code=416, detail="Incorrect address")
|
183
184
|
|
185
|
+
def prepare_hash(value):
|
186
|
+
if value is None:
|
187
|
+
return None
|
188
|
+
if len(value) == 44:
|
189
|
+
value = value.replace('_', '/').replace('-', '+')
|
190
|
+
data = codecs.decode(codecs.encode(value, 'utf-8'), 'base64')
|
191
|
+
b64 = codecs.encode(data, 'base64').decode('utf-8')
|
192
|
+
return b64.strip()
|
193
|
+
if len(value) == 64:
|
194
|
+
data = codecs.decode(codecs.encode(value, 'utf-8'), 'hex')
|
195
|
+
b64 = codecs.encode(data, 'base64').decode('utf-8')
|
196
|
+
return b64.strip()
|
197
|
+
raise ValueError('Invalid hash')
|
198
|
+
|
184
199
|
def address_state(account_info):
|
185
200
|
if isinstance(account_info.get("code", ""), int) or len(account_info.get("code", "")) == 0:
|
186
201
|
if len(account_info.get("frozen_hash", "")) == 0:
|
@@ -452,6 +467,9 @@ async def get_block_transactions(
|
|
452
467
|
"""
|
453
468
|
Get transactions of the given block.
|
454
469
|
"""
|
470
|
+
root_hash = prepare_hash(root_hash)
|
471
|
+
file_hash = prepare_hash(file_hash)
|
472
|
+
after_hash = prepare_hash(after_hash)
|
455
473
|
return await tonlib.getBlockTransactions(workchain, shard, seqno, count, root_hash, file_hash, after_lt, after_hash)
|
456
474
|
|
457
475
|
@app.get('/getBlockTransactionsExt', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks','transactions'])
|
@@ -470,6 +488,9 @@ async def get_block_transactions_ext(
|
|
470
488
|
"""
|
471
489
|
Get transactions of the given block.
|
472
490
|
"""
|
491
|
+
root_hash = prepare_hash(root_hash)
|
492
|
+
file_hash = prepare_hash(file_hash)
|
493
|
+
after_hash = prepare_hash(after_hash)
|
473
494
|
return await tonlib.getBlockTransactionsExt(workchain, shard, seqno, count, root_hash, file_hash, after_lt, after_hash)
|
474
495
|
|
475
496
|
@app.get('/getBlockHeader', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks'])
|
@@ -485,6 +506,8 @@ async def get_block_header(
|
|
485
506
|
"""
|
486
507
|
Get metadata of a given block.
|
487
508
|
"""
|
509
|
+
root_hash = prepare_hash(root_hash)
|
510
|
+
file_hash = prepare_hash(file_hash)
|
488
511
|
return await tonlib.getBlockHeader(workchain, shard, seqno, root_hash, file_hash)
|
489
512
|
|
490
513
|
@app.get('/getConfigParam', response_model=TonResponse, response_model_exclude_none=True, tags=['get config'])
|
@@ -499,6 +522,19 @@ async def get_config_param(
|
|
499
522
|
"""
|
500
523
|
return await tonlib.get_config_param(config_id, seqno)
|
501
524
|
|
525
|
+
|
526
|
+
@app.get('/getLibraries', response_model=TonResponse, response_model_exclude_none=True, tags=['get config'])
|
527
|
+
@json_rpc('getLibraries')
|
528
|
+
@wrap_result
|
529
|
+
async def get_libraries(
|
530
|
+
libraries: List[str] = Query(..., description="List of base64 encoded libraries hashes")
|
531
|
+
):
|
532
|
+
"""
|
533
|
+
Get libraries codes.
|
534
|
+
"""
|
535
|
+
lib_hashes = [hex_to_b64str(hash_to_hex(l)) for l in libraries]
|
536
|
+
return await tonlib.getLibraries(lib_hashes)
|
537
|
+
|
502
538
|
@app.get('/getTokenData', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts'])
|
503
539
|
@json_rpc('getTokenData')
|
504
540
|
@wrap_result
|
@@ -82,6 +82,7 @@ class TonlibManager:
|
|
82
82
|
self.getBlockTransactions = self.cache_manager.cached(expire=600)(self.getBlockTransactions)
|
83
83
|
self.getBlockHeader = self.cache_manager.cached(expire=600)(self.getBlockHeader)
|
84
84
|
self.get_config_param = self.cache_manager.cached(expire=5)(self.get_config_param)
|
85
|
+
self.getLibraries = self.cache_manager.cached(expire=600)(self.getLibraries)
|
85
86
|
self.get_token_data = self.cache_manager.cached(expire=15)(self.get_token_data)
|
86
87
|
self.tryLocateTxByOutcomingMessage = self.cache_manager.cached(expire=600, check_error=False)(self.tryLocateTxByOutcomingMessage)
|
87
88
|
self.tryLocateTxByIncomingMessage = self.cache_manager.cached(expire=600, check_error=False)(self.tryLocateTxByIncomingMessage)
|
@@ -434,6 +435,12 @@ class TonlibManager:
|
|
434
435
|
else:
|
435
436
|
return await self.dispatch_archival_request(method, config_id, seqno)
|
436
437
|
|
438
|
+
async def getLibraries(self, lib_hashes: list):
|
439
|
+
try:
|
440
|
+
return await self.dispatch_request('get_libraries', lib_hashes)
|
441
|
+
except TonlibError:
|
442
|
+
return await self.dispatch_archival_request('get_libraries', lib_hashes)
|
443
|
+
|
437
444
|
async def tryLocateTxByOutcomingMessage(self, source, destination, creation_lt):
|
438
445
|
return await self.dispatch_archival_request('try_locate_tx_by_outcoming_message', source, destination, creation_lt)
|
439
446
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|