Skip to content

Commit

Permalink
chore(sequencer): remove unnecessary result return (#1849)
Browse files Browse the repository at this point in the history
## Summary
Removed an unnecessary return of a `Result` from the `fees` state
extension trait.

## Background
The method is infallible.

## Changes
- Removed the return type from `add_fee_to_block_fees()`

## Testing
Passing all tests.

## Changelogs
No updates required

## Related Issues
closes #1845
  • Loading branch information
ethanoroshiba authored Dec 5, 2024
1 parent fc10a63 commit eac2759
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
4 changes: 1 addition & 3 deletions crates/astria-sequencer/src/fees/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@ async fn check_and_pay_fees<S: StateWrite, T: FeeHandler + Protobuf>(
.wrap_err("failed to check allowed fee assets in state")?,
"invalid fee asset",
);
state
.add_fee_to_block_fees::<_, T>(fee_asset, total_fees, position_in_transaction)
.wrap_err("failed to add to block fees")?;
state.add_fee_to_block_fees::<_, T>(fee_asset, total_fees, position_in_transaction);
state
.decrease_balance(&from, fee_asset, total_fees)
.await
Expand Down
16 changes: 4 additions & 12 deletions crates/astria-sequencer/src/fees/state_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ pub(crate) trait StateWriteExt: StateWrite {
asset: &'a TAsset,
amount: u128,
position_in_transaction: u64,
) -> Result<()>
where
) where
TAsset: Sync + std::fmt::Display,
asset::IbcPrefixed: From<&'a TAsset>,
{
Expand All @@ -409,7 +408,6 @@ pub(crate) trait StateWriteExt: StateWrite {
};

self.object_put(keys::BLOCK, new_fees);
Ok(())
}

#[instrument(skip_all)]
Expand Down Expand Up @@ -622,9 +620,7 @@ mod tests {
// can write
let asset = asset_0();
let amount = 100u128;
state
.add_fee_to_block_fees::<_, Transfer>(&asset, amount, 0)
.unwrap();
state.add_fee_to_block_fees::<_, Transfer>(&asset, amount, 0);

// holds expected
let fee_balances_updated = state.get_block_fees();
Expand Down Expand Up @@ -652,12 +648,8 @@ mod tests {
let amount_first = 100u128;
let amount_second = 200u128;

state
.add_fee_to_block_fees::<_, Transfer>(&asset_first, amount_first, 0)
.unwrap();
state
.add_fee_to_block_fees::<_, Transfer>(&asset_second, amount_second, 1)
.unwrap();
state.add_fee_to_block_fees::<_, Transfer>(&asset_first, amount_first, 0);
state.add_fee_to_block_fees::<_, Transfer>(&asset_second, amount_second, 1);
// holds expected
let fee_balances = HashSet::<_>::from_iter(state.get_block_fees());
assert_eq!(
Expand Down

0 comments on commit eac2759

Please sign in to comment.