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

Version a5 #17

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tonos_ts4/BaseContract.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def prepare_getter_params(self, method: str, params = dict(), expect_ec = 0):
assert isinstance(expect_ec, int)
return params

def run_get(self, method: str, params = dict(), expect_ec = 0, decoder = None) -> dict:
def run_get(self, method: str, params = dict(), expect_ec = 0, decoder = None):
"""Calls a given getter for funcC contract and returns an answer in raw JSON format.

:param str method: Name of a getter
Expand Down Expand Up @@ -529,6 +529,8 @@ def _generate_wrappers(self):


def _make_tuple_result(abi, method, values, decoder):
assert isinstance(abi, Abi)
assert isinstance(decoder, Decoder)
types = abi.find_getter_output_types(method)
res_dict = {}
res_arr = []
Expand Down
2 changes: 1 addition & 1 deletion tonos_ts4/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
G_MSG_FILTER = None
G_ABI_FIXER = None
G_OVERRIDE_EXPECT_EC = None

G_SET_CONFIG_PARAMS = False

core = None
version = None
Expand Down
54 changes: 34 additions & 20 deletions tonos_ts4/ts_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def reset_all(self):
self.contracts = dict()
self.messages = dict()
self.last_error = None
self.config_path = shutil.copy(make_path("bc_config", ".boc"), self.make_temp_path("bocs/bc_config.boc"))
self.config_path = make_path("config", ".boc")
assert os.path.exists(self.config_path)
self.global_config = GlobalConfig()

def set_now(self, _now):
Expand All @@ -83,19 +84,20 @@ def set_config(self, config):
print(yellow('we no need new config'), config)

def set_config_param(self, index, value):
assert isinstance(self.config_path, str)
assert os.path.exists(self.config_path)
abi_path = make_path('config', ".abi.json")
assert os.path.exists(abi_path)
cli_params = ["debug", "call", "--abi", abi_path, "--update"]
self.add_now_param(cli_params, 1)
self.add_config_param(cli_params, "--config")
self.add_temp_keys_param(cli_params, self.config_key)
method = "set_config_param"
cli_params += ["--boc", "--addr", self.config_path, "--method", method]
self.add_method_params(cli_params, value)
result = self.run_tonos_cli(cli_params)
return self.parse_execution_result("bc_config", result, method)
print(yellow('we no need new config'), index)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты смешной

# assert isinstance(self.config_path, str)
# assert os.path.exists(self.config_path)
# abi_path = make_path('config', ".abi.json")
# assert os.path.exists(abi_path)
# cli_params = ["debug", "call", "--abi", abi_path, "--update"]
# self.add_now_param(cli_params, 1)
# self.add_config_param(cli_params, "--config")
# self.add_temp_keys_param(cli_params, self.config_key)
# method = "set_config_param"
# cli_params += ["--boc", "--addr", self.config_path, "--method", method]
# self.add_method_params(cli_params, value)
# result = self.run_tonos_cli(cli_params)
# return self.parse_execution_result("bc_config", result, method)

def add_config_param(self, cli_params, name = "--bc_config"):
if self.config_path is not None and os.path.exists(self.config_path):
Expand Down Expand Up @@ -197,8 +199,8 @@ def deploy_contract(self, tvc_name: str, abi_name, ctor_params: str, initial_dat
assert os.path.exists(boc_path)
if pubkey is not None:
boc_path = shutil.move(boc_path, boc_path.removesuffix(".boc") + "-" + pubkey[:8] + ".boc")
# if name.startswith('Config'):
# self.config_path = boc_path
if name.startswith('Config'):
self.config_path = boc_path
# TODO: we don't story keys if no private
# TODO: don't store tvc_path
self.contracts[address] = ContractDescription(tvc_path, abi_path, boc_path, dbg_path, key_path)
Expand Down Expand Up @@ -238,9 +240,21 @@ def call_contract(self, address: str, method: str, is_getter, is_debot, params:

def call_getter(self, address: str, method: str, params: str, is_debot = False) -> str:
descr = self.get_contract(address)
cli_params = ["runx", "--boc", "--abi", descr.abi_path]
# self.add_config_param(cli_params) # TODO: here problem - need config params
cli_params += ["--addr", descr.boc_path, "--method", method, params]
if 0: # self.global_config.trace_tvm is not None:
# it does not give answers
cli_params = ["debug", "run", "--boc", "--abi", descr.abi_path]
self.add_config_param(cli_params, "--config")
self.add_now_param(cli_params)
self.add_output_param(cli_params, descr.dbg_path)
cli_params += ["--addr", descr.boc_path, "--method", method, params]
result = self.run_tonos_cli(cli_params)
return self.parse_execution_result(address, result, method)
else:
# it does not give debug
cli_params = ["runx", "--boc", "--abi", descr.abi_path]
self.add_config_param(cli_params, "--bc_config")
cli_params += ["--addr", descr.boc_path, "--method", method, params]

result = self.run_tonos_cli(cli_params)
error = result.get("Error")
if error is not None:
Expand Down Expand Up @@ -525,7 +539,7 @@ def dump_config_param(self, index: int):
def print_config_param(self, index: int, cell: str):
if cell == EMPTY_CELL:
return 'no parameter set'
param_path = make_path("params", ".bin")
param_path = self.make_temp_path("bocs/params", ".bin")
with open(param_path, "wb") as f:
f.write(base64.b64decode(cell))
cli_params = ["test", "config", "--decode", param_path, "--index", str(index)]
Expand Down