-
Notifications
You must be signed in to change notification settings - Fork 72
/
index.js
45 lines (37 loc) · 1023 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
if (typeof window.web3 !== 'undefined') {
window.web3 = new Web3(window.web3.currentProvider);
} else {
// Other provider
window.web3 = new Web3(new Web3.providers.HttpProvider('yourOtherProvider'));
}
function isElectron() {
if(chrome.ipcRenderer) return true;
return false;
}
function sendToElectron(message) {
chrome.ipcRenderer.send(message);
}
function openMetamaskPopup() {
sendToElectron('open-metamask-popup');
}
function closeMetamaskPopup() {
sendToElectron('close-metamask-popup');
}
function openMetamaskNotification() {
sendToElectron('open-metamask-notification');
}
function closeMetamaskNotification() {
sendToElectron('close-metamask-notification');
}
function sendEther(contractFunction) {
web3.eth.sendTransaction({
to: '0x8f6c0c887F7CAF7D512C964eA2a3e668D94C5304',
value: '1000000000000'
}, (err, res) => {
if (err) closeMetamaskNotification();
if (res) closeMetamaskNotification();
});
setTimeout(() => {
openMetamaskNotification();
}, 500);
}