aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-02-04 06:00:30 +0800
committerkumavis <aaron@kumavis.me>2017-02-04 06:00:30 +0800
commit77f8995568d64aa2d9acd878b43fdeb1e7c3bafb (patch)
tree60ef07752e49d27dcf5b9e6b8613d392fed95b05 /app
parent99d6a329a2e8358b85ff8a82c7f17e2ebf71a399 (diff)
downloadtangerine-wallet-browser-77f8995568d64aa2d9acd878b43fdeb1e7c3bafb.tar
tangerine-wallet-browser-77f8995568d64aa2d9acd878b43fdeb1e7c3bafb.tar.gz
tangerine-wallet-browser-77f8995568d64aa2d9acd878b43fdeb1e7c3bafb.tar.bz2
tangerine-wallet-browser-77f8995568d64aa2d9acd878b43fdeb1e7c3bafb.tar.lz
tangerine-wallet-browser-77f8995568d64aa2d9acd878b43fdeb1e7c3bafb.tar.xz
tangerine-wallet-browser-77f8995568d64aa2d9acd878b43fdeb1e7c3bafb.tar.zst
tangerine-wallet-browser-77f8995568d64aa2d9acd878b43fdeb1e7c3bafb.zip
migrations - fix migration #9 and add safety checks to migrator
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/migrator/index.js13
-rw-r--r--app/scripts/migrations/009.js4
2 files changed, 14 insertions, 3 deletions
diff --git a/app/scripts/lib/migrator/index.js b/app/scripts/lib/migrator/index.js
index ab5a757b3..312345263 100644
--- a/app/scripts/lib/migrator/index.js
+++ b/app/scripts/lib/migrator/index.js
@@ -15,7 +15,7 @@ class Migrator {
let remaining = this.migrations.filter(migrationIsPending)
return (
- asyncQ.eachSeries(remaining, (migration) => migration.migrate(versionedData))
+ asyncQ.eachSeries(remaining, (migration) => this.runMigration(versionedData, migration))
.then(() => versionedData)
)
@@ -26,6 +26,17 @@ class Migrator {
}
}
+ runMigration(versionedData, migration) {
+ return (
+ migration.migrate(versionedData)
+ .then((versionedData) => {
+ if (!versionedData.data) return Promise.reject(new Error('Migrator - Migration returned empty data'))
+ if (migration.version !== undefined && versionedData.meta.version !== migration.version) return Promise.reject(new Error('Migrator - Migration did not update version number correctly'))
+ return Promise.resolve(versionedData)
+ })
+ )
+ }
+
generateInitialState (initState) {
return {
meta: {
diff --git a/app/scripts/migrations/009.js b/app/scripts/migrations/009.js
index 61b8b7fa2..38e6dcc09 100644
--- a/app/scripts/migrations/009.js
+++ b/app/scripts/migrations/009.js
@@ -6,7 +6,7 @@ This migration breaks out the CurrencyController substate
*/
-const merge = require('deep-merge')
+const merge = require('deep-extend')
module.exports = {
version,
@@ -25,7 +25,7 @@ module.exports = {
}
function transformState (state) {
- const newState = merge(state, {
+ const newState = merge({}, state, {
CurrencyController: {
currentCurrency: state.currentFiat || 'USD',
conversionRate: state.conversionRate,