Skip to content

Commit

Permalink
Merge pull request #7 from icon-project/IS-716-write-a-readme
Browse files Browse the repository at this point in the history
IS-716: Write a README.md
  • Loading branch information
Chiwon Cho committed Aug 14, 2019
2 parents b8b63c0 + 860d129 commit 8b8a80c
Show file tree
Hide file tree
Showing 7 changed files with 920 additions and 69 deletions.
941 changes: 900 additions & 41 deletions README.md

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions preptools/command/prep_info_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,20 @@ def _init_for_get_preps(sub_parser, common_parent_parser):
"--start-ranking",
type=str,
required=False,
nargs="?",
help="Get P-Rep list which starts from start ranking"
)

parser.add_argument(
"--end-ranking",
type=str,
required=False,
nargs="?",
help="Get P-Rep list which ends with end ranking, inclusive"
)

parser.add_argument(
"--block-height",
type=str,
required=False,
nargs="?",
help="Block height which ranking formed"
)

Expand Down
20 changes: 2 additions & 18 deletions preptools/command/prep_setting_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,55 +47,48 @@ def _init_for_register_prep(sub_parser, common_parent_parser, tx_parent_parser):
"--name",
type=str,
required=False,
nargs="?",
help="PRep name"
help="P-Rep name"
)

parser.add_argument(
"--country",
type=str,
required=False,
nargs="?",
help="P-Rep's country"
)

parser.add_argument(
"--city",
type=str,
required=False,
nargs="?",
help="P-Rep's city"
)

parser.add_argument(
"--email",
type=str,
required=False,
nargs="?",
help="P-Rep's email"
)

parser.add_argument(
"--website",
type=str,
required=False,
nargs="?",
help="P-Rep's homepage url"
)

parser.add_argument(
"--details",
type=str,
required=False,
nargs="?",
help="P-Rep off-chain details"
)

parser.add_argument(
"--p2p-endpoint",
type=str,
required=False,
nargs="?",
dest="p2pEndpoint",
help="Network info used for connecting among P-Rep nodes"
)
Expand All @@ -104,8 +97,7 @@ def _init_for_register_prep(sub_parser, common_parent_parser, tx_parent_parser):
"--prep-json",
type=str,
required=False,
nargs="?",
help="json file having prepInfo"
help="json file having P-Rep information"
)

parser.set_defaults(func=_register_prep)
Expand Down Expand Up @@ -217,55 +209,48 @@ def _init_for_set_prep(sub_parser, common_parent_parser, tx_parent_parser):
"--name",
type=str,
required=False,
nargs="?",
help="PRep name"
)

parser.add_argument(
"--country",
type=str,
required=False,
nargs="?",
help="P-Rep's country"
)

parser.add_argument(
"--city",
type=str,
required=False,
nargs="?",
help="P-Rep's city"
)

parser.add_argument(
"--email",
type=str,
required=False,
nargs="?",
help="P-Rep's email"
)

parser.add_argument(
"--website",
type=str,
required=False,
nargs="?",
help="P-Rep's homepage url"
)

parser.add_argument(
"--details",
type=str,
required=False,
nargs="?",
help="P-Rep off-chain details"
)

parser.add_argument(
"--p2p-endpoint",
type=str,
required=False,
nargs="?",
dest="p2pEndpoint",
help="Network info used for connecting among P-Rep nodes"
)
Expand Down Expand Up @@ -312,7 +297,6 @@ def _init_for_set_governance_variables(sub_parser, common_parent_parser, tx_pare
"--irep",
type=str,
required=True,
nargs="?",
help="amounts of irep"
)

Expand Down
2 changes: 0 additions & 2 deletions preptools/command/tx_info_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def _init_for_tx_result(sub_parser, common_parent_parser):
parser.add_argument(
"tx_hash",
type=str,
nargs="?",
help="Enter the transaction hash"
)

Expand All @@ -61,7 +60,6 @@ def _init_for_tx_by_hash(sub_parser, common_parent_parser):
parser.add_argument(
"tx_hash",
type=str,
nargs="?",
help="Enter the transaction hash"
)

Expand Down
14 changes: 10 additions & 4 deletions preptools/core/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

from iconsdk.builder.call_builder import CallBuilder
from iconsdk.builder.transaction_builder import CallTransactionBuilder
from iconsdk.exception import KeyStoreException
from iconsdk.exception import KeyStoreException, DataTypeException
from iconsdk.icon_service import IconService
from iconsdk.providers.http_provider import HTTPProvider
from iconsdk.signed_transaction import SignedTransaction
from iconsdk.wallet.wallet import KeyWallet

from preptools.exception import InvalidKeyStoreException, InvalidFileReadException
from preptools.exception import InvalidKeyStoreException, InvalidFileReadException, InvalidDataTypeException
from ..utils.constants import EOA_ADDRESS, ZERO_ADDRESS, COLUMN
from ..utils.preptools_config import get_default_config
from ..utils.utils import print_title, print_dict, get_url
Expand Down Expand Up @@ -142,10 +142,16 @@ def _call(self, method, params=None) -> dict:
return self._icon_service.call(call, True)

def _tx_result(self, tx_hash):
return self._icon_service.get_transaction_result(tx_hash, True)
try:
return self._icon_service.get_transaction_result(tx_hash, True)
except DataTypeException:
raise InvalidDataTypeException("This hash value is unrecognized.")

def _tx_by_hash(self, tx_hash):
return self._icon_service.get_transaction(tx_hash, True)
try:
return self._icon_service.get_transaction(tx_hash, True)
except DataTypeException:
raise InvalidDataTypeException("This hash value is unrecognized.")

def get_prep(self, address: str) -> dict:
params = {"address": address}
Expand Down
7 changes: 7 additions & 0 deletions preptools/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PRepToolsExceptionCode(IntEnum):
FILE_WRITE_ERROR = 3
FILE_READ_ERROR = 4
KEYSTORE_ERROR = 5
DATA_TYPE_ERROR = 6

def __str__(self) -> str:
return str(self.name).capitalize().replace('_', ' ')
Expand Down Expand Up @@ -81,3 +82,9 @@ class InvalidKeyStoreException(PRepToolsBaseException):
"""Invalid Keystore"""
def __init__(self, message: Optional[str]):
super().__init__(message, PRepToolsExceptionCode.KEYSTORE_ERROR)


class InvalidDataTypeException(PRepToolsBaseException):
"""Invalid Keystore"""
def __init__(self, message: Optional[str]):
super().__init__(message, PRepToolsExceptionCode.DATA_TYPE_ERROR)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup_options = {
'name': 'preptools',
'version': '0.0.1',
'version': '1.0.0',
'description': 'Test suite for ICON SCORE development',
'author': 'ICON Foundation',
'author_email': 'foo@icon.foundation',
Expand Down

0 comments on commit 8b8a80c

Please sign in to comment.