From 3086d0ad4433baf43bc11a9888b38a21b0c34b3e Mon Sep 17 00:00:00 2001 From: Andrei Shuvalov <6286552+dronbas@users.noreply.github.com> Date: Tue, 28 Jul 2026 14:56:28 +0200 Subject: [PATCH] Update kit to v5 --- Cargo.toml | 21 +++- bee_connect/Cargo.toml | 2 +- bee_crypto/Cargo.toml | 2 +- bee_errors/Cargo.toml | 2 +- bee_miner/Cargo.toml | 2 +- bee_wallet/Cargo.toml | 28 ++++- bee_wallet/src/adapters/native/mod.rs | 1 + bee_wallet/src/bin/wallet_info.rs | 46 ++----- bee_wallet/src/client.rs | 2 +- bee_wallet/src/dapp.rs | 47 ++------ bee_wallet/src/lib.rs | 2 +- bee_wallet/src/modules/mod.rs | 2 +- bee_wallet/src/services/mod.rs | 5 +- bee_wallet/src/services/tokens/sell_orders.rs | 51 ++------ .../src/services/transaction/history.rs | 112 ++++-------------- bee_wallet/tests/dex_flows/main.rs | 9 +- bee_wallet/tests/integration.rs | 6 + 17 files changed, 120 insertions(+), 220 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a6fcd36..88c967e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ default-members = [ ] [workspace.package] -version = "3.2.0" +version = "4.0.0" edition = "2024" license = "LicenseRef-Acki-Nacki-Node-License" license-file = "LICENSE.md" @@ -41,6 +41,25 @@ rs_merkle = { version = "1.5.0", default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" +# Replicated from ackinacki-kit v5.0.0 (itself replicated from tvm-sdk v3.0.4.an). +# Cargo `[patch]` tables only apply from the top-level workspace, so both tvm-sdk's +# and the kit's own patches are ignored when they are consumed as git deps — +# without these, tvm_vm's zk stack resolves TWO copies of halo2-axiom/halo2-base +# (gosh-sh fork vs crates.io/axiom-crypto) and fails with E0277 Circuit mismatches. +[patch.crates-io] +halo2-base = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" } +halo2-axiom = { git = "https://github.com/gosh-sh/halo2-axiom", branch = "main" } + +[patch."https://github.com/axiom-crypto/halo2-lib.git"] +halo2-base = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" } +halo2-ecc = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" } +zkevm-hashes = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" } + +# gosh-sh stable-Rust fork of axiom-eth; pinned by rev so the transitively selected +# snark-verifier-sdk cannot drift (see tvm-sdk workspace Cargo.toml for details). +[patch."https://github.com/axiom-crypto/axiom-eth"] +axiom-eth = { git = "https://github.com/gosh-sh/axiom-eth", rev = "1d61be00a63ec73b3f709d74eb9e6b09b754b911" } + [profile.release] # Tell `rustc` to optimize for small code size. opt-level = "s" diff --git a/bee_connect/Cargo.toml b/bee_connect/Cargo.toml index b074167..b1cb2ca 100644 --- a/bee_connect/Cargo.toml +++ b/bee_connect/Cargo.toml @@ -13,7 +13,7 @@ wasm = ["dep:wasm-bindgen", "dep:wasm-bindgen-futures", "dep:serde-wasm-bindgen" single-wasm = ["wasm"] [dependencies] -ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false, features = ["contracts"] } +ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false, features = ["contracts"] } base64 = "0.22.1" bee-errors = { path = "../bee_errors", default-features = false } bee-infra = { path = "../bee_infra", default-features = false, features = ["tokio"] } diff --git a/bee_crypto/Cargo.toml b/bee_crypto/Cargo.toml index 71f1b83..6f7204f 100644 --- a/bee_crypto/Cargo.toml +++ b/bee_crypto/Cargo.toml @@ -19,7 +19,7 @@ wasm = [ single-wasm = ["wasm"] [dependencies] -ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false } +ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false } base64 = "0.22.1" bee-errors = { path = "../bee_errors", default-features = false } chacha20poly1305 = "0.10.1" diff --git a/bee_errors/Cargo.toml b/bee_errors/Cargo.toml index 8a89ff9..a0f5e79 100644 --- a/bee_errors/Cargo.toml +++ b/bee_errors/Cargo.toml @@ -10,7 +10,7 @@ wasm = ["ackinacki-kit/wasm", "ackinacki-kit/contracts"] single-wasm = ["wasm"] [dependencies] -ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false } +ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false } base64 = "0.22.1" hex = { workspace = true } pbkdf2 = { version = "0.12.2", features = ["simple"] } diff --git a/bee_miner/Cargo.toml b/bee_miner/Cargo.toml index f50b9e0..3b4928c 100644 --- a/bee_miner/Cargo.toml +++ b/bee_miner/Cargo.toml @@ -20,7 +20,7 @@ wasm = [ single-wasm = ["wasm"] [dependencies] -ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false, features = ["contracts"] } +ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false, features = ["contracts"] } base64 = "0.22.1" blake3.workspace = true borsh.workspace = true diff --git a/bee_wallet/Cargo.toml b/bee_wallet/Cargo.toml index 31e6121..dfb0dd5 100644 --- a/bee_wallet/Cargo.toml +++ b/bee_wallet/Cargo.toml @@ -37,9 +37,20 @@ wasm = [ "tokio", ] single-wasm = ["wasm"] +# DEX voucher generation (`generate_voucher`), backed by `dodex-contracts`. +# +# OFF by default and currently NOT BUILDABLE: `dodex-backend` still declares kit +# v4.0.1 while this workspace is on v5.0.0, and cargo keys git packages by +# source+ref — so the graph carries two `ackinacki-kit` copies whose types don't +# unify across the dodex boundary (`ParamsOfNewContract`, `AbiAccessor`). Cargo +# `[patch]` cannot bridge them ("patches must point to different sources"). +# Flip this back on together with a dodex rev that is on kit v5; the two kit tags +# differ only in the multisig binding, which dodex never touches, so it is a +# one-line bump on their side. +dex = ["dep:dodex-contracts"] [dependencies] -ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", optional = true, default-features = false } +ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", optional = true, default-features = false } base64 = "0.22.1" bech32 = "0.9.1" bee-errors = { path = "../bee_errors", default-features = false } @@ -82,9 +93,12 @@ tokio = { optional = true, version = "1.49.0", features = ["rt", "macros"] } # DEX contract wrappers (RootPn, PrivateNote, …) moved out of kit at v3.0.0 into # dodex-backend's `dodex-contracts`, built on kit's trait surface via the new # `KitModule::External` hook. Native-only: voucher generation isn't exposed on -# wasm, so this keeps the dodex graph out of the wasm build. +# wasm, so this keeps the dodex graph out of the wasm build. Gated behind the +# `dex` feature — see its comment above for why it is off. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -dodex-contracts = { git = "https://github.com/gosh-sh/dodex-backend.git", tag = "v1.0.0", package = "dodex-contracts" } +# Pinned by rev on `dev` (tag v1.0.0 is still on kit v3.0.0). Rev, not branch: +# a branch pin already broke CI once when the branch was deleted. +dodex-contracts = { git = "https://github.com/gosh-sh/dodex-backend.git", rev = "50b5f595bd6f99531fb0e77522ca2054e8d814e2", package = "dodex-contracts", optional = true } # Native integration tests (`tests/integration.rs`, `tests/dex_flows/`) only. # These pull the native tvm/kit/dodex graph, so they MUST stay off the wasm32 @@ -92,7 +106,7 @@ dodex-contracts = { git = "https://github.com/gosh-sh/dodex-backend.git", tag = # crates (e.g. errno) into wasm32 and fails to compile. The matching test files # are guarded with `#![cfg(not(target_arch = "wasm32"))]`. [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", features = ["default", "contracts"] } +ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", features = ["default", "contracts"] } base64 = "0.22.1" bee-connect = { path = "../bee_connect" } bee-crypto = { path = "../bee_crypto" } @@ -105,7 +119,11 @@ tokio = { version = "1.49.0", features = ["rt", "macros", "time"] } # full-flow tests under `tests/dex_flows/` — the two multifactor flows that # exercise bee-wallet + DEX together. Native-only: pulls the heavy halo2 graph. # Raw contract wrappers come from `dodex-contracts` (a regular dep above). -dodex-sdk = { git = "https://github.com/gosh-sh/dodex-backend.git", tag = "v1.0.0" } +# +# Dev-dependencies cannot be optional, so this stays declared while +# `tests/dex_flows/` itself is gated on the `dex` feature; with the feature off +# the test crate is empty and never names `dodex_sdk`. +dodex-sdk = { git = "https://github.com/gosh-sh/dodex-backend.git", rev = "50b5f595bd6f99531fb0e77522ca2054e8d814e2" } # wasm-bindgen-test backs the `#[wasm_bindgen_test]` unit tests in # `adapters/wasm` (run via `wasm-pack test --node`). Kept off the native build. diff --git a/bee_wallet/src/adapters/native/mod.rs b/bee_wallet/src/adapters/native/mod.rs index 284b98e..2a9d05c 100644 --- a/bee_wallet/src/adapters/native/mod.rs +++ b/bee_wallet/src/adapters/native/mod.rs @@ -443,6 +443,7 @@ impl Wallet { /// Generate a DEX voucher: adds RootPN to whitelist, then sends ECC tokens /// from the multifactor wallet to RootPN with `generatevoucher` payload. + #[cfg(feature = "dex")] pub async fn generate_voucher( &self, params: crate::modules::dex::ParamsOfGenerateVoucher, diff --git a/bee_wallet/src/bin/wallet_info.rs b/bee_wallet/src/bin/wallet_info.rs index b567915..031c672 100644 --- a/bee_wallet/src/bin/wallet_info.rs +++ b/bee_wallet/src/bin/wallet_info.rs @@ -612,20 +612,6 @@ async fn lenient_query_account_events( page_size: u32, ) -> Result, String> { const GQL: &str = r#" - query($address: String!, $last: Int!, $before: String) { - blockchain { - account(address: $address) { - events(last: $last, before: $before) { - edges { - cursor - node { msg_id created_at dst body } - } - } - } - } - } - "#; - const GQL_V3: &str = r#" query($account_id: String!, $dapp_id: String!, $last: Int!, $before: String) { blockchain { account(account_id: $account_id, dapp_id: $dapp_id) { @@ -641,29 +627,22 @@ async fn lenient_query_account_events( "#; // Diagnostic accounts queried here are mvsystem (Mobile Verifiers dApp). - let v3 = bee_wallet::dapp::server_uses_dapp_id(ctx).await.map_err(|e| e.to_string())?; let dapp_id = ackinacki_kit::contracts::dapp::SystemDapp::MobileVerifiers.dapp_id(); let mut all = Vec::new(); let before: Option = None; - loop { + // Single page only (see the tail of this block) — a labeled block, not a + // `loop`, so the early exits read as what they are. + 'page: { let raw = gql_query( ctx.clone(), GqlParams { - query: if v3 { GQL_V3 } else { GQL }.to_string(), - variables: Some(if v3 { - serde_json::json!({ - "account_id": bee_wallet::dapp::account_id(address), - "dapp_id": dapp_id, - "last": page_size, - "before": before, - }) - } else { - serde_json::json!({ - "address": address, - "last": page_size, - "before": before, - }) - }), + query: GQL.to_string(), + variables: Some(serde_json::json!({ + "account_id": bee_wallet::dapp::account_id(address), + "dapp_id": dapp_id, + "last": page_size, + "before": before, + })), }, ) .await @@ -677,11 +656,11 @@ async fn lenient_query_account_events( .and_then(|v| v.get("account")) .and_then(|v| v.get("events")); let edges = match events { - None | Some(serde_json::Value::Null) => break, + None | Some(serde_json::Value::Null) => break 'page, Some(v) => v.get("edges").and_then(|e| e.as_array()).cloned().unwrap_or_default(), }; if edges.is_empty() { - break; + break 'page; } let next_before = edges @@ -703,7 +682,6 @@ async fn lenient_query_account_events( // Fetched a single page only — `limit` semantics in our caller mean // "give me up to this many"; one page covers it for our use case. let _ = next_before; - break; } Ok(all) } diff --git a/bee_wallet/src/client.rs b/bee_wallet/src/client.rs index fe70cd4..228fd3e 100644 --- a/bee_wallet/src/client.rs +++ b/bee_wallet/src/client.rs @@ -138,7 +138,7 @@ impl WalletClient { modules::names::NamesModule::new(&self.ctx) } - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "dex"))] pub(crate) fn dex(&self) -> modules::dex::DexModule<'_> { modules::dex::DexModule::new(&self.ctx) } diff --git a/bee_wallet/src/dapp.rs b/bee_wallet/src/dapp.rs index 6360e1f..bf55bda 100644 --- a/bee_wallet/src/dapp.rs +++ b/bee_wallet/src/dapp.rs @@ -1,30 +1,21 @@ -//! Single source of truth for dApp IDs we must pass to the v3 kit, plus helpers +//! Single source of truth for dApp IDs we must pass to the kit, plus helpers //! for our OWN raw GraphQL queries that address an account. //! -//! On gql-server `< 1.0.0` (current shellnet/mainnet) `dapp_id` is ignored, so -//! a wrong value is harmless *today* — but it travels into the GraphQL query on -//! `>= 1.0.0` servers, where a wrong/placeholder dApp makes account-bearing -//! calls fail (`518 DappIdRequired` / query miss). Keep the real values here so -//! flipping them later is a one-line change, not a repo-wide hunt. - -use std::sync::Arc; +//! Since kit v4 the kit speaks only the `>= 1.0.0` GraphQL, which addresses +//! accounts by `account_id` + `dapp_id` — the server-generation probe +//! (`supports_dapp_id`) is gone and there is no legacy `account(address:)` +//! fallback left. A wrong dApp therefore fails the call outright +//! (`518 DappIdRequired` / query miss), so the real values live here. use ackinacki_kit::contracts::account::ParamsOfNewContract; -use ackinacki_kit::contracts::dapp::supports_dapp_id; use ackinacki_kit::contracts::dapp::SystemDapp; -use ackinacki_kit::contracts::error::KitModule; -use ackinacki_kit::tvm_client::ClientContext; - -use crate::errors::AppError; -use crate::errors::AppResult; /// Build `ParamsOfNewContract` for a TIP-3 token-family contract /// (`TokenRoot` / `TokenWallet` / `TokenTransaction`) at `address`. /// /// Each token has its OWN dApp, so there is no single correct constant — the /// caller supplies `dapp_id` (it arrives from the API request next to the token -/// root). Ignored on `< 1.0.0` servers; must be the token's real dApp on -/// `>= 1.0.0`. +/// root). pub fn token_contract_params( address: impl Into, dapp_id: impl Into, @@ -35,32 +26,16 @@ pub fn token_contract_params( /// dApp for DEX contracts (`RootPn` / `RootOracle` / `Oracle` / `PrivateNote` / /// `Pmp` / ...). /// -/// TODO(dapp): DEX dApp is **UNCONFIRMED**. The kit dropped its `System` -/// placeholder for DEX (`new_default` removed — "Skip dex defaults"), so we -/// pass it explicitly. Same deal as [`TOKEN_DAPP`]: harmless on `< 1.0.0`, must -/// be the real value before any `>= 1.0.0` server. -pub const DEX_DAPP: SystemDapp = SystemDapp::System; +/// Was a `System` placeholder while the kit had no DEX variant; kit v4 added +/// [`SystemDapp::Dex`] (`…0004`), which is the real value. +pub const DEX_DAPP: SystemDapp = SystemDapp::Dex; /// Build `ParamsOfNewContract` for a DEX-family contract at `address`. pub fn dex_contract_params(address: impl Into) -> ParamsOfNewContract { ParamsOfNewContract::new(address, DEX_DAPP) } -/// Whether the server reached via `ctx` speaks the v3 (`>= 1.0.0`) GraphQL that -/// addresses accounts by `account_id` + `dapp_id` instead of legacy -/// `account(address:)`. -/// -/// Use this to pick the query form for our OWN raw `net::query` calls — the -/// kit's own contract methods switch internally and need no help. The SDK -/// caches the parsed server version on the endpoint, so call it ONCE and hoist -/// the result out of paging loops. -pub async fn server_uses_dapp_id(ctx: &Arc) -> AppResult { - supports_dapp_id(ctx, KitModule::Event) - .await - .map_err(|e| AppError::from(e).with_context("detect GraphQL server version")) -} - -/// Bare account-id for the v3 `account_id` GraphQL arg: drops the `"0:"` +/// Bare account-id for the `account_id` GraphQL arg: drops the `"0:"` /// workchain prefix (`"0:hex"` -> `"hex"`). Mirrors the kit's private /// `account_id_from_address`. pub fn account_id(address: &str) -> &str { diff --git a/bee_wallet/src/lib.rs b/bee_wallet/src/lib.rs index a2215d7..a9e63db 100644 --- a/bee_wallet/src/lib.rs +++ b/bee_wallet/src/lib.rs @@ -65,7 +65,7 @@ pub use types::SendTokensReq; pub use types::UpdateMultifactorZkIdReq; pub use types::WithdrawPopitgameRewardsReq; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "dex"))] pub use crate::modules::dex::ParamsOfGenerateVoucher; pub use crate::modules::names::ResultOfValidateWalletName; pub use crate::modules::names::WalletNameErrorCode; diff --git a/bee_wallet/src/modules/mod.rs b/bee_wallet/src/modules/mod.rs index cfa2f9b..254ed23 100644 --- a/bee_wallet/src/modules/mod.rs +++ b/bee_wallet/src/modules/mod.rs @@ -12,7 +12,7 @@ pub(crate) mod balance; pub(crate) mod connect; pub(crate) mod deploy; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "dex"))] pub(crate) mod dex; pub(crate) mod history; pub(crate) mod miner; diff --git a/bee_wallet/src/services/mod.rs b/bee_wallet/src/services/mod.rs index 98e38d8..d025a2c 100644 --- a/bee_wallet/src/services/mod.rs +++ b/bee_wallet/src/services/mod.rs @@ -13,8 +13,9 @@ pub mod boost; pub mod connect; pub mod deploy; // DEX wrappers live in `dodex-contracts` (native-only dep); voucher generation -// isn't exposed on wasm. -#[cfg(not(target_arch = "wasm32"))] +// isn't exposed on wasm. Behind the `dex` feature while dodex is a kit major +// behind us — see the feature's comment in Cargo.toml. +#[cfg(all(not(target_arch = "wasm32"), feature = "dex"))] pub mod dex; pub mod miner; pub mod multifactor; diff --git a/bee_wallet/src/services/tokens/sell_orders.rs b/bee_wallet/src/services/tokens/sell_orders.rs index 397428b..b527776 100644 --- a/bee_wallet/src/services/tokens/sell_orders.rs +++ b/bee_wallet/src/services/tokens/sell_orders.rs @@ -66,25 +66,9 @@ fn sell_orders_retry_policy() -> bee_infra::RetryPolicy { } } +/// Accumulator events by `dst`. Addresses the account by `account_id` + +/// `dapp_id` (gql-server `>= 1.0.0`; the only form the kit speaks since v4). const GQL_EVENTS_BY_DST: &str = r#" - query($address: String!, $dst: String!, $last: Int!, $before: String) { - blockchain { - account(address: $address) { - events(dst: $dst, last: $last, before: $before) { - edges { - cursor - node { msg_id created_at dst body } - } - pageInfo { hasPreviousPage } - } - } - } - } -"#; - -/// v3 (`>= 1.0.0`) form of [`GQL_EVENTS_BY_DST`] — addresses the accumulator by -/// `account_id` + `dapp_id` instead of `address`. -const GQL_EVENTS_BY_DST_V3: &str = r#" query($account_id: String!, $dapp_id: String!, $dst: String!, $last: Int!, $before: String) { blockchain { account(account_id: $account_id, dapp_id: $dapp_id) { @@ -125,30 +109,18 @@ async fn fetch_events_one_endpoint( accumulator_addr: &str, dst: &str, ) -> AppResult> { - // Pick the GraphQL wire form once (cached per-endpoint by the SDK). The - // accumulator lives under the Mobile Verifiers dApp; `dapp_id` is only - // consumed by `>= 1.0.0` servers but must be correct now. - let v3 = crate::dapp::server_uses_dapp_id(ctx).await?; + // The accumulator lives under the Mobile Verifiers dApp. let dapp_id = ackinacki_kit::contracts::dapp::SystemDapp::MobileVerifiers.dapp_id(); let mut all = Vec::new(); let mut before: Option = None; for _ in 0..MAX_EVENT_PAGES { - let variables = if v3 { - json!({ - "account_id": crate::dapp::account_id(accumulator_addr), - "dapp_id": dapp_id, - "dst": dst, - "last": EVENT_PAGE_SIZE, - "before": before, - }) - } else { - json!({ - "address": accumulator_addr, - "dst": dst, - "last": EVENT_PAGE_SIZE, - "before": before, - }) - }; + let variables = json!({ + "account_id": crate::dapp::account_id(accumulator_addr), + "dapp_id": dapp_id, + "dst": dst, + "last": EVENT_PAGE_SIZE, + "before": before, + }); let ctx_clone = ctx.clone(); let result_value = bee_infra::with_retry_policy( &sell_orders_retry_policy(), @@ -161,8 +133,7 @@ async fn fetch_events_one_endpoint( gql_query( ctx_clone, GqlParams { - query: if v3 { GQL_EVENTS_BY_DST_V3 } else { GQL_EVENTS_BY_DST } - .to_string(), + query: GQL_EVENTS_BY_DST.to_string(), variables: Some(variables), }, ) diff --git a/bee_wallet/src/services/transaction/history.rs b/bee_wallet/src/services/transaction/history.rs index 9ea97d8..624eb9f 100644 --- a/bee_wallet/src/services/transaction/history.rs +++ b/bee_wallet/src/services/transaction/history.rs @@ -216,38 +216,10 @@ struct GqlPageInfo { // ---------- GraphQL queries ---------- /// ECC: all incoming and outgoing internal messages for multifactor account. -/// Uses `last`/`before` to get newest messages first (reverse cursor -/// pagination). +/// Addresses the account by `account_id` + `dapp_id` (gql-server `>= 1.0.0`; +/// the only form the kit speaks since v4). Uses `last`/`before` to get newest +/// messages first (reverse cursor pagination). const GQL_ECC_QUERY: &str = r#" - query($address: String!, $last: Int!, $before: String) { - blockchain { - account(address: $address) { - messages(msg_type: [IntIn, IntOut], last: $last, before: $before) { - edges { - node { - id - src - dst - created_at - value_other { - currency - value(format: DEC) - } - } - } - pageInfo { - startCursor - hasPreviousPage - } - } - } - } - } -"#; - -/// v3 (`>= 1.0.0`) form of [`GQL_ECC_QUERY`] — account by `account_id` + -/// `dapp_id`. -const GQL_ECC_QUERY_V3: &str = r#" query($account_id: String!, $dapp_id: String!, $last: Int!, $before: String) { blockchain { account(account_id: $account_id, dapp_id: $dapp_id) { @@ -276,33 +248,9 @@ const GQL_ECC_QUERY_V3: &str = r#" /// Mining: RewardedPopitGame events emitted by GameRoot, filtered by dst = /// popitgame external address. Each event body contains `reward: uint128`. -/// Uses `last`/`before` for reverse cursor pagination (newest first). +/// Addresses the account by `account_id` + `dapp_id`. Uses `last`/`before` for +/// reverse cursor pagination (newest first). const GQL_MINING_EVENTS_QUERY: &str = r#" - query($address: String!, $dst: String!, $last: Int!, $before: String) { - blockchain { - account(address: $address) { - events(dst: $dst, last: $last, before: $before) { - edges { - node { - msg_id - created_at - dst - body - } - } - pageInfo { - startCursor - hasPreviousPage - } - } - } - } - } -"#; - -/// v3 (`>= 1.0.0`) form of [`GQL_MINING_EVENTS_QUERY`] — account by -/// `account_id` + `dapp_id`. -const GQL_MINING_EVENTS_QUERY_V3: &str = r#" query($account_id: String!, $dapp_id: String!, $dst: String!, $last: Int!, $before: String) { blockchain { account(account_id: $account_id, dapp_id: $dapp_id) { @@ -334,27 +282,18 @@ async fn execute_gql_query( cursor: Option<&str>, ) -> crate::errors::AppResult<(Vec, GqlPageInfo)> { // Multifactor account lives under the Mobile Verifiers dApp. - let v3 = crate::dapp::server_uses_dapp_id(tvm_client).await?; let dapp_id = ackinacki_kit::contracts::dapp::SystemDapp::MobileVerifiers.dapp_id(); - let variables = if v3 { - json!({ - "account_id": crate::dapp::account_id(address), - "dapp_id": dapp_id, - "last": page_size, - "before": cursor, - }) - } else { - json!({ - "address": address, - "last": page_size, - "before": cursor, - }) - }; + let variables = json!({ + "account_id": crate::dapp::account_id(address), + "dapp_id": dapp_id, + "last": page_size, + "before": cursor, + }); let result = ackinacki_kit::tvm_client::net::query( tvm_client.clone(), ackinacki_kit::tvm_client::net::ParamsOfQuery { - query: if v3 { GQL_ECC_QUERY_V3 } else { GQL_ECC_QUERY }.to_string(), + query: GQL_ECC_QUERY.to_string(), variables: Some(variables), }, ) @@ -430,30 +369,19 @@ async fn execute_mining_events_query( let popitgame_ext_dst = popitgame_address.replacen("0:", ":", 1); // GameRoot lives under the Mobile Verifiers dApp. - let v3 = crate::dapp::server_uses_dapp_id(tvm_client).await?; let dapp_id = ackinacki_kit::contracts::dapp::SystemDapp::MobileVerifiers.dapp_id(); - let variables = if v3 { - json!({ - "account_id": crate::dapp::account_id(GAME_ROOT_ADDRESS), - "dapp_id": dapp_id, - "dst": popitgame_ext_dst, - "last": page_size, - "before": cursor, - }) - } else { - json!({ - "address": GAME_ROOT_ADDRESS, - "dst": popitgame_ext_dst, - "last": page_size, - "before": cursor, - }) - }; + let variables = json!({ + "account_id": crate::dapp::account_id(GAME_ROOT_ADDRESS), + "dapp_id": dapp_id, + "dst": popitgame_ext_dst, + "last": page_size, + "before": cursor, + }); let result = ackinacki_kit::tvm_client::net::query( tvm_client.clone(), ackinacki_kit::tvm_client::net::ParamsOfQuery { - query: if v3 { GQL_MINING_EVENTS_QUERY_V3 } else { GQL_MINING_EVENTS_QUERY } - .to_string(), + query: GQL_MINING_EVENTS_QUERY.to_string(), variables: Some(variables), }, ) diff --git a/bee_wallet/tests/dex_flows/main.rs b/bee_wallet/tests/dex_flows/main.rs index 2d57425..d2b0fe8 100644 --- a/bee_wallet/tests/dex_flows/main.rs +++ b/bee_wallet/tests/dex_flows/main.rs @@ -14,14 +14,17 @@ //! //! Run (needs SSH access to the halo2 kit + local halo2 params; see //! `PARAMS_DIR` / `HALO2_PK_CACHE` defaults in `Halo2Paths::from_env`): -//! cargo test -p bee-wallet --test dex_flows -- --nocapture --test-threads=1 +//! cargo test -p bee-wallet --features dex --test dex_flows \ +//! -- --nocapture --test-threads=1 // `common/` is a shared helper module: each test uses a subset, so some // helpers are unused from any single flow's point of view. #![allow(dead_code)] // Native-only (heavy halo2 + dodex-sdk graph). Empty crate on wasm32 so -// `wasm-pack test --tests` doesn't try to build it. -#![cfg(not(target_arch = "wasm32"))] +// `wasm-pack test --tests` doesn't try to build it. Also empty without the +// `dex` feature: dodex is still on kit v4.0.1 and its types don't unify with +// ours on v5.0.0 (see the `dex` feature comment in Cargo.toml). +#![cfg(all(not(target_arch = "wasm32"), feature = "dex"))] mod common; mod flows; diff --git a/bee_wallet/tests/integration.rs b/bee_wallet/tests/integration.rs index f283b7b..ff7112a 100644 --- a/bee_wallet/tests/integration.rs +++ b/bee_wallet/tests/integration.rs @@ -281,6 +281,7 @@ async fn deploy_fresh_wallet(wallet: &Wallet) -> DeployedWallet { /// Deploy a fresh wallet with enough ECC for DEX operations (voucher nominal = /// 100+). +#[cfg(feature = "dex")] async fn deploy_fresh_wallet_for_dex(wallet: &Wallet) -> DeployedWallet { static COUNTER: AtomicU32 = AtomicU32::new(0); let idx = COUNTER.fetch_add(1, Ordering::SeqCst); @@ -4259,7 +4260,11 @@ async fn test_update_contract_flags() { // ============================================================ // DEX voucher generation (bee_wallet responsibility) // ============================================================ +// Behind the `dex` feature: the voucher path needs `dodex-contracts`, which is +// still on kit v4.0.1 while we are on v5.0.0 (see the feature's comment in +// Cargo.toml). +#[cfg(feature = "dex")] #[tokio::test] async fn test_generate_voucher_deposit() { let wallet = create_shellnet_wallet(); @@ -4279,6 +4284,7 @@ async fn test_generate_voucher_deposit() { .expect("generate_voucher (deposit NACKL)"); } +#[cfg(feature = "dex")] #[tokio::test] async fn test_generate_voucher_gas() { let wallet = create_shellnet_wallet();