Skip to content

Commit

Permalink
Precompute native token asset types to increase chances of decoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
murisi committed Feb 3, 2025
1 parent d9ef9fc commit 5778606
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion crates/apps_lib/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,12 @@ async fn query_shielded_balance(
{
let mut shielded = context.shielded_mut().await;
let _ = shielded.load().await;
// Precompute asset types to increase chances of success in decoding
let token_map = context.wallet().await.get_addresses();
let mut tokens: BTreeSet<_> = token_map.values().collect();
tokens.insert(&token);
let _ = shielded
.precompute_asset_types(context.client(), vec![&token])
.precompute_asset_types(context.client(), tokens)
.await;
// Save the update state so that future fetches can be short-circuited
let _ = shielded.save().await;
Expand Down
2 changes: 1 addition & 1 deletion crates/shielded_token/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ where
let mut current_convs = BTreeMap::<
(Address, Denomination, MaspDigitPos),
AllowedConversion,
>::new();
>::new();
// Native token inflation values are always with respect to this
let ref_inflation = calculate_masp_rewards_precision::<S, TransToken>(
storage,
Expand Down
2 changes: 1 addition & 1 deletion crates/shielded_token/src/masp/shielded_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ pub trait ShieldedApi<U: ShieldedUtils + MaybeSend + MaybeSync>:
async fn precompute_asset_types<C: Client + Sync>(
&mut self,
client: &C,
tokens: Vec<&Address>,
tokens: BTreeSet<&Address>,
) -> Result<(), eyre::Error> {
// To facilitate lookups of human-readable token names
for token in tokens {
Expand Down
4 changes: 2 additions & 2 deletions crates/shielded_token/src/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ where

// Note the balance changes they imply
let ChangedBalances {
unepoched_tokens: tokens,
unepoched_tokens,
decoder,
pre,
post,
Expand All @@ -438,7 +438,7 @@ where
keys_changed,
)?;
Ok(ChangedBalances {
unepoched_tokens: tokens,
unepoched_tokens,
decoder,
pre,
post,
Expand Down

0 comments on commit 5778606

Please sign in to comment.