Skip to content

Fix setGasPrice dispatch function parameters#9865

Merged
rekmarks merged 4 commits intodevelopfrom
set-gas-price-params-fix
Nov 13, 2020
Merged

Fix setGasPrice dispatch function parameters#9865
rekmarks merged 4 commits intodevelopfrom
set-gas-price-params-fix

Conversation

@rekmarks
Copy link
Copy Markdown
Member

@rekmarks rekmarks commented Nov 12, 2020

This fixes a bug introduced in #9599. In that PR, the gas-price-button-group prop handleGasPriceSelection was overwritten in the swaps gas customization modal in order to take the gas estimate type (a string constant) as its second parameter (context: #9599 (comment)). At the time, we missed that handleGasPriceSelection normally takes as its second parameter a hexadecimal string gas limit. BigNumber errors result.

This PR enables handleGasPriceSelection to be used in both contexts by means of named parameters. Note that most of the diff is changing assert.equal and assert.deepEqual to their strict equivalents in unit tests.

@rekmarks rekmarks requested a review from a team as a code owner November 12, 2020 22:58
@rekmarks rekmarks requested a review from brad-decker November 12, 2020 22:58
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [8c6c944]
Page Load Metrics (379 ± 53 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint309546188
domContentLoaded25867737711053
load26067937911053
domInteractive25867737710953

@danjm
Copy link
Copy Markdown
Contributor

danjm commented Nov 13, 2020

Does updateCustomGasPrice on line 213 of ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js also need its parameters updated?

As I read it:
const updateCustomGasPrice = (newPrice) => dispatch(setCustomGasPrice(addHexPrefix(newPrice)))
⬇️

 gasPriceButtonGroupProps: {
      ...gasPriceButtonGroupProps,
      handleGasPriceSelection: otherDispatchProps.updateCustomGasPrice,
    },

⬇️

<GasPriceButtonGroup
            className="gas-price-button-group--alt"
            showCheck
            {...gasPriceButtonGroupProps}
          />

⬇️

  onClick={() =>
          handleGasPriceSelection({
            gasPrice: priceInHexWei,
            gasEstimateType: renderableGasInfo.gasEstimateType,
          })
        }
        key={`gas-price-button-${index}`}
      >

So updateCustomGasPrice now gets passed on object

Copy link
Copy Markdown
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.

one change needed I think

@rekmarks
Copy link
Copy Markdown
Member Author

@danjm feedback addressed in 406f06d. The location you highlighted overwrites the handleGasPriceSelection prop with a new function, so I just fixed its signature directly. Also updated related tests, with the same equal -> strictEqual fixes.

@rekmarks rekmarks requested a review from danjm November 13, 2020 00:41
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [0dbeae5]
Page Load Metrics (358 ± 44 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint308040147
domContentLoaded2546473559144
load2586483589144
domInteractive2546463559144

Copy link
Copy Markdown
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.

LGTM

@rekmarks rekmarks merged commit ed27c35 into develop Nov 13, 2020
@rekmarks rekmarks deleted the set-gas-price-params-fix branch November 13, 2020 01:07
@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 2020
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.

3 participants