Skip to content

Commit

Permalink
1. Comment improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark A. Greenslade committed Aug 10, 2020
1 parent 1117cc7 commit f36cbff
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
29 changes: 29 additions & 0 deletions sh/scripts/view_account_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import argparse

from stests.core import crypto
from stests.core.utils import cli as utils


# CLI argument parser.
ARGS = argparse.ArgumentParser("Displays derived account identifier.")

# CLI argument: network name.
ARGS.add_argument(
"public_key",
help="Hexadecimal representation of a public key associated with an account.",
type=str
)


def main(args):
"""Entry point.
:param args: Parsed CLI arguments.
"""
account_id = crypto.get_account_id(crypto.KeyAlgorithm.ED25519, args.public_key)
utils.log(account_id)


if __name__ == '__main__':
main(ARGS.parse_args())
2 changes: 2 additions & 0 deletions sh/utils/set_aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ alias stests-set-node-status='_exec_cmd $STESTS_PATH_SH_SCRIPTS/set_node_status.
# ALIASES: chain - view
# ###############################################################

alias stests-view-account-id='_exec_cmd $STESTS_PATH_SH_SCRIPTS/view_account_id.py'

alias stests-view-account-balance='_exec_cmd $STESTS_PATH_SH_SCRIPTS/view_account_balance.py'
alias stests-view-account-info='_exec_cmd $STESTS_PATH_SH_SCRIPTS/view_account_info.py'
alias stests-view-block-info='_exec_cmd $STESTS_PATH_SH_SCRIPTS/view_block_info.py'
Expand Down
6 changes: 5 additions & 1 deletion stests/core/crypto/account_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@



# Seperator to be applied when setting data to be passed to hashifier.
_SEPERATOR = b"\x00"


def get_account_id(key_algo: KeyAlgorithm, public_key: str) -> str:
"""Returns an on-chain account identifier.
Expand All @@ -15,7 +19,7 @@ def get_account_id(key_algo: KeyAlgorithm, public_key: str) -> str:
"""
return get_hash(
key_algo.name.encode("UTF-8") + b"\x00" + bytes.fromhex(public_key),
key_algo.name.encode("UTF-8") + _SEPERATOR + bytes.fromhex(public_key),
algo=HashAlgorithm.BLAKE2B,
encoding=HashEncoding.HEX,
)
10 changes: 0 additions & 10 deletions stests/core/utils/env.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
"""
.. module:: stests.core.utils.env.py
:copyright: Copyright "December 01, 2016", IPSL
:license: GPL/CeCIL
:platform: Unix, Windows
:synopsis: System test environment access utility functions.
.. moduleauthor:: Mark Conway-Greenslade <[email protected]>
"""
import os
import typing

Expand Down

0 comments on commit f36cbff

Please sign in to comment.