Skip to content
Snippets Groups Projects
Commit 51bcc060 authored by Moul's avatar Moul
Browse files

[mypy] #163: Add type annotation on cert

parent 1b4f3486
No related branches found
No related tags found
No related merge requests found
......@@ -14,10 +14,13 @@
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import sys
from typing import Dict
import click
from duniterpy.api import bma
from duniterpy.documents import BlockID, Certification, Identity, get_block_id
from duniterpy.api.client import Client
from duniterpy.documents import Block, BlockID, Certification, Identity, get_block_id
from duniterpy.key import SigningKey
from pendulum import from_timestamp, now
from tabulate import tabulate
......@@ -34,12 +37,12 @@ from silkaj.network_tools import client_instance, send_document
@click.command("cert", help="Send certification")
@click.argument("uid_pubkey_to_certify")
@click.pass_context
def send_certification(ctx, uid_pubkey_to_certify):
def send_certification(ctx: click.Context, uid_pubkey_to_certify: str) -> None:
client = client_instance()
checked_pubkey = is_pubkey_and_check(uid_pubkey_to_certify)
if checked_pubkey:
uid_pubkey_to_certify = checked_pubkey
uid_pubkey_to_certify = str(checked_pubkey)
idty_to_certify, pubkey_to_certify, send_certs = wot.choose_identity(
uid_pubkey_to_certify
......@@ -79,7 +82,7 @@ def send_certification(ctx, uid_pubkey_to_certify):
send_document(bma.wot.certify, certification)
def pre_checks(client, issuer_pubkey, pubkey_to_certify):
def pre_checks(client: Client, issuer_pubkey: str, pubkey_to_certify: str) -> Dict:
# Check whether current user is member
issuer = wt.is_member(issuer_pubkey)
if not issuer:
......@@ -90,8 +93,8 @@ def pre_checks(client, issuer_pubkey, pubkey_to_certify):
# Check if the certification can be renewed
params = get_blockchain_parameters()
req = client(bma.wot.requirements, pubkey_to_certify)
req = req["identities"][0]
requirements = client(bma.wot.requirements, pubkey_to_certify)
req = requirements["identities"][0] # type: Dict
for cert in req["certifications"]:
if cert["from"] == issuer_pubkey:
# Ğ1: 0<–>2y - 2y + 2m
......@@ -109,8 +112,12 @@ def pre_checks(client, issuer_pubkey, pubkey_to_certify):
def certification_confirmation(
ctx, issuer, issuer_pubkey, pubkey_to_certify, idty_to_certify
):
ctx: click.Context,
issuer: Dict,
issuer_pubkey: str,
pubkey_to_certify: str,
idty_to_certify: Dict,
) -> None:
cert = list()
cert.append(["Cert", "Issuer", "–>", "Recipient: Published: #block-hash date"])
client = client_instance()
......@@ -138,8 +145,13 @@ def certification_confirmation(
def docs_generation(
currency, pubkey_to_certify, idty_to_certify, issuer_pubkey, head, key
):
currency: str,
pubkey_to_certify: str,
idty_to_certify: Dict,
issuer_pubkey: str,
head: Block,
key: SigningKey,
) -> Certification:
identity = Identity(
pubkey=pubkey_to_certify,
uid=idty_to_certify["uid"],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment