@@ -32,92 +32,99 @@ pub trait EntropyStorage: Send + Sync {
3232 ) -> Result < Option < DcdContractTokenEntropies > > ;
3333}
3434
35+ #[ derive( Clone , Debug ) ]
36+ pub enum TransactionOption {
37+ TakerFundOrder ( Txid ) ,
38+ TakerTerminationEarly ( Txid ) ,
39+ TakerSettlement ( Txid ) ,
40+ MakerFund ( Txid ) ,
41+ MakerTerminationCollateral ( Txid ) ,
42+ MakerTerminationSettlement ( Txid ) ,
43+ MakerSettlement ( Txid ) ,
44+ }
45+
46+ #[ derive( Clone , Debug ) ]
47+ pub enum TransactionInputsOption {
48+ TakerFundOrder ( TakerFundInputs ) ,
49+ TakerTerminationEarly ( TakerTerminationEarlyInputs ) ,
50+ TakerSettlement ( TakerSettlementInputs ) ,
51+ MakerFund ( MakerFundInputs ) ,
52+ MakerTerminationCollateral ( MakerTerminationCollateralInputs ) ,
53+ MakerTerminationSettlement ( MakerTerminationSettlmentInputs ) ,
54+ MakerSettlement ( MakerSettlementInputs ) ,
55+ }
56+
57+ #[ derive( Clone , Debug ) ]
58+ pub enum TransactionInputs {
59+ TakerFundOrder ,
60+ TakerTerminationEarly ,
61+ TakerSettlement ( GetSettlementFilter ) ,
62+ MakerFund ,
63+ MakerTerminationCollateral ,
64+ MakerTerminationSettlement ,
65+ MakerSettlement ( GetSettlementFilter ) ,
66+ }
67+
3568#[ async_trait]
3669pub trait CoinSelector : Send + Sync + CoinSelectionStorage + DcdParamsStorage + EntropyStorage {
37- async fn add_taker_fund_order_outputs ( & self , _tx_id : Txid ) -> Result < ( ) > {
38- Ok ( ( ) )
39- }
40- async fn add_taker_termination_early_outputs ( & self , _tx_id : Txid ) -> Result < ( ) > {
41- //todo: add inputs of transaction, mark the mas spent and
42- //todo: add implementation
43- Ok ( ( ) )
44- }
45- async fn add_taker_settlement_outputs ( & self , _tx_id : Txid ) -> Result < ( ) > {
46- //todo: add inputs of transaction, mark the mas spent and
47- //todo: add implementation
48- Ok ( ( ) )
49- }
50- async fn add_maker_fund_outputs ( & self , _tx_id : Txid ) -> Result < ( ) > {
51- //todo: add inputs of transaction, mark the mas spent and
52- //todo: add implementation
53- Ok ( ( ) )
54- }
55- async fn add_maker_termination_collateral_outputs ( & self , _tx_id : Txid ) -> Result < ( ) > {
56- //todo: add inputs of transaction, mark the mas spent and
57- //todo: add implementation
58- Ok ( ( ) )
59- }
60- async fn add_maker_termination_settlement_outputs ( & self , _tx_id : Txid ) -> Result < ( ) > {
61- //todo: add inputs of transaction, mark the mas spent and
62- //todo: add implementation
63- Ok ( ( ) )
64- }
65- async fn add_maker_settlement_outputs ( & self , _tx_id : Txid ) -> Result < ( ) > {
66- //todo: add inputs of transaction, mark the mas spent and
67- //todo: add implementation
70+ async fn add_outputs ( & self , option : TransactionOption ) -> Result < ( ) > {
71+ match option {
72+ TransactionOption :: TakerFundOrder ( _) => { }
73+ TransactionOption :: TakerTerminationEarly ( _) => { }
74+ TransactionOption :: TakerSettlement ( _) => { }
75+ TransactionOption :: MakerFund ( _) => { }
76+ TransactionOption :: MakerTerminationCollateral ( _) => { }
77+ TransactionOption :: MakerTerminationSettlement ( _) => { }
78+ TransactionOption :: MakerSettlement ( _) => { }
79+ }
6880 Ok ( ( ) )
6981 }
70- async fn get_taker_fund_order_inputs ( & self ) -> Result < TakerFundInputs > {
71- //todo: add implementation
72- Ok ( TakerFundInputs {
73- filler_token : None ,
74- collateral_token : None ,
75- } )
76- }
77- async fn get_taker_termination_early_inputs ( & self ) -> Result < TakerTerminationEarlyInputs > {
78- //todo: add implementation
79- Ok ( TakerTerminationEarlyInputs {
80- filler_token : None ,
81- collateral_token : None ,
82- } )
83- }
84- async fn get_taker_settlement_inputs ( & self , _filter : GetSettlementFilter ) -> Result < TakerSettlementInputs > {
85- //todo: add implementation
86- Ok ( TakerSettlementInputs {
87- filler_token : None ,
88- asset_token : None ,
89- } )
90- }
91- async fn get_maker_fund_inputs ( & self ) -> Result < MakerFundInputs > {
92- //todo: add implementation
93- Ok ( MakerFundInputs {
94- filler_reissuance_tx : None ,
95- grantor_collateral_reissuance_tx : None ,
96- grantor_settlement_reissuance_tx : None ,
97- asset_settlement_tx : None ,
98- } )
99- }
100- async fn get_maker_termination_collateral_inputs ( & self ) -> Result < MakerTerminationCollateralInputs > {
101- //todo: add implementation
102- Ok ( MakerTerminationCollateralInputs {
103- collateral_token_utxo : None ,
104- grantor_collateral_token_utxo : None ,
105- } )
106- }
107- async fn get_maker_termination_settlement_inputs ( & self ) -> Result < MakerTerminationSettlmentInputs > {
108- //todo: add implementation
109- Ok ( MakerTerminationSettlmentInputs {
110- settlement_asset_utxo : None ,
111- grantor_settlement_token_utxo : None ,
112- } )
113- }
114- async fn get_maker_settlement_inputs ( & self , _filter : GetSettlementFilter ) -> Result < MakerSettlementInputs > {
115- //todo: add implementation
116- Ok ( MakerSettlementInputs {
117- asset_utxo : None ,
118- grantor_collateral_token_utxo : None ,
119- grantor_settlement_token_utxo : None ,
120- } )
82+
83+ async fn get_inputs ( & self , option : TransactionInputs ) -> Result < TransactionInputsOption > {
84+ let res = match option {
85+ TransactionInputs :: TakerFundOrder => TransactionInputsOption :: TakerFundOrder ( TakerFundInputs {
86+ filler_token : None ,
87+ collateral_token : None ,
88+ } ) ,
89+ TransactionInputs :: TakerTerminationEarly => {
90+ TransactionInputsOption :: TakerTerminationEarly ( TakerTerminationEarlyInputs {
91+ filler_token : None ,
92+ collateral_token : None ,
93+ } )
94+ }
95+ TransactionInputs :: TakerSettlement ( _filter) => {
96+ TransactionInputsOption :: TakerSettlement ( TakerSettlementInputs {
97+ filler_token : None ,
98+ asset_token : None ,
99+ } )
100+ }
101+ TransactionInputs :: MakerFund => TransactionInputsOption :: MakerFund ( MakerFundInputs {
102+ filler_reissuance_tx : None ,
103+ grantor_collateral_reissuance_tx : None ,
104+ grantor_settlement_reissuance_tx : None ,
105+ asset_settlement_tx : None ,
106+ } ) ,
107+ TransactionInputs :: MakerTerminationCollateral => {
108+ TransactionInputsOption :: MakerTerminationCollateral ( MakerTerminationCollateralInputs {
109+ collateral_token_utxo : None ,
110+ grantor_collateral_token_utxo : None ,
111+ } )
112+ }
113+ TransactionInputs :: MakerTerminationSettlement => {
114+ TransactionInputsOption :: MakerTerminationSettlement ( MakerTerminationSettlmentInputs {
115+ settlement_asset_utxo : None ,
116+ grantor_settlement_token_utxo : None ,
117+ } )
118+ }
119+ TransactionInputs :: MakerSettlement ( _filter) => {
120+ TransactionInputsOption :: MakerSettlement ( MakerSettlementInputs {
121+ asset_utxo : None ,
122+ grantor_collateral_token_utxo : None ,
123+ grantor_settlement_token_utxo : None ,
124+ } )
125+ }
126+ } ;
127+ Ok ( res)
121128 }
122129}
123130
@@ -160,7 +167,7 @@ pub struct GetTokenFilter {
160167 pub asset_id : Option < String > ,
161168 /// Whether transaction is spent or not according to db or not
162169 pub spent : Option < bool > ,
163- /// Owner of
170+ /// Owner of token
164171 pub owner : Option < String > ,
165172}
166173
0 commit comments