Skip to content

Commit

Permalink
Release v0.3.0: get transaction and transactions, atomic swap info, n…
Browse files Browse the repository at this point in the history
…ode info and state commands (#43)
  • Loading branch information
dmytrostriletskyi authored May 8, 2019
1 parent 41280e4 commit a8a5079
Show file tree
Hide file tree
Showing 34 changed files with 2,043 additions and 38 deletions.
179 changes: 178 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
* [Requirements](#getting-started-requirements)
* [Installation](#installation)
* [Usage](#usage)
* [Nodes](#nodes)
* [Configuration file](#configuration-file)
* [Service](#service)
* [Account](#account)
* [Atomic Swap](#atomic-swap)
* [Node](#node)
* [Public key](#public-key)
* [State](#state)
* [Transaction](#transaction)
* [Development](#development)
* [Requirements](#development-requirements)
* [Docker](#docker)
Expand Down Expand Up @@ -158,6 +160,36 @@ $ remme atomic-swap get-public-key --node-url=node-6-testnet.remme.io
}
```

Get information about atomic swap by its identifier — ``remme atomic-swap get-info``:

| Arguments | Type | Required | Description |
| :-------: | :----: | :------: | ------------------------------------------------- |
| id | String | Yes | Swap identifier to get information about swap by. |
| node-url | String | No | Node URL to apply a command to. |

```bash
$ remme atomic-swap get-info \
--id=033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808 \
--node-url=node-genesis-testnet.remme.io
{
"result": {
"information": {
"amount": "10.0000",
"created_at": 1556803765,
"email_address_encrypted_optional": "",
"is_initiator": false,
"receiver_address": "112007484def48e1c6b77cf784aeabcac51222e48ae14f3821697f4040247ba01558b1",
"secret_key": "",
"secret_lock": "0728356568862f9da0825aa45ae9d3642d64a6a732ad70b8857b2823dbf2a0b8",
"sender_address": "1120076ecf036e857f42129b58303bcf1e03723764a1702cbe98529802aad8514ee3cf",
"sender_address_non_local": "0xe6ca0e7c974f06471759e9a05d18b538c5ced11e",
"state": "OPENED",
"swap_id": "033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808"
}
}
}
```

### Node

Get node configurations — ``remme node get-configs``:
Expand Down Expand Up @@ -197,6 +229,24 @@ $ remme node get-peers --node-url=node-genesis-testnet.remme.io
}
```

Get node information — ``remme node get-info``:

| Arguments | Type | Required | Description |
| :-------: | :----: | :------: | ------------------------------- |
| node-url | String | No | Node URL to apply a command to. |

```bash
$ remme node get-info --node-url=node-27-testnet.remme.io
{
"result": {
"information": {
"is_synced": true,
"peer_count": 3
}
}
}
```

### Public key

Get a list of the addresses of the public keys by account address — ``remme public-key get-list``:
Expand Down Expand Up @@ -249,6 +299,133 @@ $ remme public-key get-info \
}
```

### State

Get a state by its address — ``remme state get``:

| Arguments | Type | Required | Description |
| :-------: | :----: | :------: | ---------------------------------- |
| address | String | Yes | Account address to get a state by. |
| node-url | String | No | Node URL to apply a command to. |

```bash
$ remme state get \
--address=000000a87cb5eafdcca6a8cde0fb0dec1400c5ab274474a6aa82c12840f169a04216b7 \
--node-url=node-6-testnet.remme.io
{
"result": {
"state": {
"data": "CmwKJnNhd3Rvb3RoLnNldHRpbmdzLnZvdGUuYXV0aG9yaXplZF9rZXlzEkIwMmE2NTc5NmYyNDkwOTFjMzA4NzYxNGI0ZDljMjkyYjAwYjhlYmE1ODBkMDQ1YWMyZmQ3ODEyMjRiODdiNmYxM2U=",
"head": "95d78133eb98628d5ff17c7d1972b9ab03e50fceeb8e199d98cb52078550f5473bb001e57c116238697bdc1958eaf6d5f096f7b66974e1ea46b9c9da694be9d9"
}
}
}
```

### Transaction

Get a list of transactions — ``remme transaction get-list``:

| Arguments | Type | Required | Description |
| :---------: | :----: | :-------: | ----------------------------------------------------- |
| ids | String | No | Identifiers to get a list of transactions by. |
| start | String | No | Transaction identifier to get a list transaction starting from.|
| limit | Integer| No | Maximum amount of transactions to return. |
| head | String | No | Block identifier to get a list of transactions from. |
| reverse | Bool | No | Parameter to reverse result. |
| node-url | String | No | Node URL to apply a command to. |
| family-name | String | No | List of transactions by its family name. |

```bash
$ remme transaction get-list \
--ids='568a1094e574747c757c1f5028d9b929105984e509c4f2f3cb76e5f46f03ca4c3681ca0eeca86a4bd4bb5a3eaaa52fd73b08ebc5d5d85fbb1957b064f8b71972,
d9b891d3efdd51cd47156ad2083bf5cabd5b35bb2ebe66813996d1a0f783e58721bbc50917ff284a40696f24058ef1e22e48600abf37d500ace78eadf7f4ecff' \
--start=568a1094e574747c757c1f5028d9b929105984e509c4f2f3cb76e5f46f03ca4c3681ca0eeca86a4bd4bb5a3eaaa52fd73b08ebc5d5d85fbb1957b064f8b71972 \
--limit=2 \
--head=39566f24561727f5ab2d19eb23612f1a38ff5f0cf9491caa0275261706a7cf8b080d38da0a38fa5b1cbef0cced889fdf6da679cc616a9711380f76b33e53efdf \
--reverse \
--family-name=account \
--node-url=node-6-testnet.remme.io
{
"result": {
"data": [
{
"header": {
"batcher_public_key": "03d4613540ce29cd1f5f28ea9169a5cb5853bd53dede635903af9383bc9ffaf079",
"dependencies": [],
"family_name": "account",
"family_version": "0.1",
"inputs": [
"112007db16c75019f59423da4de3cd5c79609989d7dc1697c9975307ea846e1d4af91f",
"1120076ecf036e857f42129b58303bcf1e03723764a1702cbe98529802aad8514ee3cf"
],
"nonce": "99ccdbcfeb008e2c8407870b7033117e316b4b12df4173f3e2ffd510676e524a77ac64a0b65e6c7889a797fbd4e4462830548f455497e2362dde1bbf35d5372f",
"outputs": [
"112007db16c75019f59423da4de3cd5c79609989d7dc1697c9975307ea846e1d4af91f",
"1120076ecf036e857f42129b58303bcf1e03723764a1702cbe98529802aad8514ee3cf"
],
"payload_sha512": "1f0313cb9cd67559c1d33d61104882b3ebca80dfcd091d5ae3b0ee99bd27723af591551dfeea43be05e2b24a2f9a54adc6c357b60fc5c5720b161c5ff9d10ae1",
"signer_public_key": "03738df3f4ac3621ba8e89413d3ff4ad036c3a0a4dbb164b695885aab6aab614ad"
},
"header_signature": "d9b891d3efdd51cd47156ad2083bf5cabd5b35bb2ebe66813996d1a0f783e58721bbc50917ff284a40696f24058ef1e22e48600abf37d500ace78eadf7f4ecff",
"payload": "CAASTQgAEkYxMTIwMDdkYjE2Yzc1MDE5ZjU5NDIzZGE0ZGUzY2Q1Yzc5NjA5OTg5ZDdkYzE2OTdjOTk3NTMwN2VhODQ2ZTFkNGFmOTFmGOgH"
}
],
"head": "39566f24561727f5ab2d19eb23612f1a38ff5f0cf9491caa0275261706a7cf8b080d38da0a38fa5b1cbef0cced889fdf6da679cc616a9711380f76b33e53efdf",
"paging": {
"limit": 2,
"next": "",
"start": "568a1094e574747c757c1f5028d9b929105984e509c4f2f3cb76e5f46f03ca4c3681ca0eeca86a4bd4bb5a3eaaa52fd73b08ebc5d5d85fbb1957b064f8b71972"
}
}
}
```

Get a transaction by identifier — ``remme transaction get``:

| Arguments | Type | Required | Description |
| :---------: | :----: | :-------: | -------------------------------- |
| id | String | Yes | Identifier to get transaction by. |
| node-url | String | No | Node URL to apply a command to. |

```bash
$ remme transaction get \
--id=64d032fbaae9bc59f9e5484ec6f52cbceef567923456039a26a1cfb8bc9ee2431ac2b5de43efce28ef11820a3734dab9fa56db57a1b2fbdc2323036cceeab6ab \
--node-url=node-6-testnet.remme.io
{
"result": {
"data": {
"header": {
"batcher_public_key": "03738df3f4ac3621ba8e89413d3ff4ad036c3a0a4dbb164b695885aab6aab614ad",
"dependencies": [],
"family_name": "consensus_account",
"family_version": "0.1",
"inputs": [
"116829",
"112007",
"0000007ca83d6bbb759da9cde0fb0dec1400c54773f137ea7cfe91e3b0c44298fc1c14",
"0000007ca83d6bbb759da9cde0fb0dec1400c5034223fb6c3e825ee3b0c44298fc1c14",
"0000007ca83d6bbb759da9cde0fb0dec1400c5e64de9aa6a37ac92e3b0c44298fc1c14",
"00b10c0100000000000000000000000000000000000000000000000000000000000000",
"00b10c00",
"fd0e4f0000000000000000000000000000000000000000000000000000000000000000"
],
"nonce": "b8baa6c54ab9463590627c18fb9c10ed",
"outputs": [
"116829",
"112007",
"fd0e4f0000000000000000000000000000000000000000000000000000000000000000"
],
"payload_sha512": "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
"signer_public_key": "03738df3f4ac3621ba8e89413d3ff4ad036c3a0a4dbb164b695885aab6aab614ad"
},
"header_signature": "64d032fbaae9bc59f9e5484ec6f52cbceef567923456039a26a1cfb8bc9ee2431ac2b5de43efce28ef11820a3734dab9fa56db57a1b2fbdc2323036cceeab6ab",
"payload": ""
}
}
}
```

## Development

<h3 id="development-requirements">Requirements</h4>
Expand Down
38 changes: 37 additions & 1 deletion cli/atomic_swap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import click
from remme import Remme

from cli.atomic_swap.forms import GetAtomicSwapPublicKeyForm
from cli.atomic_swap.forms import (
GetAtomicSwapInformationForm,
GetAtomicSwapPublicKeyForm,
)
from cli.atomic_swap.help import SWAP_IDENTIFIER_ARGUMENT_HELP_MESSAGE
from cli.atomic_swap.service import AtomicSwap
from cli.constants import (
FAILED_EXIT_FROM_COMMAND_CODE,
Expand Down Expand Up @@ -54,3 +58,35 @@ def get_public_key(node_url):
sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

print_result(result=result)


@click.option('--id', type=str, required=True, help=SWAP_IDENTIFIER_ARGUMENT_HELP_MESSAGE)
@click.option('--node-url', type=str, required=False, help=NODE_URL_ARGUMENT_HELP_MESSAGE, default=default_node_url())
@atomic_swap_commands.command('get-info')
def get_swap_info(id, node_url):
"""
Get information about atomic swap by its identifier.
"""
arguments, errors = GetAtomicSwapInformationForm().load({
'id': id,
'node_url': node_url,
})

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

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

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

result, errors = AtomicSwap(service=remme).get(swap_id=swap_id)

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

print_result(result=result)
14 changes: 13 additions & 1 deletion cli/atomic_swap/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@
"""
from marshmallow import Schema

from cli.generic.forms.fields import NodeUrlField
from cli.generic.forms.fields import (
NodeUrlField,
SwapIdentifierField,
)


class GetAtomicSwapInformationForm(Schema):
"""
Get information about atomic swap by its identifier form.
"""

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


class GetAtomicSwapPublicKeyForm(Schema):
Expand Down
1 change: 1 addition & 0 deletions cli/atomic_swap/help.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""
Provide help messages for command line interface's atomic swap commands.
"""
SWAP_IDENTIFIER_ARGUMENT_HELP_MESSAGE = 'Swap identifier to get information about swap by.'
6 changes: 6 additions & 0 deletions cli/atomic_swap/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ def get_public_key(self):
Get public key of atomic swap.
"""
pass

def get(self, swap_id):
"""
Get information about atomic swap by its identifier.
"""
pass
18 changes: 18 additions & 0 deletions cli/atomic_swap/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio

from accessify import implements
from aiohttp_json_rpc import RpcGenericServerDefinedError

from cli.atomic_swap.interfaces import AtomicSwapInterface

Expand Down Expand Up @@ -38,3 +39,20 @@ def get_public_key(self):
return {
'public_key': public_key,
}, None

def get(self, swap_id):
"""
Get information about atomic swap by its identifier.
"""
try:
swap_info = loop.run_until_complete(self.service.swap.get_info(swap_id=swap_id))

except RpcGenericServerDefinedError as error:
return None, str(error.message)

except Exception as error:
return None, str(error)

return {
'information': swap_info.data,
}, None
13 changes: 12 additions & 1 deletion cli/constants.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
"""
Provide constants for command line interface.
"""
from remme.models.utils.family_name import RemmeFamilyName

ADDRESS_REGEXP = r'^[0-9a-f]{70}$'
BATCH_ID_REGEXP = r'^[0-9a-f]{128}$'
PRIVATE_KEY_REGEXP = r'^[a-f0-9]{64}$'
PUBLIC_KEY_REGEXP = r'^[0-9a-f]{66}$'
PRIVATE_KEY_REGEXP = r'^[a-f0-9]{64}$'
PUBLIC_KEY_ADDRESS_REGEXP = r'^[0-9a-f]{70}$'
HEADER_SIGNATURE_REGEXP = r'^[0-9a-f]{128}$'
SWAP_IDENTIFIER_REGEXP = r'^[a-f0-9]{64}$'
TRANSACTION_HEADER_SIGNATURE_REGEXP = r'^[0-9a-f]{128}$'
DOMAIN_NAME_REGEXP = r'(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]'

PASSED_EXIT_FROM_COMMAND_CODE = 0
Expand All @@ -17,6 +21,13 @@

CLI_CONFIG_FILE_NAME = 'remme-core-cli'

FAMILY_NAMES = [
RemmeFamilyName.ACCOUNT.value,
RemmeFamilyName.NODE_ACCOUNT.value,
RemmeFamilyName.PUBLIC_KEY.value,
RemmeFamilyName.SWAP.value,
]

NODE_IP_ADDRESS_FOR_TESTING = '159.89.104.9'
LATEST_RELEASE_NODE_IP_ADDRESS_FOR_TESTING = '165.22.75.163'
RELEASE_0_9_0_ALPHA_NODE_ADDRESS = '165.227.169.119'
Expand Down
4 changes: 4 additions & 0 deletions cli/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from cli.atomic_swap.cli import atomic_swap_commands
from cli.node.cli import node_commands
from cli.public_key.cli import public_key_commands
from cli.state.cli import state_command
from cli.transaction.cli import transaction_command


@click.group()
Expand All @@ -23,3 +25,5 @@ def cli():
cli.add_command(atomic_swap_commands)
cli.add_command(node_commands)
cli.add_command(public_key_commands)
cli.add_command(state_command)
cli.add_command(transaction_command)
Loading

0 comments on commit a8a5079

Please sign in to comment.