Skip to content

Commit 3e5dc37

Browse files
authored
Fixing tx-builder-config-builder to take references and no values (#269)
1 parent 0fe8676 commit 3e5dc37

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

rust/pkg/cardano_serialization_lib.js.flow

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5342,6 +5342,14 @@ declare export class TransactionBuilderConfigBuilder {
53425342
*/
53435343
fee_algo(fee_algo: LinearFee): TransactionBuilderConfigBuilder;
53445344

5345+
/**
5346+
* @param {BigNum} coins_per_utxo_word
5347+
* @returns {TransactionBuilderConfigBuilder}
5348+
*/
5349+
coins_per_utxo_word(
5350+
coins_per_utxo_word: BigNum
5351+
): TransactionBuilderConfigBuilder;
5352+
53455353
/**
53465354
* @param {BigNum} pool_deposit
53475355
* @returns {TransactionBuilderConfigBuilder}
@@ -5366,14 +5374,6 @@ declare export class TransactionBuilderConfigBuilder {
53665374
*/
53675375
max_tx_size(max_tx_size: number): TransactionBuilderConfigBuilder;
53685376

5369-
/**
5370-
* @param {BigNum} coins_per_utxo_word
5371-
* @returns {TransactionBuilderConfigBuilder}
5372-
*/
5373-
coins_per_utxo_word(
5374-
coins_per_utxo_word: BigNum
5375-
): TransactionBuilderConfigBuilder;
5376-
53775377
/**
53785378
* @param {boolean} prefer_pure_change
53795379
* @returns {TransactionBuilderConfigBuilder}

rust/src/tx_builder.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,23 @@ impl TransactionBuilderConfigBuilder {
190190
}
191191
}
192192

193-
pub fn fee_algo(mut self, fee_algo: fees::LinearFee) -> Self {
194-
self.fee_algo = Some(fee_algo);
193+
pub fn fee_algo(mut self, fee_algo: &fees::LinearFee) -> Self {
194+
self.fee_algo = Some(fee_algo.clone());
195195
self
196196
}
197197

198-
pub fn pool_deposit(mut self, pool_deposit: BigNum) -> Self {
199-
self.pool_deposit = Some(pool_deposit);
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());
200200
self
201201
}
202202

203-
pub fn key_deposit(mut self, key_deposit: BigNum) -> Self {
204-
self.key_deposit = Some(key_deposit);
203+
pub fn pool_deposit(mut self, pool_deposit: &BigNum) -> Self {
204+
self.pool_deposit = Some(pool_deposit.clone());
205+
self
206+
}
207+
208+
pub fn key_deposit(mut self, key_deposit: &BigNum) -> Self {
209+
self.key_deposit = Some(key_deposit.clone());
205210
self
206211
}
207212

@@ -215,11 +220,6 @@ impl TransactionBuilderConfigBuilder {
215220
self
216221
}
217222

218-
pub fn coins_per_utxo_word(mut self, coins_per_utxo_word: Coin) -> Self {
219-
self.coins_per_utxo_word = Some(coins_per_utxo_word);
220-
self
221-
}
222-
223223
pub fn prefer_pure_change(mut self, prefer_pure_change: bool) -> Self {
224224
self.prefer_pure_change = prefer_pure_change;
225225
self
@@ -1134,12 +1134,12 @@ mod tests {
11341134
coins_per_utxo_word: u64,
11351135
) -> TransactionBuilder {
11361136
let cfg = TransactionBuilderConfigBuilder::new()
1137-
.fee_algo(linear_fee.clone())
1138-
.pool_deposit(to_bignum(pool_deposit))
1139-
.key_deposit(to_bignum(key_deposit))
1137+
.fee_algo(linear_fee)
1138+
.pool_deposit(&to_bignum(pool_deposit))
1139+
.key_deposit(&to_bignum(key_deposit))
11401140
.max_value_size(max_val_size)
11411141
.max_tx_size(MAX_TX_SIZE)
1142-
.coins_per_utxo_word(to_bignum(coins_per_utxo_word))
1142+
.coins_per_utxo_word(&to_bignum(coins_per_utxo_word))
11431143
.build()
11441144
.unwrap();
11451145
TransactionBuilder::new(&cfg)
@@ -1173,12 +1173,12 @@ mod tests {
11731173

11741174
fn create_tx_builder_with_fee_and_pure_change(linear_fee: &LinearFee) -> TransactionBuilder {
11751175
TransactionBuilder::new(&TransactionBuilderConfigBuilder::new()
1176-
.fee_algo(linear_fee.clone())
1177-
.pool_deposit(to_bignum(1))
1178-
.key_deposit(to_bignum(1))
1176+
.fee_algo(linear_fee)
1177+
.pool_deposit(&to_bignum(1))
1178+
.key_deposit(&to_bignum(1))
11791179
.max_value_size(MAX_VALUE_SIZE)
11801180
.max_tx_size(MAX_TX_SIZE)
1181-
.coins_per_utxo_word(to_bignum(1))
1181+
.coins_per_utxo_word(&to_bignum(1))
11821182
.prefer_pure_change(true)
11831183
.build()
11841184
.unwrap())
@@ -2589,12 +2589,12 @@ mod tests {
25892589
// we have a = 1 to test increasing fees when more inputs are added
25902590
let linear_fee = LinearFee::new(&to_bignum(1), &to_bignum(0));
25912591
let cfg = TransactionBuilderConfigBuilder::new()
2592-
.fee_algo(linear_fee)
2593-
.pool_deposit(to_bignum(0))
2594-
.key_deposit(to_bignum(0))
2592+
.fee_algo(&linear_fee)
2593+
.pool_deposit(&to_bignum(0))
2594+
.key_deposit(&to_bignum(0))
25952595
.max_value_size(9999)
25962596
.max_tx_size(9999)
2597-
.coins_per_utxo_word(Coin::zero())
2597+
.coins_per_utxo_word(&Coin::zero())
25982598
.build()
25992599
.unwrap();
26002600
let mut tx_builder = TransactionBuilder::new(&cfg);
@@ -2616,12 +2616,12 @@ mod tests {
26162616
// we have a = 1 to test increasing fees when more inputs are added
26172617
let linear_fee = LinearFee::new(&to_bignum(1), &to_bignum(0));
26182618
let cfg = TransactionBuilderConfigBuilder::new()
2619-
.fee_algo(linear_fee)
2620-
.pool_deposit(to_bignum(0))
2621-
.key_deposit(to_bignum(0))
2619+
.fee_algo(&linear_fee)
2620+
.pool_deposit(&to_bignum(0))
2621+
.key_deposit(&to_bignum(0))
26222622
.max_value_size(9999)
26232623
.max_tx_size(9999)
2624-
.coins_per_utxo_word(Coin::zero())
2624+
.coins_per_utxo_word(&Coin::zero())
26252625
.build()
26262626
.unwrap();
26272627
let mut tx_builder = TransactionBuilder::new(&cfg);

0 commit comments

Comments
 (0)