|
50 | 50 | MultiAsset,
|
51 | 51 | Transaction,
|
52 | 52 | TransactionBody,
|
| 53 | + TransactionInput, |
53 | 54 | TransactionOutput,
|
54 | 55 | UTxO,
|
55 | 56 | Value,
|
@@ -105,7 +106,9 @@ class TransactionBuilder:
|
105 | 106 |
|
106 | 107 | withdrawals: Optional[Withdrawals] = field(default=None)
|
107 | 108 |
|
108 |
| - reference_inputs: List[UTxO] = field(init=False, default_factory=lambda: list()) |
| 109 | + reference_inputs: Set[Union[UTxO, TransactionInput]] = field( |
| 110 | + init=False, default_factory=lambda: set() |
| 111 | + ) |
109 | 112 |
|
110 | 113 | _inputs: List[UTxO] = field(init=False, default_factory=lambda: [])
|
111 | 114 |
|
@@ -234,19 +237,19 @@ def add_script_input(
|
234 | 237 |
|
235 | 238 | if utxo.output.script:
|
236 | 239 | self._inputs_to_scripts[utxo] = utxo.output.script
|
237 |
| - self.reference_inputs.append(utxo) |
| 240 | + self.reference_inputs.add(utxo) |
238 | 241 | self._reference_scripts.append(utxo.output.script)
|
239 | 242 | elif not script:
|
240 | 243 | for i in self.context.utxos(str(utxo.output.address)):
|
241 | 244 | if i.output.script:
|
242 | 245 | self._inputs_to_scripts[utxo] = i.output.script
|
243 |
| - self.reference_inputs.append(i) |
| 246 | + self.reference_inputs.add(i) |
244 | 247 | self._reference_scripts.append(i.output.script)
|
245 | 248 | break
|
246 | 249 | elif isinstance(script, UTxO):
|
247 | 250 | assert script.output.script is not None
|
248 | 251 | self._inputs_to_scripts[utxo] = script.output.script
|
249 |
| - self.reference_inputs.append(script) |
| 252 | + self.reference_inputs.add(script) |
250 | 253 | self._reference_scripts.append(script.output.script)
|
251 | 254 | else:
|
252 | 255 | self._inputs_to_scripts[utxo] = script
|
@@ -280,7 +283,7 @@ def add_minting_script(
|
280 | 283 | if isinstance(script, UTxO):
|
281 | 284 | assert script.output.script is not None
|
282 | 285 | self._minting_script_to_redeemers.append((script.output.script, redeemer))
|
283 |
| - self.reference_inputs.append(script) |
| 286 | + self.reference_inputs.add(script) |
284 | 287 | self._reference_scripts.append(script.output.script)
|
285 | 288 | else:
|
286 | 289 | self._minting_script_to_redeemers.append((script, redeemer))
|
@@ -774,7 +777,9 @@ def _build_tx_body(self) -> TransactionBody:
|
774 | 777 | withdraws=self.withdrawals,
|
775 | 778 | collateral_return=self._collateral_return,
|
776 | 779 | total_collateral=self._total_collateral,
|
777 |
| - reference_inputs=[i.input for i in self.reference_inputs] |
| 780 | + reference_inputs=[ |
| 781 | + i.input if isinstance(i, UTxO) else i for i in self.reference_inputs |
| 782 | + ] |
778 | 783 | if self.reference_inputs
|
779 | 784 | else None,
|
780 | 785 | )
|
|
0 commit comments