Skip to content

Commit 9753ad4

Browse files
authored
Merge pull request #435 from namada-net/fix-gas-price
Fix gas price
2 parents 78e84b0 + 65d1a38 commit 9753ad4

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

webserver/src/entity/gas.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,25 @@ impl GasPrice {
1313
pub fn from_db(
1414
gas_price_db: GasPriceDb,
1515
tokens: Vec<(TokenDb, Option<IbcTokenDb>)>,
16-
) -> Self {
17-
let token = tokens
18-
.into_iter()
19-
.find_map(|(token, ibc_token)| {
20-
if gas_price_db.token == token.address {
21-
match ibc_token {
22-
Some(ibc_token) => Some(Token::Ibc(IbcToken {
23-
address: Id::Account(ibc_token.address),
24-
trace: Some(Id::IbcTrace(ibc_token.ibc_trace)),
25-
})),
26-
None => Some(Token::Native(Id::Account(token.address))),
27-
}
28-
} else {
29-
None
16+
) -> Option<Self> {
17+
let token = tokens.into_iter().find_map(|(token, ibc_token)| {
18+
if gas_price_db.token == token.address {
19+
match ibc_token {
20+
Some(ibc_token) => Some(Token::Ibc(IbcToken {
21+
address: Id::Account(ibc_token.address),
22+
trace: Some(Id::IbcTrace(ibc_token.ibc_trace)),
23+
})),
24+
None => Some(Token::Native(Id::Account(token.address))),
3025
}
31-
})
32-
.expect("Fee token should be known.");
26+
} else {
27+
None
28+
}
29+
})?;
3330

34-
Self {
31+
Some(Self {
3532
token,
3633
min_denom_amount: gas_price_db.amount.to_string(),
37-
}
34+
})
3835
}
3936
}
4037

webserver/src/service/gas.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl GasService {
4040
.map(|r| {
4141
r.iter()
4242
.cloned()
43-
.map(|gas_price| {
43+
.filter_map(|gas_price| {
4444
GasPrice::from_db(gas_price, tokens.clone())
4545
})
4646
.collect()
@@ -61,7 +61,7 @@ impl GasService {
6161
.map(|r| {
6262
r.iter()
6363
.cloned()
64-
.map(|gas_price| {
64+
.filter_map(|gas_price| {
6565
GasPrice::from_db(gas_price, tokens.clone())
6666
})
6767
.collect()

0 commit comments

Comments
 (0)