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

Prepare for release #11

Merged
merged 14 commits into from Sep 10, 2019
4 changes: 4 additions & 0 deletions .gitignore
@@ -1,3 +1,7 @@
venv
.idea
.coverage
__pycache__
build/
dist/
py_factom_did.egg-info/
7 changes: 4 additions & 3 deletions .travis.yml
@@ -1,13 +1,14 @@
language: python
matrix:
include:
- python: 3.5
- python: 3.6
- python: 3.7
dist: xenial
sudo: true
install:
- pip install pipenv
- pipenv install
- pipenv install -d --pre
script:
- pytest
- pytest --cov=./did/
after_success:
- coveralls
2 changes: 2 additions & 0 deletions Pipfile
Expand Up @@ -7,6 +7,8 @@ verify_ssl = true
pytest = "*"
black = "*"
pre-commit = "*"
pytest-cov = "*"
coveralls = "*"

[packages]
pycryptodome = "*"
Expand Down
102 changes: 98 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 20 additions & 7 deletions README.md
@@ -1,3 +1,8 @@
[![Build Status](https://travis-ci.org/factomatic/py-factom-did.svg?branch=master)](https://travis-ci.org/factomatic/py-factom-did)
[![Coverage Status](https://coveralls.io/repos/github/factomatic/py-factom-did/badge.svg?branch=prepare-for-release)](https://coveralls.io/github/factomatic/py-factom-did?branch=prepare-for-release)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

# py-factom-did

py-factom-did is a Python library, allowing the creation of a Decentralized Identifier (DID) and
Expand All @@ -12,35 +17,43 @@ The library enables:
* encrypting the newly created keys

You can find an example of the library workflow in the `examples/` directory. In order to run the
example, please note that it is necessary to create an environment variable called `EC_ADDR`, which
contains a funded EC address to pay the fees for recording the DID on-chain.
example, please note that it is necessary to:

* have local instances of `factomd` and `factom-walletd` running
* create an environment variable called `EC_ADDR`, which contains a funded EC
address to pay the fees for recording the DID on-chain

## Installation
```
pip install py-factom-did
```

## Build

* Clone the repo

* Create the virtual environment and install the dependencies:
```
pipenv install
pipenv install
```

or
```
pipenv install --pre -d
pipenv install --pre -d
```
to install both the default and development dependencies

* Activate the virtual environment:
```
pipenv shell
pipenv shell
```

* Execute the tests:
```
pytest
pytest
```

* Execute the example:
```
python -m examples.example
python -m examples.example
```
14 changes: 10 additions & 4 deletions did/did.py
Expand Up @@ -23,7 +23,7 @@

ENTRY_SCHEMA_VERSION = "1.0.0"
DID_METHOD_NAME = "did:factom"
DID_METHOD_SPEC_VERSION = "0.1.0"
DID_METHOD_SPEC_VERSION = "0.2.0"
ENTRY_SIZE_LIMIT = 10275


Expand All @@ -36,7 +36,7 @@ def __init__(self):
self.used_key_aliases = set()
self.used_service_aliases = set()

def add_management_key(
def management_key(
self,
alias,
priority,
Expand Down Expand Up @@ -83,7 +83,9 @@ def add_management_key(
)
)

def add_did_key(
return self

def did_key(
self,
alias,
purpose,
Expand Down Expand Up @@ -129,7 +131,9 @@ def add_did_key(
)
)

def add_service(self, alias, service_type, endpoint, priority_requirement=None):
return self

def service(self, alias, service_type, endpoint, priority_requirement=None):
"""
Adds a new service to the DID Document.

Expand All @@ -156,6 +160,8 @@ def add_service(self, alias, service_type, endpoint, priority_requirement=None):
ServiceModel(alias, service_type, endpoint, priority_requirement)
)

return self

def export_entry_data(self):
"""
Exports content that can be recorded on-chain to create the DID.
Expand Down
4 changes: 2 additions & 2 deletions did/encryptor.py
Expand Up @@ -8,8 +8,8 @@
__all__ = [
"encrypt_keys",
"decrypt_keys_from_str",
"decrypt_keys_from_json",
"decrypt_keys_from_ui_store_file",
"decrypt_keys_from_json_str",
"decrypt_keys_from_json_file",
]


Expand Down