Skip to content

Commit

Permalink
remove redundant pub crate
Browse files Browse the repository at this point in the history
  • Loading branch information
segfault-magnet committed Nov 13, 2024
1 parent 43110e5 commit 57550ef
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 39 deletions.
14 changes: 5 additions & 9 deletions packages/fuels-programs/src/assembly/contract_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use fuel_tx::{AssetId, ContractId};
use fuels_core::{constants::WORD_SIZE, error, types::errors::Result};

use super::cursor::WasmFriendlyCursor;
pub(crate) struct ContractCallInstructions {
pub struct ContractCallInstructions {
instructions: Vec<Instruction>,
gas_fwd: bool,
}
Expand Down Expand Up @@ -102,7 +102,7 @@ impl ContractCallInstructions {
Self::extract_if_match(instructions, &gas_fwd_instructions)
}

pub(crate) fn extract_from(instructions: &[Instruction]) -> Option<Self> {
pub fn extract_from(instructions: &[Instruction]) -> Option<Self> {
if let Some(instructions) = Self::extract_normal_variant(instructions) {
return Some(Self {
instructions: instructions.to_vec(),
Expand All @@ -128,7 +128,7 @@ impl ContractCallInstructions {
movi.imm18().into()
}

pub(crate) fn is_gas_fwd_variant(&self) -> bool {
pub fn is_gas_fwd_variant(&self) -> bool {
self.gas_fwd
}

Expand Down Expand Up @@ -173,11 +173,7 @@ impl ContractCallData {
/// 6. Encoded function selector - method name
/// 7. Encoded arguments
/// 8. Gas to be forwarded `(1 * `[`WORD_SIZE`]`)` - Optional
pub(crate) fn encode(
&self,
memory_offset: usize,
buffer: &mut Vec<u8>,
) -> CallOpcodeParamsOffset {
pub fn encode(&self, memory_offset: usize, buffer: &mut Vec<u8>) -> CallOpcodeParamsOffset {
let amount_offset = memory_offset;
let asset_id_offset = amount_offset + WORD_SIZE;
let call_data_offset = asset_id_offset + AssetId::LEN;
Expand Down Expand Up @@ -262,7 +258,7 @@ impl ContractCallData {
#[derive(Default)]
/// Specifies offsets of [`Opcode::CALL`][`fuel_asm::Opcode::CALL`] parameters stored in the script
/// data from which they can be loaded into registers
pub(crate) struct CallOpcodeParamsOffset {
pub struct CallOpcodeParamsOffset {
pub call_data_offset: usize,
pub amount_offset: usize,
pub asset_id_offset: usize,
Expand Down
4 changes: 2 additions & 2 deletions packages/fuels-programs/src/assembly/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fuels_core::{error, types::errors::Result};

pub(crate) struct WasmFriendlyCursor<'a> {
pub(crate) data: &'a [u8],
pub struct WasmFriendlyCursor<'a> {
data: &'a [u8],
}

impl<'a> WasmFriendlyCursor<'a> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use fuels_core::error;

use fuel_asm::{op, Instruction, RegId};
use fuels_core::{
constants::WORD_SIZE,
Expand Down Expand Up @@ -124,7 +122,7 @@ impl LoaderCode {
}
}

pub(crate) fn loader_instructions_no_data_section() -> [Instruction; 8] {
pub fn loader_instructions_no_data_section() -> [Instruction; 8] {
const REG_ADDRESS_OF_DATA_AFTER_CODE: u8 = 0x10;
const REG_START_OF_LOADED_CODE: u8 = 0x11;
const REG_GENERAL_USE: u8 = 0x12;
Expand Down Expand Up @@ -170,7 +168,7 @@ pub(crate) fn loader_instructions_no_data_section() -> [Instruction; 8] {
instructions
}

pub(crate) fn loader_instructions() -> [Instruction; 12] {
pub fn loader_instructions() -> [Instruction; 12] {
const BLOB_ID_SIZE: u16 = 32;
const REG_ADDRESS_OF_DATA_AFTER_CODE: u8 = 0x10;
const REG_START_OF_LOADED_CODE: u8 = 0x11;
Expand Down Expand Up @@ -236,7 +234,7 @@ pub(crate) fn loader_instructions() -> [Instruction; 12] {
instructions
}

pub(crate) fn extract_data_offset(binary: &[u8]) -> Result<usize> {
pub fn extract_data_offset(binary: &[u8]) -> Result<usize> {
if binary.len() < 16 {
return Err(fuels_core::error!(
Other,
Expand All @@ -250,7 +248,7 @@ pub(crate) fn extract_data_offset(binary: &[u8]) -> Result<usize> {
Ok(u64::from_be_bytes(data_offset) as usize)
}

pub(crate) fn split_at_data_offset(binary: &[u8]) -> Result<(&[u8], &[u8])> {
pub fn split_at_data_offset(binary: &[u8]) -> Result<(&[u8], &[u8])> {
let offset = extract_data_offset(binary)?;
if binary.len() < offset {
return Err(fuels_core::error!(
Expand Down
23 changes: 1 addition & 22 deletions packages/fuels-programs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,4 @@ pub mod responses;
pub mod debug;

pub(crate) mod assembly;

pub(crate) mod utils {
use fuels_core::types::errors::{error, Error};

pub fn prepend_msg<'a>(msg: impl AsRef<str> + 'a) -> impl Fn(Error) -> Error + 'a {
move |err| match err {
Error::IO(orig_msg) => {
error!(IO, "{}: {}", msg.as_ref(), orig_msg)
}
Error::Codec(orig_msg) => {
error!(Codec, "{}: {}", msg.as_ref(), orig_msg)
}
Error::Transaction(reason) => Error::Transaction(reason),
Error::Provider(orig_msg) => {
error!(Provider, "{}: {}", msg.as_ref(), orig_msg)
}
Error::Other(orig_msg) => {
error!(Other, "{}: {}", msg.as_ref(), orig_msg)
}
}
}
}
pub(crate) mod utils;
19 changes: 19 additions & 0 deletions packages/fuels-programs/src/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use fuels_core::types::errors::{error, Error};

pub fn prepend_msg<'a>(msg: impl AsRef<str> + 'a) -> impl Fn(Error) -> Error + 'a {
move |err| match err {
Error::IO(orig_msg) => {
error!(IO, "{}: {}", msg.as_ref(), orig_msg)
}
Error::Codec(orig_msg) => {
error!(Codec, "{}: {}", msg.as_ref(), orig_msg)
}
Error::Transaction(reason) => Error::Transaction(reason),
Error::Provider(orig_msg) => {
error!(Provider, "{}: {}", msg.as_ref(), orig_msg)
}
Error::Other(orig_msg) => {
error!(Other, "{}: {}", msg.as_ref(), orig_msg)
}
}
}

0 comments on commit 57550ef

Please sign in to comment.