Skip to content

Commit

Permalink
Remove duplicate gas from std (FuelLabs#3588)
Browse files Browse the repository at this point in the history
Removed `gas` function in favor of `context_gas`.

Resolves FuelLabs#2464
  • Loading branch information
jtriley-eth authored Dec 13, 2022
1 parent a036dc5 commit 949dfb9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
5 changes: 0 additions & 5 deletions sway-lib-std/src/context.sw
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ pub fn balance_of(asset_id: ContractId, target: ContractId) -> u64 {
}
}

/// Get the remaining gas in the context.
pub fn gas() -> u64 {
asm() { cgas: u64 }
}

/// Get the amount of units of `call_frames::msg_asset_id()` being sent.
pub fn msg_amount() -> u64 {
balance()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

use std::{call_frames::{contract_id, msg_asset_id}, context::{balance_of, gas, msg_amount, this_balance}, contract_id::ContractId, registers::global_gas};
use std::{call_frames::{contract_id, msg_asset_id}, context::{balance_of, msg_amount, this_balance}, contract_id::ContractId, registers::{global_gas, context_gas}};
use context_testing_abi::*;

impl ContextTesting for Contract {
Expand All @@ -25,7 +25,7 @@ impl ContextTesting for Contract {
}

fn get_gas() -> u64 {
gas()
context_gas()
}

fn get_global_gas() -> u64 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
contract;

use std::{auth::*, call_frames::contract_id, context::gas, reentrancy::*};
use std::{auth::*, call_frames::contract_id, reentrancy::*};

use reentrancy_attacker_abi::Attacker;
use reentrancy_target_abi::Target;
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/context/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl ContextTesting for Contract {
}

fn get_gas() -> u64 {
gas()
context_gas()
}

fn get_global_gas() -> u64 {
Expand Down

0 comments on commit 949dfb9

Please sign in to comment.