mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 05:35:42 +00:00
Fix overflow in srml-contract. (#1113)
This commit is contained in:
committed by
Bastian Köcher
parent
fa84cec382
commit
2a9f6bed10
@@ -150,9 +150,12 @@ pub fn buy_gas<T: Trait>(
|
|||||||
let cost = <T::Gas as As<T::Balance>>::as_(gas_limit.clone())
|
let cost = <T::Gas as As<T::Balance>>::as_(gas_limit.clone())
|
||||||
.checked_mul(&gas_price)
|
.checked_mul(&gas_price)
|
||||||
.ok_or("overflow multiplying gas limit by price")?;
|
.ok_or("overflow multiplying gas limit by price")?;
|
||||||
if b < cost + <balances::Module<T>>::existential_deposit() {
|
|
||||||
|
let new_balance = b.checked_sub(&cost);
|
||||||
|
if new_balance < Some(<balances::Module<T>>::existential_deposit()) {
|
||||||
return Err("not enough funds for transaction fee");
|
return Err("not enough funds for transaction fee");
|
||||||
}
|
}
|
||||||
|
|
||||||
<balances::Module<T>>::set_free_balance(transactor, b - cost);
|
<balances::Module<T>>::set_free_balance(transactor, b - cost);
|
||||||
<balances::Module<T>>::decrease_total_stake_by(cost);
|
<balances::Module<T>>::decrease_total_stake_by(cost);
|
||||||
Ok(GasMeter {
|
Ok(GasMeter {
|
||||||
|
|||||||
Reference in New Issue
Block a user