Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove async-trait #1244

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
RUSTFLAGS: "-D warnings"
FUEL_CORE_VERSION: 0.22.0
FUEL_CORE_PATCH_BRANCH:
RUST_VERSION: 1.74.0
RUST_VERSION: 1.75.0
FORC_VERSION: 0.48.0
FORC_PATCH_BRANCH: ""
FORC_PATCH_REVISION: ""
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ homepage = "https://fuel.network/"
readme = "README.md"
license = "Apache-2.0"
repository = "https://github.com/FuelLabs/fuels-rs"
rust-version = "1.74.0"
rust-version = "1.75.0"
version = "0.54.0"

[workspace.dependencies]
Inflector = "0.11.4"
async-trait = { version = "0.1.74", default-features = false }
bech32 = "0.9.1"
bytes = { version = "1.5.0", default-features = false }
chrono = "0.4.31"
Expand Down
1 change: 0 additions & 1 deletion packages/fuels-accounts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rust-version = { workspace = true }
description = "Fuel Rust SDK accounts."

[dependencies]
async-trait = { workspace = true, default-features = false }
chrono = { workspace = true }
elliptic-curve = { workspace = true, default-features = false }
eth-keystore = { workspace = true, optional = true }
Expand Down
8 changes: 2 additions & 6 deletions packages/fuels-accounts/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(async_fn_in_trait)]

use std::{collections::HashMap, fmt::Display};

