Upstream Updates
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// In renderer process (web page).
|
||||
const {ipcRenderer} = require("electron");
|
||||
const {
|
||||
ipcRenderer
|
||||
} = require("electron");
|
||||
|
||||
class Blockchain {
|
||||
constructor() {
|
||||
@@ -8,7 +10,7 @@ class Blockchain {
|
||||
}
|
||||
|
||||
getBlock(blockToGet, includeData, clbError, clbSuccess) {
|
||||
web3Local.eth.getBlock(blockToGet, includeData, function (error, block) {
|
||||
web3Local.eth.getBlock(blockToGet, includeData, function(error, block) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -18,7 +20,7 @@ class Blockchain {
|
||||
}
|
||||
|
||||
getAccounts(clbError, clbSuccess) {
|
||||
web3Local.eth.getAccounts(function (err, res) {
|
||||
web3Local.eth.getAccounts(function(err, res) {
|
||||
if (err) {
|
||||
clbError(err);
|
||||
} else {
|
||||
@@ -32,7 +34,7 @@ class Blockchain {
|
||||
}
|
||||
|
||||
getTransaction(thxid, clbError, clbSuccess) {
|
||||
web3Local.eth.getTransaction(thxid, function (error, result) {
|
||||
web3Local.eth.getTransaction(thxid, function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -42,7 +44,7 @@ class Blockchain {
|
||||
}
|
||||
|
||||
getTranasctionFee(fromAddress, toAddress, value, clbError, clbSuccess) {
|
||||
web3Local.eth.getTransactionCount(fromAddress, function (error, result) {
|
||||
web3Local.eth.getTransactionCount(fromAddress, function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -54,12 +56,12 @@ class Blockchain {
|
||||
nonce: result
|
||||
};
|
||||
|
||||
web3Local.eth.estimateGas(RawTransaction, function (error, result) {
|
||||
web3Local.eth.estimateGas(RawTransaction, function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
var usedGas = result + 1;
|
||||
web3Local.eth.getGasPrice(function (error, result) {
|
||||
web3Local.eth.getGasPrice(function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -73,11 +75,11 @@ class Blockchain {
|
||||
}
|
||||
|
||||
prepareTransaction(password, fromAddress, toAddress, value, clbError, clbSuccess) {
|
||||
web3Local.eth.personal.unlockAccount(fromAddress, password, function (error, result) {
|
||||
web3Local.eth.personal.unlockAccount(fromAddress, password, function(error, result) {
|
||||
if (error) {
|
||||
clbError("Wrong password for the selected address!");
|
||||
} else {
|
||||
web3Local.eth.getTransactionCount(fromAddress, "pending", function (error, result) {
|
||||
web3Local.eth.getTransactionCount(fromAddress, "pending", function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -89,17 +91,17 @@ class Blockchain {
|
||||
nonce: result
|
||||
};
|
||||
|
||||
web3Local.eth.estimateGas(RawTransaction, function (error, result) {
|
||||
web3Local.eth.estimateGas(RawTransaction, function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
RawTransaction.gas = result + 1;
|
||||
web3Local.eth.getGasPrice(function (error, result) {
|
||||
web3Local.eth.getGasPrice(function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
RawTransaction.gasPrice = result;
|
||||
web3Local.eth.signTransaction(RawTransaction, fromAddress, function (error, result) {
|
||||
web3Local.eth.signTransaction(RawTransaction, fromAddress, function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -117,7 +119,7 @@ class Blockchain {
|
||||
}
|
||||
|
||||
sendTransaction(rawTransaction, clbError, clbSuccess) {
|
||||
web3Local.eth.sendSignedTransaction(rawTransaction, function (error, result) {
|
||||
web3Local.eth.sendSignedTransaction(rawTransaction, function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -134,7 +136,7 @@ class Blockchain {
|
||||
var wallets = EthoDatatabse.getWallets();
|
||||
var counter = 0;
|
||||
|
||||
web3Local.eth.getAccounts(function (err, res) {
|
||||
web3Local.eth.getAccounts(function(err, res) {
|
||||
if (err) {
|
||||
clbError(err);
|
||||
} else {
|
||||
@@ -160,7 +162,7 @@ class Blockchain {
|
||||
});
|
||||
|
||||
function updateBalance(index) {
|
||||
web3Local.eth.getBalance(rendererData.addressData[index].address, function (error, balance) {
|
||||
web3Local.eth.getBalance(rendererData.addressData[index].address, function(error, balance) {
|
||||
rendererData.addressData[index].balance = parseFloat(web3Local.utils.fromWei(balance, "ether")).toFixed(2);
|
||||
rendererData.sumBalance = rendererData.sumBalance + parseFloat(web3Local.utils.fromWei(balance, "ether"));
|
||||
|
||||
@@ -170,6 +172,7 @@ class Blockchain {
|
||||
} else {
|
||||
rendererData.sumBalance = parseFloat(rendererData.sumBalance).toFixed(2);
|
||||
clbSuccess(rendererData);
|
||||
document.getElementById('colorbal').style.color = "#49e449";
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -182,7 +185,7 @@ class Blockchain {
|
||||
var wallets = EthoDatatabse.getWallets();
|
||||
var counter = 0;
|
||||
|
||||
web3Local.eth.getAccounts(function (err, res) {
|
||||
web3Local.eth.getAccounts(function(err, res) {
|
||||
if (err) {
|
||||
clbError(err);
|
||||
} else {
|
||||
@@ -204,7 +207,7 @@ class Blockchain {
|
||||
}
|
||||
|
||||
createNewAccount(password, clbError, clbSuccess) {
|
||||
web3Local.eth.personal.newAccount(password, function (error, account) {
|
||||
web3Local.eth.personal.newAccount(password, function(error, account) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -214,7 +217,7 @@ class Blockchain {
|
||||
}
|
||||
|
||||
importFromPrivateKey(privateKey, keyPassword, clbError, clbSuccess) {
|
||||
web3Local.eth.personal.importRawKey(privateKey, keyPassword, function (error, account) {
|
||||
web3Local.eth.personal.importRawKey(privateKey, keyPassword, function(error, account) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -224,13 +227,13 @@ class Blockchain {
|
||||
}
|
||||
|
||||
subsribePendingTransactions(clbError, clbSuccess, clbData) {
|
||||
this.txSubscribe = web3Local.eth.subscribe("pendingTransactions", function (error, result) {
|
||||
this.txSubscribe = web3Local.eth.subscribe("pendingTransactions", function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
clbSuccess(result);
|
||||
}
|
||||
}).on("data", function (transaction) {
|
||||
}).on("data", function(transaction) {
|
||||
if (clbData) {
|
||||
clbData(transaction);
|
||||
}
|
||||
@@ -239,7 +242,7 @@ class Blockchain {
|
||||
|
||||
unsubsribePendingTransactions(clbError, clbSuccess) {
|
||||
if (this.txSubscribe) {
|
||||
this.txSubscribe.unsubscribe(function (error, success) {
|
||||
this.txSubscribe.unsubscribe(function(error, success) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
@@ -250,13 +253,13 @@ class Blockchain {
|
||||
}
|
||||
|
||||
subsribeNewBlockHeaders(clbError, clbSuccess, clbData) {
|
||||
this.bhSubscribe = web3Local.eth.subscribe("newBlockHeaders", function (error, result) {
|
||||
this.bhSubscribe = web3Local.eth.subscribe("newBlockHeaders", function(error, result) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
clbSuccess(result);
|
||||
}
|
||||
}).on("data", function (blockHeader) {
|
||||
}).on("data", function(blockHeader) {
|
||||
if (clbData) {
|
||||
clbData(blockHeader);
|
||||
}
|
||||
@@ -265,7 +268,7 @@ class Blockchain {
|
||||
|
||||
unsubsribeNewBlockHeaders(clbError, clbSuccess) {
|
||||
if (this.bhSubscribe) {
|
||||
this.bhSubscribe.unsubscribe(function (error, success) {
|
||||
this.bhSubscribe.unsubscribe(function(error, success) {
|
||||
if (error) {
|
||||
clbError(error);
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// In renderer process (web page).
|
||||
const {ipcRenderer} = require("electron");
|
||||
const {
|
||||
ipcRenderer
|
||||
} = require("electron");
|
||||
var web3;
|
||||
|
||||
// Set the provider you want from Web3.providers
|
||||
SyncProgress = new ProgressBar.Line("#syncProgress", {
|
||||
strokeWidth: 6,
|
||||
@@ -34,8 +37,8 @@ SyncProgress = new ProgressBar.Line("#syncProgress", {
|
||||
SyncProgress.setText("Waiting for blockchain, please wait...");
|
||||
isFullySynced = false;
|
||||
|
||||
var peerCountInterval = setInterval(function () {
|
||||
web3Local.eth.net.getPeerCount(function (error, count) {
|
||||
var peerCountInterval = setInterval(function() {
|
||||
web3Local.eth.net.getPeerCount(function(error, count) {
|
||||
$("#peerCount").html(vsprintf("Peer Count: %d", [count]));
|
||||
});
|
||||
}, 5000);
|
||||
@@ -44,20 +47,26 @@ function StartSyncProcess() {
|
||||
var alreadyCatchedUp = false;
|
||||
var nodeSyncInterval = null;
|
||||
|
||||
var subscription = web3Local.eth.subscribe("syncing", function (error, sync) {
|
||||
var subscription = web3Local.eth.subscribe("syncing", function(error, sync) {
|
||||
if (!error) {
|
||||
if (!sync) {
|
||||
if (nodeSyncInterval) {
|
||||
clearInterval(nodeSyncInterval);
|
||||
}
|
||||
|
||||
nodeSyncInterval = setInterval(function () {
|
||||
web3Local.eth.getBlock("latest", function (error, localBlock) {
|
||||
nodeSyncInterval = setInterval(function() {
|
||||
web3Local.eth.getBlock("latest", function(error, localBlock) {
|
||||
if (!error) {
|
||||
if (localBlock.number > 0) {
|
||||
if (!EthoTransactions.getIsSyncing()) {
|
||||
SyncProgress.animate(1);
|
||||
SyncProgress.setText(vsprintf("%d/%d (100%%)", [localBlock.number, localBlock.number]));
|
||||
(function($, _M) {
|
||||
M.toast({
|
||||
html: 'Your Node is still syncing please do not attempt to use the wallet.',
|
||||
displayLength: 10000
|
||||
});
|
||||
}(jQuery, M));
|
||||
}
|
||||
|
||||
if (alreadyCatchedUp == false) {
|
||||
@@ -73,6 +82,12 @@ function StartSyncProcess() {
|
||||
|
||||
// signal that the sync is complete
|
||||
$(document).trigger("onSyncComplete");
|
||||
(function($, _M) {
|
||||
M.toast({
|
||||
html: 'Your Node is fully synced and operational.',
|
||||
displayLength: 40000
|
||||
});
|
||||
}(jQuery, M));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -84,7 +99,7 @@ function StartSyncProcess() {
|
||||
} else {
|
||||
EthoMainGUI.showGeneralError(error);
|
||||
}
|
||||
}).on("data", function (sync) {
|
||||
}).on("data", function(sync) {
|
||||
if (sync && sync.HighestBlock > 0) {
|
||||
SyncProgress.animate(sync.CurrentBlock / sync.HighestBlock);
|
||||
SyncProgress.setText(vsprintf("%d/%d (%d%%)", [
|
||||
@@ -93,10 +108,11 @@ function StartSyncProcess() {
|
||||
Math.floor(sync.CurrentBlock / sync.HighestBlock * 100)
|
||||
]));
|
||||
}
|
||||
}).on("changed", function (isSyncing) {
|
||||
}).on("changed", function(isSyncing) {
|
||||
if (isSyncing) {
|
||||
nodeSyncInterval = setInterval(function () {
|
||||
web3Local.eth.isSyncing(function (error, sync) {
|
||||
|
||||
nodeSyncInterval = setInterval(function() {
|
||||
web3Local.eth.isSyncing(function(error, sync) {
|
||||
if (!error && sync) {
|
||||
SyncProgress.animate(sync.currentBlock / sync.highestBlock);
|
||||
SyncProgress.setText(vsprintf("%d/%d (%d%%)", [
|
||||
@@ -117,11 +133,11 @@ function StartSyncProcess() {
|
||||
});
|
||||
}
|
||||
|
||||
var InitWeb3 = setInterval(function () {
|
||||
var InitWeb3 = setInterval(function() {
|
||||
try {
|
||||
web3Local = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546"));
|
||||
|
||||
web3Local.eth.net.isListening(function (error, success) {
|
||||
|
||||
web3Local.eth.net.isListening(function(error, success) {
|
||||
if (!error) {
|
||||
$(document).trigger("onGethReady");
|
||||
clearInterval(InitWeb3);
|
||||
|
||||
Reference in New Issue
Block a user