Skip to content

Commit 3e00df4

Browse files
lklimekclaude
andcommitted
refactor(rs-platform-wallet/e2e): use dash_sdk address_inputs helpers in transfer_capturing_st_bytes
Replace the hand-rolled AddressInfo::fetch_many + manual nonce bump in transfer_capturing_st_bytes with the now-public dash_sdk::platform::transition::address_inputs::{fetch_inputs_with_nonce, nonce_inc} helpers (promoted to pub in PR #3549's dedup base). Closes the wallet-side half of PR #3549 dedup §3.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f3cbd29 commit 3e00df4

1 file changed

Lines changed: 7 additions & 21 deletions

File tree

packages/rs-platform-wallet/tests/e2e/framework/wallet_factory.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -238,33 +238,19 @@ impl TestWallet {
238238
outputs: BTreeMap<PlatformAddress, Credits>,
239239
inputs: BTreeMap<PlatformAddress, Credits>,
240240
) -> FrameworkResult<(PlatformAddressChangeSet, Vec<u8>)> {
241-
use std::collections::BTreeSet;
242-
243-
use dash_sdk::platform::FetchMany;
244-
use dash_sdk::query_types::AddressInfo;
245-
use dpp::prelude::AddressNonce;
241+
use dash_sdk::platform::transition::address_inputs::{fetch_inputs_with_nonce, nonce_inc};
246242
use dpp::serialization::PlatformSerializable;
247243
use dpp::state_transition::address_funds_transfer_transition::methods::AddressFundsTransferTransitionMethodsV0;
248244
use dpp::state_transition::address_funds_transfer_transition::AddressFundsTransferTransition;
249245

250-
// Sibling build for byte capture. Fetch on-chain nonces via
251-
// the public `AddressInfo::fetch_many`, bump by one to match
252-
// the SDK's `nonce_inc` convention, sign, then serialize.
253-
// The transition is NEVER broadcast — the production
254-
// `transfer_with_inputs` below does its own nonce fetch +
255-
// sign + broadcast.
256-
let address_set: BTreeSet<PlatformAddress> = inputs.keys().copied().collect();
257-
let address_infos = AddressInfo::fetch_many(self.wallet.sdk(), address_set)
246+
// Sibling build for byte capture. Fetches on-chain nonces and
247+
// bumps them via the public SDK helpers, then signs + serializes.
248+
// The transition is NEVER broadcast — `transfer_with_inputs`
249+
// below does its own nonce fetch + sign + broadcast.
250+
let inputs_with_nonce = fetch_inputs_with_nonce(self.wallet.sdk(), &inputs)
258251
.await
259252
.map_err(|err| FrameworkError::Wallet(format!("nonce fetch: {err}")))?;
260-
let mut inputs_with_nonce: BTreeMap<PlatformAddress, (AddressNonce, Credits)> =
261-
BTreeMap::new();
262-
for (addr, amount) in &inputs {
263-
let info = address_infos.get(addr).cloned().flatten().ok_or_else(|| {
264-
FrameworkError::Wallet(format!("address {addr:?} missing from nonce response"))
265-
})?;
266-
inputs_with_nonce.insert(*addr, (info.nonce + 1, *amount));
267-
}
253+
let inputs_with_nonce = nonce_inc(inputs_with_nonce);
268254

269255
let st = AddressFundsTransferTransition::try_from_inputs_with_signer(
270256
inputs_with_nonce,

0 commit comments

Comments
 (0)