Skip to content

Commit

Permalink
fix: do not compare objects, compare tx reference (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
joacohoyos authored Sep 13, 2024
1 parent 73e34a6 commit bdf17aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-teachers-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blaze-cardano/tx": patch
---

Fix utxo comparison from object comparison to comparing the output reference manually
13 changes: 11 additions & 2 deletions packages/blaze-tx/src/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,12 @@ export class TxBuilder {
} else {
// If no provided collateral inputs, iterate over the inputs to find the best candidate.
for (const input of inputs) {
const utxo = scope.find((x) => x.input() == input);
const utxo = scope.find(
(x) =>
x.input().transactionId() === input.transactionId() &&
x.input().index() === input.index(),
);

if (utxo) {
// Check if the UTXO amount is sufficient for collateral.
if (
Expand Down Expand Up @@ -1398,7 +1403,11 @@ export class TxBuilder {
.collateral()!
.values()
.reduce((acc, input) => {
const utxo = scope.find((x) => x.input() == input);
const utxo = scope.find(
(x) =>
x.input().transactionId() === input.transactionId() &&
x.input().index() === input.index(),
);
if (!utxo) {
throw new Error(
"balanceCollateralChange: Could not resolve some collateral input",
Expand Down

0 comments on commit bdf17aa

Please sign in to comment.