mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
config - add config starting with rpc endpoint
This commit is contained in:
parent
099bb6e63d
commit
4c6b2fb03f
@ -32,9 +32,10 @@ function handleExternalCommunication(remotePort){
|
||||
// state and network
|
||||
//
|
||||
|
||||
var config = getConfig()
|
||||
var idStore = new IdentityStore()
|
||||
var zeroClient = MetaMaskProvider({
|
||||
rpcUrl: 'https://rawtestrpc.metamask.io/',
|
||||
rpcUrl: config.rpcTarget,
|
||||
getAccounts: function(cb){
|
||||
var selectedAddress = idStore.getSelectedAddress()
|
||||
var result = selectedAddress ? [selectedAddress] : []
|
||||
@ -53,7 +54,11 @@ var ethStore = new EthStore(zeroClient)
|
||||
idStore.setStore(ethStore)
|
||||
|
||||
function getState(){
|
||||
var state = extend(ethStore.getState(), idStore.getState())
|
||||
var state = extend(
|
||||
ethStore.getState(),
|
||||
idStore.getState(),
|
||||
getConfig()
|
||||
)
|
||||
return state
|
||||
}
|
||||
|
||||
@ -80,6 +85,7 @@ function handleInternalCommunication(remotePort){
|
||||
var duplex = new PortStream(remotePort)
|
||||
var connection = Dnode({
|
||||
getState: function(cb){ cb(null, getState()) },
|
||||
setRpcTarget: setRpcTarget,
|
||||
// forward directly to idStore
|
||||
createNewVault: idStore.createNewVault.bind(idStore),
|
||||
submitPassword: idStore.submitPassword.bind(idStore),
|
||||
@ -122,3 +128,24 @@ function updateBadge(state){
|
||||
chrome.browserAction.setBadgeBackgroundColor({ color: '#506F8B' })
|
||||
}
|
||||
|
||||
//
|
||||
// config
|
||||
//
|
||||
|
||||
// called from popup
|
||||
function setRpcTarget(rpcTarget){
|
||||
var config = getConfig()
|
||||
config.rpcTarget = rpcTarget
|
||||
setConfig(config)
|
||||
chrome.runtime.reload()
|
||||
}
|
||||
|
||||
function getConfig(){
|
||||
return extend({
|
||||
rpcTarget: 'https://rawtestrpc.metamask.io/',
|
||||
}, JSON.parse(localStorage['config'] || '{}'))
|
||||
}
|
||||
|
||||
function setConfig(state){
|
||||
localStorage['config'] = JSON.stringify(state)
|
||||
}
|
Loading…
Reference in New Issue
Block a user