11import os
22import json
3+ from typing import Optional
4+
35import requests
46
57from bitpay .utils .key_utils import *
68from bitpay .exceptions .bitpay_exception import BitPayException
79
810# Will be set to Test otherwise
911private_key_name = "private_key.pem" # Add here the name for your Private key
10- private_key_path = os .path .join (os .path .abspath (os .curdir ), private_key_name )
12+ private_key_path : Optional [str ] = os .path .join (
13+ os .path .abspath (os .curdir ), private_key_name
14+ )
1115plain_private_key = None
1216proxy = None
1317api_url = None
1620payout_token = None
1721
1822
19- def select_env ():
23+ def select_env () -> None :
2024 global environment
2125 try :
2226 print ("Select target environment: " )
@@ -29,21 +33,21 @@ def select_env():
2933 else :
3034 select_env ()
3135
32- set_environment (environment )
36+ set_environment (environment ) # type: ignore
3337 select_create_key ()
3438 except BitPayException as exe :
3539 print (exe )
3640
3741
38- def set_environment (env ) :
42+ def set_environment (env : str ) -> None :
3943 global api_url
4044 if env == "Test" :
4145 api_url = "https://test.bitpay.com"
4246 else :
4347 api_url = "https://bitpay.com"
4448
4549
46- def select_create_key ():
50+ def select_create_key () -> None :
4751 try :
4852 input_value = input (
4953 "Press enter to generate a brand new key or enter your private key location:"
@@ -56,15 +60,15 @@ def select_create_key():
5660 print (exe )
5761
5862
59- def create_new_key ():
63+ def create_new_key () -> None :
6064 try :
61- private_key = generate_pem ()
65+ private_key = generate_pem () # type: ignore
6266 store_key (private_key )
6367 except BitPayException as exe :
6468 print (exe )
6569
6670
67- def store_key (private_key ) :
71+ def store_key (private_key : str ) -> None :
6872 global plain_private_key , private_key_path
6973 try :
7074 print ("Select the way you want to store your private key:" )
@@ -89,7 +93,7 @@ def store_key(private_key):
8993 print (exe )
9094
9195
92- def select_tokens (private_key ) :
96+ def select_tokens (private_key : str ) -> None :
9397 try :
9498 print ("Select the tokens that you would like to request:" )
9599 input_value = input ("Press M for merchant, P for payout, or B for both: \n " )
@@ -102,12 +106,12 @@ def select_tokens(private_key):
102106 print (exe )
103107
104108
105- def request_tokens (token_type , private_key ) :
109+ def request_tokens (token_type : str , private_key : str ) -> None :
106110 global merchant_token
107111 global payout_token
108112
109113 try :
110- sin = get_sin_from_pem (private_key )
114+ sin = get_sin_from_pem (private_key ) # type: ignore
111115 url = "%s/tokens" % api_url
112116 headers = {"content-type" : "application/json" , "X-accept-version" : "2.0.0" }
113117
@@ -148,7 +152,7 @@ def request_tokens(token_type, private_key):
148152 print (exe )
149153
150154
151- def update_config_file ():
155+ def update_config_file () -> None :
152156 try :
153157 config = {
154158 "BitPayConfiguration" : {
@@ -187,7 +191,7 @@ def update_config_file():
187191 print (exe )
188192
189193
190- def load_key ():
194+ def load_key () -> None :
191195 # TODO: Need to implement this function
192196 pass
193197
0 commit comments