-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into get-node-configs
- Loading branch information
Showing
14 changed files
with
400 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Provide implementation of the command line interface's public key commands. | ||
""" | ||
import sys | ||
|
||
import click | ||
from remme import Remme | ||
|
||
from cli.constants import ( | ||
FAILED_EXIT_FROM_COMMAND_CODE, | ||
NODE_URL_ARGUMENT_HELP_MESSAGE, | ||
) | ||
from cli.public_key.forms import GetPublicKeysForm | ||
from cli.public_key.help import ADDRESS_ARGUMENT_HELP_MESSAGE | ||
from cli.public_key.service import PublicKey | ||
from cli.utils import ( | ||
default_node_url, | ||
print_errors, | ||
print_result, | ||
) | ||
|
||
|
||
@click.group('public-key', chain=True) | ||
def public_key_commands(): | ||
""" | ||
Provide commands for working with public key. | ||
""" | ||
pass | ||
|
||
|
||
@click.option('--address', type=str, required=True, help=ADDRESS_ARGUMENT_HELP_MESSAGE) | ||
@click.option('--node-url', type=str, required=False, help=NODE_URL_ARGUMENT_HELP_MESSAGE, default=default_node_url()) | ||
@public_key_commands.command('get-list') | ||
def get_public_keys(address, node_url): | ||
""" | ||
Get a list of the addresses of the public keys by account address. | ||
""" | ||
arguments, errors = GetPublicKeysForm().load({ | ||
'address': address, | ||
'node_url': node_url, | ||
}) | ||
|
||
if errors: | ||
print_errors(errors) | ||
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE) | ||
|
||
address = arguments.get('address') | ||
node_url = arguments.get('node_url') | ||
|
||
remme = Remme(network_config={ | ||
'node_address': str(node_url) + ':8080', | ||
}) | ||
|
||
result, errors = PublicKey(service=remme).get_list(address=address) | ||
|
||
if errors is not None: | ||
print_errors(errors=errors) | ||
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE) | ||
|
||
print_result(result=result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Provide forms for command line interface's public key commands. | ||
""" | ||
from marshmallow import Schema | ||
|
||
from cli.generic.forms.fields import ( | ||
AccountAddressField, | ||
NodeURLField, | ||
) | ||
|
||
|
||
class GetPublicKeysForm(Schema): | ||
""" | ||
Get a list of the addresses of the public keys form. | ||
""" | ||
|
||
address = AccountAddressField(required=True) | ||
node_url = NodeURLField(allow_none=True, required=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
Provide help messages for command line interface's public key commands. | ||
""" | ||
ADDRESS_ARGUMENT_HELP_MESSAGE = 'Account address to get a list of the addresses of the public keys by.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Provide implementation of the public key interfaces. | ||
""" | ||
|
||
|
||
class PublicKeyInterface: | ||
""" | ||
Implements public key interface. | ||
""" | ||
|
||
def get_list(self, address): | ||
""" | ||
Get a list of the addresses of the public keys by account address. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Provide implementation of the public key. | ||
""" | ||
import asyncio | ||
|
||
from accessify import implements | ||
|
||
from cli.public_key.interfaces import PublicKeyInterface | ||
|
||
loop = asyncio.get_event_loop() | ||
|
||
|
||
@implements(PublicKeyInterface) | ||
class PublicKey: | ||
""" | ||
Implements public key. | ||
""" | ||
|
||
def __init__(self, service): | ||
""" | ||
Constructor. | ||
Arguments: | ||
service: object to interact with Remme core API. | ||
""" | ||
self.service = service | ||
|
||
def get_list(self, address): | ||
""" | ||
Get a list of the addresses of the public keys by account address. | ||
""" | ||
try: | ||
public_key_addresses = loop.run_until_complete( | ||
self.service.public_key_storage.get_account_public_keys(address=address), | ||
) | ||
|
||
except Exception as error: | ||
return None, str(error) | ||
|
||
return { | ||
'public_key_addresses': public_key_addresses, | ||
}, None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.