A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
var ConfigManager = require('../../app/scripts/lib/config-manager')
|
|
|
|
const STORAGE_KEY = 'metamask-config'
|
|
|
|
const extend = require('xtend')
|
|
|
|
|
|
|
|
module.exports = function() {
|
|
|
|
return new ConfigManager({ loadData, setData })
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadData () {
|
|
|
|
var oldData = getOldStyleData()
|
|
|
|
var newData
|
|
|
|
|
|
|
|
try {
|
|
|
|
newData = JSON.parse(window.localStorage[STORAGE_KEY])
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
var data = extend({
|
|
|
|
meta: {
|
|
|
|
version: 0,
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
config: {
|
|
|
|
provider: {
|
|
|
|
type: 'testnet',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}, oldData || null, newData || null)
|
|
|
|
return data
|
|
|
|
}
|
|
|
|
|
|
|
|
function getOldStyleData () {
|
|
|
|
var config, wallet, seedWords
|
|
|
|
|
|
|
|
var result = {
|
|
|
|
meta: { version: 0 },
|
|
|
|
data: {},
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
config = JSON.parse(window.localStorage['config'])
|
|
|
|
result.data.config = config
|
|
|
|
} catch (e) {}
|
|
|
|
try {
|
|
|
|
wallet = JSON.parse(window.localStorage['lightwallet'])
|
|
|
|
result.data.wallet = wallet
|
|
|
|
} catch (e) {}
|
|
|
|
try {
|
|
|
|
seedWords = window.localStorage['seedWords']
|
|
|
|
result.data.seedWords = seedWords
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
function setData (data) {
|
|
|
|
window.localStorage[STORAGE_KEY] = JSON.stringify(data)
|
|
|
|
}
|