First implementation of color based on wallet value & Clean up
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 {
|
||||
|
||||
Reference in New Issue
Block a user