-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl Display
for Receipt
#901
Conversation
@@ -156,6 +156,51 @@ pub enum Receipt { | |||
}, | |||
} | |||
|
|||
impl core::fmt::Display for Receipt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we derive the implementation with all fields?=D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding all fields - I thought it may be just a bit too much details, which, when needed, could be retrieved by Debug
. I prefer Display
to be more concise, targeted on humans, not developers :)
I have no strong opinions here, so if you prefer to have all fields, I can just stick derive_more::Display
without any custom #[display(fmt =
attributes.
Let me know what you think.
fuel-tx/src/receipt.rs
Outdated
Receipt::Call { id, .. } => write!(f, "Call({})", id), | ||
Receipt::Return { id, .. } => write!(f, "Return({})", id), | ||
Receipt::ReturnData { id, .. } => write!(f, "ReturnData({})", id), | ||
Receipt::Panic { id, .. } => write!(f, "Panic({})", id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think we can display the panic reason in a meaningful way?
fuel-vm/fuel-tx/src/receipt.rs
Line 65 in 2fc9c5d
reason: PanicInstruction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since PanicReason
is a simple repr(u8)
enum, we can just debug-print it to get an output like:
Panic(id=0000000000000000000000000000000000000000000000000000000000000000, reason=OutOfGas)
Updated in 7e04606
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, ty
This PR implements
Display
forReceipt
for easier logging.Once this is merged and released, there will be a follow-up PR to the
fuel-core
to get rid of this boilerplate.Follow-up PR: FuelLabs/fuel-core#2616
Checklist
Before requesting review