@@ -1486,39 +1486,29 @@ pub async fn format_denominated_amount(
1486
1486
/// Look up IBC tokens. The given base token can be non-Namada token.
1487
1487
pub async fn query_ibc_tokens < N : Namada > (
1488
1488
context : & N ,
1489
- base_token : Option < String > ,
1490
1489
owner : Option < & Address > ,
1491
1490
) -> Result < BTreeMap < String , Address > , Error > {
1492
- // Check the base token
1493
- let prefixes = match ( base_token, owner) {
1494
- ( Some ( base_token) , Some ( owner) ) => vec ! [
1495
- ibc_trace_key_prefix( Some ( base_token) ) ,
1496
- ibc_trace_key_prefix( Some ( owner. to_string( ) ) ) ,
1497
- ] ,
1498
- ( Some ( base_token) , None ) => {
1499
- vec ! [ ibc_trace_key_prefix( Some ( base_token) ) ]
1500
- }
1501
- _ => {
1491
+ let prefix = match owner {
1492
+ Some ( owner) => ibc_trace_key_prefix ( Some ( owner. to_string ( ) ) ) ,
1493
+ None => {
1502
1494
// Check all IBC denoms because the owner might not know IBC token
1503
1495
// transfers in the same chain
1504
- vec ! [ ibc_trace_key_prefix( None ) ]
1496
+ ibc_trace_key_prefix ( None )
1505
1497
}
1506
1498
} ;
1507
1499
1508
1500
let mut tokens = BTreeMap :: new ( ) ;
1509
- for prefix in prefixes {
1510
- let ibc_traces =
1511
- query_storage_prefix :: < _ , String > ( context, & prefix) . await ?;
1512
- if let Some ( ibc_traces) = ibc_traces {
1513
- for ( key, ibc_trace) in ibc_traces {
1514
- if let Some ( ( _, hash) ) = is_ibc_trace_key ( & key) {
1515
- let hash: IbcTokenHash = hash. parse ( ) . expect (
1516
- "Parsing an IBC token hash from storage shouldn't fail" ,
1517
- ) ;
1518
- let ibc_token =
1519
- Address :: Internal ( InternalAddress :: IbcToken ( hash) ) ;
1520
- tokens. insert ( ibc_trace, ibc_token) ;
1521
- }
1501
+ let ibc_traces =
1502
+ query_storage_prefix :: < _ , String > ( context, & prefix) . await ?;
1503
+ if let Some ( ibc_traces) = ibc_traces {
1504
+ for ( key, ibc_trace) in ibc_traces {
1505
+ if let Some ( ( _, hash) ) = is_ibc_trace_key ( & key) {
1506
+ let hash: IbcTokenHash = hash. parse ( ) . expect (
1507
+ "Parsing an IBC token hash from storage shouldn't fail" ,
1508
+ ) ;
1509
+ let ibc_token =
1510
+ Address :: Internal ( InternalAddress :: IbcToken ( hash) ) ;
1511
+ tokens. insert ( ibc_trace, ibc_token) ;
1522
1512
}
1523
1513
}
1524
1514
}
0 commit comments