@@ -9,13 +9,15 @@ use aptos_config::config::{ApiConfig, DEFAULT_MAX_PAGE_SIZE};
9
9
use aptos_logger:: prelude:: * ;
10
10
use aptos_node:: AptosNodeArgs ;
11
11
use aptos_rosetta:: { bootstrap, common:: native_coin, types:: Currency } ;
12
+ use aptos_sdk:: move_types:: language_storage:: StructTag ;
12
13
use aptos_types:: chain_id:: ChainId ;
13
14
use clap:: Parser ;
14
15
use std:: {
15
16
collections:: HashSet ,
16
17
fs:: File ,
17
18
net:: SocketAddr ,
18
19
path:: PathBuf ,
20
+ str:: FromStr ,
19
21
sync:: {
20
22
atomic:: { AtomicBool , Ordering } ,
21
23
Arc ,
@@ -243,9 +245,28 @@ impl ServerArgs for OfflineArgs {
243
245
if let Some ( ref filepath) = self . currency_config_file {
244
246
let file = File :: open ( filepath) . unwrap ( ) ;
245
247
let currencies: Vec < Currency > = serde_json:: from_reader ( file) . unwrap ( ) ;
246
- currencies. into_iter ( ) . for_each ( |item| {
247
- supported_currencies. insert ( item) ;
248
- } ) ;
248
+ for item in currencies. into_iter ( ) {
249
+ // Do a safety check on possible currencies on startup
250
+ if item. symbol . as_str ( ) == "" {
251
+ warn ! (
252
+ "Currency {:?} has an empty symbol, and is being skipped" ,
253
+ item
254
+ ) ;
255
+ } else if let Some ( metadata) = item. metadata . as_ref ( ) {
256
+ if let Some ( move_type) = metadata. move_type . as_ref ( ) {
257
+ if StructTag :: from_str ( move_type) . is_ok ( ) {
258
+ supported_currencies. insert ( item) ;
259
+ continue ;
260
+ }
261
+ }
262
+ warn ! (
263
+ "Currency {:?} has an invalid metadata coin type, and is being skipped" ,
264
+ item
265
+ ) ;
266
+ } else {
267
+ supported_currencies. insert ( item) ;
268
+ }
269
+ }
249
270
}
250
271
251
272
supported_currencies
0 commit comments