Skip to content

Commit

Permalink
fix panic where coin type is too long (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenyang007 authored Mar 24, 2024
1 parent f536b28 commit e20ecb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,18 @@ impl FungibleAssetActivity {
addr: standardize_address(event_key.account_address.as_str()),
creation_num: event_key.creation_number as i64,
};
let coin_type =
event_to_coin_type
.get(&event_move_guid)
.unwrap_or_else(|| {
panic!(
"Could not find event in resources (CoinStore), version: {}, event guid: {:?}, mapping: {:?}",
txn_version, event_move_guid, event_to_coin_type
)
}).clone();
// Given this mapping only contains coin type < 1000 length, we should not assume that the mapping exists.
// If it doesn't exist, skip.
let coin_type = match event_to_coin_type.get(&event_move_guid) {
Some(coin_type) => coin_type.clone(),
None => {
tracing::warn!(
"Could not find event in resources (CoinStore), version: {}, event guid: {:?}, mapping: {:?}",
txn_version, event_move_guid, event_to_coin_type
);
return Ok(None);
},
};
let storage_id =
CoinInfoType::get_storage_id(coin_type.as_str(), event_move_guid.addr.as_str());
Ok(Some(Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl FungibleAssetBalance {
}

/// Getting coin balances from resources for v1
/// If the fully qualified coin type is too long (currently 1000 length), we exclude from indexing
pub fn get_v1_from_write_resource(
write_resource: &WriteResource,
write_set_change_index: i64,
Expand Down

0 comments on commit e20ecb2

Please sign in to comment.