Skip to content

Commit

Permalink
chore: refactor fuel_types imports (#1273)
Browse files Browse the repository at this point in the history
This PR exposes all `fuel_types` directly through `fuels::types` and
leaves `fuel_tx` relevant exports to `fuels::tx`.

BREAKING CHANGE: 
- `Bytes32` and `Salt` are accessed through `fuels::types`
- `UtxoId` and `TxPointer` are accessed through `fuels::tx`
  • Loading branch information
hal3e authored Feb 12, 2024
1 parent 325034f commit 48292d7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
5 changes: 1 addition & 4 deletions examples/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ mod tests {

#[tokio::test]
async fn deploy_with_parameters() -> std::result::Result<(), Box<dyn std::error::Error>> {
use fuels::{
prelude::*,
tx::{Bytes32, StorageSlot},
};
use fuels::{prelude::*, tx::StorageSlot, types::Bytes32};
use rand::prelude::{Rng, SeedableRng, StdRng};

let wallet = launch_provider_and_get_wallet().await?;
Expand Down
4 changes: 2 additions & 2 deletions examples/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod tests {
// ANCHOR: bytes32
use std::str::FromStr;

use fuels::tx::Bytes32;
use fuels::types::Bytes32;

// Zeroed Bytes32
let b256 = Bytes32::zeroed();
Expand Down Expand Up @@ -70,7 +70,7 @@ mod tests {
#[tokio::test]
async fn bech32() -> Result<()> {
// ANCHOR: bech32
use fuels::{prelude::Bech32Address, tx::Bytes32, types::Address};
use fuels::types::{bech32::Bech32Address, Address, Bytes32};

// New from HRP string and a hash
let hrp = "fuel";
Expand Down
6 changes: 4 additions & 2 deletions packages/fuels-core/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::fmt;

pub use fuel_tx::{Address, AssetId, ContractId, TxPointer, UtxoId};
use fuel_types::bytes::padded_len;
pub use fuel_types::{ChainId, MessageId, Nonce};
pub use fuel_types::{
Address, AssetId, Bytes32, Bytes4, Bytes64, Bytes8, ChainId, ContractId, MessageId, Nonce,
Salt, Word,
};

pub use crate::types::{core::*, wrappers::*};
use crate::types::{
Expand Down
9 changes: 4 additions & 5 deletions packages/fuels/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
pub mod tx {
pub use fuel_tx::{
field, AssetId, Bytes32, ConsensusParameters, ContractIdExt, ContractParameters,
FeeParameters, GasCosts, PredicateParameters, Receipt, Salt, ScriptExecutionResult,
ScriptParameters, StorageSlot, Transaction as FuelTransaction, TxId, TxParameters, Witness,
field, ConsensusParameters, ContractIdExt, ContractParameters, FeeParameters, GasCosts,
PredicateParameters, Receipt, ScriptExecutionResult, ScriptParameters, StorageSlot,
Transaction as FuelTransaction, TxId, TxParameters, TxPointer, UtxoId, Witness,
};
}

Expand Down Expand Up @@ -93,12 +93,11 @@ pub mod prelude {
pub use super::{
core::constants::*,
macros::{abigen, setup_program_test},
tx::Salt,
types::{
bech32::{Bech32Address, Bech32ContractId},
errors::{Error, Result},
transaction::*,
Address, AssetId, Bytes, ContractId, RawSlice,
Address, AssetId, Bytes, ContractId, RawSlice, Salt,
},
};
}
4 changes: 2 additions & 2 deletions packages/fuels/tests/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::str::FromStr;

use fuels::{
prelude::*,
tx::{Bytes32, StorageSlot},
types::Bits256,
tx::StorageSlot,
types::{Bits256, Bytes32},
};

#[tokio::test]
Expand Down

0 comments on commit 48292d7

Please sign in to comment.