Skip to content

Commit

Permalink
charlie-contract: charge and allowance in gas points
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszm committed May 20, 2024
1 parent 7240018 commit ed5c807
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions contracts/charlie/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ impl Charlie {

/// calling this method will be paid by the contract
pub fn pay(&mut self) {
const ALLOWANCE: u64 = 10_000_000;
let allowance = ALLOWANCE * Self::gas_price();
const ALLOWANCE: u64 = 40_000_000;
let allowance = ALLOWANCE / Self::gas_price();
// this call is paid for by the contract, up to 'allowance'
rusk_abi::set_allowance(allowance);
}
Expand All @@ -30,8 +30,8 @@ impl Charlie {
/// the execution cost, transaction will fail
/// and contract balance won't be affected
pub fn pay_and_fail(&mut self) {
const ALLOWANCE: u64 = 2_000_000;
let allowance = ALLOWANCE * Self::gas_price();
const ALLOWANCE: u64 = 8_000_000;
let allowance = ALLOWANCE / Self::gas_price();
// this call is paid for by the contract, up to 'allowance'
rusk_abi::set_allowance(allowance);
}
Expand All @@ -40,8 +40,8 @@ impl Charlie {
/// increased so that contract can earn the difference between
/// the contract's charge and the cost of gas actually spent
pub fn earn(&mut self) {
const CHARGE: u64 = 20_000_000;
let charge = CHARGE * Self::gas_price();
const CHARGE: u64 = 80_000_000;
let charge = CHARGE / Self::gas_price();
// charging 'charge' for the call
rusk_abi::set_charge(charge);
}
Expand All @@ -51,8 +51,8 @@ impl Charlie {
/// the actual execution cost, as a result the transaction will fail
/// and contract balance won't be affected
pub fn earn_and_fail(&mut self) {
const CHARGE: u64 = 2_000_000;
let charge = CHARGE * Self::gas_price();
const CHARGE: u64 = 8_000_000;
let charge = CHARGE / Self::gas_price();
// charging 'charge' for the call
rusk_abi::set_charge(charge);
}
Expand Down

0 comments on commit ed5c807

Please sign in to comment.