aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/_locales/en/messages.json3
-rw-r--r--app/scripts/platforms/extension.js7
-rw-r--r--package-lock.json24
-rw-r--r--ui/app/components/modals/qr-scanner/qr-scanner.component.js38
-rw-r--r--ui/app/components/send/send.component.js5
5 files changed, 48 insertions, 29 deletions
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index 286e32194..60e873371 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -1144,6 +1144,9 @@
"whatsThis": {
"message": "What's this?"
},
+ "youNeedToAllowCameraAccess": {
+ "message": "You need to allow camera access to use this feature."
+ },
"yourSigRequested": {
"message": "Your signature is being requested"
},
diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js
index 0803164e8..71b162dd0 100644
--- a/app/scripts/platforms/extension.js
+++ b/app/scripts/platforms/extension.js
@@ -24,8 +24,13 @@ class ExtensionPlatform {
return extension.runtime.getManifest().version
}
- openExtensionInBrowser (route = null) {
+ openExtensionInBrowser (route = null, queryString = null) {
let extensionURL = extension.runtime.getURL('home.html')
+
+ if (queryString) {
+ extensionURL += `?${queryString}`
+ }
+
if (route) {
extensionURL += `#${route}`
}
diff --git a/package-lock.json b/package-lock.json
index fd5d9d1b6..3a4007048 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8406,13 +8406,12 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.1.tgz",
"integrity": "sha512-lxHZOQspexk3DaGj4RBbWy4C/qNOWRnxpaJzNnYD3WEmC8shcJ4tHs7Xv878rzvILfJnSFSCCiKQhng1m80oBQ==",
"requires": {
- "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
- "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
+ "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@@ -8690,13 +8689,12 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"requires": {
- "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
- "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
+ "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@@ -8738,14 +8736,12 @@
"integrity": "sha512-lxHZOQspexk3DaGj4RBbWy4C/qNOWRnxpaJzNnYD3WEmC8shcJ4tHs7Xv878rzvILfJnSFSCCiKQhng1m80oBQ==",
"dev": true,
"requires": {
- "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
- "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
- "dev": true,
+ "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@@ -8757,7 +8753,6 @@
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
- "dev": true,
"requires": {
"bn.js": "^4.11.0",
"create-hash": "^1.1.2",
@@ -30722,7 +30717,6 @@
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
- "dev": true,
"requires": {
"is-typedarray": "^1.0.0"
}
@@ -31746,7 +31740,6 @@
"resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz",
"integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=",
"requires": {
- "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"crypto-js": "^3.1.4",
"utf8": "^2.1.1",
"xhr2": "*",
@@ -31755,7 +31748,7 @@
"dependencies": {
"bignumber.js": {
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
- "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git"
+ "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934"
}
}
},
@@ -32254,8 +32247,7 @@
"dev": true,
"requires": {
"underscore": "1.8.3",
- "web3-core-helpers": "1.0.0-beta.34",
- "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
+ "web3-core-helpers": "1.0.0-beta.34"
},
"dependencies": {
"underscore": {
@@ -32266,8 +32258,7 @@
},
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
- "from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
- "dev": true,
+ "from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3",
@@ -33632,8 +33623,7 @@
"yaeti": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
- "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=",
- "dev": true
+ "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
},
"yallist": {
"version": "2.1.2",
diff --git a/ui/app/components/modals/qr-scanner/qr-scanner.component.js b/ui/app/components/modals/qr-scanner/qr-scanner.component.js
index 580774635..395008fca 100644
--- a/ui/app/components/modals/qr-scanner/qr-scanner.component.js
+++ b/ui/app/components/modals/qr-scanner/qr-scanner.component.js
@@ -3,6 +3,11 @@ import PropTypes from 'prop-types'
import { BrowserQRCodeReader } from '@zxing/library'
import adapter from 'webrtc-adapter' // eslint-disable-line import/no-nodejs-modules, no-unused-vars
import Spinner from '../../spinner'
+const { ENVIRONMENT_TYPE_POPUP } = require('../../../../../app/scripts/lib/enums')
+const { getEnvironmentType } = require('../../../../../app/scripts/lib/util')
+const {
+ SEND_ROUTE,
+} = require('../../../routes')
export default class QrScanner extends Component {
static propTypes = {
@@ -22,13 +27,14 @@ export default class QrScanner extends Component {
}
this.scanning = false
this.codeReader = null
+ this.notAllowed = false
}
componentDidMount () {
- console.log('[QR-SCANNER]: componentDidUpdate', this.scanning)
+
if (!this.scanning) {
this.scanning = true
- console.log('[QR-SCANNER]: componentDidUpdate - about to call initCamera')
+
this.initCamera()
}
}
@@ -38,22 +44,23 @@ export default class QrScanner extends Component {
}
initCamera () {
- console.log('[QR-SCANNER]: initCamera')
+
this.codeReader = new BrowserQRCodeReader()
this.codeReader.getVideoInputDevices()
.then(videoInputDevices => {
- console.log('[QR-SCANNER]: initCamera::getVideoInputDevices', videoInputDevices)
+
setTimeout(_ => {
- this.setState({
- ready: true,
- msg: this.context.t('scanInstructions')})
- console.log('[QR-SCANNER]: initCamera::ready')
+ if (!this.notAllowed) {
+ this.setState({
+ ready: true,
+ msg: this.context.t('scanInstructions')})
+ }
}, 2000)
- console.log('[QR-SCANNER]: initCamera::started decoding...')
+
this.codeReader.decodeFromInputVideoDevice(videoInputDevices[0].deviceId, 'video')
.then(content => {
- console.log('[QR-SCANNER]: initCamera::decodeFromInputVideoDevice callback', content)
+
const result = this.parseContent(content.text)
if (result.type !== 'unknown') {
this.props.qrCodeDetected(result)
@@ -63,6 +70,14 @@ export default class QrScanner extends Component {
}
})
.catch(err => {
+ this.notAllowed = true
+ if (err && err.name === 'NotAllowedError') {
+ if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP) {
+ global.platform.openExtensionInBrowser(`${SEND_ROUTE}`, `scan=true`)
+ } else {
+ this.setState({msg: this.context.t('youNeedToAllowCameraAccess')})
+ }
+ }
console.error('QR-SCANNER: decodeFromInputVideoDevice threw an exception: ', err)
})
}).catch(err => {
@@ -75,7 +90,8 @@ export default class QrScanner extends Component {
let values = {}
// Here we could add more cases
- // To parse other codes (transactions for ex.)
+ // To parse other type of links
+ // For ex. EIP-681 (https://eips.ethereum.org/EIPS/eip-681)
if (content.split('ethereum:').length > 1) {
type = 'address'
diff --git a/ui/app/components/send/send.component.js b/ui/app/components/send/send.component.js
index fb7eef329..8305a288e 100644
--- a/ui/app/components/send/send.component.js
+++ b/ui/app/components/send/send.component.js
@@ -175,6 +175,11 @@ export default class SendTransactionScreen extends PersistentForm {
address,
})
this.updateGas()
+
+ // Show QR Scanner modal if ?scan=true
+ if (window.location.search === '?scan=true') {
+ this.props.scanQrCode()
+ }
}
componentWillUnmount () {