mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Dont generate a popup notification when submiting a transaction from with in MetaMask
This commit is contained in:
parent
56bdccc76d
commit
eea77b828f
@ -10,31 +10,22 @@ const MetamaskController = require('./metamask-controller')
|
|||||||
const extension = require('./lib/extension')
|
const extension = require('./lib/extension')
|
||||||
|
|
||||||
const STORAGE_KEY = 'metamask-config'
|
const STORAGE_KEY = 'metamask-config'
|
||||||
|
var popupIsOpen = false
|
||||||
|
|
||||||
const controller = new MetamaskController({
|
const controller = new MetamaskController({
|
||||||
// User confirmation callbacks:
|
// User confirmation callbacks:
|
||||||
showUnconfirmedMessage,
|
showUnconfirmedMessage: triggerUi,
|
||||||
unlockAccountMessage,
|
unlockAccountMessage: triggerUi,
|
||||||
showUnconfirmedTx,
|
showUnconfirmedTx: triggerUi,
|
||||||
// Persistence Methods:
|
// Persistence Methods:
|
||||||
setData,
|
setData,
|
||||||
loadData,
|
loadData,
|
||||||
})
|
})
|
||||||
const idStore = controller.idStore
|
const idStore = controller.idStore
|
||||||
|
|
||||||
function unlockAccountMessage () {
|
function triggerUi () {
|
||||||
notification.show()
|
if (!popupIsOpen) notification.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
function showUnconfirmedMessage (msgParams, msgId) {
|
|
||||||
notification.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
function showUnconfirmedTx (txParams, txData, onTxDoneCb) {
|
|
||||||
notification.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
// On first install, open a window to MetaMask website to how-it-works.
|
// On first install, open a window to MetaMask website to how-it-works.
|
||||||
|
|
||||||
extension.runtime.onInstalled.addListener(function (details) {
|
extension.runtime.onInstalled.addListener(function (details) {
|
||||||
@ -53,7 +44,8 @@ function connectRemote (remotePort) {
|
|||||||
var portStream = new PortStream(remotePort)
|
var portStream = new PortStream(remotePort)
|
||||||
if (isMetaMaskInternalProcess) {
|
if (isMetaMaskInternalProcess) {
|
||||||
// communication with popup
|
// communication with popup
|
||||||
setupTrustedCommunication(portStream, 'MetaMask')
|
remotePort.name === 'popup' ? popupIsOpen = true : popupIsOpen = false
|
||||||
|
setupTrustedCommunication(portStream, 'MetaMask', remotePort.name)
|
||||||
} else {
|
} else {
|
||||||
// communication with page
|
// communication with page
|
||||||
var originDomain = urlUtil.parse(remotePort.sender.url).hostname
|
var originDomain = urlUtil.parse(remotePort.sender.url).hostname
|
||||||
@ -69,12 +61,13 @@ function setupUntrustedCommunication (connectionStream, originDomain) {
|
|||||||
controller.setupPublicConfig(mx.createStream('publicConfig'))
|
controller.setupPublicConfig(mx.createStream('publicConfig'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupTrustedCommunication (connectionStream, originDomain) {
|
function setupTrustedCommunication (connectionStream, originDomain, metamaskContext) {
|
||||||
// setup multiplexing
|
// setup multiplexing
|
||||||
var mx = setupMultiplex(connectionStream)
|
var mx = setupMultiplex(connectionStream)
|
||||||
// connect features
|
// connect features
|
||||||
setupControllerConnection(mx.createStream('controller'))
|
setupControllerConnection(mx.createStream('controller'))
|
||||||
controller.setupProviderConnection(mx.createStream('provider'), originDomain)
|
controller.setupProviderConnection(mx.createStream('provider'), originDomain)
|
||||||
|
if (metamaskContext === 'popup') popupIsOpen = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -95,6 +88,7 @@ function setupControllerConnection (stream) {
|
|||||||
// teardown on disconnect
|
// teardown on disconnect
|
||||||
eos(stream, () => {
|
eos(stream, () => {
|
||||||
controller.ethStore.removeListener('update', controller.sendUpdate.bind(controller))
|
controller.ethStore.removeListener('update', controller.sendUpdate.bind(controller))
|
||||||
|
popupIsOpen = false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user