@@ -190,50 +190,58 @@ impl TransactionBuilderConfigBuilder {
190
190
}
191
191
}
192
192
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
196
197
}
197
198
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
201
203
}
202
204
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
206
209
}
207
210
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
211
215
}
212
216
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
216
221
}
217
222
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
221
227
}
222
228
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
226
233
}
227
234
228
- pub fn build ( self ) -> Result < TransactionBuilderConfig , JsError > {
235
+ pub fn build ( & self ) -> Result < TransactionBuilderConfig , JsError > {
236
+ let cfg = self . clone ( ) ;
229
237
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 ,
237
245
} )
238
246
}
239
247
}
@@ -2848,12 +2856,12 @@ mod tests {
2848
2856
let max_value_size = 100 ; // super low max output size to test with fewer assets
2849
2857
let mut tx_builder = TransactionBuilder :: new (
2850
2858
& 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 ) )
2854
2862
. max_value_size ( max_value_size)
2855
2863
. max_tx_size ( MAX_TX_SIZE )
2856
- . coins_per_utxo_word ( to_bignum ( 1 ) )
2864
+ . coins_per_utxo_word ( & to_bignum ( 1 ) )
2857
2865
. prefer_pure_change ( true )
2858
2866
. build ( )
2859
2867
. unwrap ( )
0 commit comments