use async_trait::async_trait;
use fuel_core_client::client::pagination::{PaginatedResult, PaginationRequest};
#[doc(no_inline)]
pub use fuel_crypto;
Expand Down Expand Up @@ -32,8 +33,6 @@ use crate::{
/// Trait for signing transactions and messages
///
/// Implement this trait to support different signing modes, e.g. Ledger, hosted etc.
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait Signer: std::fmt::Debug + Send + Sync {
type Error: std::error::Error + Send + Sync;

Expand Down Expand Up @@ -71,7 +70,6 @@ impl From<AccountError> for Error {

pub type AccountResult<T> = std::result::Result<T, AccountError>;

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait ViewOnlyAccount: std::fmt::Debug + Send + Sync + Clone {
fn address(&self) -> &Bech32Address;

Expand Down Expand Up @@ -142,7 +140,6 @@ pub trait ViewOnlyAccount: std::fmt::Debug + Send + Sync + Clone {
}
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait Account: ViewOnlyAccount {
/// Returns a vector consisting of `Input::Coin`s and `Input::Message`s for the given
/// asset ID and amount. The `witness_index` is the position of the witness (signature)
Expand Down Expand Up @@ -375,7 +372,6 @@ mod tests {
c_param: ConsensusParameters,
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl DryRunner for MockDryRunner {
async fn dry_run_and_get_used_gas(&self, _: FuelTransaction, _: f32) -> Result<u64> {
Ok(0)
Expand Down
1 change: 0 additions & 1 deletion packages/fuels-accounts/src/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl ViewOnlyAccount for Predicate {
}

#[cfg(feature = "std")]
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
impl Account for Predicate {
async fn get_asset_inputs_for_amount(
&self,
Expand Down
1 change: 0 additions & 1 deletion packages/fuels-accounts/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ impl Provider {
}
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
impl DryRunner for Provider {
async fn dry_run_and_get_used_gas(&self, tx: FuelTransaction, tolerance: f32) -> Result<u64> {
let receipts = self.client.dry_run_opt(&tx, Some(false)).await?;
Expand Down
4 changes: 0 additions & 4 deletions packages/fuels-accounts/src/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{fmt, ops, path::Path};

use async_trait::async_trait;
use elliptic_curve::rand_core;
use eth_keystore::KeystoreError;
use fuel_crypto::{Message, PublicKey, SecretKey, Signature};
Expand Down Expand Up @@ -236,7 +235,6 @@ impl ViewOnlyAccount for WalletUnlocked {
}
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
impl Account for WalletUnlocked {
/// Returns a vector consisting of `Input::Coin`s and `Input::Message`s for the given
/// asset ID and amount. The `witness_index` is the position of the witness (signature)
Expand All @@ -260,8 +258,6 @@ impl Account for WalletUnlocked {
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl Signer for WalletUnlocked {
type Error = WalletError;
async fn sign_message<S: Send + Sync + AsRef<[u8]>>(
Expand Down
1 change: 0 additions & 1 deletion packages/fuels-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rust-version = { workspace = true }
description = "Fuel Rust SDK core."

[dependencies]
async-trait = { workspace = true, default-features = false }
bech32 = { workspace = true }
chrono = { workspace = true }
fuel-abi-types = { workspace = true }
Expand Down
9 changes: 1 addition & 8 deletions packages/fuels-core/src/types/transaction_builders.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![cfg(feature = "std")]
#![allow(async_fn_in_trait)]

use std::{collections::HashMap, iter::repeat_with};

use async_trait::async_trait;
use fuel_asm::{op, GTFArgs, RegId};
use fuel_crypto::{Message as CryptoMessage, SecretKey, Signature};
use fuel_tx::{
Expand Down Expand Up @@ -34,14 +34,12 @@ use crate::{
utils::calculate_witnesses_size,
};

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait DryRunner: Send + Sync {
async fn dry_run_and_get_used_gas(&self, tx: FuelTransaction, tolerance: f32) -> Result<u64>;
async fn min_gas_price(&self) -> Result<u64>;
fn consensus_parameters(&self) -> &ConsensusParameters;
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<T: DryRunner> DryRunner for &T {
async fn dry_run_and_get_used_gas(&self, tx: FuelTransaction, tolerance: f32) -> Result<u64> {
(*self).dry_run_and_get_used_gas(tx, tolerance).await
Expand All @@ -63,14 +61,12 @@ struct UnresolvedSignatures {
secret_keys: Vec<SecretKey>,
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait BuildableTransaction {
type TxType: Transaction;

async fn build(self, provider: &impl DryRunner) -> Result<Self::TxType>;
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl BuildableTransaction for ScriptTransactionBuilder {
type TxType = ScriptTransaction;

Expand All @@ -79,7 +75,6 @@ impl BuildableTransaction for ScriptTransactionBuilder {
}
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl BuildableTransaction for CreateTransactionBuilder {
type TxType = CreateTransaction;

Expand All @@ -88,7 +83,6 @@ impl BuildableTransaction for CreateTransactionBuilder {
}
}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait TransactionBuilder: BuildableTransaction + Send + Clone {
type TxType: Transaction;

Expand All @@ -111,7 +105,6 @@ pub trait TransactionBuilder: BuildableTransaction + Send + Clone {

macro_rules! impl_tx_trait {
($ty: ty, $tx_ty: ident) => {
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl TransactionBuilder for $ty {
type TxType = $tx_ty;

Expand Down
1 change: 0 additions & 1 deletion packages/fuels-programs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rust-version = { workspace = true }
description = "Fuel Rust SDK contracts."

[dependencies]
async-trait = { workspace = true, default-features = false }
bytes = { workspace = true, features = ["serde"] }
fuel-abi-types = { workspace = true }
fuel-asm = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion packages/fuels-programs/src/call_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) struct CallOpcodeParamsOffset {
/// How many times to attempt to resolve missing tx dependencies.
pub const DEFAULT_TX_DEP_ESTIMATION_ATTEMPTS: u64 = 10;

#[async_trait::async_trait]
#[allow(async_fn_in_trait)]
pub trait TxDependencyExtension: Sized {
async fn simulate(&mut self) -> Result<()>;

Expand Down
2 changes: 0 additions & 2 deletions packages/fuels-programs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,6 @@ where
}
}

#[async_trait::async_trait]
impl<T, D> TxDependencyExtension for ContractCallHandler<T, D>
where
T: Account,
Expand Down Expand Up @@ -994,7 +993,6 @@ impl<T: Account> MultiContractCallHandler<T> {
}
}

#[async_trait::async_trait]
impl<T> TxDependencyExtension for MultiContractCallHandler<T>
where
T: Account,
Expand Down
1 change: 0 additions & 1 deletion packages/fuels-programs/src/script_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ where
}
}

#[async_trait::async_trait]
impl<T, D> TxDependencyExtension for ScriptCallHandler<T, D>
where
T: Account,
Expand Down
Loading