@@ -9,9 +9,6 @@ defmodule KeyStoreApi.V1.KeyStoreController do
9
9
10
10
plug ( OpenApiSpex.Plug.CastAndValidate , json_render_error_v2: true )
11
11
12
- @ keystore_dir Keystore . get_keystore_dir ( )
13
- @ keystore_pass_dir Keystore . get_keystore_pass_dir ( )
14
-
15
12
# NOTE: this function is required by OpenApiSpex, and should return the information
16
13
# of each specific endpoint. We just return the specific entry from the parsed spec.
17
14
def open_api_operation ( :get_keys ) ,
@@ -60,8 +57,8 @@ defmodule KeyStoreApi.V1.KeyStoreController do
60
57
base_name = keystore . pubkey |> Utils . hex_encode ( )
61
58
62
59
# This overrides any existing credential with the same pubkey.
63
- File . write! ( get_keystore_file_path ( base_name ) , keystore_str )
64
- File . write! ( get_keystore_pass_file_path ( base_name ) , password_str )
60
+ File . write! ( Keystore . keystore_file ( base_name ) , keystore_str )
61
+ File . write! ( Keystore . keystore_pass_file ( base_name ) , password_str )
65
62
Libp2pPort . add_validator ( keystore )
66
63
67
64
% {
@@ -87,10 +84,10 @@ defmodule KeyStoreApi.V1.KeyStoreController do
87
84
88
85
results =
89
86
Enum . map ( body_params . pubkeys , fn pubkey ->
90
- with { :ok , pubkey } <- Utils . hex_decode ( pubkey ) ,
91
- :ok <- Libp2pPort . delete_validator ( pubkey ) do
92
- File . rm! ( get_keystore_file_path ( pubkey ) )
93
- File . rm! ( get_keystore_pass_file_path ( pubkey ) )
87
+ with { :ok , decoded_pubkey } <- Utils . hex_decode ( pubkey ) ,
88
+ :ok <- Libp2pPort . delete_validator ( decoded_pubkey ) do
89
+ File . rm! ( Keystore . keystore_file ( pubkey ) )
90
+ File . rm! ( Keystore . keystore_pass_file ( pubkey ) )
94
91
95
92
% {
96
93
status: "deleted" ,
@@ -112,9 +109,4 @@ defmodule KeyStoreApi.V1.KeyStoreController do
112
109
"data" => results
113
110
} )
114
111
end
115
-
116
- defp get_keystore_file_path ( base_name ) , do: Path . join ( @ keystore_dir , base_name <> ".json" )
117
-
118
- defp get_keystore_pass_file_path ( base_name ) ,
119
- do: Path . join ( @ keystore_pass_dir , base_name <> ".txt" )
120
112
end
0 commit comments