Skip to content

Commit e377e7f

Browse files
committed
The MASP conversions query now requires a MASP epoch to be specified.
1 parent c10115c commit e377e7f

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

crates/apps_lib/src/client/rpc.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,16 +2123,28 @@ pub async fn query_conversions(
21232123
.wallet()
21242124
.await
21252125
.get_addresses_with_vp_type(AddressVpType::Token);
2126-
let conversions = rpc::query_conversions(context.client())
2126+
2127+
// Download conversions from all epochs to facilitate decoding asset types
2128+
let mut conversions = BTreeMap::new();
2129+
let from = MaspEpoch::zero();
2130+
let to = rpc::query_masp_epoch(context.client())
21272131
.await
2128-
.expect("Conversions should be defined");
2132+
.expect("Unable to query current MASP epoch");
2133+
for epoch in MaspEpoch::iter_bounds_inclusive(from, to) {
2134+
conversions.append(
2135+
&mut rpc::query_conversions(context.client(), &epoch)
2136+
.await
2137+
.expect("Conversions should be defined"),
2138+
);
2139+
}
21292140

21302141
if args.dump_tree {
21312142
display_line!(context.io(), "Conversions: {conversions:?}");
21322143
}
21332144

21342145
// Track whether any non-sentinel conversions are found
21352146
let mut conversions_found = false;
2147+
21362148
for (addr, _denom, digit, epoch, amt) in conversions.values() {
21372149
// If the user has specified any targets, then meet them
21382150
// If we have a sentinel conversion, then skip printing

crates/sdk/src/queries/shell.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ router! {SHELL,
9898
( "conv" / [asset_type: AssetType] ) -> Option<Conversion> = read_conversion,
9999

100100
// Conversion state access - read conversion
101-
( "conversions" ) -> BTreeMap<AssetType, ConversionWithoutPath> = read_conversions,
101+
( "conversions" / [masp_epoch: MaspEpoch] ) -> BTreeMap<AssetType, ConversionWithoutPath> = read_conversions,
102102

103103
// Conversion state access - read conversion
104104
( "masp_reward_tokens" ) -> Vec<MaspTokenRewardData> = masp_reward_tokens,
@@ -211,6 +211,7 @@ where
211211
/// Query to read the conversion state
212212
fn read_conversions<D, H, V, T>(
213213
ctx: RequestCtx<'_, D, H, V, T>,
214+
masp_epoch: MaspEpoch,
214215
) -> namada_storage::Result<BTreeMap<AssetType, ConversionWithoutPath>>
215216
where
216217
D: 'static + DB + for<'iter> DBIter<'iter> + Sync,
@@ -222,6 +223,7 @@ where
222223
.conversion_state
223224
.assets
224225
.iter()
226+
.filter(|&(_, asset)| (asset.epoch == masp_epoch))
225227
.map(|(&asset_type, asset)| {
226228
(
227229
asset_type,

crates/sdk/src/rpc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ pub async fn query_conversion<C: namada_io::Client + Sync>(
390390
/// Query conversions
391391
pub async fn query_conversions<C: namada_io::Client + Sync>(
392392
client: &C,
393+
masp_epoch: &MaspEpoch,
393394
) -> Result<
394395
BTreeMap<
395396
AssetType,
@@ -403,7 +404,9 @@ pub async fn query_conversions<C: namada_io::Client + Sync>(
403404
>,
404405
error::Error,
405406
> {
406-
convert_response::<C, _>(RPC.shell().read_conversions(client).await)
407+
convert_response::<C, _>(
408+
RPC.shell().read_conversions(client, masp_epoch).await,
409+
)
407410
}
408411

409412
/// Query the total rewards minted by MASP

0 commit comments

Comments
 (0)