Skip to content

Commit

Permalink
Use PanicReason from fuel_asm (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlopes11 authored and xgreenx committed Dec 20, 2022
1 parent 6adc998 commit 6551673
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 197 deletions.
3 changes: 2 additions & 1 deletion fuel-tx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

pub mod consts;

pub use fuel_asm::{InstructionResult, PanicReason};
pub use fuel_types::{Address, Bytes32, Bytes4, Bytes64, Bytes8, Color, ContractId, Salt};

#[cfg(feature = "std")]
Expand All @@ -24,4 +25,4 @@ mod receipt;
pub use transaction::{Input, Metadata, Output, Transaction, ValidationError, Witness};

#[cfg(feature = "std")]
pub use receipt::{PanicReason, Receipt, ScriptResult};
pub use receipt::Receipt;
14 changes: 6 additions & 8 deletions fuel-tx/src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use fuel_asm::InstructionResult;
use fuel_types::bytes::{self, SizedBytes};
use fuel_types::{Address, Bytes32, Color, ContractId, Word};

use std::convert::TryFrom;
use std::io::{self, Write};
use std::mem;

mod panic_reason;
mod receipt_repr;

use receipt_repr::ReceiptRepr;

pub use panic_reason::{PanicReason, ScriptResult};

const WORD_SIZE: usize = mem::size_of::<Word>();

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -99,7 +97,7 @@ pub enum Receipt {
},

ScriptResult {
result: ScriptResult,
result: InstructionResult,
gas_used: Word,
},
}
Expand Down Expand Up @@ -238,7 +236,7 @@ impl Receipt {
}
}

pub const fn script_result(result: ScriptResult, gas_used: Word) -> Self {
pub const fn script_result(result: InstructionResult, gas_used: Word) -> Self {
Self::ScriptResult { result, gas_used }
}

Expand Down Expand Up @@ -410,9 +408,9 @@ impl Receipt {
}
}

pub const fn result(&self) -> Option<ScriptResult> {
pub const fn result(&self) -> Option<&InstructionResult> {
match self {
Self::ScriptResult { result, .. } => Some(*result),
Self::ScriptResult { result, .. } => Some(result),
_ => None,
}
}
Expand Down Expand Up @@ -741,7 +739,7 @@ impl io::Write for Receipt {
let (result, buf) = unsafe { bytes::restore_word_unchecked(buf) };
let (gas_used, _) = unsafe { bytes::restore_word_unchecked(buf) };

let result = ScriptResult::from(result);
let result = InstructionResult::from(result);

*self = Self::script_result(result, gas_used);
}
Expand Down
151 changes: 0 additions & 151 deletions fuel-tx/src/receipt/panic_reason.rs

This file was deleted.

Loading

0 comments on commit 6551673

Please sign in to comment.