Skip to content

Commit

Permalink
feat: upgrade fuels dependencies to beta-4 in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoplavkov committed Sep 2, 2023
1 parent 22f0623 commit 66fa318
Show file tree
Hide file tree
Showing 11 changed files with 3,174 additions and 7,434 deletions.
737 changes: 65 additions & 672 deletions packages/fuels/lib/src/bridge_generated.dart

Large diffs are not rendered by default.

9,019 changes: 3,037 additions & 5,982 deletions packages/fuels/lib/src/bridge_generated.freezed.dart

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/fuels/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ crate-type = ["staticlib", "cdylib"]
flutter_rust_bridge_codegen = "1.74.0"

[dependencies]
fuels = "0.39.0"
fuels-accounts = "0.39.0" # must be compatible with the fuels version
fuel-crypto = { version = "0.26.2", features = ["random"] } # must be compatible with the fuels version
fuel-tx = "0.26.2" # must be compatible with the fuels version
fuels = "0.46.0"
fuels-accounts = "0.46.0" # must be compatible with the fuels version
fuel-crypto = { version = "0.35.3", features = ["random"] } # must be compatible with the fuels version
fuel-tx = "0.35.3" # must be compatible with the fuels version
futures = "0.3"
tokio = { version = "1.14.0", features = ["rt-multi-thread"] }
rand = { version = "0.8.4", default-features = false }
Expand Down
12 changes: 2 additions & 10 deletions packages/fuels/native/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ use std::str::FromStr;

use flutter_rust_bridge::RustOpaque;
use fuel_crypto::SecretKey;
use fuel_tx::Address;
use fuels::prelude::{AssetId, generate_mnemonic_phrase};
pub use fuels::prelude::{Account, Bech32Address as NativeBech32Address, Provider as NativeProvider, ViewOnlyAccount, WalletUnlocked as NativeWalletUnlocked};
use fuels::tx::Address;
use fuels_accounts::wallet::DEFAULT_DERIVATION_PATH_PREFIX;

use crate::model::balance::{Balance, from_hash_map};
use crate::model::pagination::{PaginationRequest, TransactionsPaginatedResult};
use crate::model::response::TransferResponse;
use crate::model::transaction::TxParameters;

Expand Down Expand Up @@ -89,13 +88,6 @@ impl WalletUnlocked {
from_hash_map(result.unwrap())
}

#[tokio::main]
pub async fn get_transactions(&self, request: PaginationRequest) -> TransactionsPaginatedResult {
let native_wallet_unlocked = self.get_native_wallet_unlocked().await;
let result = native_wallet_unlocked.get_transactions(request.into()).await;
result.unwrap().into()
}

#[tokio::main]
pub async fn transfer(
&self,
Expand All @@ -108,7 +100,7 @@ impl WalletUnlocked {
let asset_id = AssetId::from_str(&asset).unwrap();
let result = native_wallet_unlocked.transfer(&*to.native, amount, asset_id, tx_parameters.into()).await;
let (tx_id, receipts) = result.unwrap();
TransferResponse { tx_id, receipts: receipts.iter().map(Into::into).collect() }
TransferResponse { tx_id: tx_id.to_string(), receipts: receipts.iter().map(Into::into).collect() }
}
}

Expand Down
56 changes: 1 addition & 55 deletions packages/fuels/native/src/bridge_generated.io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ pub extern "C" fn wire_get_balances__method__WalletUnlocked(
wire_get_balances__method__WalletUnlocked_impl(port_, that)
}

#[no_mangle]
pub extern "C" fn wire_get_transactions__method__WalletUnlocked(
port_: i64,
that: *mut wire_WalletUnlocked,
request: *mut wire_PaginationRequest,
) {
wire_get_transactions__method__WalletUnlocked_impl(port_, that, request)
}

#[no_mangle]
pub extern "C" fn wire_transfer__method__WalletUnlocked(
port_: i64,
Expand Down Expand Up @@ -131,11 +122,6 @@ pub extern "C" fn new_box_autoadd_bech_32_address_0() -> *mut wire_Bech32Address
support::new_leak_box_ptr(wire_Bech32Address::new_with_null_ptr())
}

#[no_mangle]
pub extern "C" fn new_box_autoadd_pagination_request_0() -> *mut wire_PaginationRequest {
support::new_leak_box_ptr(wire_PaginationRequest::new_with_null_ptr())
}

#[no_mangle]
pub extern "C" fn new_box_autoadd_provider_0() -> *mut wire_Provider {
support::new_leak_box_ptr(wire_Provider::new_with_null_ptr())
Expand Down Expand Up @@ -203,12 +189,6 @@ impl Wire2Api<Bech32Address> for *mut wire_Bech32Address {
Wire2Api::<Bech32Address>::wire2api(*wrap).into()
}
}
impl Wire2Api<PaginationRequest> for *mut wire_PaginationRequest {
fn wire2api(self) -> PaginationRequest {
let wrap = unsafe { support::box_from_leak_ptr(self) };
Wire2Api::<PaginationRequest>::wire2api(*wrap).into()
}
}
impl Wire2Api<Provider> for *mut wire_Provider {
fn wire2api(self) -> Provider {
let wrap = unsafe { support::box_from_leak_ptr(self) };
Expand All @@ -228,15 +208,6 @@ impl Wire2Api<WalletUnlocked> for *mut wire_WalletUnlocked {
}
}

impl Wire2Api<PaginationRequest> for wire_PaginationRequest {
fn wire2api(self) -> PaginationRequest {
PaginationRequest {
cursor: self.cursor.wire2api(),
results: self.results.wire2api(),
direction: self.direction.wire2api(),
}
}
}
impl Wire2Api<Provider> for wire_Provider {
fn wire2api(self) -> Provider {
Provider {
Expand All @@ -262,7 +233,6 @@ impl Wire2Api<Vec<u8>> for *mut wire_uint_8_list {
}
}
}

impl Wire2Api<WalletUnlocked> for wire_WalletUnlocked {
fn wire2api(self) -> WalletUnlocked {
WalletUnlocked {
Expand All @@ -286,14 +256,6 @@ pub struct wire_Bech32Address {
native: wire_NativeBech32Address,
}

#[repr(C)]
#[derive(Clone)]
pub struct wire_PaginationRequest {
cursor: *mut wire_uint_8_list,
results: usize,
direction: i32,
}

#[repr(C)]
#[derive(Clone)]
pub struct wire_Provider {
Expand All @@ -305,7 +267,7 @@ pub struct wire_Provider {
pub struct wire_TxParameters {
gas_price: u64,
gas_limit: u64,
maturity: u64,
maturity: u32,
}

#[repr(C)]
Expand Down Expand Up @@ -357,22 +319,6 @@ impl Default for wire_Bech32Address {
}
}

impl NewWithNullPtr for wire_PaginationRequest {
fn new_with_null_ptr() -> Self {
Self {
cursor: core::ptr::null_mut(),
results: Default::default(),
direction: Default::default(),
}
}
}

impl Default for wire_PaginationRequest {
fn default() -> Self {
Self::new_with_null_ptr()
}
}

impl NewWithNullPtr for wire_Provider {
fn new_with_null_ptr() -> Self {
Self {
Expand Down
Loading

0 comments on commit 66fa318

Please sign in to comment.