@@ -28,92 +28,68 @@ pub enum Error {
2828
2929#[ cfg( feature = "additional-libs" ) ]
3030mod secure_store_impl {
31- use super :: * ;
31+ use super :: { Error , Print , PublicKey , SeedPhrase , StellarEntry , ENTRY_PREFIX } ;
3232 const ENTRY_SERVICE : & str = "org.stellar.cli" ;
3333
34- pub fn get_public_key (
35- entry_name : & str ,
36- index : Option < usize > ,
37- ) -> Result < PublicKey , Error > {
34+ pub fn get_public_key ( entry_name : & str , index : Option < usize > ) -> Result < PublicKey , Error > {
3835 let entry = StellarEntry :: new ( entry_name) ?;
3936 Ok ( entry. get_public_key ( index) ?)
4037 }
41-
42- pub fn delete_secret (
43- print : & Print ,
44- entry_name : & str ,
45- ) -> Result < ( ) , Error > {
38+
39+ pub fn delete_secret ( print : & Print , entry_name : & str ) -> Result < ( ) , Error > {
4640 let entry = StellarEntry :: new ( entry_name) ?;
47- entry. delete_seed_phrase ( print) ?;
48-
49- Ok ( ( ) )
41+ Ok ( entry. delete_seed_phrase ( print) ?)
5042 }
51-
43+
5244 pub fn save_secret (
5345 print : & Print ,
5446 entry_name : & str ,
55- seed_phrase : SeedPhrase ,
47+ seed_phrase : & SeedPhrase ,
5648 ) -> Result < String , Error > {
5749 // secure_store:org.stellar.cli:<key name>
58- let entry_name_with_prefix = format ! (
59- "{}{}-{}" ,
60- ENTRY_PREFIX ,
61- ENTRY_SERVICE ,
62- entry_name
63- ) ;
64-
65- //checking that the entry name is valid before writing to the secure store
66- // let secret = entry_name_with_prefix.parse()?;
67- // without this, we end up saving to the keychain without verifying that it is a valid secret name. FIXME
50+ let entry_name_with_prefix = format ! ( "{ENTRY_PREFIX}{ENTRY_SERVICE}-{entry_name}" ) ;
6851
6952 let entry = StellarEntry :: new ( & entry_name_with_prefix) ?;
70- entry. write ( seed_phrase, print) ?;
53+ entry. write ( seed_phrase. clone ( ) , print) ?;
7154
72- return Ok ( entry_name_with_prefix)
55+ Ok ( entry_name_with_prefix)
7356 }
74-
57+
7558 pub fn sign_tx_data (
7659 entry_name : & str ,
7760 hd_path : Option < usize > ,
7861 data : & [ u8 ] ,
7962 ) -> Result < Vec < u8 > , Error > {
8063 let entry = StellarEntry :: new ( entry_name) ?;
81- return Ok ( entry. sign_data ( data, hd_path) ?)
64+ Ok ( entry. sign_data ( data, hd_path) ?)
8265 }
8366}
8467
8568#[ cfg( not( feature = "additional-libs" ) ) ]
8669mod secure_store_impl {
87- use super :: * ;
70+ use super :: { Error , Print , PublicKey , SeedPhrase } ;
8871
89- pub fn get_public_key (
90- _entry_name : & str ,
91- _index : Option < usize > ,
92- ) -> Result < PublicKey , Error > {
93- return Err ( Error :: FeatureNotEnabled ) ;
72+ pub fn get_public_key ( _entry_name : & str , _index : Option < usize > ) -> Result < PublicKey , Error > {
73+ Err ( Error :: FeatureNotEnabled )
9474 }
95-
96- pub fn delete_secret (
97- _print : & Print ,
98- _entry_name : & str ,
99- ) -> Result < ( ) , Error > {
100- return Err ( Error :: FeatureNotEnabled ) ;
75+
76+ pub fn delete_secret ( _print : & Print , _entry_name : & str ) -> Result < ( ) , Error > {
77+ Err ( Error :: FeatureNotEnabled )
10178 }
102-
79+
10380 pub fn save_secret (
10481 _print : & Print ,
10582 _entry_name : & str ,
106- _seed_phrase : SeedPhrase ,
83+ _seed_phrase : & SeedPhrase ,
10784 ) -> Result < String , Error > {
108- return Err ( Error :: FeatureNotEnabled ) ;
85+ Err ( Error :: FeatureNotEnabled )
10986 }
110-
87+
11188 pub fn sign_tx_data (
11289 _entry_name : & str ,
11390 _hd_path : Option < usize > ,
11491 _data : & [ u8 ] ,
11592 ) -> Result < Vec < u8 > , Error > {
116- return Err ( Error :: FeatureNotEnabled ) ;
93+ Err ( Error :: FeatureNotEnabled )
11794 }
11895}
119-
0 commit comments