From 84874a639d217da36926869fa3cb235c05725cf5 Mon Sep 17 00:00:00 2001 From: bitpshr Date: Wed, 17 Oct 2018 18:38:31 -0400 Subject: Add isUnlocked provider hook --- app/scripts/contentscript.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/scripts/contentscript.js') diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 29fa3f5c7..bb79e1d4a 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -131,10 +131,15 @@ function listenForProviderRequest () { origin: source.location.hostname, }) break + case 'METAMASK_UNLOCK_STATUS': + extension.runtime.sendMessage({ + action: 'init-unlock-request', + }) + break } }) - extension.runtime.onMessage.addListener(({ action, isEnabled }) => { + extension.runtime.onMessage.addListener(({ action, isEnabled, isUnlocked }) => { if (!action) { return } switch (action) { case 'approve-provider-request': @@ -147,6 +152,9 @@ function listenForProviderRequest () { case 'answer-status-request': injectScript(`window.dispatchEvent(new CustomEvent('ethereumproviderstatus', { detail: { isEnabled: ${isEnabled}}}))`) break + case 'answer-unlock-request': + injectScript(`window.dispatchEvent(new CustomEvent('metamaskunlockstatus', { detail: { isUnlocked: ${isUnlocked}}}))`) + break } }) } -- cgit