|
|
@ -2,7 +2,8 @@ const Migrator = require('pojo-migrator') |
|
|
|
const extend = require('xtend') |
|
|
|
const extend = require('xtend') |
|
|
|
|
|
|
|
|
|
|
|
const STORAGE_KEY = 'metamask-config' |
|
|
|
const STORAGE_KEY = 'metamask-config' |
|
|
|
const DEFAULT_RPC = 'https://testrpc.metamask.io/' |
|
|
|
const TESTNET_RPC = 'http://morden.infura.io' |
|
|
|
|
|
|
|
const MAINNET_RPC = 'http://mainnet.infura.io/' |
|
|
|
|
|
|
|
|
|
|
|
const migrations = require('./migrations') |
|
|
|
const migrations = require('./migrations') |
|
|
|
|
|
|
|
|
|
|
@ -59,8 +60,7 @@ ConfigManager.prototype.getConfig = function() { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return { |
|
|
|
return { |
|
|
|
provider: { |
|
|
|
provider: { |
|
|
|
type: 'rpc', |
|
|
|
type: 'testnet', |
|
|
|
rpcTarget: DEFAULT_RPC, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -75,6 +75,14 @@ ConfigManager.prototype.setRpcTarget = function(rpcUrl) { |
|
|
|
this.setConfig(config) |
|
|
|
this.setConfig(config) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConfigManager.prototype.setProviderType = function(type) { |
|
|
|
|
|
|
|
var config = this.getConfig() |
|
|
|
|
|
|
|
config.provider = { |
|
|
|
|
|
|
|
type: type, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.setConfig(config) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ConfigManager.prototype.useEtherscanProvider = function() { |
|
|
|
ConfigManager.prototype.useEtherscanProvider = function() { |
|
|
|
var config = this.getConfig() |
|
|
|
var config = this.getConfig() |
|
|
|
config.provider = { |
|
|
|
config.provider = { |
|
|
@ -130,9 +138,19 @@ ConfigManager.prototype.getShouldShowSeedWords = function() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ConfigManager.prototype.getCurrentRpcAddress = function() { |
|
|
|
ConfigManager.prototype.getCurrentRpcAddress = function() { |
|
|
|
var config = this.getConfig() |
|
|
|
var provider = this.getProvider() |
|
|
|
if (!config) return null |
|
|
|
if (!provider) return null |
|
|
|
return config.provider && config.provider.rpcTarget ? config.provider.rpcTarget : DEFAULT_RPC |
|
|
|
switch (provider.type) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'mainnet': |
|
|
|
|
|
|
|
return MAINNET_RPC |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'testnet': |
|
|
|
|
|
|
|
return TESTNET_RPC |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return provider && provider.rpcTarget ? provider.rpcTarget : TESTNET_RPC |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ConfigManager.prototype.clearWallet = function() { |
|
|
|
ConfigManager.prototype.clearWallet = function() { |
|
|
@ -246,7 +264,9 @@ function loadData() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
config: { |
|
|
|
config: { |
|
|
|
rpcTarget: DEFAULT_RPC, |
|
|
|
provider: { |
|
|
|
|
|
|
|
type: 'testnet', |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, oldData ? oldData : null, newData ? newData : null) |
|
|
|
}, oldData ? oldData : null, newData ? newData : null) |
|
|
|