@@ -2123,55 +2123,67 @@ pub async fn query_conversions(
2123
2123
. wallet ( )
2124
2124
. await
2125
2125
. get_addresses_with_vp_type ( AddressVpType :: Token ) ;
2126
- let conversions = rpc:: query_conversions ( context. client ( ) )
2127
- . await
2128
- . expect ( "Conversions should be defined" ) ;
2129
-
2130
- if args. dump_tree {
2131
- display_line ! ( context. io( ) , "Conversions: {conversions:?}" ) ;
2132
- }
2133
-
2126
+ // Determine the range of relevant MASP epochs
2127
+ let epoch_range = if let Some ( target_epoch) = & args. epoch {
2128
+ MaspEpoch :: iter_bounds_inclusive ( * target_epoch, * target_epoch)
2129
+ } else {
2130
+ let from = MaspEpoch :: zero ( ) ;
2131
+ let to = rpc:: query_masp_epoch ( context. client ( ) )
2132
+ . await
2133
+ . expect ( "Unable to query current MASP epoch" ) ;
2134
+ MaspEpoch :: iter_bounds_inclusive ( from, to)
2135
+ } ;
2134
2136
// Track whether any non-sentinel conversions are found
2135
2137
let mut conversions_found = false ;
2136
- for ( addr , _denom , digit , epoch , amt ) in conversions . values ( ) {
2137
- // If the user has specified any targets, then meet them
2138
- // If we have a sentinel conversion, then skip printing
2139
- if matches ! ( & target_token , Some ( target ) if target != addr )
2140
- || matches ! ( & args . epoch , Some ( target ) if target != epoch )
2141
- || amt . is_zero ( )
2142
- {
2143
- continue ;
2138
+ // Query the conversions for each relevant epoch
2139
+ for epoch in epoch_range {
2140
+ let conversions = rpc :: query_conversions ( context . client ( ) , & epoch )
2141
+ . await
2142
+ . expect ( "Conversions should be defined" ) ;
2143
+
2144
+ if args . dump_tree {
2145
+ display_line ! ( context . io ( ) , "Conversions: {conversions:?}" ) ;
2144
2146
}
2145
- conversions_found = true ;
2146
- // Print the asset to which the conversion applies
2147
- display ! (
2148
- context. io( ) ,
2149
- "{}*2^{}[{}]: " ,
2150
- tokens. get( addr) . cloned( ) . unwrap_or_else( || addr. clone( ) ) ,
2151
- * digit as u8 * 64 ,
2152
- epoch,
2153
- ) ;
2154
- // Now print out the components of the allowed conversion
2155
- let mut prefix = "" ;
2156
- for ( asset_type, val) in amt. components ( ) {
2157
- // Look up the address and epoch of asset to facilitate pretty
2158
- // printing
2159
- let ( addr, _denom, digit, epoch, _) = & conversions[ asset_type] ;
2160
- // Now print out this component of the conversion
2147
+
2148
+ for ( addr, _denom, digit, amt) in conversions. values ( ) {
2149
+ // If the user has specified any targets, then meet them
2150
+ // If we have a sentinel conversion, then skip printing
2151
+ if matches ! ( & target_token, Some ( target) if target != addr)
2152
+ || amt. is_zero ( )
2153
+ {
2154
+ continue ;
2155
+ }
2156
+ conversions_found = true ;
2157
+ // Print the asset to which the conversion applies
2161
2158
display ! (
2162
2159
context. io( ) ,
2163
- "{}{} {}*2^{}[{}]" ,
2164
- prefix,
2165
- val,
2160
+ "{}*2^{}[{}]: " ,
2166
2161
tokens. get( addr) . cloned( ) . unwrap_or_else( || addr. clone( ) ) ,
2167
2162
* digit as u8 * 64 ,
2168
- epoch
2163
+ epoch,
2169
2164
) ;
2170
- // Future iterations need to be prefixed with +
2171
- prefix = " + " ;
2165
+ // Now print out the components of the allowed conversion
2166
+ let mut prefix = "" ;
2167
+ for ( asset_type, val) in amt. components ( ) {
2168
+ // Look up the address and epoch of asset to facilitate pretty
2169
+ // printing
2170
+ let ( addr, _denom, digit, _) = & conversions[ asset_type] ;
2171
+ // Now print out this component of the conversion
2172
+ display ! (
2173
+ context. io( ) ,
2174
+ "{}{} {}*2^{}[{}]" ,
2175
+ prefix,
2176
+ val,
2177
+ tokens. get( addr) . cloned( ) . unwrap_or_else( || addr. clone( ) ) ,
2178
+ * digit as u8 * 64 ,
2179
+ epoch
2180
+ ) ;
2181
+ // Future iterations need to be prefixed with +
2182
+ prefix = " + " ;
2183
+ }
2184
+ // Allowed conversions are always implicit equations
2185
+ display_line ! ( context. io( ) , " = 0" ) ;
2172
2186
}
2173
- // Allowed conversions are always implicit equations
2174
- display_line ! ( context. io( ) , " = 0" ) ;
2175
2187
}
2176
2188
if !conversions_found {
2177
2189
display_line ! (
0 commit comments