-
-
Notifications
You must be signed in to change notification settings - Fork 261
update types to be more identifiable #508
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
Conversation
| never | ||
| >; | ||
| state?: Partial<GasFeeState>; | ||
| state?: GasFeeState; |
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.
State is now very much required to have all pieces to write it, but that doesn't always have to be true. if in the future one of the state keys is optional in all shapes, we can add it to the shapes with the ?: syntax so that partial spreads are supported, but this would still be GasFeeState versus Partial
| estimatedGasFeeTimeBounds: { persist: true, anonymous: false }, | ||
| gasEstimateType: { persist: true, anonymous: false }, | ||
| }; | ||
|
|
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.
So, just to confirm I understand: state will always have a estimatedGasFeeTimeBounds property, but it will be an empty object unless isEIP1559Compatible is true?
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.
Yep, all fields are always present, but their shape is determined by the value of gasEstimateType.
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.
and the fee-market value will only be set if we get a successful response from the EIP1559 gas estimate API.
|
|
||
| export type unknownString = 'unknown'; | ||
|
|
||
| export type FeeMarketEstimateType = 'fee-market'; |
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.
It might be helpful to add a brief comment here that explains that the FeeMarketEstimateType is the type used for EIP1559 compatible estimates
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.
This makes it such that the state tree of the Gas Fee Controller is variable, but also known, and you can use
state.gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKETand the like to put Typescript in the branch that has the gasEstimate shape typed. This removes the need to have helper methods to check for object structure to identify type.This also has a 'NONE' state that can be used to identify states in which we can rely on no values (still loading values)