Ensure approve button can be enabled when using ledger webhid (#12685)

feature/default_network_editable
Dan J Miller 3 years ago committed by ryanml
parent 56760efaa2
commit 58cccdf1cd
  1. 6
      ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js
  2. 21
      ui/pages/confirm-approve/confirm-approve.js

@ -46,7 +46,7 @@ export default class ConfirmApproveContent extends Component {
showCustomizeNonceModal: PropTypes.func, showCustomizeNonceModal: PropTypes.func,
warning: PropTypes.string, warning: PropTypes.string,
txData: PropTypes.object, txData: PropTypes.object,
ledgerWalletRequiredHidConnection: PropTypes.bool, fromAddressIsLedger: PropTypes.bool,
}; };
state = { state = {
@ -242,7 +242,7 @@ export default class ConfirmApproveContent extends Component {
useNonceField, useNonceField,
warning, warning,
txData, txData,
ledgerWalletRequiredHidConnection, fromAddressIsLedger,
} = this.props; } = this.props;
const { showFullTxDetails } = this.state; const { showFullTxDetails } = this.state;
@ -351,7 +351,7 @@ export default class ConfirmApproveContent extends Component {
})} })}
</div> </div>
{ledgerWalletRequiredHidConnection ? ( {fromAddressIsLedger ? (
<div className="confirm-approve-content__ledger-instruction-wrapper"> <div className="confirm-approve-content__ledger-instruction-wrapper">
<LedgerInstructionField <LedgerInstructionField
showDataInstruction={Boolean(txData.txParams?.data)} showDataInstruction={Boolean(txData.txParams?.data)}

@ -15,7 +15,11 @@ import {
getTokenValueParam, getTokenValueParam,
} from '../../helpers/utils/token-util'; } from '../../helpers/utils/token-util';
import { useTokenTracker } from '../../hooks/useTokenTracker'; import { useTokenTracker } from '../../hooks/useTokenTracker';
import { getTokens, getNativeCurrency } from '../../ducks/metamask/metamask'; import {
getTokens,
getNativeCurrency,
isAddressLedger,
} from '../../ducks/metamask/metamask';
import { import {
transactionFeeSelector, transactionFeeSelector,
txDataSelector, txDataSelector,
@ -24,7 +28,6 @@ import {
getUseNonceField, getUseNonceField,
getCustomNonceValue, getCustomNonceValue,
getNextSuggestedNonce, getNextSuggestedNonce,
doesAddressRequireLedgerHidConnection,
} from '../../selectors'; } from '../../selectors';
import { useApproveTransaction } from '../../hooks/useApproveTransaction'; import { useApproveTransaction } from '../../hooks/useApproveTransaction';
@ -36,10 +39,8 @@ import { isEqualCaseInsensitive } from '../../helpers/utils/util';
import { getCustomTxParamsData } from './confirm-approve.util'; import { getCustomTxParamsData } from './confirm-approve.util';
import ConfirmApproveContent from './confirm-approve-content'; import ConfirmApproveContent from './confirm-approve-content';
const doesAddressRequireLedgerHidConnectionByFromAddress = (address) => ( const isAddressLedgerByFromAddress = (address) => (state) => {
state, return isAddressLedger(state, address);
) => {
return doesAddressRequireLedgerHidConnection(state, address);
}; };
export default function ConfirmApprove() { export default function ConfirmApprove() {
@ -59,9 +60,7 @@ export default function ConfirmApprove() {
const nextNonce = useSelector(getNextSuggestedNonce); const nextNonce = useSelector(getNextSuggestedNonce);
const customNonceValue = useSelector(getCustomNonceValue); const customNonceValue = useSelector(getCustomNonceValue);
const ledgerWalletRequiredHidConnection = useSelector( const fromAddressIsLedger = useSelector(isAddressLedgerByFromAddress(from));
doesAddressRequireLedgerHidConnectionByFromAddress(from),
);
const transaction = const transaction =
currentNetworkTxList.find( currentNetworkTxList.find(
@ -219,9 +218,7 @@ export default function ConfirmApprove() {
} }
warning={submitWarning} warning={submitWarning}
txData={transaction} txData={transaction}
ledgerWalletRequiredHidConnection={ fromAddressIsLedger={fromAddressIsLedger}
ledgerWalletRequiredHidConnection
}
/> />
{showCustomizeGasPopover && ( {showCustomizeGasPopover && (
<EditGasPopover <EditGasPopover

Loading…
Cancel
Save