forked from TrueCloudLab/frostfs-testlib
[#351] Added method resolve NNS contract
Signed-off-by: Ilyas Niyazov <i.niyazov@yadro.com>
This commit is contained in:
parent
b44705eb2f
commit
42100da507
1 changed files with 14 additions and 6 deletions
|
@ -40,6 +40,18 @@ def get_contract_hash(morph_chain: MorphChain, resolve_name: str, shell: Shell)
|
|||
return bytes.decode(base64.b64decode(stack_data[0]["value"]))
|
||||
|
||||
|
||||
def resolve_nns_contract(morph_chain: MorphChain, resolve_name: str, shell: Shell, nns_contract_hash: str) -> str:
|
||||
neogo = NeoGo(shell=shell, neo_go_exec_path=NEOGO_EXECUTABLE)
|
||||
out = neogo.contract.testinvokefunction(
|
||||
scripthash=nns_contract_hash,
|
||||
method="resolve",
|
||||
arguments=f"string:{resolve_name} int:16",
|
||||
rpc_endpoint=morph_chain.get_http_endpoint(),
|
||||
)
|
||||
stack_data = json.loads(out.stdout.replace("\n", ""))["stack"][0]["value"]
|
||||
return bytes.decode(base64.b64decode(stack_data[0]["value"]))
|
||||
|
||||
|
||||
def transaction_accepted(morph_chain: MorphChain, tx_id: str):
|
||||
"""
|
||||
This function returns True in case of accepted TX.
|
||||
|
@ -73,9 +85,7 @@ def get_balance(shell: Shell, morph_chain: MorphChain, wallet_path: str, wallet_
|
|||
acc = wallet.accounts[-1]
|
||||
payload = [{"type": "Hash160", "value": str(acc.script_hash)}]
|
||||
try:
|
||||
resp = morph_chain.rpc_client.invoke_function(
|
||||
get_contract_hash(morph_chain, "balance.frostfs", shell=shell), "balanceOf", payload
|
||||
)
|
||||
resp = morph_chain.rpc_client.invoke_function(get_contract_hash(morph_chain, "balance.frostfs", shell=shell), "balanceOf", payload)
|
||||
logger.info(f"Got response \n{resp}")
|
||||
value = int(resp["stack"][0]["value"])
|
||||
return value / ASSET_POWER_SIDECHAIN
|
||||
|
@ -112,9 +122,7 @@ def transfer_gas(
|
|||
amount: Amount of gas to transfer.
|
||||
"""
|
||||
wallet_from_path = wallet_from_path or morph_chain.get_wallet_path()
|
||||
wallet_from_password = (
|
||||
wallet_from_password if wallet_from_password is not None else morph_chain.get_wallet_password()
|
||||
)
|
||||
wallet_from_password = wallet_from_password if wallet_from_password is not None else morph_chain.get_wallet_password()
|
||||
address_from = address_from or wallet_utils.get_last_address_from_wallet(wallet_from_path, wallet_from_password)
|
||||
address_to = address_to or wallet_utils.get_last_address_from_wallet(wallet_to_path, wallet_to_password)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue