@@ -55,9 +55,9 @@ use strict_types::StrictVal;
5555
5656use crate :: contracts:: SyncError ;
5757use crate :: {
58- Assignment , CodexId , Consensus , ConsumeError , Contract , ContractState , ContractStateName ,
59- Contracts , CreateParams , EitherSeal , Identity , Issuer , IssuerError , OwnedState , Pile , SigBlob ,
60- Stockpile , WalletState , WitnessStatus ,
58+ Assignment , CodexId , Consensus , ConsumeError , Contract , ContractState , Contracts , CreateParams ,
59+ EitherSeal , Identity , Issuer , IssuerError , OwnedState , Pile , SigBlob , Stockpile , WalletState ,
60+ WitnessStatus ,
6161} ;
6262
6363/// Trait abstracting a specific implementation of a bitcoin wallet.
@@ -468,26 +468,11 @@ where
468468 }
469469
470470 pub fn wallet_state ( & self ) -> WalletState < TxoSeal > {
471- let mut wallet_state = WalletState :: default ( ) ;
472- for contract_id in self . contracts . contract_ids ( ) {
473- let contract_state = self . contracts . contract_state ( contract_id) ;
474- for ( state_name, state) in contract_state. immutable {
475- wallet_state
476- . immutable
477- . insert ( ContractStateName :: new ( contract_id, state_name) , state) ;
478- }
479- for ( state_name, state) in contract_state. owned {
480- wallet_state
481- . owned
482- . insert ( ContractStateName :: new ( contract_id, state_name) , state) ;
483- }
484- for ( state_name, state) in contract_state. aggregated {
485- wallet_state
486- . aggregated
487- . insert ( ContractStateName :: new ( contract_id, state_name) , state) ;
488- }
489- }
490- wallet_state
471+ let iter = self
472+ . contracts
473+ . contract_ids ( )
474+ . map ( |id| ( id, self . contracts . contract_state ( id) ) ) ;
475+ WalletState :: from_contracts_state ( iter)
491476 }
492477
493478 pub fn wallet_contract_state ( & self , contract_id : ContractId ) -> ContractState < Outpoint > {
0 commit comments