@@ -190,50 +190,58 @@ impl TransactionBuilderConfigBuilder {
190190 }
191191 }
192192
193- pub fn fee_algo ( mut self , fee_algo : & fees:: LinearFee ) -> Self {
194- self . fee_algo = Some ( fee_algo. clone ( ) ) ;
195- self
193+ pub fn fee_algo ( & self , fee_algo : & fees:: LinearFee ) -> Self {
194+ let mut cfg = self . clone ( ) ;
195+ cfg. fee_algo = Some ( fee_algo. clone ( ) ) ;
196+ cfg
196197 }
197198
198- pub fn coins_per_utxo_word ( mut self , coins_per_utxo_word : & Coin ) -> Self {
199- self . coins_per_utxo_word = Some ( coins_per_utxo_word. clone ( ) ) ;
200- self
199+ pub fn coins_per_utxo_word ( & self , coins_per_utxo_word : & Coin ) -> Self {
200+ let mut cfg = self . clone ( ) ;
201+ cfg. coins_per_utxo_word = Some ( coins_per_utxo_word. clone ( ) ) ;
202+ cfg
201203 }
202204
203- pub fn pool_deposit ( mut self , pool_deposit : & BigNum ) -> Self {
204- self . pool_deposit = Some ( pool_deposit. clone ( ) ) ;
205- self
205+ pub fn pool_deposit ( & self , pool_deposit : & BigNum ) -> Self {
206+ let mut cfg = self . clone ( ) ;
207+ cfg. pool_deposit = Some ( pool_deposit. clone ( ) ) ;
208+ cfg
206209 }
207210
208- pub fn key_deposit ( mut self , key_deposit : & BigNum ) -> Self {
209- self . key_deposit = Some ( key_deposit. clone ( ) ) ;
210- self
211+ pub fn key_deposit ( & self , key_deposit : & BigNum ) -> Self {
212+ let mut cfg = self . clone ( ) ;
213+ cfg. key_deposit = Some ( key_deposit. clone ( ) ) ;
214+ cfg
211215 }
212216
213- pub fn max_value_size ( mut self , max_value_size : u32 ) -> Self {
214- self . max_value_size = Some ( max_value_size) ;
215- self
217+ pub fn max_value_size ( & self , max_value_size : u32 ) -> Self {
218+ let mut cfg = self . clone ( ) ;
219+ cfg. max_value_size = Some ( max_value_size) ;
220+ cfg
216221 }
217222
218- pub fn max_tx_size ( mut self , max_tx_size : u32 ) -> Self {
219- self . max_tx_size = Some ( max_tx_size) ;
220- self
223+ pub fn max_tx_size ( & self , max_tx_size : u32 ) -> Self {
224+ let mut cfg = self . clone ( ) ;
225+ cfg. max_tx_size = Some ( max_tx_size) ;
226+ cfg
221227 }
222228
223- pub fn prefer_pure_change ( mut self , prefer_pure_change : bool ) -> Self {
224- self . prefer_pure_change = prefer_pure_change;
225- self
229+ pub fn prefer_pure_change ( & self , prefer_pure_change : bool ) -> Self {
230+ let mut cfg = self . clone ( ) ;
231+ cfg. prefer_pure_change = prefer_pure_change;
232+ cfg
226233 }
227234
228- pub fn build ( self ) -> Result < TransactionBuilderConfig , JsError > {
235+ pub fn build ( & self ) -> Result < TransactionBuilderConfig , JsError > {
236+ let cfg = self . clone ( ) ;
229237 Ok ( TransactionBuilderConfig {
230- fee_algo : self . fee_algo . ok_or ( JsError :: from_str ( "uninitialized field: fee_algo" ) ) ?,
231- pool_deposit : self . pool_deposit . ok_or ( JsError :: from_str ( "uninitialized field: pool_deposit" ) ) ?,
232- key_deposit : self . key_deposit . ok_or ( JsError :: from_str ( "uninitialized field: key_deposit" ) ) ?,
233- max_value_size : self . max_value_size . ok_or ( JsError :: from_str ( "uninitialized field: max_value_size" ) ) ?,
234- max_tx_size : self . max_tx_size . ok_or ( JsError :: from_str ( "uninitialized field: max_tx_size" ) ) ?,
235- coins_per_utxo_word : self . coins_per_utxo_word . ok_or ( JsError :: from_str ( "uninitialized field: coins_per_utxo_word" ) ) ?,
236- prefer_pure_change : self . prefer_pure_change ,
238+ fee_algo : cfg . fee_algo . ok_or ( JsError :: from_str ( "uninitialized field: fee_algo" ) ) ?,
239+ pool_deposit : cfg . pool_deposit . ok_or ( JsError :: from_str ( "uninitialized field: pool_deposit" ) ) ?,
240+ key_deposit : cfg . key_deposit . ok_or ( JsError :: from_str ( "uninitialized field: key_deposit" ) ) ?,
241+ max_value_size : cfg . max_value_size . ok_or ( JsError :: from_str ( "uninitialized field: max_value_size" ) ) ?,
242+ max_tx_size : cfg . max_tx_size . ok_or ( JsError :: from_str ( "uninitialized field: max_tx_size" ) ) ?,
243+ coins_per_utxo_word : cfg . coins_per_utxo_word . ok_or ( JsError :: from_str ( "uninitialized field: coins_per_utxo_word" ) ) ?,
244+ prefer_pure_change : cfg . prefer_pure_change ,
237245 } )
238246 }
239247}
@@ -2848,12 +2856,12 @@ mod tests {
28482856 let max_value_size = 100 ; // super low max output size to test with fewer assets
28492857 let mut tx_builder = TransactionBuilder :: new (
28502858 & TransactionBuilderConfigBuilder :: new ( )
2851- . fee_algo ( linear_fee)
2852- . pool_deposit ( to_bignum ( 0 ) )
2853- . key_deposit ( to_bignum ( 0 ) )
2859+ . fee_algo ( & linear_fee)
2860+ . pool_deposit ( & to_bignum ( 0 ) )
2861+ . key_deposit ( & to_bignum ( 0 ) )
28542862 . max_value_size ( max_value_size)
28552863 . max_tx_size ( MAX_TX_SIZE )
2856- . coins_per_utxo_word ( to_bignum ( 1 ) )
2864+ . coins_per_utxo_word ( & to_bignum ( 1 ) )
28572865 . prefer_pure_change ( true )
28582866 . build ( )
28592867 . unwrap ( )
0 commit comments