aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/metamask-controller.js10
-rw-r--r--gulpfile.js30
-rw-r--r--ui/app/actions.js74
5 files changed, 65 insertions, 52 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a06314e0..dd2770a53 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Current Master
+- Remove certain non-essential permissions from certain builds.
- Add a check for when a tx is included in a block.
- Implement replay attack protections allowed by EIP 155.
diff --git a/app/manifest.json b/app/manifest.json
index 61775ed93..95dcfc31a 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -56,9 +56,7 @@
],
"permissions": [
"storage",
- "tabs",
"clipboardWrite",
- "clipboardRead",
"http://localhost:8545/"
],
"web_accessible_resources": [
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 86eab9d9c..50456b9fa 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -60,6 +60,8 @@ module.exports = class MetamaskController {
this.idStoreMigrator = new IdStoreMigrator({
configManager: this.configManager,
})
+
+ this.ethStore.on('update', this.sendUpdate.bind(this))
}
getState () {
@@ -161,8 +163,12 @@ module.exports = class MetamaskController {
}
sendUpdate () {
- this.listeners.forEach((remote) => {
- remote.sendUpdate(this.getState())
+ this.getState()
+ .then((state) => {
+
+ this.listeners.forEach((remote) => {
+ remote.sendUpdate(state)
+ })
})
}
diff --git a/gulpfile.js b/gulpfile.js
index 26ad0c1f8..ca69b36a8 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -46,6 +46,7 @@ gulp.task('copy:locales', copyTask({
'./dist/firefox/_locales',
'./dist/chrome/_locales',
'./dist/edge/_locales',
+ './dist/opera/_locales',
]
}))
gulp.task('copy:images', copyTask({
@@ -54,6 +55,7 @@ gulp.task('copy:images', copyTask({
'./dist/firefox/images',
'./dist/chrome/images',
'./dist/edge/images',
+ './dist/opera/images',
],
}))
gulp.task('copy:fonts', copyTask({
@@ -62,6 +64,7 @@ gulp.task('copy:fonts', copyTask({
'./dist/firefox/fonts',
'./dist/chrome/fonts',
'./dist/edge/fonts',
+ './dist/opera/fonts',
],
}))
gulp.task('copy:reload', copyTask({
@@ -70,6 +73,7 @@ gulp.task('copy:reload', copyTask({
'./dist/firefox/scripts',
'./dist/chrome/scripts',
'./dist/edge/scripts',
+ './dist/opera/scripts',
],
pattern: '/chromereload.js',
}))
@@ -79,6 +83,7 @@ gulp.task('copy:root', copyTask({
'./dist/firefox',
'./dist/chrome',
'./dist/edge',
+ './dist/opera',
],
pattern: '/*',
}))
@@ -92,6 +97,21 @@ gulp.task('manifest:chrome', function() {
.pipe(gulp.dest('./dist/chrome', { overwrite: true }))
})
+gulp.task('manifest:opera', function() {
+ return gulp.src('./dist/opera/manifest.json')
+ .pipe(jsoneditor(function(json) {
+ json.permissions = [
+ "storage",
+ "tabs",
+ "clipboardWrite",
+ "clipboardRead",
+ "http://localhost:8545/"
+ ]
+ return json
+ }))
+ .pipe(gulp.dest('./dist/opera', { overwrite: true }))
+})
+
gulp.task('manifest:production', function() {
return gulp.src([
'./dist/firefox/manifest.json',
@@ -118,7 +138,7 @@ if (!disableLiveReload) {
copyStrings.push('copy:reload')
}
-gulp.task('copy', gulp.series(gulp.parallel(...copyStrings), 'manifest:production', 'manifest:chrome'))
+gulp.task('copy', gulp.series(gulp.parallel(...copyStrings), 'manifest:production', 'manifest:chrome', 'manifest:opera'))
gulp.task('copy:watch', function(){
gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy'))
})
@@ -188,7 +208,12 @@ gulp.task('zip:edge', () => {
.pipe(zip(`metamask-edge-${manifest.version}.zip`))
.pipe(gulp.dest('builds'));
})
-gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox', 'zip:edge'))
+gulp.task('zip:opera', () => {
+ return gulp.src('dist/opera/**')
+ .pipe(zip(`metamask-opera-${manifest.version}.zip`))
+ .pipe(gulp.dest('builds'));
+})
+gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox', 'zip:edge', 'zip:opera'))
// high level tasks
@@ -255,6 +280,7 @@ function bundleTask(opts) {
.pipe(gulp.dest('./dist/firefox/scripts'))
.pipe(gulp.dest('./dist/chrome/scripts'))
.pipe(gulp.dest('./dist/edge/scripts'))
+ .pipe(gulp.dest('./dist/opera/scripts'))
.pipe(gulpif(!disableLiveReload,livereload()))
)
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 606460314..d63d36f19 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -153,7 +153,7 @@ var actions = {
SHOW_NEW_KEYCHAIN: 'SHOW_NEW_KEYCHAIN',
showNewKeychain: showNewKeychain,
-
+ callBackgroundThenUpdate,
}
module.exports = actions
@@ -226,14 +226,7 @@ function createNewVaultAndRestore (password, seed) {
}
function createNewVaultAndKeychain (password) {
- return (dispatch) => {
- background.createNewVaultAndKeychain(password, (err, newState) => {
- if (err) {
- return dispatch(actions.showWarning(err.message))
- }
- dispatch(actions.updateMetamaskState(newState))
- })
- }
+ return callBackgroundThenUpdate(background.createNewVaultAndKeychain, password)
}
function revealSeedConfirmation () {
@@ -255,29 +248,12 @@ function requestRevealSeed (password) {
}
}
-
function addNewKeyring (type, opts) {
- return (dispatch) => {
- dispatch(actions.showLoadingIndication())
- background.addNewKeyring(type, opts, (err) => {
- dispatch(this.hideLoadingIndication())
- if (err) {
- return dispatch(actions.showWarning(err))
- }
- })
- }
+ return callBackgroundThenUpdate(background.addNewKeyring, type, opts)
}
function addNewAccount (ringNumber = 0) {
- return (dispatch) => {
- dispatch(actions.showLoadingIndication())
- background.addNewAccount(ringNumber, (err) => {
- dispatch(this.hideLoadingIndication())
- if (err) {
- return dispatch(actions.showWarning(err))
- }
- })
- }
+ return callBackgroundThenUpdate(background.addNewAccount, ringNumber)
}
function showInfoPage () {
@@ -475,15 +451,7 @@ function updateMetamaskState (newState) {
}
function lockMetamask () {
- return (dispatch) => {
- background.setLocked((err, newState) => {
- dispatch(actions.hideLoadingIndication())
- if (err) {
- return dispatch(actions.displayWarning(err.message))
- }
- dispatch(actions.updateMetamaskState(newState))
- })
- }
+ return callBackgroundThenUpdate(background.setLocked)
}
function showAccountDetail (address) {
@@ -565,7 +533,7 @@ function markNoticeRead (notice) {
background.markNoticeRead(notice, (err, notice) => {
dispatch(this.hideLoadingIndication())
if (err) {
- return dispatch(actions.showWarning(err))
+ return dispatch(actions.displayWarning(err))
}
if (notice) {
return dispatch(actions.showNotice(notice))
@@ -593,14 +561,7 @@ function clearNotices () {
}
function markAccountsFound() {
- return (dispatch) => {
- dispatch(this.showLoadingIndication())
- background.markAccountsFound((err, newState) => {
- dispatch(this.hideLoadingIndication())
- if (err) return dispatch(this.showWarning(err.message))
- dispatch(actions.updateMetamaskState(newState))
- })
- }
+ return callBackgroundThenUpdate(background.markAccountsFound)
}
//
@@ -857,3 +818,24 @@ function shapeShiftRequest (query, options, cb) {
return shapShiftReq.send()
}
}
+
+// Call Background Then Update
+//
+// A function generator for a common pattern wherein:
+// We show loading indication.
+// We call a background method.
+// We hide loading indication.
+// If it errored, we show a warning.
+// If it didn't, we update the state.
+function callBackgroundThenUpdate (method, ...args) {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ method.call(background, ...args, (err, newState) => {
+ dispatch(actions.hideLoadingIndication())
+ if (err) {
+ return dispatch(actions.displayWarning(err.message))
+ }
+ dispatch(actions.updateMetamaskState(newState))
+ })
+ }
+}