diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2017-02-16 07:56:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-16 07:56:25 +0800 |
commit | 3bd23564fbdc5dc81c23f5246956c4de07fb1601 (patch) | |
tree | d3db707f1c2e8236c78e143b48e1a2fd9f0323f9 /app/scripts | |
parent | f2539d125c2cfe240511f8505e222a9893bf7748 (diff) | |
parent | 352bb5cb3941c3a07b383c2400dae337771c6d3a (diff) | |
download | tangerine-wallet-browser-3bd23564fbdc5dc81c23f5246956c4de07fb1601.tar tangerine-wallet-browser-3bd23564fbdc5dc81c23f5246956c4de07fb1601.tar.gz tangerine-wallet-browser-3bd23564fbdc5dc81c23f5246956c4de07fb1601.tar.bz2 tangerine-wallet-browser-3bd23564fbdc5dc81c23f5246956c4de07fb1601.tar.lz tangerine-wallet-browser-3bd23564fbdc5dc81c23f5246956c4de07fb1601.tar.xz tangerine-wallet-browser-3bd23564fbdc5dc81c23f5246956c4de07fb1601.tar.zst tangerine-wallet-browser-3bd23564fbdc5dc81c23f5246956c4de07fb1601.zip |
Merge pull request #1121 from MetaMask/dev
Merge dev into master
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/config.js | 1 | ||||
-rw-r--r-- | app/scripts/lib/config-manager.js | 22 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 2 | ||||
-rw-r--r-- | app/scripts/lib/inpage-provider.js | 5 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 51 | ||||
-rw-r--r-- | app/scripts/migrations/002.js | 6 | ||||
-rw-r--r-- | app/scripts/migrations/003.js | 5 | ||||
-rw-r--r-- | app/scripts/migrations/004.js | 17 | ||||
-rw-r--r-- | app/scripts/migrations/005.js | 7 | ||||
-rw-r--r-- | app/scripts/migrations/006.js | 6 | ||||
-rw-r--r-- | app/scripts/migrations/007.js | 6 | ||||
-rw-r--r-- | app/scripts/migrations/008.js | 6 | ||||
-rw-r--r-- | app/scripts/migrations/009.js | 9 | ||||
-rw-r--r-- | app/scripts/migrations/010.js | 4 | ||||
-rw-r--r-- | app/scripts/migrations/011.js | 33 | ||||
-rw-r--r-- | app/scripts/migrations/index.js | 1 | ||||
-rw-r--r-- | app/scripts/notice-controller.js | 6 |
17 files changed, 89 insertions, 98 deletions
diff --git a/app/scripts/config.js b/app/scripts/config.js index e09206c5f..b4541a04a 100644 --- a/app/scripts/config.js +++ b/app/scripts/config.js @@ -3,7 +3,6 @@ const TESTNET_RPC_URL = 'https://ropsten.infura.io/metamask' const DEFAULT_RPC_URL = TESTNET_RPC_URL global.METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' -global.TOS_HASH = 'GULP_TOS_HASH' module.exports = { network: { diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 7ae2d4400..6267eab68 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -228,28 +228,6 @@ ConfigManager.prototype._emitUpdates = function (state) { }) } -ConfigManager.prototype.setConfirmedDisclaimer = function (confirmed) { - var data = this.getData() - data.isDisclaimerConfirmed = confirmed - this.setData(data) -} - -ConfigManager.prototype.getConfirmedDisclaimer = function () { - var data = this.getData() - return data.isDisclaimerConfirmed -} - -ConfigManager.prototype.setTOSHash = function (hash) { - var data = this.getData() - data.TOSHash = hash - this.setData(data) -} - -ConfigManager.prototype.getTOSHash = function () { - var data = this.getData() - return data.TOSHash -} - ConfigManager.prototype.getGasMultiplier = function () { var data = this.getData() return data.gasMultiplier diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 1afe5f651..7a6968c6c 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -94,7 +94,6 @@ IdentityStore.prototype.getState = function () { isInitialized: !!configManager.getWallet() && !seedWords, isUnlocked: this._isUnlocked(), seedWords: seedWords, - isDisclaimerConfirmed: configManager.getConfirmedDisclaimer(), selectedAddress: configManager.getSelectedAccount(), gasMultiplier: configManager.getGasMultiplier(), })) @@ -343,4 +342,3 @@ IdentityStore.prototype._autoFaucet = function () { } // util - diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index faecac137..92936de2f 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -84,6 +84,11 @@ MetamaskInpageProvider.prototype.send = function (payload) { result = true break + case 'net_version': + let networkVersion = self.publicConfigStore.getState().networkVersion + result = networkVersion + break + // throw not-supported Error default: var link = 'https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client' diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index fb2040c63..29b13dc62 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -107,8 +107,6 @@ module.exports = class MetamaskController extends EventEmitter { this.messageManager = new MessageManager() this.publicConfigStore = this.initPublicConfigStore() - this.checkTOSChange() - // TEMPORARY UNTIL FULL DEPRECATION: this.idStoreMigrator = new IdStoreMigrator({ configManager: this.configManager, @@ -178,7 +176,7 @@ module.exports = class MetamaskController extends EventEmitter { // sync publicConfigStore with transform pipe( this.store, - storeTransform(selectPublicState), + storeTransform(selectPublicState.bind(this)), publicConfigStore ) @@ -186,6 +184,7 @@ module.exports = class MetamaskController extends EventEmitter { const result = { selectedAddress: undefined } try { result.selectedAddress = state.PreferencesController.selectedAddress + result.networkVersion = this.getNetworkState() } catch (_) {} return result } @@ -219,7 +218,6 @@ module.exports = class MetamaskController extends EventEmitter { this.shapeshiftController.store.getState(), { lostAccounts: this.configManager.getLostAccounts(), - isDisclaimerConfirmed: this.configManager.getConfirmedDisclaimer(), seedWords: this.configManager.getSeedWords(), } ) @@ -242,11 +240,7 @@ module.exports = class MetamaskController extends EventEmitter { setRpcTarget: this.setRpcTarget.bind(this), setProviderType: this.setProviderType.bind(this), useEtherscanProvider: this.useEtherscanProvider.bind(this), - agreeToDisclaimer: this.agreeToDisclaimer.bind(this), - resetDisclaimer: this.resetDisclaimer.bind(this), setCurrentCurrency: this.setCurrentCurrency.bind(this), - setTOSHash: this.setTOSHash.bind(this), - checkTOSChange: this.checkTOSChange.bind(this), setGasMultiplier: this.setGasMultiplier.bind(this), markAccountsFound: this.markAccountsFound.bind(this), // coinbase @@ -519,47 +513,6 @@ module.exports = class MetamaskController extends EventEmitter { } // - // disclaimer - // - - agreeToDisclaimer (cb) { - try { - this.configManager.setConfirmedDisclaimer(true) - cb() - } catch (err) { - cb(err) - } - } - - resetDisclaimer () { - try { - this.configManager.setConfirmedDisclaimer(false) - } catch (e) { - console.error(e) - } - } - - setTOSHash (hash) { - try { - this.configManager.setTOSHash(hash) - } catch (err) { - console.error('Error in setting terms of service hash.') - } - } - - checkTOSChange () { - try { - const storedHash = this.configManager.getTOSHash() || 0 - if (storedHash !== global.TOS_HASH) { - this.resetDisclaimer() - this.setTOSHash(global.TOS_HASH) - } - } catch (err) { - console.error('Error in checking TOS change.') - } - } - - // // config // diff --git a/app/scripts/migrations/002.js b/app/scripts/migrations/002.js index 476b0a43a..36a870342 100644 --- a/app/scripts/migrations/002.js +++ b/app/scripts/migrations/002.js @@ -1,9 +1,13 @@ const version = 2 +const clone = require('clone') + + module.exports = { version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { if (versionedData.data.config.provider.type === 'etherscan') { diff --git a/app/scripts/migrations/003.js b/app/scripts/migrations/003.js index eceaeaa4b..1893576ad 100644 --- a/app/scripts/migrations/003.js +++ b/app/scripts/migrations/003.js @@ -2,10 +2,13 @@ const version = 3 const oldTestRpc = 'https://rawtestrpc.metamask.io/' const newTestRpc = 'https://testrpc.metamask.io/' +const clone = require('clone') + module.exports = { version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { if (versionedData.data.config.provider.rpcTarget === oldTestRpc) { diff --git a/app/scripts/migrations/004.js b/app/scripts/migrations/004.js index 0f9850208..405d932f8 100644 --- a/app/scripts/migrations/004.js +++ b/app/scripts/migrations/004.js @@ -1,25 +1,28 @@ const version = 4 +const clone = require('clone') + module.exports = { - version, + version, migrate: function (versionedData) { - versionedData.meta.version = version + let safeVersionedData = clone(versionedData) + safeVersionedData.meta.version = version try { - if (versionedData.data.config.provider.type !== 'rpc') return Promise.resolve(versionedData) - switch (versionedData.data.config.provider.rpcTarget) { + if (safeVersionedData.data.config.provider.type !== 'rpc') return Promise.resolve(safeVersionedData) + switch (safeVersionedData.data.config.provider.rpcTarget) { case 'https://testrpc.metamask.io/': - versionedData.data.config.provider = { + safeVersionedData.data.config.provider = { type: 'testnet', } break case 'https://rpc.metamask.io/': - versionedData.data.config.provider = { + safeVersionedData.data.config.provider = { type: 'mainnet', } break } } catch (_) {} - return Promise.resolve(versionedData) + return Promise.resolve(safeVersionedData) }, } diff --git a/app/scripts/migrations/005.js b/app/scripts/migrations/005.js index 65f62a861..e4b84f460 100644 --- a/app/scripts/migrations/005.js +++ b/app/scripts/migrations/005.js @@ -7,11 +7,14 @@ This migration moves state from the flat state trie into KeyringController subst */ const extend = require('xtend') +const clone = require('clone') + module.exports = { - version, + version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { const state = versionedData.data diff --git a/app/scripts/migrations/006.js b/app/scripts/migrations/006.js index 950c4deb8..94d1b6ecd 100644 --- a/app/scripts/migrations/006.js +++ b/app/scripts/migrations/006.js @@ -7,11 +7,13 @@ This migration moves KeyringController.selectedAddress to PreferencesController. */ const extend = require('xtend') +const clone = require('clone') module.exports = { - version, + version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { const state = versionedData.data diff --git a/app/scripts/migrations/007.js b/app/scripts/migrations/007.js index 3ae8cdc2d..236e35224 100644 --- a/app/scripts/migrations/007.js +++ b/app/scripts/migrations/007.js @@ -7,11 +7,13 @@ This migration breaks out the TransactionManager substate */ const extend = require('xtend') +const clone = require('clone') module.exports = { - version, + version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { const state = versionedData.data diff --git a/app/scripts/migrations/008.js b/app/scripts/migrations/008.js index 7f6e72ee6..cd5e95d22 100644 --- a/app/scripts/migrations/008.js +++ b/app/scripts/migrations/008.js @@ -7,11 +7,13 @@ This migration breaks out the NoticeController substate */ const extend = require('xtend') +const clone = require('clone') module.exports = { - version, + version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { const state = versionedData.data diff --git a/app/scripts/migrations/009.js b/app/scripts/migrations/009.js index 38e6dcc09..4612fefdc 100644 --- a/app/scripts/migrations/009.js +++ b/app/scripts/migrations/009.js @@ -7,11 +7,13 @@ This migration breaks out the CurrencyController substate */ const merge = require('deep-extend') +const clone = require('clone') module.exports = { - version, + version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { const state = versionedData.data @@ -27,12 +29,13 @@ module.exports = { function transformState (state) { const newState = merge({}, state, { CurrencyController: { - currentCurrency: state.currentFiat || 'USD', + currentCurrency: state.currentFiat || state.fiatCurrency || 'USD', conversionRate: state.conversionRate, conversionDate: state.conversionDate, }, }) delete newState.currentFiat + delete newState.fiatCurrency delete newState.conversionRate delete newState.conversionDate diff --git a/app/scripts/migrations/010.js b/app/scripts/migrations/010.js index d41c63fcd..48a841bc1 100644 --- a/app/scripts/migrations/010.js +++ b/app/scripts/migrations/010.js @@ -7,11 +7,13 @@ This migration breaks out the CurrencyController substate */ const merge = require('deep-extend') +const clone = require('clone') module.exports = { version, - migrate: function (versionedData) { + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) versionedData.meta.version = version try { const state = versionedData.data diff --git a/app/scripts/migrations/011.js b/app/scripts/migrations/011.js new file mode 100644 index 000000000..bf283ef98 --- /dev/null +++ b/app/scripts/migrations/011.js @@ -0,0 +1,33 @@ +const version = 11 + +/* + +This migration breaks out the CurrencyController substate + +*/ + +const clone = require('clone') + +module.exports = { + version, + + migrate: function (originalVersionedData) { + let versionedData = clone(originalVersionedData) + versionedData.meta.version = version + try { + const state = versionedData.data + const newState = transformState(state) + versionedData.data = newState + } catch (err) { + console.warn(`MetaMask Migration #${version}` + err.stack) + } + return Promise.resolve(versionedData) + }, +} + +function transformState (state) { + const newState = state + delete newState.TOSHash + delete newState.isDisclaimerConfirmed + return newState +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index 2db8646b0..a3dd48c17 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -21,4 +21,5 @@ module.exports = [ require('./008'), require('./009'), require('./010'), + require('./011'), ] diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index ba7c68df4..0d72760fe 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -35,12 +35,12 @@ module.exports = class NoticeController extends EventEmitter { return Promise.resolve(true) } - markNoticeRead (notice, cb) { + markNoticeRead (noticeToMark, cb) { cb = cb || function (err) { if (err) throw err } try { var notices = this.getNoticesList() - var id = notice.id - notices[id].read = true + var index = notices.findIndex((currentNotice) => currentNotice.id === noticeToMark.id) + notices[index].read = true this.setNoticesList(notices) const latestNotice = this.getLatestUnreadNotice() cb(null, latestNotice) |