Skip to content

Commit

Permalink
[rosetta] Remove supported currencies with an empty symbol (#14973)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnazario authored Oct 16, 2024
1 parent fa4d47c commit c8511eb
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions crates/aptos-rosetta/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ use aptos_config::config::{ApiConfig, DEFAULT_MAX_PAGE_SIZE};
use aptos_logger::prelude::*;
use aptos_node::AptosNodeArgs;
use aptos_rosetta::{bootstrap, common::native_coin, types::Currency};
use aptos_sdk::move_types::language_storage::StructTag;
use aptos_types::chain_id::ChainId;
use clap::Parser;
use std::{
collections::HashSet,
fs::File,
net::SocketAddr,
path::PathBuf,
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
Expand Down Expand Up @@ -243,9 +245,28 @@ impl ServerArgs for OfflineArgs {
if let Some(ref filepath) = self.currency_config_file {
let file = File::open(filepath).unwrap();
let currencies: Vec<Currency> = serde_json::from_reader(file).unwrap();
currencies.into_iter().for_each(|item| {
supported_currencies.insert(item);
});
for item in currencies.into_iter() {
// Do a safety check on possible currencies on startup
if item.symbol.as_str() == "" {
warn!(
"Currency {:?} has an empty symbol, and is being skipped",
item
);
} else if let Some(metadata) = item.metadata.as_ref() {
if let Some(move_type) = metadata.move_type.as_ref() {
if StructTag::from_str(move_type).is_ok() {
supported_currencies.insert(item);
continue;
}
}
warn!(
"Currency {:?} has an invalid metadata coin type, and is being skipped",
item
);
} else {
supported_currencies.insert(item);
}
}
}

supported_currencies
Expand Down

0 comments on commit c8511eb

Please sign in to comment.