From b33c51c0a6c7c8a7b0c0a9a6ca101f874f2db3d1 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 12 Jan 2017 01:17:05 -0800 Subject: migrations - introduce promise-based migrator --- app/scripts/migrations/002.js | 15 +++++++++------ app/scripts/migrations/003.js | 16 +++++++++------- app/scripts/migrations/004.js | 17 ++++++++++------- 3 files changed, 28 insertions(+), 20 deletions(-) (limited to 'app/scripts/migrations') diff --git a/app/scripts/migrations/002.js b/app/scripts/migrations/002.js index 0b654f825..97f427d3a 100644 --- a/app/scripts/migrations/002.js +++ b/app/scripts/migrations/002.js @@ -1,13 +1,16 @@ +const version = 2 + module.exports = { - version: 2, + version, - migrate: function (data) { + migrate: function (meta) { + meta.version = version try { - if (data.config.provider.type === 'etherscan') { - data.config.provider.type = 'rpc' - data.config.provider.rpcTarget = 'https://rpc.metamask.io/' + if (meta.data.config.provider.type === 'etherscan') { + meta.data.config.provider.type = 'rpc' + meta.data.config.provider.rpcTarget = 'https://rpc.metamask.io/' } } catch (e) {} - return data + return Promise.resolve(meta) }, } diff --git a/app/scripts/migrations/003.js b/app/scripts/migrations/003.js index 617c55c09..b25e26e01 100644 --- a/app/scripts/migrations/003.js +++ b/app/scripts/migrations/003.js @@ -1,15 +1,17 @@ -var oldTestRpc = 'https://rawtestrpc.metamask.io/' -var newTestRpc = 'https://testrpc.metamask.io/' +const version = 3 +const oldTestRpc = 'https://rawtestrpc.metamask.io/' +const newTestRpc = 'https://testrpc.metamask.io/' module.exports = { - version: 3, + version, - migrate: function (data) { + migrate: function (meta) { + meta.version = version try { - if (data.config.provider.rpcTarget === oldTestRpc) { - data.config.provider.rpcTarget = newTestRpc + if (meta.data.config.provider.rpcTarget === oldTestRpc) { + meta.data.config.provider.rpcTarget = newTestRpc } } catch (e) {} - return data + return Promise.resolve(meta) }, } diff --git a/app/scripts/migrations/004.js b/app/scripts/migrations/004.js index 1329a1eed..e72eef2b7 100644 --- a/app/scripts/migrations/004.js +++ b/app/scripts/migrations/004.js @@ -1,22 +1,25 @@ +const version = 4 + module.exports = { - version: 4, + version, - migrate: function (data) { + migrate: function (meta) { + meta.version = version try { - if (data.config.provider.type !== 'rpc') return data - switch (data.config.provider.rpcTarget) { + if (meta.data.config.provider.type !== 'rpc') return Promise.resolve(meta) + switch (meta.data.config.provider.rpcTarget) { case 'https://testrpc.metamask.io/': - data.config.provider = { + meta.data.config.provider = { type: 'testnet', } break case 'https://rpc.metamask.io/': - data.config.provider = { + meta.data.config.provider = { type: 'mainnet', } break } } catch (_) {} - return data + return Promise.resolve(meta) }, } -- cgit v1.2.3