diff --git a/app/scripts/background.js b/app/scripts/background.js index dfcdcc06c..a4f80d7f6 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -48,7 +48,6 @@ var providerOpts = { }, approveTransaction: addUnconfirmedTx, signTransaction: idStore.signTransaction.bind(idStore), - etherscan: providerConfig.type === 'etherscan', } var provider = MetaMaskProvider(providerOpts) diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index c46d0b213..065f69629 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -11,7 +11,7 @@ const createPayload = require('web3-provider-engine/util/create-payload') const StreamProvider = require('./lib/stream-provider.js') const LocalMessageDuplexStream = require('./lib/local-message-stream.js') -const RPC_URL = 'https://rawtestrpc.metamask.io/' +const RPC_URL = 'https://testrpc.metamask.io/' // @@ -57,7 +57,7 @@ var syncProvider = new Web3.providers.HttpProvider(RPC_URL) remoteProvider.send = function(payload){ var result = null switch (payload.method) { - + case 'eth_accounts': // read from localStorage accountsCache = JSON.parse(localStorage['MetaMask-Accounts'] || '[]') diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 121ede838..c557891fe 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -2,7 +2,9 @@ const Migrator = require('pojo-migrator') const extend = require('xtend') const STORAGE_KEY = 'metamask-config' -var DEFAULT_RPC = 'https://rawtestrpc.metamask.io/' +const DEFAULT_RPC = 'https://testrpc.metamask.io/' + +const migrations = require('./migrations') /* The config-manager is a convenience object * wrapping a pojo-migrator. @@ -28,7 +30,7 @@ function ConfigManager() { // // The `migrate` function receives the previous // config data format, and returns the new one. - migrations: [], + migrations: migrations, // How to load initial config. // Includes step on migrating pre-pojo-migrator data. @@ -134,7 +136,9 @@ function loadData() { } catch (e) {} var data = extend({ - version: 0, + meta: { + version: 0, + }, data: { config: { rpcTarget: DEFAULT_RPC, diff --git a/app/scripts/lib/migrations.js b/app/scripts/lib/migrations.js new file mode 100644 index 000000000..cab5bec66 --- /dev/null +++ b/app/scripts/lib/migrations.js @@ -0,0 +1,8 @@ +var path = require('path') +var fs = require('fs') + +var migration2 = require('../migrations/002') + +module.exports = [ + migration2, +] diff --git a/app/scripts/migrations/002.js b/app/scripts/migrations/002.js new file mode 100644 index 000000000..ab6a256ab --- /dev/null +++ b/app/scripts/migrations/002.js @@ -0,0 +1,13 @@ +module.exports = { + version: 2, + + migrate: function(data) { + try { + if (data.config.provider.type === 'etherscan') { + data.config.provider.type = 'rpc' + data.config.provider.rpcTarget = 'https://rpc.metamask.io/' + } + } catch (e) {} + return data + } +} diff --git a/test/lib/migrations/001.json b/test/lib/migrations/001.json new file mode 100644 index 000000000..2fe6dd836 --- /dev/null +++ b/test/lib/migrations/001.json @@ -0,0 +1 @@ +{"version":0,"data":{"wallet":"{\"encSeed\":{\"encStr\":\"rT1C1jjkFRfmrwefscFcwZohl4f+HfIFlBZ9AM4ZD8atJmfKDIQCVK11NYDKYv8ZMIY03f3t8MuoZvfzBL8IJsWnZUhpzVTNNiARQJD2WpGA19eNBzgZm4vd0GwkIUruUDeJXu0iv2j9wU8hOQUqPbOePPy2Am5ro97iuvMAroRTnEKD60qFVg==\",\"nonce\":\"YUY2mwNq2v3FV0Fi94QnSiKFOLYfDR95\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"Iyi7ft4JQ9UtwrSXRT6ZIHPtZqJhe99rh0uWhNc6QLan6GanY2ZQeU0tt76CBealEWJyrJReSxGQdqDmSDYjpjH3m4JO5l0DfPLPseCqzXV/W+dzM0ubJ8lztLwpwi0L+vULNMqCx4dQtoNbNBq1QZUnjtpm6O8mWpScspboww==\",\"nonce\":\"Z7RqtjNjC6FrLUj5wVW1+HkjOW6Hib6K\"},\"hdIndex\":3,\"encPrivKeys\":{\"edb81c10122f34040cc4bef719a272fbbb1cf897\":{\"key\":\"8ab81tKBd4+CLAbzvS7SBFRTd6VWXBs86uBE43lgcmBu2U7UB22xdH64Q2hUf9eB\",\"nonce\":\"aGUEqI033FY39zKjWmZSI6PQrCLvkiRP\"},\"8bd7d5c000cf05284e98356370dc5ccaa3dbfc38\":{\"key\":\"+i3wmf4b+B898QtlOBfL0Ixirjg59/LLPX61vQ2L0xRPjXzNog0O4Wn15RemM5mY\",\"nonce\":\"imKrlkuoC5uuFkzJBbuDBluGCPJXNTKm\"},\"2340695474656e3124b8eba1172fbfb00eeac8f8\":{\"key\":\"pi+H9D8LYKsdCQKrfaJtsGFjE+X9s74xN675tsoIKrbPXhtpxMLOIQVtSqYveF62\",\"nonce\":\"49g80wDTovHwbguVVYf2FsYbp7Db5OAR\"}},\"addresses\":[\"edb81c10122f34040cc4bef719a272fbbb1cf897\",\"8bd7d5c000cf05284e98356370dc5ccaa3dbfc38\",\"2340695474656e3124b8eba1172fbfb00eeac8f8\"]}},\"version\":2}","config":{"provider":{"type":"etherscan"}}},"meta":{"version":0}} \ No newline at end of file diff --git a/test/unit/migrations-test.js b/test/unit/migrations-test.js new file mode 100644 index 000000000..3a3213ac5 --- /dev/null +++ b/test/unit/migrations-test.js @@ -0,0 +1,14 @@ +var test = require('tape') +var path = require('path') + +var wallet1 = require(path.join('..', 'lib', 'migrations', '001.json')) +var migration2 = require(path.join('..', '..', 'app', 'scripts', 'migrations', '002')) + +test('wallet1 is migrated successfully', function(t) { + + var result = migration2.migrate(wallet1.data) + t.equal(result.config.provider.type, 'rpc', 'provider should be rpc') + t.equal(result.config.provider.rpcTarget, 'https://rpc.metamask.io/', 'provider should be our rpc') + +}) +