From c38b168b669222bd9fc9ff0da76b7440a35ed3e7 Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Fri, 15 Dec 2023 02:43:35 +0100 Subject: [PATCH 1/4] initial wallet event pass --- .../examples/exchange/4-listen-events.ts | 7 +++--- bindings/nodejs/examples/wallet/events.ts | 4 ++-- bindings/nodejs/lib/types/wallet/event.ts | 24 ------------------- .../lib/wallet/wallet-method-handler.ts | 8 +++---- bindings/nodejs/lib/wallet/wallet.ts | 3 +-- .../examples/exchange/4_listen_events.py | 3 +-- 6 files changed, 11 insertions(+), 38 deletions(-) diff --git a/bindings/nodejs/examples/exchange/4-listen-events.ts b/bindings/nodejs/examples/exchange/4-listen-events.ts index 09e93b7f45..9eda5a1f7d 100644 --- a/bindings/nodejs/examples/exchange/4-listen-events.ts +++ b/bindings/nodejs/examples/exchange/4-listen-events.ts @@ -5,7 +5,7 @@ // Run with command: // yarn run-example ./exchange/4-listen-events.ts -import { Wallet, Event, WalletEventType } from '@iota/sdk'; +import { Wallet, WalletEvent, WalletEventType } from '@iota/sdk'; // This example uses secrets in environment variables for simplicity which should not be done in production. require('dotenv').config({ path: '.env' }); @@ -24,9 +24,8 @@ async function run() { storagePath: process.env.WALLET_DB_PATH, }); - const callback = function (err: any, event: Event) { - console.log('AccountIndex:', event.accountIndex); - console.log('Event:', event.event); + const callback = function (err: any, event: WalletEvent) { + console.log('Event:', event); // Exit after receiving an event. process.exit(0); diff --git a/bindings/nodejs/examples/wallet/events.ts b/bindings/nodejs/examples/wallet/events.ts index f11178fc82..5b7fdb88b5 100644 --- a/bindings/nodejs/examples/wallet/events.ts +++ b/bindings/nodejs/examples/wallet/events.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { - Event, + WalletEvent, ConsolidationRequiredWalletEvent, TransactionProgressWalletEvent, SelectingInputsProgress, @@ -24,7 +24,7 @@ async function run() { // Create the wallet const wallet = await getUnlockedWallet(); - const callback = function (err: any, event: Event) { + const callback = function (err: any, event: WalletEvent) { console.log('Event:', event); }; diff --git a/bindings/nodejs/lib/types/wallet/event.ts b/bindings/nodejs/lib/types/wallet/event.ts index 2ade953208..ccbe28ad52 100644 --- a/bindings/nodejs/lib/types/wallet/event.ts +++ b/bindings/nodejs/lib/types/wallet/event.ts @@ -13,29 +13,6 @@ import { HexEncodedString } from '../utils'; */ export type TransactionId = string; -/** - * An wallet account event. - */ -class Event { - /** - * The account index for which the event was emitted. - */ - accountIndex: number; - /** - * The wallet event. - */ - event: WalletEvent; - - /** - * @param accountIndex The account index. - * @param event The wallet event. - */ - constructor(accountIndex: number, event: WalletEvent) { - this.accountIndex = accountIndex; - this.event = event; - } -} - /** * All of the wallet event types. */ @@ -280,7 +257,6 @@ class BroadcastingProgress extends TransactionProgress { } export { - Event, WalletEventType, WalletEvent, ConsolidationRequiredWalletEvent, diff --git a/bindings/nodejs/lib/wallet/wallet-method-handler.ts b/bindings/nodejs/lib/wallet/wallet-method-handler.ts index b91eda5834..7bb9783da5 100644 --- a/bindings/nodejs/lib/wallet/wallet-method-handler.ts +++ b/bindings/nodejs/lib/wallet/wallet-method-handler.ts @@ -11,9 +11,9 @@ import { } from '../bindings'; import { WalletEventType, + WalletEvent, WalletOptions, __WalletMethod__, - Event, } from '../types/wallet'; import { Client, ClientMethodHandler } from '../client'; import { SecretManager, SecretManagerMethodHandler } from '../secret_manager'; @@ -74,17 +74,17 @@ export class WalletMethodHandler { */ async listen( eventTypes: WalletEventType[], - callback: (error: Error, event: Event) => void, + callback: (error: Error, event: WalletEvent) => void, ): Promise { return listenWallet( this.methodHandler, eventTypes, function (err: any, data: string) { - const parsed = JSON.parse(data); + const parsed: WalletEvent = JSON.parse(data); callback( // Send back raw error instead of parsing err, - new Event(parsed.accountIndex, parsed.event), + parsed, ); }, ).catch((error: any) => { diff --git a/bindings/nodejs/lib/wallet/wallet.ts b/bindings/nodejs/lib/wallet/wallet.ts index a8b1a53a2a..380b55a7b9 100644 --- a/bindings/nodejs/lib/wallet/wallet.ts +++ b/bindings/nodejs/lib/wallet/wallet.ts @@ -52,7 +52,6 @@ import type { WalletOptions, WalletEventType, WalletEvent, - Event, } from '../types/wallet'; import { IAuth, IClientOptions, LedgerNanoStatus } from '../types/client'; import { SecretManager } from '../secret_manager'; @@ -169,7 +168,7 @@ export class Wallet { */ async listen( eventTypes: WalletEventType[], - callback: (error: Error, event: Event) => void, + callback: (error: Error, event: WalletEvent) => void, ): Promise { return this.methodHandler.listen(eventTypes, callback); } diff --git a/bindings/python/examples/exchange/4_listen_events.py b/bindings/python/examples/exchange/4_listen_events.py index 0da6091589..74736f7967 100644 --- a/bindings/python/examples/exchange/4_listen_events.py +++ b/bindings/python/examples/exchange/4_listen_events.py @@ -29,8 +29,7 @@ def callback(event): """Callback function for the event listener""" event_dict = json.loads(event) - print('AccountIndex:', event_dict["accountIndex"]) - print('Event:', event_dict["event"]) + print('Event:', event) # Exit after receiving an event. # pylint: disable=global-statement From ba69ef3ebc8bb8e459414b1d958e4e1274332737 Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Sat, 16 Dec 2023 13:28:29 +0100 Subject: [PATCH 2/4] env fix --- bindings/nodejs/examples/exchange/4-listen-events.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/nodejs/examples/exchange/4-listen-events.ts b/bindings/nodejs/examples/exchange/4-listen-events.ts index 9eda5a1f7d..d80cfd2046 100644 --- a/bindings/nodejs/examples/exchange/4-listen-events.ts +++ b/bindings/nodejs/examples/exchange/4-listen-events.ts @@ -12,7 +12,7 @@ require('dotenv').config({ path: '.env' }); async function run() { try { - for (const envVar of ['WALLET_DB_PATH']) { + for (const envVar of ['WALLET_DB_PATH', 'FAUCET_URL']) { if (!(envVar in process.env)) { throw new Error( `.env ${envVar} is undefined, see .env.example`, @@ -36,7 +36,7 @@ async function run() { // Use the faucet to send testnet tokens to your address. console.log( - 'Fill your address with the faucet: https://faucet.testnet.shimmer.network/', + `Fill your address with the faucet: ${process.env.FAUCET_URL}`, ); const address = await wallet.address(); From 6b6f6ae4fce8c783ea0a58a0c5b65b985b8ea670 Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 18 Dec 2023 14:58:56 +0100 Subject: [PATCH 3/4] removed consolidationrequired --- bindings/nodejs/examples/wallet/events.ts | 2 - bindings/nodejs/lib/types/wallet/event.ts | 22 ++------ bindings/python/iota_sdk/types/event.py | 22 ++++---- sdk/src/client/error.rs | 3 - sdk/src/wallet/core/builder.rs | 5 +- .../core/operations/address_generation.rs | 55 ++++++++----------- sdk/src/wallet/error.rs | 3 - sdk/src/wallet/events/mod.rs | 31 ++++++----- sdk/src/wallet/events/types.rs | 49 +++++++---------- .../operations/transaction/input_selection.rs | 17 +----- sdk/tests/wallet/events.rs | 2 - 11 files changed, 77 insertions(+), 134 deletions(-) diff --git a/bindings/nodejs/examples/wallet/events.ts b/bindings/nodejs/examples/wallet/events.ts index 5b7fdb88b5..d0f8f4f5fd 100644 --- a/bindings/nodejs/examples/wallet/events.ts +++ b/bindings/nodejs/examples/wallet/events.ts @@ -3,7 +3,6 @@ import { WalletEvent, - ConsolidationRequiredWalletEvent, TransactionProgressWalletEvent, SelectingInputsProgress, } from '@iota/sdk'; @@ -30,7 +29,6 @@ async function run() { await wallet.listen([], callback); - await wallet.emitTestEvent(new ConsolidationRequiredWalletEvent()); await wallet.emitTestEvent( new TransactionProgressWalletEvent(new SelectingInputsProgress()), ); diff --git a/bindings/nodejs/lib/types/wallet/event.ts b/bindings/nodejs/lib/types/wallet/event.ts index ccbe28ad52..fbe8d2b7fa 100644 --- a/bindings/nodejs/lib/types/wallet/event.ts +++ b/bindings/nodejs/lib/types/wallet/event.ts @@ -17,18 +17,16 @@ export type TransactionId = string; * All of the wallet event types. */ enum WalletEventType { - /** Consolidation is required. */ - ConsolidationRequired = 0, /** Nano Ledger has generated an address. */ - LedgerAddressGeneration = 1, + LedgerAddressGeneration = 0, /** A new output was created. */ - NewOutput = 2, + NewOutput = 1, /** An output was spent. */ - SpentOutput = 3, + SpentOutput = 2, /** A transaction was included into the ledger. */ - TransactionInclusion = 4, + TransactionInclusion = 3, /** A progress update while submitting a transaction. */ - TransactionProgress = 5, + TransactionProgress = 4, } /** @@ -45,15 +43,6 @@ abstract class WalletEvent { } } -/** - * A 'consolidation required' wallet event. - */ -class ConsolidationRequiredWalletEvent extends WalletEvent { - constructor() { - super(WalletEventType.ConsolidationRequired); - } -} - /** * A 'ledger address generation' wallet event. */ @@ -259,7 +248,6 @@ class BroadcastingProgress extends TransactionProgress { export { WalletEventType, WalletEvent, - ConsolidationRequiredWalletEvent, LedgerAddressGenerationWalletEvent, NewOutputWalletEvent, SpentOutputWalletEvent, diff --git a/bindings/python/iota_sdk/types/event.py b/bindings/python/iota_sdk/types/event.py index 9e378dea09..75ed34886a 100644 --- a/bindings/python/iota_sdk/types/event.py +++ b/bindings/python/iota_sdk/types/event.py @@ -8,16 +8,14 @@ class WalletEventType(IntEnum): """Types of wallet events. Attributes: - ConsolidationRequired (0): Consolidation is required. - LedgerAddressGeneration (1): Nano Ledger has generated an address. - NewOutput (2): A new output was created. - SpentOutput (3): An output was spent. - TransactionInclusion (4): A transaction was included into the ledger. - TransactionProgress (5): A progress update while submitting a transaction. + LedgerAddressGeneration (0): Nano Ledger has generated an address. + NewOutput (1): A new output was created. + SpentOutput (2): An output was spent. + TransactionInclusion (3): A transaction was included into the ledger. + TransactionProgress (4): A progress update while submitting a transaction. """ - ConsolidationRequired = 0 - LedgerAddressGeneration = 1 - NewOutput = 2 - SpentOutput = 3 - TransactionInclusion = 4 - TransactionProgress = 5 + LedgerAddressGeneration = 0 + NewOutput = 1 + SpentOutput = 2 + TransactionInclusion = 3 + TransactionProgress = 4 diff --git a/sdk/src/client/error.rs b/sdk/src/client/error.rs index 5c9bdcbdff..8094d81ea2 100644 --- a/sdk/src/client/error.rs +++ b/sdk/src/client/error.rs @@ -36,9 +36,6 @@ pub enum Error { /// Block types error #[error("{0}")] Block(#[from] crate::types::block::Error), - /// The wallet has enough funds, but split on too many outputs - #[error("the wallet has enough funds, but split on too many outputs: {0}, max. is 128, consolidate them")] - ConsolidationRequired(usize), /// Crypto.rs error #[error("{0}")] Crypto(#[from] crypto::Error), diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index 63e87715ee..c9aa3e7e23 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -227,9 +227,6 @@ where #[cfg(feature = "storage")] self.save(&storage_manager).await?; - #[cfg(feature = "events")] - let event_emitter = tokio::sync::RwLock::new(EventEmitter::new()); - // It happened that inputs got locked, the transaction failed, but they weren't unlocked again, so we do this // here #[cfg(feature = "storage")] @@ -253,7 +250,7 @@ where client, secret_manager: self.secret_manager.expect("make WalletInner::secret_manager optional?"), #[cfg(feature = "events")] - event_emitter, + event_emitter: tokio::sync::RwLock::new(EventEmitter::new()), #[cfg(feature = "storage")] storage_options, #[cfg(feature = "storage")] diff --git a/sdk/src/wallet/core/operations/address_generation.rs b/sdk/src/wallet/core/operations/address_generation.rs index fe902ee8ec..50427dd324 100644 --- a/sdk/src/wallet/core/operations/address_generation.rs +++ b/sdk/src/wallet/core/operations/address_generation.rs @@ -36,41 +36,34 @@ impl Wallet { // needs to have it visible on the computer first, so we need to generate it without the // prompt first let options = options.into(); + #[cfg(feature = "events")] if options.as_ref().map_or(false, |o| o.ledger_nano_prompt) { - #[cfg(feature = "events")] - { - let changed_options = options.map(|mut options| { - // Change options so ledger will not show the prompt the first time - options.ledger_nano_prompt = false; - options - }); - // Generate without prompt to be able to display it - let address = ledger_nano - .generate_ed25519_addresses( - coin_type, - account_index, - address_index..address_index + 1, - changed_options, - ) - .await?; + let changed_options = options.map(|mut options| { + // Change options so ledger will not show the prompt the first time + options.ledger_nano_prompt = false; + options + }); + // Generate without prompt to be able to display it + let address = ledger_nano + .generate_ed25519_addresses( + coin_type, + account_index, + address_index..address_index + 1, + changed_options, + ) + .await?; - let bech32_hrp = self.bech32_hrp().await; + let bech32_hrp = self.bech32_hrp().await; - self.emit(WalletEvent::LedgerAddressGeneration(AddressData { - address: address[0].to_bech32(bech32_hrp), - })) - .await; - } - - // Generate with prompt so the user can verify - ledger_nano - .generate_ed25519_addresses(coin_type, account_index, address_index..address_index + 1, options) - .await? - } else { - ledger_nano - .generate_ed25519_addresses(coin_type, account_index, address_index..address_index + 1, options) - .await? + self.emit(WalletEvent::LedgerAddressGeneration(AddressData { + address: address[0].to_bech32(bech32_hrp), + })) + .await; } + // Generate with prompt so the user can verify + ledger_nano + .generate_ed25519_addresses(coin_type, account_index, address_index..address_index + 1, options) + .await? } #[cfg(feature = "stronghold")] SecretManager::Stronghold(stronghold) => { diff --git a/sdk/src/wallet/error.rs b/sdk/src/wallet/error.rs index ad26c39a91..e6b222517f 100644 --- a/sdk/src/wallet/error.rs +++ b/sdk/src/wallet/error.rs @@ -33,9 +33,6 @@ pub enum Error { new_bip_path: Option, old_bip_path: Option, }, - /// Funds are spread over too many outputs - #[error("funds are spread over too many outputs {output_count}/{output_count_max}, consolidation required")] - ConsolidationRequired { output_count: usize, output_count_max: u16 }, /// Crypto.rs error #[error("{0}")] Crypto(#[from] crypto::Error), diff --git a/sdk/src/wallet/events/mod.rs b/sdk/src/wallet/events/mod.rs index e908a0d1f9..c75cc39acc 100644 --- a/sdk/src/wallet/events/mod.rs +++ b/sdk/src/wallet/events/mod.rs @@ -41,7 +41,6 @@ impl EventEmitter { WalletEventType::SpentOutput, WalletEventType::TransactionInclusion, WalletEventType::TransactionProgress, - WalletEventType::ConsolidationRequired, #[cfg(feature = "ledger_nano")] WalletEventType::LedgerAddressGeneration, ] { @@ -74,7 +73,6 @@ impl EventEmitter { WalletEvent::SpentOutput(_) => WalletEventType::SpentOutput, WalletEvent::TransactionInclusion(_) => WalletEventType::TransactionInclusion, WalletEvent::TransactionProgress(_) => WalletEventType::TransactionProgress, - WalletEvent::ConsolidationRequired => WalletEventType::ConsolidationRequired, #[cfg(feature = "ledger_nano")] WalletEvent::LedgerAddressGeneration(_) => WalletEventType::LedgerAddressGeneration, }; @@ -126,18 +124,18 @@ mod tests { let event_counter = Arc::new(AtomicUsize::new(0)); // single event - emitter.on([WalletEventType::ConsolidationRequired], |_name| { - // println!("ConsolidationRequired: {:?}", name); + emitter.on([WalletEventType::TransactionInclusion], |_name| { + // println!("TransactionInclusion: {:?}", name); }); // listen to two events emitter.on( [ WalletEventType::TransactionProgress, - WalletEventType::ConsolidationRequired, + WalletEventType::TransactionInclusion, ], move |_name| { - // println!("TransactionProgress or ConsolidationRequired: {:?}", name); + // println!("TransactionProgress or TransactionInclusion: {:?}", name); }, ); @@ -149,7 +147,6 @@ mod tests { }); // emit events - emitter.emit(WalletEvent::ConsolidationRequired); emitter.emit(WalletEvent::TransactionProgress( TransactionProgressEvent::SelectingInputs, )); @@ -161,14 +158,16 @@ mod tests { inclusion_state: InclusionState::Confirmed, })); - assert_eq!(3, event_counter.load(Ordering::SeqCst)); + assert_eq!(2, event_counter.load(Ordering::SeqCst)); // remove handlers of single event - emitter.clear([WalletEventType::ConsolidationRequired]); + emitter.clear([WalletEventType::TransactionProgress]); // emit event of removed type - emitter.emit(WalletEvent::ConsolidationRequired); + emitter.emit(WalletEvent::TransactionProgress( + TransactionProgressEvent::SelectingInputs, + )); - assert_eq!(3, event_counter.load(Ordering::SeqCst)); + assert_eq!(2, event_counter.load(Ordering::SeqCst)); // remove handlers of all events emitter.clear([]); @@ -183,18 +182,20 @@ mod tests { .expect("invalid tx id"), inclusion_state: InclusionState::Confirmed, })); - assert_eq!(3, event_counter.load(Ordering::SeqCst)); + assert_eq!(2, event_counter.load(Ordering::SeqCst)); // listen to a single event let event_counter_clone = Arc::clone(&event_counter); - emitter.on([WalletEventType::ConsolidationRequired], move |_name| { + emitter.on([WalletEventType::TransactionProgress], move |_name| { // println!("Any event: {:?}", name); event_counter_clone.fetch_add(1, Ordering::SeqCst); }); for _ in 0..1_000_000 { - emitter.emit(WalletEvent::ConsolidationRequired); + emitter.emit(WalletEvent::TransactionProgress( + TransactionProgressEvent::SelectingInputs, + )); } - assert_eq!(1_000_003, event_counter.load(Ordering::SeqCst)); + assert_eq!(1_000_002, event_counter.load(Ordering::SeqCst)); } } diff --git a/sdk/src/wallet/events/types.rs b/sdk/src/wallet/events/types.rs index 71a4e7b927..475fd5ab2e 100644 --- a/sdk/src/wallet/events/types.rs +++ b/sdk/src/wallet/events/types.rs @@ -22,7 +22,6 @@ use crate::{ #[derive(Clone, Debug, Eq, PartialEq)] #[non_exhaustive] pub enum WalletEvent { - ConsolidationRequired, #[cfg(feature = "ledger_nano")] #[cfg_attr(docsrs, doc(cfg(feature = "ledger_nano")))] LedgerAddressGeneration(AddressData), @@ -45,13 +44,12 @@ impl Serialize for WalletEvent { #[derive(Serialize)] #[serde(untagged)] enum WalletEvent_<'a> { - T0, #[cfg(feature = "ledger_nano")] - T1(&'a AddressData), - T2(&'a NewOutputEvent), - T3(&'a SpentOutputEvent), - T4(&'a TransactionInclusionEvent), - T5(TransactionProgressEvent_<'a>), + T0(&'a AddressData), + T1(&'a NewOutputEvent), + T2(&'a SpentOutputEvent), + T3(&'a TransactionInclusionEvent), + T4(TransactionProgressEvent_<'a>), } #[derive(Serialize)] struct TypedWalletEvent_<'a> { @@ -61,30 +59,26 @@ impl Serialize for WalletEvent { event: WalletEvent_<'a>, } let event = match self { - Self::ConsolidationRequired => TypedWalletEvent_ { - kind: WalletEventType::ConsolidationRequired as u8, - event: WalletEvent_::T0, - }, #[cfg(feature = "ledger_nano")] Self::LedgerAddressGeneration(e) => TypedWalletEvent_ { kind: WalletEventType::LedgerAddressGeneration as u8, - event: WalletEvent_::T1(e), + event: WalletEvent_::T0(e), }, Self::NewOutput(e) => TypedWalletEvent_ { kind: WalletEventType::NewOutput as u8, - event: WalletEvent_::T2(e), + event: WalletEvent_::T1(e), }, Self::SpentOutput(e) => TypedWalletEvent_ { kind: WalletEventType::SpentOutput as u8, - event: WalletEvent_::T3(e), + event: WalletEvent_::T2(e), }, Self::TransactionInclusion(e) => TypedWalletEvent_ { kind: WalletEventType::TransactionInclusion as u8, - event: WalletEvent_::T4(e), + event: WalletEvent_::T3(e), }, Self::TransactionProgress(e) => TypedWalletEvent_ { kind: WalletEventType::TransactionProgress as u8, - event: WalletEvent_::T5(TransactionProgressEvent_ { progress: e }), + event: WalletEvent_::T4(TransactionProgressEvent_ { progress: e }), }, }; event.serialize(serializer) @@ -108,7 +102,6 @@ impl<'de> Deserialize<'de> for WalletEvent { ) .map_err(serde::de::Error::custom)? { - WalletEventType::ConsolidationRequired => Self::ConsolidationRequired, #[cfg(feature = "ledger_nano")] WalletEventType::LedgerAddressGeneration => { Self::LedgerAddressGeneration(AddressData::deserialize(value).map_err(|e| { @@ -146,14 +139,13 @@ impl<'de> Deserialize<'de> for WalletEvent { #[repr(u8)] #[non_exhaustive] pub enum WalletEventType { - ConsolidationRequired = 0, #[cfg(feature = "ledger_nano")] #[cfg_attr(docsrs, doc(cfg(feature = "ledger_nano")))] - LedgerAddressGeneration = 1, - NewOutput = 2, - SpentOutput = 3, - TransactionInclusion = 4, - TransactionProgress = 5, + LedgerAddressGeneration = 0, + NewOutput = 1, + SpentOutput = 2, + TransactionInclusion = 3, + TransactionProgress = 4, } impl TryFrom for WalletEventType { @@ -161,13 +153,12 @@ impl TryFrom for WalletEventType { fn try_from(value: u8) -> Result { let event_type = match value { - 0 => Self::ConsolidationRequired, #[cfg(feature = "ledger_nano")] - 1 => Self::LedgerAddressGeneration, - 2 => Self::NewOutput, - 3 => Self::SpentOutput, - 4 => Self::TransactionInclusion, - 5 => Self::TransactionProgress, + 0 => Self::LedgerAddressGeneration, + 1 => Self::NewOutput, + 2 => Self::SpentOutput, + 3 => Self::TransactionInclusion, + 4 => Self::TransactionProgress, _ => return Err(Error::InvalidEventType(value)), }; Ok(event_type) diff --git a/sdk/src/wallet/operations/transaction/input_selection.rs b/sdk/src/wallet/operations/transaction/input_selection.rs index 5422f2a922..9a5b8c8bb2 100644 --- a/sdk/src/wallet/operations/transaction/input_selection.rs +++ b/sdk/src/wallet/operations/transaction/input_selection.rs @@ -171,22 +171,7 @@ where input_selection = input_selection.with_burn(burn.clone()); } - let selected_transaction_data = match input_selection.select() { - Ok(r) => r, - // TODO this error doesn't exist with the new ISA - // Err(crate::client::Error::ConsolidationRequired(output_count)) => { - // #[cfg(feature = "events")] - // self.event_emitter - // .lock() - // .await - // .emit(account.index, WalletEvent::ConsolidationRequired); - // return Err(crate::wallet::Error::ConsolidationRequired { - // output_count, - // output_count_max: INPUT_COUNT_MAX, - // }); - // } - Err(e) => return Err(e.into()), - }; + let selected_transaction_data = input_selection.select()?; // lock outputs so they don't get used by another transaction for output in &selected_transaction_data.inputs { diff --git a/sdk/tests/wallet/events.rs b/sdk/tests/wallet/events.rs index d30eedb89f..23a7c8abe1 100644 --- a/sdk/tests/wallet/events.rs +++ b/sdk/tests/wallet/events.rs @@ -40,8 +40,6 @@ fn assert_serde_eq(event_0: WalletEvent) { #[test] fn wallet_events_serde() { - assert_serde_eq(WalletEvent::ConsolidationRequired); - #[cfg(feature = "ledger_nano")] assert_serde_eq(WalletEvent::LedgerAddressGeneration(AddressData { address: Bech32Address::try_from_str("rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy") From 2a19afb918d0ad326f12ecc3fc1f3898ab83c082 Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 8 Jan 2024 15:06:40 +0100 Subject: [PATCH 4/4] fix event example --- bindings/python/examples/exchange/4_listen_events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/examples/exchange/4_listen_events.py b/bindings/python/examples/exchange/4_listen_events.py index 74736f7967..de17a4c248 100644 --- a/bindings/python/examples/exchange/4_listen_events.py +++ b/bindings/python/examples/exchange/4_listen_events.py @@ -28,7 +28,7 @@ def callback(event): """Callback function for the event listener""" - event_dict = json.loads(event) + event = json.loads(event) print('Event:', event) # Exit after receiving an event.