Skip to content

Commit

Permalink
Explicitly parse U256 gas payment data as dec strs
Browse files Browse the repository at this point in the history
  • Loading branch information
tkporter committed Oct 31, 2023
1 parent 8b9d8e7 commit 3088758
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions rust/chains/hyperlane-cosmos/src/interchain_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,15 @@ impl CosmosInterchainGasPaymasterIndexer {
}
"payment" => res.payment = value.parse().unwrap(),
"cGF5bWVudA==" => {
res.payment = String::from_utf8(STANDARD.decode(value).unwrap())
.unwrap()
.parse()
.unwrap()
let dec_str = String::from_utf8(STANDARD.decode(value).unwrap()).unwrap();
// U256's from_str assumes a radix of 16, so we explicitly use from_dec_str.
res.payment = U256::from_dec_str(dec_str.as_str()).unwrap();
}
"gas_amount" => res.gas_amount = value.parse().unwrap(),
"Z2FzX2Ftb3VudA==" => {
res.gas_amount = String::from_utf8(STANDARD.decode(value).unwrap())
.unwrap()
.parse()
.unwrap()
let dec_str = String::from_utf8(STANDARD.decode(value).unwrap()).unwrap();
// U256's from_str assumes a radix of 16, so we explicitly use from_dec_str.
res.gas_amount = U256::from_dec_str(dec_str.as_str()).unwrap();
}
"dest_domain" => res.destination = value.parse().unwrap(),
"ZGVzdF9kb21haW4=" => {
Expand Down

0 comments on commit 3088758

Please sign in to comment.