@@ -55,8 +55,9 @@ use strict_types::StrictVal;
5555
5656use crate :: contracts:: SyncError ;
5757use crate :: {
58- Assignment , CodexId , Consensus , ConsumeError , Contract , ContractState , Contracts , CreateParams ,
59- EitherSeal , Identity , Issuer , IssuerError , OwnedState , Pile , SigBlob , Stockpile , WitnessStatus ,
58+ Assignment , CodexId , Consensus , ConsumeError , Contract , ContractState , ContractStateName ,
59+ Contracts , CreateParams , EitherSeal , Identity , Issuer , IssuerError , OwnedState , Pile , SigBlob ,
60+ Stockpile , WalletState , WitnessStatus ,
6061} ;
6162
6263/// Trait abstracting a specific implementation of a bitcoin wallet.
@@ -466,6 +467,29 @@ where
466467 WitnessOut :: new ( address. payload , nonce)
467468 }
468469
470+ 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
491+ }
492+
469493 pub fn wallet_contract_state ( & self , contract_id : ContractId ) -> ContractState < Outpoint > {
470494 self . contracts
471495 . contract_state ( contract_id)
0 commit comments