Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
235e1b0
extension talking to mobile
brunobar79 Sep 29, 2018
14e28a2
sync data + txs
brunobar79 Sep 29, 2018
38328bf
add cipher stuff
brunobar79 Oct 1, 2018
e655df3
account syncing works
brunobar79 Oct 2, 2018
cb772ad
clean up
brunobar79 Oct 8, 2018
8d06f6f
updates
brunobar79 Oct 11, 2018
8890822
more fixes
brunobar79 Oct 16, 2018
c1abb44
fix merge conflicts
brunobar79 Oct 20, 2018
1f657d5
fix merge conflicst
brunobar79 Oct 23, 2018
c7a1e54
check for dupes and send error to phone
brunobar79 Oct 23, 2018
fb3e267
updates
brunobar79 Oct 30, 2018
2c76373
fix merge conflicts
brunobar79 Nov 3, 2018
5698af6
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
brunobar79 Nov 3, 2018
e69c49d
updated pkg-lock
brunobar79 Nov 6, 2018
7d627f7
fix merge conflicts
brunobar79 Nov 6, 2018
18764ca
merge develop
brunobar79 Nov 20, 2018
a6a9922
fix merge conflicts
brunobar79 Nov 20, 2018
5a5cdc8
fix merge conflicts
brunobar79 Dec 14, 2018
ce0cfbf
lint
brunobar79 Dec 14, 2018
8732f31
move mobile sync to the end
brunobar79 Dec 14, 2018
bd0ff16
remove harcoded channel name
Dec 16, 2018
4bd91cd
Add background console command for enabling UI-hidden features
danfinlay Dec 19, 2018
5d33482
Merge branch 'mobile-sync' into FeatureFlagMobileSync
danfinlay Dec 19, 2018
30c1080
Reuse feature flag method
danfinlay Dec 19, 2018
8d72920
Complete secret feature flags
danfinlay Dec 20, 2018
29ef081
Fix linting
danfinlay Dec 20, 2018
8bc2a34
fix merge conflicts
brunobar79 Jan 30, 2019
51b826f
add missing route
brunobar79 Jan 30, 2019
42cb688
fix merge conflicts
brunobar79 Feb 19, 2019
0a5b7ad
use env vars
brunobar79 Feb 20, 2019
0f55566
clean up
brunobar79 Feb 20, 2019
68a842f
Added notes about proper usage of feature flags.
danfinlay Feb 21, 2019
457c831
Merge branch 'FeatureFlagMobileSync' of github.com:MetaMask/metamask-…
danfinlay Feb 21, 2019
99a3c5c
fix merge conflicts
brunobar79 Feb 21, 2019
b73d618
fix regressions
brunobar79 Feb 25, 2019
c2c56f0
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
brunobar79 Feb 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,12 @@
"minutesShorthand": {
"message": "Min"
},
"mobileSyncTitle": {
"message": "Sync accounts with mobile"
},
"mobileSyncText": {
"message": "Please enter your password to confirm it's you!"
},
"myAccounts": {
"message": "My Accounts"
},
Expand Down Expand Up @@ -1333,6 +1339,27 @@
"symbolBetweenZeroTwelve": {
"message": "Symbol must be between 0 and 12 characters."
},
"syncWithMobile": {
"message": "Sync with mobile"
},
"syncWithMobileTitle": {
"message": "Sync with mobile"
},
"syncWithMobileDesc": {
"message": "You can sync your accounts and information with your mobile device. Open the MetaMask mobile app, go to \"Settings\" and tap on \"Sync from Browser Extension\""
},
"syncWithMobileDescNewUsers": {
"message": "If you just open the MetaMask Mobile app for the first time, just follow the steps in your phone."
},
"syncWithMobileScanThisCode": {
"message": "Scan this code with your MetaMask mobile app"
},
"syncWithMobileBeCareful": {
"message": "Make sure nobody else is looking at your screen when you scan this code"
},
"syncWithMobileComplete": {
"message": "Your data has been synced succesfully. Enjoy the MetaMask mobile app!"
},
"takesTooLong": {
"message": "Taking too long?"
},
Expand Down
13 changes: 12 additions & 1 deletion app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class PreferencesController {
* @property {object} store.assetImages Contains assets objects related to assets added
* @property {boolean} store.useBlockie The users preference for blockie identicons within the UI
* @property {object} store.featureFlags A key-boolean map, where keys refer to features and booleans to whether the
* user wishes to see that feature
* user wishes to see that feature.
*
* Feature flags can be set by the global function `setPreference(feature, enabled)`, and so should not expose any sensitive behavior.
* @property {object} store.knownMethodData Contains all data methods known by the user
* @property {string} store.currentLocale The preferred language locale key
* @property {string} store.selectedAddress A hex string that matches the currently selected address in the app
Expand All @@ -33,6 +35,11 @@ class PreferencesController {
tokens: [],
suggestedTokens: {},
useBlockie: false,

// WARNING: Do not use feature flags for security-sensitive things.
// Feature flag toggling is available in the global namespace
// for convenient testing of pre-release features, and should never
// perform sensitive operations.
featureFlags: {},
knownMethodData: {},
currentLocale: opts.initLangCode,
Expand All @@ -52,6 +59,10 @@ class PreferencesController {
this.store = new ObservableStore(initState)
this.openPopup = opts.openPopup
this._subscribeProviderType()

global.setPreference = (key, value) => {
return this.setFeatureFlag(key, value)
}
}
// PUBLIC METHODS

Expand Down
58 changes: 58 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const EthQuery = require('eth-query')
const ethUtil = require('ethereumjs-util')
const sigUtil = require('eth-sig-util')


module.exports = class MetamaskController extends EventEmitter {

/**
Expand Down Expand Up @@ -410,6 +411,9 @@ module.exports = class MetamaskController extends EventEmitter {
checkHardwareStatus: nodeify(this.checkHardwareStatus, this),
unlockHardwareWalletAccount: nodeify(this.unlockHardwareWalletAccount, this),

// mobile
fetchInfoToSync: nodeify(this.fetchInfoToSync, this),

// vault management
submitPassword: nodeify(this.submitPassword, this),

Expand Down Expand Up @@ -586,6 +590,60 @@ module.exports = class MetamaskController extends EventEmitter {
})
}

/**
* Collects all the information that we want to share
* with the mobile client for syncing purposes
* @returns Promise<Object> Parts of the state that we want to syncx
*/
async fetchInfoToSync () {
// Preferences
const {
accountTokens,
currentLocale,
frequentRpcList,
identities,
selectedAddress,
tokens,
} = this.preferencesController.store.getState()

const preferences = {
accountTokens,
currentLocale,
frequentRpcList,
identities,
selectedAddress,
tokens,
}

// Accounts
const hdKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0]
const hdAccounts = await hdKeyring.getAccounts()
const accounts = {
hd: hdAccounts.filter((item, pos) => (hdAccounts.indexOf(item) === pos)).map(address => ethUtil.toChecksumAddress(address)),
simpleKeyPair: [],
ledger: [],
trezor: [],
}

// transactions

let transactions = this.txController.store.getState().transactions
// delete tx for other accounts that we're not importing
transactions = transactions.filter(tx => {
const checksummedTxFrom = ethUtil.toChecksumAddress(tx.txParams.from)
return (
accounts.hd.includes(checksummedTxFrom)
)
})

return {
accounts,
preferences,
transactions,
network: this.networkController.store.getState(),
}
}

/*
* Submits the user's password and attempts to unlock the vault.
* Also synchronizes the preferencesController, to ensure its schema
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ To learn how to develop MetaMask-compatible applications, visit our [Developer D
- [How to manage notices that appear when the app starts up](./notices.md)
- [How to port MetaMask to a new platform](./porting_to_new_environment.md)
- [How to generate a visualization of this repository's development](./development-visualization.md)
- [How to add a feature behind a secret feature flag](./secret-preferences.md)
10 changes: 10 additions & 0 deletions docs/secret-preferences.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Secret Preferences

Sometimes we want to test a feature in the wild that may not be ready for public consumption.

One example is our "sync with mobile" feature, which didn't make sense to roll out before the mobile version was live.

To enable features like this, first open the background console, and then you can use the global method `global.setPreference(key, value)`.

For example, if the feature flag was a booelan was called `mobileSync`, you might type `setPreference('mobileSync', true)`.

3 changes: 3 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ createTasksForBuildJsMascara({ taskPrefix: 'dev:mascara:js', devMode: true })
function createTasksForBuildJsUIDeps ({ dependenciesToBundle, filename }) {
const destinations = browserPlatforms.map(platform => `./dist/${platform}`)


const bundleTaskOpts = Object.assign({
buildSourceMaps: true,
sourceMapDir: '../sourcemaps',
Expand Down Expand Up @@ -512,6 +513,8 @@ function generateBundler (opts, performBundle) {
bundler.transform(envify({
METAMASK_DEBUG: opts.devMode,
NODE_ENV: opts.devMode ? 'development' : 'production',
PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY || '',
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
}), {
global: true,
})
Expand Down
2 changes: 1 addition & 1 deletion mascara/src/app/buy-ether-widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {connect} from 'react-redux'
import {qrcode} from 'qrcode-npm'
import {qrcode} from 'qrcode-generator'
import copyToClipboard from 'copy-to-clipboard'
import ShapeShiftForm from '../shapeshift-form'
import {buyEth, showAccountDetail} from '../../../../ui/app/actions'
Expand Down
2 changes: 1 addition & 1 deletion mascara/src/app/shapeshift-form/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {qrcode} from 'qrcode-npm'
import qrcode from 'qrcode-generator'
import {connect} from 'react-redux'
import {shapeShiftSubview, pairUpdate, buyWithShapeShift} from '../../../../ui/app/actions'
import {isValidAddress} from '../../../../ui/app/util'
Expand Down
Loading