@@ -67,31 +67,23 @@ namespace fc::api {
67
67
return std::move (address);
68
68
}};
69
69
api->WalletList = [=]() -> outcome::result<std::vector<Address>> {
70
- OUTCOME_TRY (all, key_store->list ());
71
- std::sort (all.begin (), all.end ());
70
+ OUTCOME_TRY (addresses, key_store->list ());
72
71
73
72
std::set<Address> seen;
74
- std::vector<Address> out;
75
- out.reserve (all.size ());
76
73
77
- std::string k_name_prefix = " wallet-" ; // TODO not needed
78
- for (auto &a : all) {
79
- fmt::print (encodeToString (a));
80
- // if (encodeToString(a).substr(0, k_name_prefix.size())
81
- // == k_name_prefix) {
82
- // std::string name = encodeToString(a).erase(0,
83
- // k_name_prefix.size());
74
+ for (const Address &address_temp : addresses) {
84
75
OUTCOME_TRY (address,
85
- primitives::address::decodeFromString (encodeToString (a )));
86
- if (seen.find (address) ! = seen.end ()) {
87
- continue ;
76
+ primitives::address::decodeFromString (encodeToString (address_temp )));
77
+ if (seen.find (address) = = seen.end ()) {
78
+ seen. insert (address) ;
88
79
}
89
- seen.insert (address);
90
-
91
- out.push_back (address);
92
80
}
93
81
94
- std::sort (out.begin (), out.end ());
82
+ std::vector<Address> out;
83
+ while (not seen.empty ())
84
+ {
85
+ out.emplace_back (std::move (seen.extract (seen.begin ()).value ()));
86
+ }
95
87
96
88
return out;
97
89
};
@@ -119,10 +111,6 @@ namespace fc::api {
119
111
OUTCOME_TRY (has, key_store->has (address));
120
112
if (has) {
121
113
OUTCOME_TRY (key_store->remove (address));
122
- // OUTCOME_TRY(default_address, api->WalletDefaultAddress());
123
- // if (address == default_address) {
124
- // wallet_default_address->remove();
125
- // }
126
114
return outcome::success ();
127
115
}
128
116
return ERROR_TEXT (" WalletDelete: Address does not exist" );
0 commit comments