diff --git a/e2e/Cargo.toml b/e2e/Cargo.toml index 2b929232e2..88376aaabf 100644 --- a/e2e/Cargo.toml +++ b/e2e/Cargo.toml @@ -26,6 +26,7 @@ tokio = { workspace = true, features = ["test-util"] } [build-dependencies] anyhow = { workspace = true, features = ["std"] } flate2 = { workspace = true, features = ["zlib"] } +fuels-accounts = { workspace = true, features = ["std"] } reqwest = { workspace = true, features = ["blocking", "default-tls"] } semver = { workspace = true } tar = { workspace = true } diff --git a/e2e/build.rs b/e2e/build.rs index b2131fe614..e857bf8d23 100644 --- a/e2e/build.rs +++ b/e2e/build.rs @@ -1,5 +1,5 @@ use flate2::read::GzDecoder; -use semver::Version; +use fuels_accounts::provider::SUPPORTED_FUEL_CORE_VERSION; use std::{ io::Cursor, path::{Path, PathBuf}, @@ -12,8 +12,6 @@ struct Downloader { impl Downloader { const EXECUTOR_FILE_NAME: &'static str = "fuel-core-wasm-executor.wasm"; - const CORRECT_VERSION_CONTENTS: &'static str = - include_str!("../scripts/fuel-core-version/version.rs"); pub fn new() -> Self { let env = std::env::var("OUT_DIR").unwrap(); @@ -32,8 +30,8 @@ impl Downloader { return Ok(true); } - let saved_version = std::fs::read_to_string(self.version_path())?; - if saved_version != Self::CORRECT_VERSION_CONTENTS { + let saved_version = semver::Version::parse(&std::fs::read_to_string(self.version_path())?)?; + if saved_version != SUPPORTED_FUEL_CORE_VERSION { return Ok(true); } @@ -44,8 +42,7 @@ impl Downloader { std::fs::create_dir_all(&self.dir)?; const LINK_TEMPLATE: &str = "https://github.com/FuelLabs/fuel-core/releases/download/vVERSION/fuel-core-VERSION-x86_64-unknown-linux-gnu.tar.gz"; - const CORE_VERSION: semver::Version = include!("../scripts/fuel-core-version/version.rs"); - let link = LINK_TEMPLATE.replace("VERSION", &CORE_VERSION.to_string()); + let link = LINK_TEMPLATE.replace("VERSION", &SUPPORTED_FUEL_CORE_VERSION.to_string()); let response = reqwest::blocking::get(link)?; if !response.status().is_success() { @@ -58,7 +55,7 @@ impl Downloader { let mut extracted = false; let executor_in_tar = Path::new(&format!( - "fuel-core-{CORE_VERSION}-x86_64-unknown-linux-gnu" + "fuel-core-{SUPPORTED_FUEL_CORE_VERSION}-x86_64-unknown-linux-gnu" )) .join(Self::EXECUTOR_FILE_NAME); @@ -67,7 +64,10 @@ impl Downloader { if entry.path()? == executor_in_tar { entry.unpack(self.executor_path())?; - std::fs::write(self.version_path(), Self::CORRECT_VERSION_CONTENTS)?; + std::fs::write( + self.version_path(), + format!("{SUPPORTED_FUEL_CORE_VERSION}"), + )?; extracted = true; break; diff --git a/packages/fuels-accounts/src/provider.rs b/packages/fuels-accounts/src/provider.rs index 761545e5e4..adcc321130 100644 --- a/packages/fuels-accounts/src/provider.rs +++ b/packages/fuels-accounts/src/provider.rs @@ -2,6 +2,7 @@ use std::{collections::HashMap, fmt::Debug, net::SocketAddr}; mod retry_util; mod retryable_client; +mod supported_fuel_core_version; mod supported_versions; #[cfg(feature = "coin-cache")] @@ -41,6 +42,7 @@ use fuels_core::{ }, }; pub use retry_util::{Backoff, RetryConfig}; +pub use supported_fuel_core_version::SUPPORTED_FUEL_CORE_VERSION; use tai64::Tai64; #[cfg(feature = "coin-cache")] use tokio::sync::Mutex; diff --git a/packages/fuels-accounts/src/provider/supported_fuel_core_version.rs b/packages/fuels-accounts/src/provider/supported_fuel_core_version.rs new file mode 100644 index 0000000000..91fea557ae --- /dev/null +++ b/packages/fuels-accounts/src/provider/supported_fuel_core_version.rs @@ -0,0 +1 @@ +pub const SUPPORTED_FUEL_CORE_VERSION: semver::Version = semver::Version::new(0, 27, 0); diff --git a/packages/fuels-accounts/src/provider/supported_versions.rs b/packages/fuels-accounts/src/provider/supported_versions.rs index da20a4b8fb..54d0a22301 100644 --- a/packages/fuels-accounts/src/provider/supported_versions.rs +++ b/packages/fuels-accounts/src/provider/supported_versions.rs @@ -1,8 +1,6 @@ +use crate::provider::supported_fuel_core_version::SUPPORTED_FUEL_CORE_VERSION; use semver::Version; -pub const SUPPORTED_FUEL_CORE_VERSION: Version = - include!("../../../../scripts/fuel-core-version/version.rs"); - #[derive(Debug, PartialEq, Eq)] pub(crate) struct VersionCompatibility { pub(crate) supported_version: Version, diff --git a/scripts/fuel-core-version/Cargo.toml b/scripts/fuel-core-version/Cargo.toml index af158ca4e7..54a21f015d 100644 --- a/scripts/fuel-core-version/Cargo.toml +++ b/scripts/fuel-core-version/Cargo.toml @@ -12,5 +12,6 @@ rust-version = { workspace = true } [dependencies] clap = { version = "4.5.3", features = ["derive"] } color-eyre = "0.6.2" +fuels-accounts = { workspace = true, features = ["std"] } semver = { workspace = true } versions-replacer = { workspace = true } diff --git a/scripts/fuel-core-version/src/main.rs b/scripts/fuel-core-version/src/main.rs index 4725a0808f..c3d329f73f 100644 --- a/scripts/fuel-core-version/src/main.rs +++ b/scripts/fuel-core-version/src/main.rs @@ -8,6 +8,7 @@ use color_eyre::{ eyre::{bail, ContextCompat}, Result, }; +use fuels_accounts::provider::SUPPORTED_FUEL_CORE_VERSION; use semver::Version; use versions_replacer::metadata::collect_versions_from_cargo_toml; @@ -40,11 +41,10 @@ fn get_version_file_path( } fn verify_version_from_file(version: Version) -> Result<()> { - let version_from_file: Version = include!("../version.rs"); - if version != version_from_file { + if version != SUPPORTED_FUEL_CORE_VERSION { bail!( "fuel_core version in version.rs ({}) doesn't match one in Cargo.toml ({})", - version_from_file, + SUPPORTED_FUEL_CORE_VERSION, version ); } diff --git a/scripts/fuel-core-version/version.rs b/scripts/fuel-core-version/version.rs deleted file mode 100644 index 7735d63d35..0000000000 --- a/scripts/fuel-core-version/version.rs +++ /dev/null @@ -1 +0,0 @@ -Version::new(0, 27, 0)