Skip to content

Commit eb6bac4

Browse files
yito88tzemanovic
authored andcommitted
remove base_token arg from query_ibc_tokens
1 parent bab4163 commit eb6bac4

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

crates/sdk/src/rpc.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,39 +1486,29 @@ pub async fn format_denominated_amount(
14861486
/// Look up IBC tokens. The given base token can be non-Namada token.
14871487
pub async fn query_ibc_tokens<N: Namada>(
14881488
context: &N,
1489-
base_token: Option<String>,
14901489
owner: Option<&Address>,
14911490
) -> 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 => {
15021494
// Check all IBC denoms because the owner might not know IBC token
15031495
// transfers in the same chain
1504-
vec![ibc_trace_key_prefix(None)]
1496+
ibc_trace_key_prefix(None)
15051497
}
15061498
};
15071499

15081500
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);
15221512
}
15231513
}
15241514
}

0 commit comments

Comments
 (0)