-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: use SDK type for tx in TransactionResponse #960
Conversation
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.
LGTM
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.
lgtm
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.
Can't make up my mind. Hate that the user has to always match before doing anything useful with the type.
But then again I can imagine how ugly the delegation might have looked.
Besides the impact on maintenance cost, is there any other reason for not implementing the delegating methods so that it may be used as is?
Good catch, didn't realise myself. I'd like to know as well before merging. |
@FuelLabs/sdk-rust did we decide what to do with this PR ? |
It was only about the maintenance. IMO matching isn't that bad considering that this type is only used when fetching a The last commit has the changes with delegation. |
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.
Might be confusing down the line to have Transaction trait and TransactionType type
But we'll solve it if it becomes an issue.
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.
👍
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.
LGTM
Closes #959
I've explored several approaches to make our API consistent here.
One option was to have
TransactionResponse
hold a `Box, but because of the object safety requirements, this had the following downsides:Into<FuelTransaction>
super trait possible, this would need to become a separate methodTransactionResponse
would no longer beClone
with_
methods + a Box would have to be returned which could cause confusionScript
orCreate
The second option was to use an enum for the implementors of
Transaction
and then have the enum implement it too. The downside here is that we get a lot of repeated match statements to delegate every method ofTransaction
to the corresponding variant. Macros didn't provide a significant improvement here either.Ultimately I decided to keep the enum but not implement
Transaction
for it. This means that we don't change our API anywhere else but also that the user has to potentially match the enum every time to use the underlyingTransaction
methods.Checklist