Skip to content
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

EIP-1559 - Restore custom values in Edit Gas Popover #11589

Merged
merged 6 commits into from
Jul 27, 2021

Conversation

darkwing
Copy link
Contributor

@darkwing darkwing commented Jul 22, 2021

Here we grab values from an existing transaction so we can restore values chose by the user.

ToDo

  • Why are these prices being set ahead of time? We should be defaulting to medium values (are we?)
  • Compare those custom values with the gasEstimates to see if we should select any of the radio buttons

@darkwing darkwing requested a review from a team as a code owner July 22, 2021 20:34
@darkwing darkwing requested a review from PeterYinusa July 22, 2021 20:34
@darkwing darkwing marked this pull request as draft July 22, 2021 20:34
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@@ -120,6 +120,12 @@ export default function EditGasPopover({
dispatch(createSpeedUpTransaction(transaction.id, newGasSettings));
break;
case EDIT_GAS_MODES.MODIFY_IN_PLACE:
// TODO: This shouldn't be required by prevents the following error:
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danjm Is this confirmed? Should I remove from here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Confirmed that between that change and #11615, this bug goes away and the below if block is not needed

ui/hooks/useGasFeeInputs.js Outdated Show resolved Hide resolved
// transitional because it is only used to modify a transaction in the
// metamask (background) state tree.
const [maxFeePerGas, setMaxFeePerGas] = useState(
transaction?.txParams?.maxFeePerGas
Copy link
Contributor

Choose a reason for hiding this comment

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

So, in Swaps when we want to edit gas on the View Quote page, we don't have a transaction yet.

However, we store custom gasLimit, maxFeePerGas and maxPriorityFeePerGas in swapsState, which we could pass to the EditGasPopover component, e.g. in the customGas object instead of the transaction object.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

@darkwing was this addressed ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@adonesky1 Yup, but in another place. @danjm has a commit that handles prefilling of the gas editing modal in Swaps for EIP-1559. We just need to get this PR in and then I can include Dan's commit in my PR that I will open shortly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Swaps can be addressed separately from this PR, IMO

transaction?.txParams?.gasPrice
? Number(hexWEIToDecGWEI(transaction.txParams.gasPrice))
: null,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is needed below:
Screenshot from 2021-07-27 04-59-04

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the property on txParams is called gas and no gasLimit, and because gas/gasLimit is not in WEI or GWEI (it does not have a unit)

Copy link
Contributor

Choose a reason for hiding this comment

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

the property on txParams is called gas and not gasLimit

We do need to better improve this naming situation in the codebase. Ideally, it would be the same everywhere... but that is for a different PR

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

see latest two comments

@darkwing
Copy link
Contributor Author

Updated!

@dan437 dan437 merged commit 604524f into MetaMask:develop Jul 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants