Skip to content

Commit

Permalink
add seqno parameter for few methods, block_id and last_transaction_id…
Browse files Browse the repository at this point in the history
… for raw_run_method, get_out_msg_queue_sizes, update linux x86_64 binary
  • Loading branch information
dungeon-master-666 committed Jun 20, 2024
1 parent 8d67262 commit 8cb2b61
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 13 deletions.
107 changes: 94 additions & 13 deletions pytonlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def raw_get_transactions(self, account_address: str, from_transaction_lt:
}
return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def raw_get_account_state(self, address: str, *args, **kwargs):
async def raw_get_account_state(self, address: str, seqno = None, *args, **kwargs):
"""
TL Spec:
raw.getAccountState account_address:accountAddress = raw.AccountState;
Expand All @@ -186,10 +186,36 @@ async def raw_get_account_state(self, address: str, *args, **kwargs):
'account_address': address
}
}
if seqno is not None:
wc, shard = -1, -9223372036854775808
block_id = await self.lookup_block(wc, shard, seqno)
request = {
'@type': 'withBlock',
'id': block_id,
'function' : request
}

return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def get_shard_account_cell(self, address: str, seqno = None, *args, **kwargs):
request = {
'@type': 'getShardAccountCell',
'account_address': {
'account_address': address
}
}
if seqno is not None:
wc, shard = -1, -9223372036854775808
block_id = await self.lookup_block(wc, shard, seqno)
request = {
'@type': 'withBlock',
'id': block_id,
'function' : request
}

return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def generic_get_account_state(self, address: str, *args, **kwargs):
async def generic_get_account_state(self, address: str, seqno = None, *args, **kwargs):
# TODO: understand why this is not used
account_address = prepare_address(address)
request = {
Expand All @@ -198,21 +224,38 @@ async def generic_get_account_state(self, address: str, *args, **kwargs):
'account_address': address
}
}
if seqno is not None:
wc, shard = -1, -9223372036854775808
block_id = await self.lookup_block(wc, shard, seqno)
request = {
'@type': 'withBlock',
'id': block_id,
'function' : request
}

return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def _load_contract(self, address, *args, **kwargs):
async def _load_contract(self, address, seqno = None, *args, **kwargs):
# TODO: understand why this is not used
account_address = prepare_address(address)
# account_address = prepare_address(address)
request = {
'@type': 'smc.load',
'account_address': {
'account_address': address
}
}
if seqno is not None:
wc, shard = -1, -9223372036854775808
block_id = await self.lookup_block(wc, shard, seqno)
request = {
'@type': 'withBlock',
'id': block_id,
'function' : request
}
result = await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)
return result["id"]

async def raw_run_method(self, address, method, stack_data, output_layout=None, *args, **kwargs):
async def raw_run_method(self, address, method, stack_data, seqno = None, *args, **kwargs):
"""
For numeric data only
TL Spec:
Expand Down Expand Up @@ -241,7 +284,7 @@ async def raw_run_method(self, address, method, stack_data, output_layout=None,
method = {'@type': 'smc.methodIdNumber', 'number': method}
else:
method = {'@type': 'smc.methodIdName', 'name': str(method)}
contract_id = await self._load_contract(address)
contract_id = await self._load_contract(address, seqno)
request = {
'@type': 'smc.runGetMethod',
'id': contract_id,
Expand All @@ -251,6 +294,13 @@ async def raw_run_method(self, address, method, stack_data, output_layout=None,
r = await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)
if 'stack' in r:
r['stack'] = serialize_tvm_stack(r['stack'])
request = {
'@type': 'smc.getRawFullAccountState',
'id': contract_id
}
raw_full_account_state = await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)
r['block_id'] = raw_full_account_state['block_id']
r['last_transaction_id'] = raw_full_account_state['last_transaction_id']
return r

async def raw_send_message(self, serialized_boc, *args, **kwargs):
Expand Down Expand Up @@ -474,7 +524,7 @@ async def get_masterchain_block_signatures(self, seqno: int, *args, **kwargs):
}
return await self.tonlib_wrapper.execute(request)

async def get_shard_block_proof(self, workchain: int, shard: int, seqno: int, from_seqno=None, *args, **kwargs):
async def get_shard_block_proof(self, workchain: int, shard: int, seqno: int, from_seqno = None, *args, **kwargs):
block_id = await self.lookup_block(workchain, shard, seqno)
mode = 0
if from_seqno is not None:
Expand All @@ -491,8 +541,16 @@ async def get_shard_block_proof(self, workchain: int, shard: int, seqno: int, fr
request['from'] = from_block_id

return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def get_out_msg_queue_sizes(self, *args, **kwargs):
request = {
'@type': 'blocks.getOutMsgQueueSizes',
'mode': 0
}

async def lookup_block(self, workchain, shard, seqno=None, lt=None, unixtime=None, *args, **kwargs):
return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def lookup_block(self, workchain, shard, seqno = None, lt=None, unixtime=None, *args, **kwargs):
assert (seqno is not None) or (lt is not None) or (unixtime is not None), "Seqno, LT or unixtime should be defined"
mode = 0
if seqno is not None:
Expand All @@ -515,7 +573,7 @@ async def lookup_block(self, workchain, shard, seqno=None, lt=None, unixtime=Non
}
return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def get_shards(self, master_seqno=None, lt=None, unixtime=None, *args, **kwargs):
async def get_shards(self, master_seqno = None, lt=None, unixtime=None, *args, **kwargs):
assert (master_seqno is not None) or (lt is not None) or (unixtime is not None), "Seqno, LT or unixtime should be defined"
wc, shard = -1, -9223372036854775808
fullblock = await self.lookup_block(wc, shard, master_seqno, lt, unixtime)
Expand Down Expand Up @@ -651,16 +709,39 @@ async def get_block_header(self, workchain, shard, seqno, root_hash=None, file_h
}
return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def get_config_param(self, config_id: int, seqno: int, *args, **kwargs):
wc, shard = -1, -9223372036854775808
fullblock = await self.lookup_block(wc, shard, seqno)
async def get_config_param(self, config_id: int, seqno = None, *args, **kwargs):
request = {
'@type': 'getConfigParam',
'id': fullblock,
'param': config_id,
'mode': 0
}

if seqno is not None:
wc, shard = -1, -9223372036854775808
block_id = await self.lookup_block(wc, shard, seqno)
request = {
'@type': 'withBlock',
'id': block_id,
'function' : request
}

return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def get_config_all(self, seqno = None, *args, **kwargs):
request = {
'@type': 'getConfigAll',
'mode': 0
}

if seqno is not None:
wc, shard = -1, -9223372036854775808
block_id = await self.lookup_block(wc, shard, seqno)
request = {
'@type': 'withBlock',
'id': block_id,
'function' : request
}

return await self.tonlib_wrapper.execute(request, timeout=self.tonlib_timeout)

async def try_locate_tx_by_incoming_message(self, source, destination, creation_lt, *args, **kwargs):
Expand Down
Binary file modified pytonlib/distlib/linux/libtonlibjson.x86_64.so
100644 → 100755
Binary file not shown.

0 comments on commit 8cb2b61

Please sign in to comment.