mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
code review changes
This commit is contained in:
parent
2e0916d8ff
commit
c6b7e460b5
@ -1074,6 +1074,9 @@
|
|||||||
"message": "We had trouble loading your token balances. You can view them ",
|
"message": "We had trouble loading your token balances. You can view them ",
|
||||||
"description": "Followed by a link (here) to view token balances"
|
"description": "Followed by a link (here) to view token balances"
|
||||||
},
|
},
|
||||||
|
"tryAgain": {
|
||||||
|
"message": "Try again"
|
||||||
|
},
|
||||||
"twelveWords": {
|
"twelveWords": {
|
||||||
"message": "These 12 words are the only way to restore your MetaMask accounts.\nSave them somewhere safe and secret."
|
"message": "These 12 words are the only way to restore your MetaMask accounts.\nSave them somewhere safe and secret."
|
||||||
},
|
},
|
||||||
|
@ -2,8 +2,19 @@ const ENVIRONMENT_TYPE_POPUP = 'popup'
|
|||||||
const ENVIRONMENT_TYPE_NOTIFICATION = 'notification'
|
const ENVIRONMENT_TYPE_NOTIFICATION = 'notification'
|
||||||
const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen'
|
const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen'
|
||||||
|
|
||||||
|
const PLATFORM_BRAVE = 'Brave'
|
||||||
|
const PLATFORM_CHROME = 'Chrome'
|
||||||
|
const PLATFORM_EDGE = 'Edge'
|
||||||
|
const PLATFORM_FIREFOX = 'Firefox'
|
||||||
|
const PLATFORM_OPERA = 'Opera'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
ENVIRONMENT_TYPE_POPUP,
|
ENVIRONMENT_TYPE_POPUP,
|
||||||
ENVIRONMENT_TYPE_NOTIFICATION,
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
||||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
ENVIRONMENT_TYPE_FULLSCREEN,
|
||||||
|
PLATFORM_BRAVE,
|
||||||
|
PLATFORM_CHROME,
|
||||||
|
PLATFORM_EDGE,
|
||||||
|
PLATFORM_FIREFOX,
|
||||||
|
PLATFORM_OPERA,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,11 @@ const {
|
|||||||
ENVIRONMENT_TYPE_POPUP,
|
ENVIRONMENT_TYPE_POPUP,
|
||||||
ENVIRONMENT_TYPE_NOTIFICATION,
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
||||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
ENVIRONMENT_TYPE_FULLSCREEN,
|
||||||
|
PLATFORM_FIREFOX,
|
||||||
|
PLATFORM_OPERA,
|
||||||
|
PLATFORM_CHROME,
|
||||||
|
PLATFORM_EDGE,
|
||||||
|
PLATFORM_BRAVE,
|
||||||
} = require('./enums')
|
} = require('./enums')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,6 +42,29 @@ const getEnvironmentType = (url = window.location.href) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the platform (browser) where the extension is running.
|
||||||
|
*
|
||||||
|
* @returns {string} the platform ENUM
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const getPlatform = _ => {
|
||||||
|
const ua = navigator.userAgent
|
||||||
|
if (ua.search('Firefox') !== -1) {
|
||||||
|
return PLATFORM_FIREFOX
|
||||||
|
} else {
|
||||||
|
if (window && window.chrome && window.chrome.ipcRenderer) {
|
||||||
|
return PLATFORM_BRAVE
|
||||||
|
} else if (ua.search('Edge') !== -1) {
|
||||||
|
return PLATFORM_EDGE
|
||||||
|
} else if (ua.search('OPR') !== -1) {
|
||||||
|
return PLATFORM_OPERA
|
||||||
|
} else {
|
||||||
|
return PLATFORM_CHROME
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a given balance of ETH, represented as a hex string, is sufficient to pay a value plus a gas fee
|
* Checks whether a given balance of ETH, represented as a hex string, is sufficient to pay a value plus a gas fee
|
||||||
*
|
*
|
||||||
@ -100,6 +128,7 @@ function BnMultiplyByFraction (targetBN, numerator, denominator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
getPlatform,
|
||||||
getStack,
|
getStack,
|
||||||
getEnvironmentType,
|
getEnvironmentType,
|
||||||
sufficientBalance,
|
sufficientBalance,
|
||||||
|
@ -4,6 +4,7 @@ import { BrowserQRCodeReader } from '@zxing/library'
|
|||||||
import adapter from 'webrtc-adapter' // eslint-disable-line import/no-nodejs-modules, no-unused-vars
|
import adapter from 'webrtc-adapter' // eslint-disable-line import/no-nodejs-modules, no-unused-vars
|
||||||
import Spinner from '../../spinner'
|
import Spinner from '../../spinner'
|
||||||
import WebcamUtils from '../../../../lib/webcam-utils'
|
import WebcamUtils from '../../../../lib/webcam-utils'
|
||||||
|
import PageContainerFooter from '../../page-container/page-container-footer/page-container-footer.component';
|
||||||
|
|
||||||
export default class QrScanner extends Component {
|
export default class QrScanner extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -104,9 +105,19 @@ export default class QrScanner extends Component {
|
|||||||
// To parse other type of links
|
// To parse other type of links
|
||||||
// For ex. EIP-681 (https://eips.ethereum.org/EIPS/eip-681)
|
// For ex. EIP-681 (https://eips.ethereum.org/EIPS/eip-681)
|
||||||
|
|
||||||
|
|
||||||
|
// Ethereum address links - fox ex. ethereum:0x.....1111
|
||||||
if (content.split('ethereum:').length > 1) {
|
if (content.split('ethereum:').length > 1) {
|
||||||
|
|
||||||
type = 'address'
|
type = 'address'
|
||||||
values = {'address': content.split('ethereum:')[1] }
|
values = {'address': content.split('ethereum:')[1] }
|
||||||
|
|
||||||
|
// Regular ethereum addresses - fox ex. 0x.....1111
|
||||||
|
} else if (content.substring(0, 2).toLowerCase() === '0x') {
|
||||||
|
|
||||||
|
type = 'address'
|
||||||
|
values = {'address': content }
|
||||||
|
|
||||||
}
|
}
|
||||||
return {type, values}
|
return {type, values}
|
||||||
}
|
}
|
||||||
@ -169,14 +180,12 @@ export default class QrScanner extends Component {
|
|||||||
<div className={'qr-scanner__error'}>
|
<div className={'qr-scanner__error'}>
|
||||||
{msg}
|
{msg}
|
||||||
</div>
|
</div>
|
||||||
<div className={'qr-scanner__footer'}>
|
<PageContainerFooter
|
||||||
<button className="btn-default btn--large" onClick={this.stopAndClose}>
|
onCancel={this.stopAndClose}
|
||||||
CANCEL
|
onSubmit={this.tryAgain}
|
||||||
</button>
|
cancelText={this.context.t('cancel')}
|
||||||
<button className="btn-primary btn--large" onClick={this.tryAgain}>
|
submitText={this.context.t('tryAgain')}
|
||||||
TRY AGAIN
|
/>
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,15 @@
|
|||||||
|
|
||||||
import DetectRTC from 'detectrtc'
|
import DetectRTC from 'detectrtc'
|
||||||
const { ENVIRONMENT_TYPE_POPUP } = require('../../app/scripts/lib/enums')
|
const { ENVIRONMENT_TYPE_POPUP } = require('../../app/scripts/lib/enums')
|
||||||
const { getEnvironmentType } = require('../../app/scripts/lib/util')
|
const { getEnvironmentType, getPlatform } = require('../../app/scripts/lib/util')
|
||||||
|
const { PLATFORM_BRAVE, PLATFORM_FIREFOX } = require('../../app/scripts/lib/enums')
|
||||||
|
|
||||||
class WebcamUtils {
|
class WebcamUtils {
|
||||||
|
|
||||||
static checkStatus () {
|
static checkStatus () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const isPopup = getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP
|
const isPopup = getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP
|
||||||
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1
|
const isFirefoxOrBrave = getPlatform() === (PLATFORM_FIREFOX || PLATFORM_BRAVE)
|
||||||
const isBrave = !!window.chrome.ipcRenderer
|
|
||||||
const isFirefoxOrBrave = isFirefox || isBrave
|
|
||||||
try {
|
try {
|
||||||
DetectRTC.load(_ => {
|
DetectRTC.load(_ => {
|
||||||
if (DetectRTC.hasWebcam) {
|
if (DetectRTC.hasWebcam) {
|
||||||
|
Loading…
Reference in New Issue
Block a user