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

Release v0.4.0: node account info, list of blocks, batch status by identifier commands #55

Merged
merged 61 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
459d095
Create skeleton of the project (#1)
dmytrostriletskyi Apr 9, 2019
43bdfa0
Create development Dockerfile (#4)
dmytrostriletskyi Apr 11, 2019
c82ddc6
Add Python 3.6 and 3.7 as requirement for library usage (#5)
dmytrostriletskyi Apr 11, 2019
d2aa9d6
Get the balance of the account by its address implementation (#3)
dmytrostriletskyi Apr 11, 2019
2d0c391
Add PyPi version to the CI (#6)
dmytrostriletskyi Apr 11, 2019
64a3554
Add contribution docs section (#8)
dmytrostriletskyi Apr 12, 2019
15818bf
Bump pytest from 4.4.0 to 4.4.1 (#9)
dependabot[bot] Apr 16, 2019
6a312f8
Create configurations implementation (#10)
anastasiia-bilova Apr 16, 2019
09a98df
Create dictionary to pretty json util (#14)
dmytrostriletskyi Apr 17, 2019
5be9279
Bump pytest-mock from 1.10.3 to 1.10.4 (#19)
dependabot[bot] Apr 21, 2019
a8cef2a
Solve weekly technical debt (#13)
dmytrostriletskyi Apr 22, 2019
fcf353a
Refactor account CLI commands and implementation (#26)
dmytrostriletskyi Apr 23, 2019
789714a
Bump remme package version from 1.0.0 to 1.1.0a1 (#27)
dmytrostriletskyi Apr 23, 2019
0278639
Implement transfer tokens to address (#23)
dmytrostriletskyi Apr 24, 2019
850d3a3
REM-1366: Integrate configuration file reading to the commands (#21)
anastasiia-bilova Apr 24, 2019
ef7ecd5
Get list of the public keys by account address on which these keys de…
anastasiia-bilova Apr 24, 2019
e036a9c
Implement getting node configurations (#25)
dmytrostriletskyi Apr 25, 2019
95605f6
Add a brand new node IP address, change checking to regexp (#31)
dmytrostriletskyi Apr 26, 2019
358d37f
Implement getting node's peers (#29)
dmytrostriletskyi Apr 26, 2019
bc3ba52
Implement getting node private key (#30)
dmytrostriletskyi Apr 26, 2019
079d447
Get information about public key by public key address (#17)
anastasiia-bilova May 2, 2019
a0c768f
Get Atomic Swap public key (#20)
anastasiia-bilova May 2, 2019
b2371d8
Integrate sort requirements and imports, pytest inits linters (#32)
dmytrostriletskyi May 2, 2019
a5ed649
Solve weekly technical debt (#35)
dmytrostriletskyi May 2, 2019
698daf4
Bump pypi-version from 0.1.0 to 0.2.0 (#33)
dependabot[bot] May 2, 2019
89c3279
Bump isort from 4.3.17 to 4.3.18 (#34)
dependabot[bot] May 2, 2019
9db7de7
Merge branch 'master' into develop
dmytrostriletskyi May 2, 2019
b56301a
Bump PyPi package version of the project to 0.2.0
dmytrostriletskyi May 2, 2019
666eb09
Implement get a list of the transactions and fetch particular transac…
Alladin9393 May 3, 2019
f7852ff
REM-1312: Get particular Atomic Swap information by its identifier (#24)
anastasiia-bilova May 6, 2019
5d11f13
Create command line interface for method get node information, add te…
anastasiia-bilova May 7, 2019
bb56429
Create command line interface for method get state (#38)
Alladin9393 May 8, 2019
f533eac
Merge branch 'master' into develop
dmytrostriletskyi May 8, 2019
50bf56e
Bump project version to v0.3.0
dmytrostriletskyi May 8, 2019
583691b
Implement fetching single block (#11)
dmytrostriletskyi May 8, 2019
4d89cf0
REM-1297: Fetch particular batch by identifier (#7)
Art17 May 8, 2019
034e4c6
Add complete requirements for Ubuntu (#41)
dmytrostriletskyi May 8, 2019
cc3ea01
Bump pytest from 4.4.1 to 4.4.2 (#44)
dependabot[bot] May 9, 2019
71d53cc
Add requirements for usage on MacOS (#46)
dmytrostriletskyi May 10, 2019
9e00903
Implement getting transaction receipts (#42)
anastasiia-bilova May 10, 2019
661a393
Implement getting node account information (#40)
anastasiia-bilova May 10, 2019
fe48493
REM-1307: Get particular batch status by identifier (#15)
Art17 May 10, 2019
2e4c83b
Implement getting initial stake of the node (#45)
anastasiia-bilova May 10, 2019
2f79f46
REM-1296: Get list of the batches (#12)
Art17 May 14, 2019
d854036
Actualize blockchain data in tests according to new testing node (#52)
dmytrostriletskyi May 15, 2019
c609d08
Bump pytest from 4.4.2 to 4.5.0 (#48)
dependabot[bot] May 15, 2019
cc1f8f9
Bump isort from 4.3.18 to 4.3.20 (#54)
dependabot[bot] May 15, 2019
9e9d6fc
Implement getting only the list of transaction identifiers (#53)
anastasiia-bilova May 15, 2019
8f7c87a
Implement getting list of blocks CLI command (#39)
dmytrostriletskyi May 16, 2019
3c18461
REM-1313: Implement getting only identifiers of batches (#51)
Art17 May 16, 2019
83a1fd9
Implement getting blocks identifiers (#50)
dmytrostriletskyi May 16, 2019
e9bdfc5
Implement list of states CLI command (#49)
Alladin9393 May 17, 2019
c7c29c1
Solve weekly technical debt (#56)
anastasiia-bilova May 20, 2019
d974669
Bump radon from 3.0.1 to 3.0.3 (#57)
dependabot[bot] May 20, 2019
afe8e3a
Merge branch 'master' into develop
dmytrostriletskyi May 20, 2019
c0539f4
Remove redefinition of unused get method
dmytrostriletskyi May 20, 2019
38caa3a
Update node IP address for testing
dmytrostriletskyi May 20, 2019
5da6192
Remove unused old node IP address for testing
dmytrostriletskyi May 20, 2019
b0b3d5d
Fix merging develop to master in case of old code
dmytrostriletskyi May 20, 2019
948abe4
Update test_get_list_transactions.py
dmytrostriletskyi May 20, 2019
f771659
Bump project version from 0.3.0 to 0.4.0
dmytrostriletskyi May 20, 2019
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
578 changes: 545 additions & 33 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cli/account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GetAccountBalanceForm(Schema):
"""

address = AccountAddressField(required=True)
node_url = NodeUrlField(required=False)
node_url = NodeUrlField(required=True)


class TransferTokensForm(Schema):
Expand All @@ -37,4 +37,4 @@ class TransferTokensForm(Schema):
validate.Range(min=1, error='Amount must be greater than 0.'),
],
)
node_url = NodeUrlField(required=False)
node_url = NodeUrlField(required=True)
2 changes: 1 addition & 1 deletion cli/atomic_swap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def atomic_swap_commands():
@atomic_swap_commands.command('get-public-key')
def get_public_key(node_url):
"""
Get public key of atomic swap.
Get the public key of atomic swap.
"""
arguments, errors = GetAtomicSwapPublicKeyForm().load({
'node_url': node_url,
Expand Down
6 changes: 3 additions & 3 deletions cli/atomic_swap/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class GetAtomicSwapInformationForm(Schema):
"""

id = SwapIdentifierField(required=True)
node_url = NodeUrlField(required=False)
node_url = NodeUrlField(required=True)


class GetAtomicSwapPublicKeyForm(Schema):
"""
Get public key of the atomic swap form.
Get the public key of the atomic swap form.
"""

node_url = NodeUrlField(required=False)
node_url = NodeUrlField(required=True)
2 changes: 1 addition & 1 deletion cli/atomic_swap/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AtomicSwapInterface:

def get_public_key(self):
"""
Get public key of atomic swap.
Get the public key of atomic swap.
"""
pass

Expand Down
2 changes: 1 addition & 1 deletion cli/atomic_swap/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, service):

def get_public_key(self):
"""
Get public key of atomic swap.
Get the public key of atomic swap.
"""
try:
public_key = loop.run_until_complete(self.service.swap.get_public_key())
Expand Down
File renamed without changes.
159 changes: 159 additions & 0 deletions cli/batch/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
"""
Provide implementation of the command line interface's batch commands.
"""
import sys

import click
from remme import Remme

from cli.batch.forms import (
GetBatchesListForm,
GetBatchForm,
GetBatchStatusForm,
)
from cli.batch.help import (
BATCH_IDENTIFIER_ARGUMENT_HELP_MESSAGE,
BATCH_STATUS_IDENTIFIER_ARGUMENT_HELP_MESSAGE,
BATCHES_HEAD_ARGUMENT_HELP_MESSAGE,
BATCHES_IDENTIFIERS_ARGUMENT_HELP_MESSAGE,
BATCHES_IDENTIFIERS_ONLY_ARGUMENT_HELP_MESSAGE,
BATCHES_LIMIT_ARGUMENT_HELP_MESSAGE,
BATCHES_REVERSE_ARGUMENT_HELP_MESSAGE,
BATCHES_START_ARGUMENT_HELP_MESSAGE,
)
from cli.batch.service import Batch
from cli.constants import (
FAILED_EXIT_FROM_COMMAND_CODE,
NODE_URL_ARGUMENT_HELP_MESSAGE,
)
from cli.utils import (
default_node_url,
print_errors,
print_result,
)


@click.group('batch', chain=True)
def batch_commands():
"""
Provide commands for working with batch.
"""
pass


@click.option('--id', required=True, type=str, help=BATCH_IDENTIFIER_ARGUMENT_HELP_MESSAGE)
@click.option('--node-url', required=False, type=str, help=NODE_URL_ARGUMENT_HELP_MESSAGE, default=default_node_url())
@batch_commands.command('get')
def get_batch(id, node_url):
"""
Get a batch by its identifier.
"""
arguments, errors = GetBatchForm().load({
'id': id,
'node_url': node_url,
})

if errors:
print_errors(errors=errors)
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

batch_id = arguments.get('id')
node_url = arguments.get('node_url')

remme = Remme(network_config={
'node_address': str(node_url) + ':8080',
})

batch, errors = Batch(service=remme).get(id=batch_id)

if errors is not None:
print_errors(errors=errors)
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

print_result(result=batch)


@click.option('--id', required=True, type=str, help=BATCH_STATUS_IDENTIFIER_ARGUMENT_HELP_MESSAGE)
@click.option('--node-url', required=False, type=str, help=NODE_URL_ARGUMENT_HELP_MESSAGE, default=default_node_url())
@batch_commands.command('get-status')
def get_batch_status(id, node_url):
"""
Get a batch status by its identifier.
"""
arguments, errors = GetBatchStatusForm().load({
'id': id,
'node_url': node_url,
})

if errors:
print_errors(errors=errors)
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

batch_id = arguments.get('id')
node_url = arguments.get('node_url')

remme = Remme(network_config={
'node_address': str(node_url) + ':8080',
})

result, errors = Batch(service=remme).get_status(id=batch_id)

if errors is not None:
print_errors(errors=errors)
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

print_result(result=result)


@click.option('--ids', required=False, type=str, help=BATCHES_IDENTIFIERS_ARGUMENT_HELP_MESSAGE)
@click.option('--start', required=False, type=str, help=BATCHES_START_ARGUMENT_HELP_MESSAGE)
@click.option('--limit', required=False, type=int, help=BATCHES_LIMIT_ARGUMENT_HELP_MESSAGE)
@click.option('--head', required=False, type=str, help=BATCHES_HEAD_ARGUMENT_HELP_MESSAGE)
@click.option('--reverse', required=False, is_flag=True, help=BATCHES_REVERSE_ARGUMENT_HELP_MESSAGE)
@click.option('--ids-only', required=False, is_flag=True, help=BATCHES_IDENTIFIERS_ONLY_ARGUMENT_HELP_MESSAGE)
@click.option('--node-url', required=False, type=str, help=NODE_URL_ARGUMENT_HELP_MESSAGE, default=default_node_url())
@batch_commands.command('get-list')
def get_batches(ids, start, limit, head, reverse, ids_only, node_url):
"""
Get a list of batches.
"""
arguments, errors = GetBatchesListForm().load({
'ids': ids,
'start': start,
'limit': limit,
'head': head,
'reverse': reverse,
'ids_only': ids_only,
'node_url': node_url,
})

if errors:
print_errors(errors=errors)
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

batch_ids = arguments.get('ids')
start = arguments.get('start')
limit = arguments.get('limit')
head = arguments.get('head')
reverse = arguments.get('reverse')
ids_only = arguments.get('ids_only')
node_url = arguments.get('node_url')

remme = Remme(network_config={
'node_address': str(node_url) + ':8080',
})

if ids_only:
result, errors = Batch(service=remme).get_list_ids(
ids=batch_ids, start=start, limit=limit, head=head, reverse=reverse,
)
else:
result, errors = Batch(service=remme).get_list(
ids=batch_ids, start=start, limit=limit, head=head, reverse=reverse,
)

if errors is not None:
print_errors(errors=errors)
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

print_result(result=result)
53 changes: 53 additions & 0 deletions cli/batch/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
Provide forms for command line interface's batch commands.
"""
from marshmallow import (
Schema,
fields,
validate,
)

from cli.generic.forms.fields import (
BatchIdentifierField,
BatchIdentifiersListField,
NodeUrlField,
)


class GetBatchForm(Schema):
"""
Get a batch by its identifier form.
"""

id = BatchIdentifierField(required=True)
node_url = NodeUrlField(required=True)


class GetBatchStatusForm(Schema):
"""
Get a batch status by its identifier form.
"""

id = BatchIdentifierField(required=True)
node_url = NodeUrlField(required=True)


class GetBatchesListForm(Schema):
"""
Get a list of batches form.
"""

ids = BatchIdentifiersListField(allow_none=True, required=False)
start = BatchIdentifierField(allow_none=True, required=False)
head = BatchIdentifierField(allow_none=True, required=False)
limit = fields.Integer(
allow_none=True,
strict=True,
required=False,
validate=[
validate.Range(min=1, error='Limit must be greater than 0.'),
],
)
reverse = fields.Boolean(required=False)
ids_only = fields.Boolean(required=False)
node_url = NodeUrlField(required=True)
11 changes: 11 additions & 0 deletions cli/batch/help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Provide help messages for command line interface's batch commands.
"""
BATCH_IDENTIFIER_ARGUMENT_HELP_MESSAGE = 'Identifier to get a batch by.'
BATCH_STATUS_IDENTIFIER_ARGUMENT_HELP_MESSAGE = 'Identifier to get a batch status by.'
BATCHES_IDENTIFIERS_ARGUMENT_HELP_MESSAGE = 'Identifiers to get a list of batches by.'
BATCHES_START_ARGUMENT_HELP_MESSAGE = 'Batch identifier to get a list of batches starting from.'
BATCHES_LIMIT_ARGUMENT_HELP_MESSAGE = 'Maximum amount of batches to return.'
BATCHES_HEAD_ARGUMENT_HELP_MESSAGE = 'Block identifier to get a list of batches to.'
BATCHES_REVERSE_ARGUMENT_HELP_MESSAGE = 'Parameter to reverse result.'
BATCHES_IDENTIFIERS_ONLY_ARGUMENT_HELP_MESSAGE = 'The flag to get a list of batches\' identifiers.'
59 changes: 59 additions & 0 deletions cli/batch/interfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
Provide implementation of the batch interfaces.
"""


class BatchInterface:
"""
Implements batch interface.
"""

def get(self, id):
"""
Get a batch by its identifier.

Arguments:
id (string, required): batch identifier.
"""
pass

def get_status(self, id):
"""
Get a batch status by its identifier.

Arguments:
id (string, required): batch identifier.
"""
pass

def get_list(self, ids, start, limit, head, reverse):
"""
Get a list of batches.

A list of batches could be filtered by batch identifiers, start identifier, limit, head identifier,
reverse.

Arguments:
ids (list, optional): identifiers to get a list of batches by.
start (string, optional): batch identifier to get a list of batches starting from.
limit (int, optional): maximum amount of batches to return.
head (string, optional): block identifier to get a list of batches from.
reverse (bool, optional): parameter to reverse result.
"""
pass

def get_list_ids(self, ids, start, limit, head, reverse):
"""
Get a list of batches' identifiers.

A list of batch identifiers could be filtered by batch identifiers, start identifier, limit, head identifier,
reverse.

Arguments:
ids (list, optional): identifiers to get a list of batches by.
start (string, optional): batch identifier to get a list of batches starting from.
limit (int, optional): maximum amount of batches to return.
head (string, optional): block identifier to get a list of batches from.
reverse (bool, optional): parameter to reverse result.
"""
pass
Loading