1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crate::prelude::{
Bug,
BugVariant,
ExecutableTransaction,
Interpreter,
InterpreterStorage,
RuntimeError,
};
use crate::interpreter::{
InitialBalances,
RuntimeBalances,
};
use fuel_tx::{
FeeParameters,
GasCosts,
};
use fuel_types::{
AssetId,
Word,
};
impl<M, S, T, Ecal, V> Interpreter<M, S, T, Ecal, V>
where
S: InterpreterStorage,
{
/// Finalize outputs post-execution.
///
/// For more information, check [`ExecutableTransaction::update_outputs`].
///
/// # Panics
///
/// This will panic if the transaction is malformed (e.g. it contains an output change
/// with asset id that doesn't exist as balance).
///
/// The transaction validation is expected to halt in such case. Since the VM only
/// accepts checked transactions - hence, validated - this case should be
/// unreachable.
#[allow(clippy::too_many_arguments)]
pub(crate) fn finalize_outputs<Tx>(
tx: &mut Tx,
gas_costs: &GasCosts,
fee_params: &FeeParameters,
base_asset_id: &AssetId,
revert: bool,
used_gas: Word,
initial_balances: &InitialBalances,
balances: &RuntimeBalances,
gas_price: Word,
) -> Result<(), RuntimeError<S::DataError>>
where
Tx: ExecutableTransaction,
{
tx.update_outputs(
revert,
used_gas,
initial_balances,
balances,
gas_costs,
fee_params,
base_asset_id,
gas_price,
)
.map_err(|e| Bug::new(BugVariant::UncomputableRefund).with_message(e))?;
Ok(())
}
}