Skip to content

Conversation

arepala-uml
Copy link
Contributor

  1. Added String() to the ledger.TransactionOutput interface and created the function on each era-specific TransactionOutput object.
  2. Used this new String() function in the Error() function for any validation rule errors that take TX outputs.
  3. Updated validation error messages to use String() instead of raw struct.

Closes #958

…the eras alonzo, babbage, byron, mary and shelley

Signed-off-by: Akhil Repala <[email protected]>
@arepala-uml arepala-uml marked this pull request as ready for review September 1, 2025 21:58
@arepala-uml arepala-uml requested a review from a team as a code owner September 1, 2025 21:58
…ted string instead of using a regex

Signed-off-by: Akhil Repala <[email protected]>
@arepala-uml arepala-uml requested a review from agaffney September 3, 2025 05:53
OutputAmount: mary.MaryTransactionOutputValue{Amount: 456, Assets: &ma},
}
s := out.String()
expected := "(AlonzoTransactionOutput address=" + addr.String() + " amount=456 assets=...)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of converting the address back to string representation, you can split the original string representation at the top to a separate var and compare to that instead. This prevents any weirdness with Address from throwing off the test.

assets := ""
if o.OutputAmount.Assets != nil && len(o.OutputAmount.Assets.Policies()) > 0 {
assets = " assets=..."
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should build out a list of the assets for the string output

OutputAmount: mary.MaryTransactionOutputValue{Amount: 456, Assets: &ma},
}
s := out.String()
expected := "(BabbageTransactionOutput address=" + addr.String() + " amount=456 assets=...)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the original address string instead of converting Address back to string to avoid potential weirdness

OutputAmount: 456,
}
s := out.String()
expected := "(ByronTransactionOutput address=" + addr.String() + " amount=456)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the original address string instead of converting Address back to string to avoid potential weirdness

OutputAmount: MaryTransactionOutputValue{Amount: 456, Assets: &ma},
}
s := out.String()
expected := fmt.Sprintf("(MaryTransactionOutput address=%s amount=456 assets=...)", addr.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the original address string instead of converting Address back to string to avoid potential weirdness

OutputAmount: MaryTransactionOutputValue{Amount: 456},
}
errStr := OutputTooBigUtxoError{Outputs: []common.TransactionOutput{out}}.Error()
expected := fmt.Sprintf("output value too large: (MaryTransactionOutput address=%s amount=456)", addr.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the original address string instead of converting Address back to string to avoid potential weirdness

OutputAmount: 456,
}
s := out.String()
expected := fmt.Sprintf("(ShelleyTransactionOutput address=%s amount=456)", addr.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the original address string instead of converting Address back to string to avoid potential weirdness

OutputAmount: 456,
}
errStr := shelley.OutputTooSmallUtxoError{Outputs: []common.TransactionOutput{out}}.Error()
expected := fmt.Sprintf("output too small: (ShelleyTransactionOutput address=%s amount=456)", addr.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the original address string instead of converting Address back to string to avoid potential weirdness

…instead of addr.String() and removed the placeholder for assets

Signed-off-by: Akhil Repala <[email protected]>
@wolf31o2 wolf31o2 requested a review from agaffney September 8, 2025 13:59
@agaffney agaffney merged commit 543fcbc into main Sep 8, 2025
8 of 9 checks passed
@agaffney agaffney deleted the tx_output_string_format branch September 8, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add friendly string representation of TX outputs
3 participants