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

fix: cherry-pick: Default to dApp suggested fees only when user selects the option… #28442

Open
wants to merge 1 commit into
base: Version-v12.7.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ exports[`Info renders info section for approve request 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--margin-right-2 mm-box--color-text-alternative"
data-testid="native-currency"
>
$0.04
$0.08
</p>
<button
class="mm-box mm-text mm-button-base mm-button-base--size-sm mm-button-link mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
Expand Down Expand Up @@ -819,7 +819,7 @@ exports[`Info renders info section for setApprovalForAll request 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--margin-right-2 mm-box--color-text-alternative"
data-testid="native-currency"
>
$0.04
$0.08
</p>
<button
class="mm-box mm-text mm-button-base mm-button-base--size-sm mm-button-link mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ exports[`<ApproveInfo /> renders component for approve request 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--margin-right-2 mm-box--color-text-alternative"
data-testid="native-currency"
>
$0.04
$0.08
</p>
<button
class="mm-box mm-text mm-button-base mm-button-base--size-sm mm-button-link mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
Expand Down Expand Up @@ -582,12 +582,12 @@ exports[`<ApproveInfo /> renders component for approve request 1`] = `
<p
class="mm-box mm-text mm-text--body-md mm-box--margin-right-1 mm-box--color-text-default"
>
0.0011 ETH
0.0023 ETH
</p>
<p
class="mm-box mm-text mm-text--body-md mm-box--color-text-alternative"
>
$0.60
$1.26
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ export const useEIP1559TxFees = (
maxFeePerGas: string;
maxPriorityFeePerGas: string;
} => {
const hexMaxFeePerGas =
transactionMeta.dappSuggestedGasFees?.maxFeePerGas ||
transactionMeta?.txParams?.maxFeePerGas;
const hexMaxFeePerGas = transactionMeta?.txParams?.maxFeePerGas;

const hexMaxPriorityFeePerGas =
transactionMeta.dappSuggestedGasFees?.maxPriorityFeePerGas ||
transactionMeta?.txParams?.maxPriorityFeePerGas;

return useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) {
);

// Max fee
const gasLimit =
transactionMeta?.dappSuggestedGasFees?.gas ||
transactionMeta?.txParams?.gas ||
HEX_ZERO;
const gasLimit = transactionMeta?.txParams?.gas || HEX_ZERO;
const gasPrice = transactionMeta?.txParams?.gasPrice || HEX_ZERO;

const maxFee = useMemo(() => {
Expand Down Expand Up @@ -140,7 +137,13 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) {
);

return getFeesFromHex(estimatedFee);
}, [gasFeeEstimate, transactionMeta, estimatedBaseFee, getFeesFromHex]);
}, [
gasFeeEstimate,
transactionMeta,
estimatedBaseFee,
maxPriorityFeePerGas,
getFeesFromHex,
]);

return {
estimatedFeeFiat: estimatedFees.currentCurrencyFee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,11 @@ export function useTransactionGasFeeEstimate(
?.estimatedBaseFee;

// override with values from `dappSuggestedGasFees` if they exist
gasLimit = transactionMeta.dappSuggestedGasFees?.gas || gasLimit || HEX_ZERO;
gasPrice =
transactionMeta.dappSuggestedGasFees?.gasPrice || gasPrice || HEX_ZERO;
gasLimit = gasLimit || HEX_ZERO;
gasPrice = gasPrice || HEX_ZERO;
const maxPriorityFeePerGas =
transactionMeta.dappSuggestedGasFees?.maxPriorityFeePerGas ||
transactionMeta.txParams?.maxPriorityFeePerGas ||
HEX_ZERO;
const maxFeePerGas =
transactionMeta.dappSuggestedGasFees?.maxFeePerGas ||
transactionMeta.txParams?.maxFeePerGas ||
HEX_ZERO;
transactionMeta.txParams?.maxPriorityFeePerGas || HEX_ZERO;
const maxFeePerGas = transactionMeta.txParams?.maxFeePerGas || HEX_ZERO;

let gasEstimate: Hex;
if (supportsEIP1559) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ exports[`NativeTransferInfo renders correctly 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--margin-right-2 mm-box--color-text-alternative"
data-testid="native-currency"
>
$0.04
$0.08
</p>
<button
class="mm-box mm-text mm-button-base mm-button-base--size-sm mm-button-link mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ exports[`NFTTokenTransferInfo renders correctly 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--margin-right-2 mm-box--color-text-alternative"
data-testid="native-currency"
>
$0.04
$0.08
</p>
<button
class="mm-box mm-text mm-button-base mm-button-base--size-sm mm-button-link mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ exports[`<SetApprovalForAllInfo /> renders component for approve request 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--margin-right-2 mm-box--color-text-alternative"
data-testid="native-currency"
>
$0.04
$0.08
</p>
<button
class="mm-box mm-text mm-button-base mm-button-base--size-sm mm-button-link mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ exports[`TokenTransferInfo renders correctly 1`] = `
class="mm-box mm-text mm-text--body-md mm-box--margin-right-2 mm-box--color-text-alternative"
data-testid="native-currency"
>
$0.04
$0.08
</p>
<button
class="mm-box mm-text mm-button-base mm-button-base--size-sm mm-button-link mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-0 mm-box--padding-left-0 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent"
Expand Down