Skip to content

Commit

Permalink
Use Gas alias
Browse files Browse the repository at this point in the history
  • Loading branch information
ark0f committed Oct 18, 2023
1 parent 8a53782 commit b796d33
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core-backend/src/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use gear_sandbox::{ReturnValue, Value};
use gear_sandbox_env::{HostError, WasmReturnValue};
use gsys::{
BlockNumberWithHash, ErrorBytes, ErrorWithBlockNumberAndValue, ErrorWithGas, ErrorWithHandle,
ErrorWithHash, ErrorWithReplyCode, ErrorWithSignalCode, ErrorWithTwoHashes, Hash,
ErrorWithHash, ErrorWithReplyCode, ErrorWithSignalCode, ErrorWithTwoHashes, Gas, Hash,
HashWithValue, TwoHashesWithValue,
};

Expand Down Expand Up @@ -213,22 +213,22 @@ where
self,
caller: &mut CallerWrap<Ext>,
ctx: Self::Context,
) -> Result<(u64, T), HostError> {
) -> Result<(Gas, T), HostError> {
let res = (self)(caller)?;
let InfallibleSysCallContext { gas } = ctx;
Ok((gas, res))
}
}

struct FallibleSysCallContext {
gas: u64,
gas: Gas,
res_ptr: u32,
}

impl SysCallContext for FallibleSysCallContext {
fn from_args(args: &[Value]) -> Result<(Self, &[Value]), HostError> {
let (gas, args) = args.split_first().ok_or(HostError)?;
let gas: u64 = SysCallValue(*gas).try_into()?;
let gas: Gas = SysCallValue(*gas).try_into()?;
let (res_ptr, args) = args.split_last().ok_or(HostError)?;
let res_ptr: u32 = SysCallValue(*res_ptr).try_into()?;
Ok((FallibleSysCallContext { gas, res_ptr }, args))
Expand Down Expand Up @@ -260,13 +260,13 @@ where
}

pub struct InfallibleSysCallContext {
gas: u64,
gas: Gas,
}

impl SysCallContext for InfallibleSysCallContext {
fn from_args(args: &[Value]) -> Result<(Self, &[Value]), HostError> {
let (gas, args) = args.split_first().ok_or(HostError)?;
let gas: u64 = SysCallValue(*gas).try_into()?;
let gas: Gas = SysCallValue(*gas).try_into()?;
Ok((Self { gas }, args))
}
}
Expand Down

0 comments on commit b796d33

Please sign in to comment.