mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix no-negated-condition issues (#9222)
See [`no-negated-condition`](https://eslint.org/docs/rules/no-negated-condition) for more information. This change enables `no-negated-condition` and fixes the issues raised by the rule.
This commit is contained in:
parent
c11888f287
commit
884775cf71
@ -57,6 +57,7 @@ module.exports = {
|
|||||||
'no-eq-null': 'error',
|
'no-eq-null': 'error',
|
||||||
'no-global-assign': 'error',
|
'no-global-assign': 'error',
|
||||||
'no-loop-func': 'error',
|
'no-loop-func': 'error',
|
||||||
|
'no-negated-condition': 'error',
|
||||||
'no-nested-ternary': 'error',
|
'no-nested-ternary': 'error',
|
||||||
'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }],
|
'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }],
|
||||||
'no-process-exit': 'error',
|
'no-process-exit': 'error',
|
||||||
|
@ -560,9 +560,9 @@ export default class TransactionController extends EventEmitter {
|
|||||||
|
|
||||||
// It seems that sometimes the numerical values being returned from
|
// It seems that sometimes the numerical values being returned from
|
||||||
// this.query.getTransactionReceipt are BN instances and not strings.
|
// this.query.getTransactionReceipt are BN instances and not strings.
|
||||||
const gasUsed = typeof txReceipt.gasUsed !== 'string'
|
const gasUsed = typeof txReceipt.gasUsed === 'string'
|
||||||
? txReceipt.gasUsed.toString(16)
|
? txReceipt.gasUsed
|
||||||
: txReceipt.gasUsed
|
: txReceipt.gasUsed.toString(16)
|
||||||
|
|
||||||
txMeta.txReceipt = {
|
txMeta.txReceipt = {
|
||||||
...txReceipt,
|
...txReceipt,
|
||||||
|
@ -424,7 +424,7 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
@param {erroObject} err - error object
|
@param {erroObject} err - error object
|
||||||
*/
|
*/
|
||||||
setTxStatusFailed (txId, err) {
|
setTxStatusFailed (txId, err) {
|
||||||
const error = !err ? new Error('Internal metamask failure') : err
|
const error = err || new Error('Internal metamask failure')
|
||||||
|
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
txMeta.err = {
|
txMeta.err = {
|
||||||
|
@ -30,11 +30,11 @@ function freeze (target, key, value, enumerable = true) {
|
|||||||
configurable: false, writable: false,
|
configurable: false, writable: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value !== undefined) {
|
if (value === undefined) {
|
||||||
|
target[key] = deepFreeze(target[key])
|
||||||
|
} else {
|
||||||
opts.value = deepFreeze(value)
|
opts.value = deepFreeze(value)
|
||||||
opts.enumerable = enumerable
|
opts.enumerable = enumerable
|
||||||
} else {
|
|
||||||
target[key] = deepFreeze(target[key])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(target, key, opts)
|
Object.defineProperty(target, key, opts)
|
||||||
|
@ -55,19 +55,19 @@ const getEnvironmentType = (url = window.location.href) => getEnvironmentTypeMem
|
|||||||
*/
|
*/
|
||||||
const getPlatform = (_) => {
|
const getPlatform = (_) => {
|
||||||
const ua = window.navigator.userAgent
|
const ua = window.navigator.userAgent
|
||||||
if (ua.search('Firefox') !== -1) {
|
if (ua.search('Firefox') === -1) {
|
||||||
return PLATFORM_FIREFOX
|
|
||||||
} else {
|
|
||||||
if (window && window.chrome && window.chrome.ipcRenderer) {
|
if (window && window.chrome && window.chrome.ipcRenderer) {
|
||||||
return PLATFORM_BRAVE
|
return PLATFORM_BRAVE
|
||||||
} else if (ua.search('Edge') !== -1) {
|
}
|
||||||
|
if (ua.search('Edge') !== -1) {
|
||||||
return PLATFORM_EDGE
|
return PLATFORM_EDGE
|
||||||
} else if (ua.search('OPR') !== -1) {
|
}
|
||||||
|
if (ua.search('OPR') !== -1) {
|
||||||
return PLATFORM_OPERA
|
return PLATFORM_OPERA
|
||||||
} else {
|
}
|
||||||
return PLATFORM_CHROME
|
return PLATFORM_CHROME
|
||||||
}
|
}
|
||||||
}
|
return PLATFORM_FIREFOX
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -710,15 +710,16 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
Object.keys(accountTokens).forEach((address) => {
|
Object.keys(accountTokens).forEach((address) => {
|
||||||
const checksummedAddress = ethUtil.toChecksumAddress(address)
|
const checksummedAddress = ethUtil.toChecksumAddress(address)
|
||||||
filteredAccountTokens[checksummedAddress] = {}
|
filteredAccountTokens[checksummedAddress] = {}
|
||||||
Object.keys(accountTokens[address]).forEach(
|
Object.keys(accountTokens[address]).forEach((networkType) => {
|
||||||
(networkType) => (filteredAccountTokens[checksummedAddress][networkType] = networkType !== 'mainnet' ?
|
filteredAccountTokens[checksummedAddress][networkType] = networkType === 'mainnet'
|
||||||
accountTokens[address][networkType] :
|
? (
|
||||||
accountTokens[address][networkType].filter(({ address }) => {
|
accountTokens[address][networkType].filter(({ address }) => {
|
||||||
const tokenAddress = ethUtil.toChecksumAddress(address)
|
const tokenAddress = ethUtil.toChecksumAddress(address)
|
||||||
return contractMap[tokenAddress] ? contractMap[tokenAddress].erc20 : true
|
return contractMap[tokenAddress] ? contractMap[tokenAddress].erc20 : true
|
||||||
})
|
})
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
: accountTokens[address][networkType]
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const preferences = {
|
const preferences = {
|
||||||
|
@ -81,10 +81,7 @@ async function start () {
|
|||||||
const summaryPlatform = 'chrome'
|
const summaryPlatform = 'chrome'
|
||||||
const summaryPage = 'home'
|
const summaryPage = 'home'
|
||||||
let commentBody
|
let commentBody
|
||||||
if (!benchmarkResults[summaryPlatform]) {
|
if (benchmarkResults[summaryPlatform]) {
|
||||||
console.log(`No results for ${summaryPlatform} found; skipping benchmark`)
|
|
||||||
commentBody = artifactsBody
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
const summaryPageLoad = Math.round(parseFloat(benchmarkResults[summaryPlatform][summaryPage].average.load))
|
const summaryPageLoad = Math.round(parseFloat(benchmarkResults[summaryPlatform][summaryPage].average.load))
|
||||||
const summaryPageLoadMarginOfError = Math.round(parseFloat(benchmarkResults[summaryPlatform][summaryPage].marginOfError.load))
|
const summaryPageLoadMarginOfError = Math.round(parseFloat(benchmarkResults[summaryPlatform][summaryPage].marginOfError.load))
|
||||||
@ -147,6 +144,9 @@ async function start () {
|
|||||||
console.error(`Error constructing benchmark results: '${error}'`)
|
console.error(`Error constructing benchmark results: '${error}'`)
|
||||||
commentBody = artifactsBody
|
commentBody = artifactsBody
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`No results for ${summaryPlatform} found; skipping benchmark`)
|
||||||
|
commentBody = artifactsBody
|
||||||
}
|
}
|
||||||
|
|
||||||
const JSON_PAYLOAD = JSON.stringify({ body: commentBody })
|
const JSON_PAYLOAD = JSON.stringify({ body: commentBody })
|
||||||
|
@ -25,12 +25,14 @@ async function start () {
|
|||||||
|
|
||||||
// check if version has artifacts or not
|
// check if version has artifacts or not
|
||||||
const versionHasArtifacts = versionAlreadyExists && await checkIfVersionHasArtifacts()
|
const versionHasArtifacts = versionAlreadyExists && await checkIfVersionHasArtifacts()
|
||||||
if (!versionHasArtifacts) {
|
if (versionHasArtifacts) {
|
||||||
|
console.log(`Version "${VERSION}" already has artifacts on Sentry, skipping sourcemap upload`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// upload sentry source and sourcemaps
|
// upload sentry source and sourcemaps
|
||||||
await exec(`./development/sentry-upload-artifacts.sh --release ${VERSION}`)
|
await exec(`./development/sentry-upload-artifacts.sh --release ${VERSION}`)
|
||||||
} else {
|
|
||||||
console.log(`Version "${VERSION}" already has artifacts on Sentry, skipping sourcemap upload`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkIfAuthWorks () {
|
async function checkIfAuthWorks () {
|
||||||
|
@ -16,9 +16,10 @@ describe('nodeify', function () {
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
assert.equal(res, 'barbaz')
|
assert.equal(res, 'barbaz')
|
||||||
done()
|
done()
|
||||||
} else {
|
return
|
||||||
done(new Error(err.toString()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done(new Error(err.toString()))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -30,8 +30,22 @@ export default function ConfirmPageContainerHeader ({
|
|||||||
return (
|
return (
|
||||||
<div className="confirm-page-container-header">
|
<div className="confirm-page-container-header">
|
||||||
<div className="confirm-page-container-header__row">
|
<div className="confirm-page-container-header__row">
|
||||||
{ !showAccountInHeader
|
{ showAccountInHeader
|
||||||
? (
|
? (
|
||||||
|
<div className="confirm-page-container-header__address-container">
|
||||||
|
<div className="confirm-page-container-header__address-identicon">
|
||||||
|
<Identicon
|
||||||
|
address={accountAddress}
|
||||||
|
diameter={24}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="confirm-page-container-header__address">
|
||||||
|
{ shortenAddress(accountAddress) }
|
||||||
|
</div>
|
||||||
|
<AccountMismatchWarning address={accountAddress} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
: (
|
||||||
<div
|
<div
|
||||||
className="confirm-page-container-header__back-button-container"
|
className="confirm-page-container-header__back-button-container"
|
||||||
style={{
|
style={{
|
||||||
@ -49,24 +63,6 @@ export default function ConfirmPageContainerHeader ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
: null
|
|
||||||
}
|
|
||||||
{ showAccountInHeader
|
|
||||||
? (
|
|
||||||
<div className="confirm-page-container-header__address-container">
|
|
||||||
<div className="confirm-page-container-header__address-identicon">
|
|
||||||
<Identicon
|
|
||||||
address={accountAddress}
|
|
||||||
diameter={24}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="confirm-page-container-header__address">
|
|
||||||
{ shortenAddress(accountAddress) }
|
|
||||||
</div>
|
|
||||||
<AccountMismatchWarning address={accountAddress} />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
{ !isFullScreen && <NetworkDisplay /> }
|
{ !isFullScreen && <NetworkDisplay /> }
|
||||||
</div>
|
</div>
|
||||||
|
@ -149,9 +149,9 @@ export default class ConnectedAccountsList extends PureComponent {
|
|||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
action={
|
action={
|
||||||
address !== selectedAddress
|
address === selectedAddress
|
||||||
? this.renderListItemAction(address)
|
? null
|
||||||
: null
|
: this.renderListItemAction(address)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -86,9 +86,9 @@ export default class AdvancedTabContent extends Component {
|
|||||||
? (
|
? (
|
||||||
<div>
|
<div>
|
||||||
<div className="advanced-tab__fee-chart__title">{ t('liveGasPricePredictions') }</div>
|
<div className="advanced-tab__fee-chart__title">{ t('liveGasPricePredictions') }</div>
|
||||||
{!gasEstimatesLoading
|
{gasEstimatesLoading
|
||||||
? <GasPriceChart {...gasChartProps} updateCustomGasPrice={this.onGasChartUpdate} />
|
? <Loading />
|
||||||
: <Loading />
|
: <GasPriceChart {...gasChartProps} updateCustomGasPrice={this.onGasChartUpdate} />
|
||||||
}
|
}
|
||||||
<div className="advanced-tab__fee-chart__speed-buttons">
|
<div className="advanced-tab__fee-chart__speed-buttons">
|
||||||
<span>{ t('slower') }</span>
|
<span>{ t('slower') }</span>
|
||||||
|
@ -20,15 +20,15 @@ export default class BasicTabContent extends Component {
|
|||||||
<div className="basic-tab-content">
|
<div className="basic-tab-content">
|
||||||
<div className="basic-tab-content__title">{ t('estimatedProcessingTimes') }</div>
|
<div className="basic-tab-content__title">{ t('estimatedProcessingTimes') }</div>
|
||||||
<div className="basic-tab-content__blurb">{ t('selectAHigherGasFee') }</div>
|
<div className="basic-tab-content__blurb">{ t('selectAHigherGasFee') }</div>
|
||||||
{!gasPriceButtonGroupProps.loading
|
{gasPriceButtonGroupProps.loading
|
||||||
? (
|
? <Loading />
|
||||||
|
: (
|
||||||
<GasPriceButtonGroup
|
<GasPriceButtonGroup
|
||||||
className="gas-price-button-group--alt"
|
className="gas-price-button-group--alt"
|
||||||
showCheck
|
showCheck
|
||||||
{...gasPriceButtonGroupProps}
|
{...gasPriceButtonGroupProps}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
: <Loading />
|
|
||||||
}
|
}
|
||||||
<div className="basic-tab-content__footer-blurb">{ t('acceleratingATransaction') }</div>
|
<div className="basic-tab-content__footer-blurb">{ t('acceleratingATransaction') }</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -89,8 +89,9 @@ export default class GasPriceButtonGroup extends Component {
|
|||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!buttonDataLoading
|
buttonDataLoading
|
||||||
? (
|
? <div className={`${buttonPropsAndFlags.className}__loading-container`}>{this.context.t('loading')}</div>
|
||||||
|
: (
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
className={buttonPropsAndFlags.className}
|
className={buttonPropsAndFlags.className}
|
||||||
defaultActiveButtonIndex={defaultActiveButtonIndex}
|
defaultActiveButtonIndex={defaultActiveButtonIndex}
|
||||||
@ -100,7 +101,6 @@ export default class GasPriceButtonGroup extends Component {
|
|||||||
{gasButtonInfo.map((obj, index) => this.renderButton(obj, buttonPropsAndFlags, index))}
|
{gasButtonInfo.map((obj, index) => this.renderButton(obj, buttonPropsAndFlags, index))}
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
)
|
)
|
||||||
: <div className={`${buttonPropsAndFlags.className}__loading-container`}>{ this.context.t('loading') }</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,8 @@ export default class InfoBox extends Component {
|
|||||||
render () {
|
render () {
|
||||||
const { title, description } = this.props
|
const { title, description } = this.props
|
||||||
|
|
||||||
return !this.state.isShowing
|
return this.state.isShowing
|
||||||
? null
|
? (
|
||||||
: (
|
|
||||||
<div className="info-box">
|
<div className="info-box">
|
||||||
<div
|
<div
|
||||||
className="info-box__close"
|
className="info-box__close"
|
||||||
@ -41,5 +40,6 @@ export default class InfoBox extends Component {
|
|||||||
<div className="info-box__description">{description}</div>
|
<div className="info-box__description">{description}</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,10 @@ export default class Modal extends PureComponent {
|
|||||||
<div className={classnames('modal-container__content', contentClass)}>
|
<div className={classnames('modal-container__content', contentClass)}>
|
||||||
{ children }
|
{ children }
|
||||||
</div>
|
</div>
|
||||||
{ !hideFooter
|
{
|
||||||
? (
|
hideFooter
|
||||||
|
? null
|
||||||
|
: (
|
||||||
<div className="modal-container__footer">
|
<div className="modal-container__footer">
|
||||||
{
|
{
|
||||||
onCancel && (
|
onCancel && (
|
||||||
@ -87,7 +89,6 @@ export default class Modal extends PureComponent {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -204,7 +204,7 @@ export default class EditApprovalPermission extends PureComponent {
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
setCustomAmount(!selectedOptionIsUnlimited ? customSpendLimit : '')
|
setCustomAmount(selectedOptionIsUnlimited ? '' : customSpendLimit)
|
||||||
hideModal()
|
hideModal()
|
||||||
}}
|
}}
|
||||||
submitText={t('save')}
|
submitText={t('save')}
|
||||||
|
@ -117,11 +117,11 @@ export default class QrScanner extends Component {
|
|||||||
const result = this.parseContent(content.text)
|
const result = this.parseContent(content.text)
|
||||||
if (!this.mounted) {
|
if (!this.mounted) {
|
||||||
return
|
return
|
||||||
} else if (result.type !== 'unknown') {
|
} else if (result.type === 'unknown') {
|
||||||
|
this.setState({ error: new Error(this.context.t('unknownQrCode')) })
|
||||||
|
} else {
|
||||||
this.props.qrCodeDetected(result)
|
this.props.qrCodeDetected(result)
|
||||||
this.stopAndClose()
|
this.stopAndClose()
|
||||||
} else {
|
|
||||||
this.setState({ error: new Error(this.context.t('unknownQrCode')) })
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!this.mounted) {
|
if (!this.mounted) {
|
||||||
@ -248,7 +248,7 @@ export default class QrScanner extends Component {
|
|||||||
display: ready === READY_STATE.READY ? 'block' : 'none',
|
display: ready === READY_STATE.READY ? 'block' : 'none',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{ ready !== READY_STATE.READY ? <Spinner color="#F7C06C" /> : null}
|
{ready === READY_STATE.READY ? null : <Spinner color="#F7C06C" />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="qr-scanner__status">
|
<div className="qr-scanner__status">
|
||||||
|
@ -37,13 +37,14 @@ export default class TransactionBreakdown extends PureComponent {
|
|||||||
{ t('transaction') }
|
{ t('transaction') }
|
||||||
</div>
|
</div>
|
||||||
<TransactionBreakdownRow title="Nonce">
|
<TransactionBreakdownRow title="Nonce">
|
||||||
{typeof nonce !== 'undefined'
|
{typeof nonce === 'undefined'
|
||||||
? (
|
? null
|
||||||
|
: (
|
||||||
<HexToDecimal
|
<HexToDecimal
|
||||||
className="transaction-breakdown__value"
|
className="transaction-breakdown__value"
|
||||||
value={nonce}
|
value={nonce}
|
||||||
/>
|
/>
|
||||||
) : null
|
)
|
||||||
}
|
}
|
||||||
</TransactionBreakdownRow>
|
</TransactionBreakdownRow>
|
||||||
<TransactionBreakdownRow title={t('amount')}>
|
<TransactionBreakdownRow title={t('amount')}>
|
||||||
@ -57,14 +58,14 @@ export default class TransactionBreakdown extends PureComponent {
|
|||||||
title={`${t('gasLimit')} (${t('units')})`}
|
title={`${t('gasLimit')} (${t('units')})`}
|
||||||
className="transaction-breakdown__row-title"
|
className="transaction-breakdown__row-title"
|
||||||
>
|
>
|
||||||
{typeof gas !== 'undefined'
|
{typeof gas === 'undefined'
|
||||||
? (
|
? '?'
|
||||||
|
: (
|
||||||
<HexToDecimal
|
<HexToDecimal
|
||||||
className="transaction-breakdown__value"
|
className="transaction-breakdown__value"
|
||||||
value={gas}
|
value={gas}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
: '?'
|
|
||||||
}
|
}
|
||||||
</TransactionBreakdownRow>
|
</TransactionBreakdownRow>
|
||||||
{
|
{
|
||||||
@ -81,8 +82,9 @@ export default class TransactionBreakdown extends PureComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
<TransactionBreakdownRow title={t('gasPrice')}>
|
<TransactionBreakdownRow title={t('gasPrice')}>
|
||||||
{typeof gasPrice !== 'undefined'
|
{typeof gasPrice === 'undefined'
|
||||||
? (
|
? '?'
|
||||||
|
: (
|
||||||
<CurrencyDisplay
|
<CurrencyDisplay
|
||||||
className="transaction-breakdown__value"
|
className="transaction-breakdown__value"
|
||||||
data-testid="transaction-breakdown__gas-price"
|
data-testid="transaction-breakdown__gas-price"
|
||||||
@ -92,7 +94,6 @@ export default class TransactionBreakdown extends PureComponent {
|
|||||||
hideLabel
|
hideLabel
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
: '?'
|
|
||||||
}
|
}
|
||||||
</TransactionBreakdownRow>
|
</TransactionBreakdownRow>
|
||||||
<TransactionBreakdownRow title={t('total')}>
|
<TransactionBreakdownRow title={t('total')}>
|
||||||
|
@ -86,13 +86,15 @@ export default function TransactionListItem ({ transactionGroup, isEarliestNonce
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return !cancelEnabled ? (
|
return cancelEnabled
|
||||||
|
? cancelButton
|
||||||
|
: (
|
||||||
<Tooltip title={t('notEnoughGas')}>
|
<Tooltip title={t('notEnoughGas')}>
|
||||||
<div>
|
<div>
|
||||||
{cancelButton}
|
{cancelButton}
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
) : cancelButton
|
)
|
||||||
|
|
||||||
}, [isPending, t, isUnapproved, cancelEnabled, cancelTransaction, hasCancelled])
|
}, [isPending, t, isUnapproved, cancelEnabled, cancelTransaction, hasCancelled])
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ export function fetchGasEstimates (blockTime) {
|
|||||||
const next = arr[i + 1]
|
const next = arr[i + 1]
|
||||||
if (!next) {
|
if (!next) {
|
||||||
return [{ expectedWait, gasprice }]
|
return [{ expectedWait, gasprice }]
|
||||||
} else {
|
}
|
||||||
const supplementalPrice = getRandomArbitrary(gasprice, next.gasprice)
|
const supplementalPrice = getRandomArbitrary(gasprice, next.gasprice)
|
||||||
const supplementalTime = extrapolateY({
|
const supplementalTime = extrapolateY({
|
||||||
higherY: next.expectedWait,
|
higherY: next.expectedWait,
|
||||||
@ -421,7 +421,6 @@ export function fetchGasEstimates (blockTime) {
|
|||||||
{ expectedWait: supplementalTime, gasprice: supplementalPrice },
|
{ expectedWait: supplementalTime, gasprice: supplementalPrice },
|
||||||
{ expectedWait: supplementalTime2, gasprice: supplementalPrice2 },
|
{ expectedWait: supplementalTime2, gasprice: supplementalPrice2 },
|
||||||
]
|
]
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
const withOutliersRemoved = inliersByIQR(withSupplementalTimeEstimates.slice(0).reverse(), 'expectedWait').reverse()
|
const withOutliersRemoved = inliersByIQR(withSupplementalTimeEstimates.slice(0).reverse(), 'expectedWait').reverse()
|
||||||
const timeMappedToSeconds = withOutliersRemoved.map(({ expectedWait, gasprice }) => {
|
const timeMappedToSeconds = withOutliersRemoved.map(({ expectedWait, gasprice }) => {
|
||||||
@ -453,11 +452,11 @@ export function fetchGasEstimates (blockTime) {
|
|||||||
|
|
||||||
export function setCustomGasPriceForRetry (newPrice) {
|
export function setCustomGasPriceForRetry (newPrice) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
if (newPrice !== '0x0') {
|
if (newPrice === '0x0') {
|
||||||
dispatch(setCustomGasPrice(newPrice))
|
|
||||||
} else {
|
|
||||||
const { fast } = loadLocalStorageData('BASIC_PRICE_ESTIMATES')
|
const { fast } = loadLocalStorageData('BASIC_PRICE_ESTIMATES')
|
||||||
dispatch(setCustomGasPrice(decGWEIToHexWEI(fast)))
|
dispatch(setCustomGasPrice(decGWEIToHexWEI(fast)))
|
||||||
|
} else {
|
||||||
|
dispatch(setCustomGasPrice(newPrice))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,10 @@ function composeUrl (config) {
|
|||||||
|
|
||||||
const urlref = previousPath && composeUrlRefParamAddition(previousPath, confirmTransactionOrigin)
|
const urlref = previousPath && composeUrlRefParamAddition(previousPath, confirmTransactionOrigin)
|
||||||
|
|
||||||
const dimensions = !pageOpts.hideDimensions ? composeCustomDimensionParamAddition({
|
const dimensions = pageOpts.hideDimensions
|
||||||
|
? ''
|
||||||
|
: (
|
||||||
|
composeCustomDimensionParamAddition({
|
||||||
network,
|
network,
|
||||||
environmentType,
|
environmentType,
|
||||||
activeCurrency,
|
activeCurrency,
|
||||||
@ -165,7 +168,8 @@ function composeUrl (config) {
|
|||||||
version,
|
version,
|
||||||
numberOfTokens: (customVariables && customVariables.numberOfTokens) || numberOfTokens,
|
numberOfTokens: (customVariables && customVariables.numberOfTokens) || numberOfTokens,
|
||||||
numberOfAccounts: (customVariables && customVariables.numberOfAccounts) || numberOfAccounts,
|
numberOfAccounts: (customVariables && customVariables.numberOfAccounts) || numberOfAccounts,
|
||||||
}) : ''
|
})
|
||||||
|
)
|
||||||
const url = currentPath ? `&url=${encodeURIComponent(`${METAMETRICS_TRACKING_URL}${currentPath}`)}` : ''
|
const url = currentPath ? `&url=${encodeURIComponent(`${METAMETRICS_TRACKING_URL}${currentPath}`)}` : ''
|
||||||
const _id = metaMetricsId && !excludeMetaMetricsId ? `&_id=${metaMetricsId.slice(2, 18)}` : ''
|
const _id = metaMetricsId && !excludeMetaMetricsId ? `&_id=${metaMetricsId.slice(2, 18)}` : ''
|
||||||
const rand = `&rand=${String(Math.random()).slice(2)}`
|
const rand = `&rand=${String(Math.random()).slice(2)}`
|
||||||
|
@ -65,9 +65,9 @@ const tests = [
|
|||||||
|
|
||||||
describe('useTokenData', function () {
|
describe('useTokenData', function () {
|
||||||
tests.forEach((test) => {
|
tests.forEach((test) => {
|
||||||
const testTitle = test.tokenData !== null
|
const testTitle = test.tokenData === null
|
||||||
? `should return properly decoded data with _value ${test.tokenData.params[1].value}`
|
? `should return null when no data provided`
|
||||||
: `should return null when no data provided`
|
: `should return properly decoded data with _value ${test.tokenData.params[1].value}`
|
||||||
it(testTitle, function () {
|
it(testTitle, function () {
|
||||||
const { result } = renderHook(() => useTokenData(test.data))
|
const { result } = renderHook(() => useTokenData(test.data))
|
||||||
assert.deepEqual(result.current, test.tokenData)
|
assert.deepEqual(result.current, test.tokenData)
|
||||||
|
@ -220,7 +220,7 @@ export default class ConfirmDecryptMessage extends Component {
|
|||||||
className="request-decrypt-message__message-text"
|
className="request-decrypt-message__message-text"
|
||||||
>
|
>
|
||||||
{ !hasDecrypted && !hasError ? txData.msgParams.data : rawMessage }
|
{ !hasDecrypted && !hasError ? txData.msgParams.data : rawMessage }
|
||||||
{ !hasError ? '' : errorMessage }
|
{ hasError ? errorMessage : '' }
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={classnames({
|
className={classnames({
|
||||||
@ -236,10 +236,10 @@ export default class ConfirmDecryptMessage extends Component {
|
|||||||
})}
|
})}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
decryptMessageInline(txData, event).then((result) => {
|
decryptMessageInline(txData, event).then((result) => {
|
||||||
if (!result.error) {
|
if (result.error) {
|
||||||
this.setState({ hasDecrypted: true, rawMessage: result.rawData })
|
|
||||||
} else {
|
|
||||||
this.setState({ hasError: true, errorMessage: this.context.t('decryptInlineError', [result.error]) })
|
this.setState({ hasError: true, errorMessage: this.context.t('decryptInlineError', [result.error]) })
|
||||||
|
} else {
|
||||||
|
this.setState({ hasDecrypted: true, rawMessage: result.rawData })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
@ -88,7 +88,7 @@ export default class MetaMetricsOptIn extends Component {
|
|||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setParticipateInMetaMetrics(false)
|
setParticipateInMetaMetrics(false)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const promise = participateInMetaMetrics !== false
|
const promise = participateInMetaMetrics === true
|
||||||
? metricsEvent({
|
? metricsEvent({
|
||||||
eventOpts: {
|
eventOpts: {
|
||||||
category: 'Onboarding',
|
category: 'Onboarding',
|
||||||
@ -110,7 +110,7 @@ export default class MetaMetricsOptIn extends Component {
|
|||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
setParticipateInMetaMetrics(true)
|
setParticipateInMetaMetrics(true)
|
||||||
.then(([_, metaMetricsId]) => {
|
.then(([_, metaMetricsId]) => {
|
||||||
const promise = participateInMetaMetrics !== true
|
const promise = participateInMetaMetrics === false
|
||||||
? metricsEvent({
|
? metricsEvent({
|
||||||
eventOpts: {
|
eventOpts: {
|
||||||
category: 'Onboarding',
|
category: 'Onboarding',
|
||||||
|
@ -16,12 +16,12 @@ const returnToOnboardingInitiatorTab = async (onboardingInitiator) => {
|
|||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (!tab) {
|
if (tab) {
|
||||||
|
window.close()
|
||||||
|
} else {
|
||||||
// this case can happen if the tab was closed since being checked with `extension.tabs.get`
|
// this case can happen if the tab was closed since being checked with `extension.tabs.get`
|
||||||
log.warn(`Setting current tab to onboarding initiator has failed; falling back to redirect`)
|
log.warn(`Setting current tab to onboarding initiator has failed; falling back to redirect`)
|
||||||
window.location.assign(onboardingInitiator.location)
|
window.location.assign(onboardingInitiator.location)
|
||||||
} else {
|
|
||||||
window.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,10 +173,10 @@ export default class ConfirmSeedPhrase extends PureComponent {
|
|||||||
className="confirm-seed-phrase__seed-word--sorted"
|
className="confirm-seed-phrase__seed-word--sorted"
|
||||||
selected={isSelected}
|
selected={isSelected}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!isSelected) {
|
if (isSelected) {
|
||||||
this.handleSelectSeedWord(index)
|
|
||||||
} else {
|
|
||||||
this.handleDeselectSeedWord(index)
|
this.handleDeselectSeedWord(index)
|
||||||
|
} else {
|
||||||
|
this.handleSelectSeedWord(index)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
word={word}
|
word={word}
|
||||||
|
@ -30,10 +30,10 @@ export default class SeedPhrase extends PureComponent {
|
|||||||
if (!seedPhrase) {
|
if (!seedPhrase) {
|
||||||
verifySeedPhrase()
|
verifySeedPhrase()
|
||||||
.then((verifiedSeedPhrase) => {
|
.then((verifiedSeedPhrase) => {
|
||||||
if (!verifiedSeedPhrase) {
|
if (verifiedSeedPhrase) {
|
||||||
history.push(DEFAULT_ROUTE)
|
|
||||||
} else {
|
|
||||||
this.setState({ verifiedSeedPhrase })
|
this.setState({ verifiedSeedPhrase })
|
||||||
|
} else {
|
||||||
|
history.push(DEFAULT_ROUTE)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -194,10 +194,10 @@ export default class MobileSyncPage extends Component {
|
|||||||
storeInHistory: false,
|
storeInHistory: false,
|
||||||
},
|
},
|
||||||
(status, response) => {
|
(status, response) => {
|
||||||
if (!status.error) {
|
if (status.error) {
|
||||||
resolve()
|
|
||||||
} else {
|
|
||||||
reject(response)
|
reject(response)
|
||||||
|
} else {
|
||||||
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -253,10 +253,10 @@ export default class MobileSyncPage extends Component {
|
|||||||
storeInHistory: false,
|
storeInHistory: false,
|
||||||
},
|
},
|
||||||
(status, response) => {
|
(status, response) => {
|
||||||
if (!status.error) {
|
if (status.error) {
|
||||||
resolve()
|
|
||||||
} else {
|
|
||||||
reject(response)
|
reject(response)
|
||||||
|
} else {
|
||||||
|
resolve()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -162,11 +162,10 @@ export default class PermissionConnect extends Component {
|
|||||||
const { redirecting } = this.state
|
const { redirecting } = this.state
|
||||||
const { page } = this.props
|
const { page } = this.props
|
||||||
const { t } = this.context
|
const { t } = this.context
|
||||||
return !redirecting
|
return redirecting
|
||||||
? (
|
? null
|
||||||
<div
|
: (
|
||||||
className="permissions-connect__top-bar"
|
<div className="permissions-connect__top-bar">
|
||||||
>
|
|
||||||
{page === '2'
|
{page === '2'
|
||||||
? (
|
? (
|
||||||
<div className="permissions-connect__back" onClick={() => this.goBack()}>
|
<div className="permissions-connect__back" onClick={() => this.goBack()}>
|
||||||
@ -181,7 +180,6 @@ export default class PermissionConnect extends Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -265,16 +265,16 @@ export default class Routes extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleMetamaskActive () {
|
toggleMetamaskActive () {
|
||||||
if (!this.props.isUnlocked) {
|
if (this.props.isUnlocked) {
|
||||||
|
// currently active: deactivate
|
||||||
|
this.props.lockMetaMask()
|
||||||
|
} else {
|
||||||
// currently inactive: redirect to password box
|
// currently inactive: redirect to password box
|
||||||
const passwordBox = document.querySelector('input[type=password]')
|
const passwordBox = document.querySelector('input[type=password]')
|
||||||
if (!passwordBox) {
|
if (!passwordBox) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
passwordBox.focus()
|
passwordBox.focus()
|
||||||
} else {
|
|
||||||
// currently active: deactivate
|
|
||||||
this.props.lockMetaMask()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ export default class EnsInput extends Component {
|
|||||||
|
|
||||||
if (!networkHasEnsSupport && !isValidAddress(input) && !isValidAddressHead(input)) {
|
if (!networkHasEnsSupport && !isValidAddress(input) && !isValidAddressHead(input)) {
|
||||||
updateEnsResolution('')
|
updateEnsResolution('')
|
||||||
updateEnsResolutionError(!networkHasEnsSupport ? 'Network does not support ENS' : '')
|
updateEnsResolutionError(networkHasEnsSupport ? '' : 'Network does not support ENS')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ export default class AmountMaxButton extends Component {
|
|||||||
name: 'Clicked "Amount Max"',
|
name: 'Clicked "Amount Max"',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (!maxModeOn) {
|
if (maxModeOn) {
|
||||||
setMaxModeTo(true)
|
|
||||||
this.setMaxAmount()
|
|
||||||
} else {
|
|
||||||
setMaxModeTo(false)
|
setMaxModeTo(false)
|
||||||
clearMaxAmount()
|
clearMaxAmount()
|
||||||
|
} else {
|
||||||
|
setMaxModeTo(true)
|
||||||
|
this.setMaxAmount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ function mapDispatchToProps (dispatch) {
|
|||||||
value,
|
value,
|
||||||
data,
|
data,
|
||||||
}) => {
|
}) => {
|
||||||
!editingTransactionId
|
editingTransactionId
|
||||||
? dispatch(updateGasData({ gasPrice, selectedAddress, sendToken, blockGasLimit, to, value, data }))
|
? dispatch(setGasTotal(calcGasTotal(gasLimit, gasPrice)))
|
||||||
: dispatch(setGasTotal(calcGasTotal(gasLimit, gasPrice)))
|
: dispatch(updateGasData({ gasPrice, selectedAddress, sendToken, blockGasLimit, to, value, data }))
|
||||||
},
|
},
|
||||||
updateSendTokenBalance: ({ sendToken, tokenContract, address }) => {
|
updateSendTokenBalance: ({ sendToken, tokenContract, address }) => {
|
||||||
dispatch(updateSendTokenBalance({
|
dispatch(updateSendTokenBalance({
|
||||||
|
@ -261,10 +261,10 @@ export function getPermissionsMetadataHostCounts (state) {
|
|||||||
const metadata = getPermissionDomainsMetadata(state)
|
const metadata = getPermissionDomainsMetadata(state)
|
||||||
return Object.values(metadata).reduce((counts, { host }) => {
|
return Object.values(metadata).reduce((counts, { host }) => {
|
||||||
if (host) {
|
if (host) {
|
||||||
if (!counts[host]) {
|
if (counts[host]) {
|
||||||
counts[host] = 1
|
|
||||||
} else {
|
|
||||||
counts[host] += 1
|
counts[host] += 1
|
||||||
|
} else {
|
||||||
|
counts[host] = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return counts
|
return counts
|
||||||
|
Loading…
Reference in New Issue
Block a user