@@ -33,18 +33,20 @@ namespace fc::cli::_node {
33
33
using storage::ipfs::ApiIpfsDatastore;
34
34
using vm::message::UnsignedMessage;
35
35
using vm::state::StateTreeImpl;
36
+ using vm::message::SignedMessage;
37
+ using api::MsgWait;
36
38
37
39
struct walletNew : Empty {
38
40
CLI_RUN () {
39
- Node::Api api{argm};
41
+ const Node::Api api{argm};
40
42
std::string type = " secp256k1" ;
41
43
42
44
if (argv.size () == 1 ) {
43
45
type = std::string{cliArgv<std::string>(
44
46
argv, 0 , " [bls|secp256k1 (default secp256k1)]" )};
45
47
}
46
48
47
- Address address =
49
+ const Address address =
48
50
cliTry (api._ ->WalletNew (type), " Creating new wallet..." );
49
51
50
52
fmt::print (" {}" , encodeToString (address));
@@ -65,13 +67,13 @@ namespace fc::cli::_node {
65
67
return opts;
66
68
}
67
69
};
68
- CLI_RUN () {
69
- Node::Api api{argm};
70
+ CLI_RUN () { // TODO express
71
+ const Node::Api api{argm};
70
72
71
- std::vector<Address> addresses =
73
+ const std::vector<Address> addresses =
72
74
cliTry (api._ ->WalletList (), " Getting list of wallets..." );
73
75
74
- Address default_address = cliTry (api._ ->WalletDefaultAddress (),
76
+ const Address default_address = cliTry (api._ ->WalletDefaultAddress (),
75
77
" Getting default address of wallet..." );
76
78
77
79
TableWriter table_writer =
@@ -84,13 +86,13 @@ namespace fc::cli::_node {
84
86
TableWriter::newColumn (" Default" ),
85
87
TableWriter::newColumn (" Error" )});
86
88
87
- for (Address &address : addresses) {
89
+ for (const Address &address : addresses) {
88
90
if (args.address_only ) {
89
91
fmt::print (" {}\n " , encodeToString (address));
90
92
} else {
91
93
auto maybe_actor = api._ ->StateGetActor (
92
94
address, TipsetKey{}); // TODO this place input on console log of
93
- // error. It isn`t correct
95
+
94
96
Actor actor;
95
97
if (maybe_actor.has_error ()) {
96
98
TipsetCPtr chain_head =
@@ -110,7 +112,7 @@ namespace fc::cli::_node {
110
112
if (not actor_exist.has_value ()) {
111
113
table_writer.write (
112
114
{{" Address" , encodeToString (address)},
113
- {" Error" , " Error" }}); // TODO add description of error
115
+ {" Error" , " Error get actor " }});
114
116
continue ;
115
117
}
116
118
actor = maybe_actor.value ();
@@ -160,14 +162,13 @@ namespace fc::cli::_node {
160
162
161
163
struct walletBalance : Empty {
162
164
CLI_RUN () {
163
- Node::Api api{argm};
164
- Address address;
165
- address = (argv.size () == 1 )
165
+ const Node::Api api{argm};
166
+ const Address address = (argv.size () == 1 )
166
167
? (Address{cliArgv<Address>(argv, 0 , " address" )})
167
168
: cliTry (api._ ->WalletDefaultAddress (),
168
169
" Getting default address..." );
169
170
170
- TokenAmount balance =
171
+ const TokenAmount balance =
171
172
cliTry (api._ ->WalletBalance (address), " Getting balance of wallet..." );
172
173
173
174
if (balance == 0 ) {
@@ -192,39 +193,39 @@ namespace fc::cli::_node {
192
193
}
193
194
};
194
195
CLI_RUN () {
195
- Node::Api api{argm};
196
+ const Node::Api api{argm};
196
197
197
- Address address_from = (args.from ) ? args.from . _ . value ()
198
+ const Address address_from = (args.from ) ? * args.from
198
199
: cliTry (api._ ->WalletDefaultAddress (),
199
200
" Getting default address..." );
200
- Address address_to{cliArgv<Address>(argv, 0 , " Address to add balance" )};
201
- TokenAmount amount{
201
+ const Address address_to{cliArgv<Address>(argv, 0 , " Address to add balance" )};
202
+ const TokenAmount amount{
202
203
cliArgv<TokenAmount>(argv, 1 , " Amount of add balance" )};
203
204
204
- auto signed_message = cliTry (api._ ->MpoolPushMessage (
205
+ const SignedMessage signed_message = cliTry (api._ ->MpoolPushMessage (
205
206
vm::message::UnsignedMessage (
206
207
address_to, address_from, 0 , amount, 0 , *args.gas_limit , 0 , {}),
207
208
boost::none));
208
209
209
- auto message_wait =
210
+ const MsgWait message_wait =
210
211
cliTry (api._ ->StateWaitMsg (signed_message.getCid (), 1 , 10 , false ),
211
212
" Wait message" );
212
213
}
213
214
};
214
215
215
216
struct walletDefault : Empty {
216
217
CLI_RUN () {
217
- Node::Api api{argm};
218
- Address default_address =
218
+ const Node::Api api{argm};
219
+ const Address default_address =
219
220
cliTry (api._ ->WalletDefaultAddress (), " Getting default address..." );
220
221
fmt::print (" {}" , encodeToString (default_address));
221
222
}
222
223
};
223
224
224
225
struct walletSetDefault : Empty {
225
226
CLI_RUN () {
226
- Node::Api api{argm};
227
- Address address{cliArgv<Address>(argv, 0 , " Address for set as default" )};
227
+ const Node::Api api{argm};
228
+ const Address address{cliArgv<Address>(argv, 0 , " Address for set as default" )};
228
229
229
230
cliTry (api._ ->WalletSetDefault (address), " Setting default address" );
230
231
}
@@ -247,17 +248,16 @@ namespace fc::cli::_node {
247
248
}
248
249
};
249
250
CLI_RUN () {
250
- Node::Api api{argm};
251
+ const Node::Api api{argm};
251
252
252
253
if (*args.format != " hex-lotus" && *args.format != " json-lotus" ) {
253
254
throw CliError (" unrecognized or unsupported format: " + *args.format );
254
255
}
255
256
256
- std::string path;
257
- if (argv.size () == 1 ) {
258
- path = {cliArgv<std::string>(
259
- argv, 0 , " <path> (optional, will read from stdin if omitted)" )};
260
- }
257
+ const std::string path = (argv.size () == 1 ) ?
258
+ cliArgv<std::string>(
259
+ argv, 0 , " <path> (optional, will read from stdin if omitted)" ) : " " ;
260
+
261
261
262
262
Bytes input_data;
263
263
@@ -283,10 +283,10 @@ namespace fc::cli::_node {
283
283
" Unhex data..." );
284
284
}
285
285
286
- auto json = cliTry (codec::json::parse (input_data), " Parse json data..." );
286
+ const auto json = cliTry (codec::json::parse (input_data), " Parse json data..." );
287
287
key_info = cliTry (api::decode<KeyInfo>(json), " Decoding json..." );
288
288
289
- Address address =
289
+ const Address address =
290
290
cliTry (api._ ->WalletImport (key_info), " Importing key..." );
291
291
292
292
if (args.as_default ) {
@@ -299,32 +299,32 @@ namespace fc::cli::_node {
299
299
300
300
struct walletSign : Empty {
301
301
CLI_RUN () {
302
- Node::Api api{argm};
303
- Address signing_address{cliArgv<Address>(argv, 0 , " Signing address" )};
304
- std::string hex_message{cliArgv<std::string>(argv, 0 , " Hex message" )};
302
+ const Node::Api api{argm};
303
+ const Address signing_address{cliArgv<Address>(argv, 0 , " Signing address" )};
304
+ const std::string hex_message{cliArgv<std::string>(argv, 0 , " Hex message" )};
305
305
306
- auto decode_message =
306
+ const Bytes decode_message =
307
307
cliTry (unhex (hex_message), " Decoding hex message..." );
308
- auto signed_message =
308
+ const Signature signature =
309
309
cliTry (api._ ->WalletSign (signing_address, decode_message),
310
310
" Signing message..." );
311
311
312
- std::cout << hex_lower (signed_message .toBytes ()) << ' \n ' ;
312
+ fmt::print ( " {} \n " , hex_lower (signature .toBytes ())) ;
313
313
}
314
314
};
315
315
316
316
struct walletVerify : Empty {
317
317
CLI_RUN () {
318
- Node::Api api{argm};
319
- Address signing_address{cliArgv<Address>(argv, 0 , " Signing address" )};
320
- std::string hex_message{cliArgv<std::string>(argv, 1 , " Hex message" )};
321
- std::string signature{cliArgv<std::string>(argv, 2 , " Signature" )};
318
+ const Node::Api api{argm};
319
+ const Address signing_address{cliArgv<Address>(argv, 0 , " Signing address" )};
320
+ const std::string hex_message{cliArgv<std::string>(argv, 1 , " Hex message" )};
321
+ const std::string signature{cliArgv<std::string>(argv, 2 , " Signature" )};
322
322
323
- auto decode_message = cliTry (unhex (hex_message), " Decoding message..." );
323
+ const Bytes decode_message = cliTry (unhex (hex_message), " Decoding message..." );
324
324
325
- auto signing_bytes = cliTry (unhex (signature), " Decoding signature..." );
325
+ const Bytes signing_bytes = cliTry (unhex (signature), " Decoding signature..." );
326
326
327
- auto signature_from_bytes = cliTry (Signature::fromBytes (signing_bytes),
327
+ const Signature signature_from_bytes = cliTry (Signature::fromBytes (signing_bytes),
328
328
" Getting signature from bytes..." );
329
329
bool flagOk = cliTry (api._ ->WalletVerify (
330
330
signing_address, decode_message, signature_from_bytes));
@@ -338,8 +338,8 @@ namespace fc::cli::_node {
338
338
339
339
struct walletDelete : Empty {
340
340
CLI_RUN () {
341
- Node::Api api{argm};
342
- Address address{cliArgv<Address>(argv, 0 , " Address for delete" )};
341
+ const Node::Api api{argm};
342
+ const Address address{cliArgv<Address>(argv, 0 , " Address for delete" )};
343
343
344
344
cliTry (api._ ->WalletDelete (address), " Deleting address..." );
345
345
}
@@ -366,26 +366,23 @@ namespace fc::cli::_node {
366
366
}
367
367
};
368
368
CLI_RUN () {
369
- Node::Api api{argm};
370
- TokenAmount amt{cliArgv<TokenAmount>(argv, 0 , " Amount" )};
371
- Address address_from = (args.from ? (args.from . _ . value () )
369
+ const Node::Api api{argm};
370
+ const TokenAmount amt{cliArgv<TokenAmount>(argv, 0 , " Amount" )};
371
+ const Address address_from = (args.from ? (* args.from )
372
372
: cliTry (api._ ->WalletDefaultAddress (),
373
373
" Getting default address..." ));
374
374
375
- Address address = address_from;
376
- if (args.address ) {
377
- address = args.address ._ .value ();
378
- }
375
+ const Address address = (args.address ) ? *args.address : address_from;
379
376
380
377
fmt::print (
381
378
" Submitting Add Balance message for amount {} for address {}\n " ,
382
379
amt,
383
380
encodeToString (address));
384
381
385
- auto smsg = cliTry (api._ ->MarketAddBalance (address_from, address, amt),
382
+ const auto cid_signed_message = cliTry (api._ ->MarketAddBalance (address_from, address, amt),
386
383
" Add balance..." );
387
384
388
- fmt::print (" Add balance message cid : {}\n " , smsg .value ());
385
+ fmt::print (" Add balance message cid : {}\n " , cid_signed_message .value ());
389
386
}
390
387
};
391
388
} // namespace fc::cli::_node
0 commit comments