First implementation of color based on wallet value & Clean up

This commit is contained in:
FallenGravity
2019-10-19 22:32:09 +02:00
parent 4823427fa1
commit a9dbef7fe1
2 changed files with 49 additions and 46 deletions

View File

@@ -27,7 +27,7 @@
<th scope="col" class="no-sort"></th>
<th scope="col">Name</th>
<th scope="col">Address</th>
<th scope="col"class="no-sort"></th>
<th scope="col" class="no-sort"></th>
<th scope="col" data-sort-method='number'>Balance</th>
</tr>
</thead>
@@ -48,7 +48,7 @@
<i class="fas fa-qrcode"></i>
</button>
</td>
<td>{{balance}}</td>
<td id="colorbal" style="color: red;">{{balance}}</td>
</tr>
{{/addressData}}
</tbody>
@@ -76,18 +76,18 @@
<!-- The modal to change wallet name -->
<div id="dlgChangeWalletName" class="modalDialog" data-izimodal-title="Wallet Name" data-izimodal-subtitle="Enter the name for this address" data-izimodal-icon="icon-home">
<div class="modalBody">
<div class="modalBody">
<div class="form-group">
<label for="inputWalletName">Type Name:</label>
<input type="text" class="form-control" id="inputWalletName">
</div>
<button type="button" class="btn btn-etho btn-dialog-confirm" id="btnChangeWalletNameConfirm">Confirm</button>
</div>
</div>
</div>
<!-- The modal to import from private key -->
<div id="dlgImportFromPrivateKey" class="modalDialog" data-izimodal-title="Import private key" data-izimodal-subtitle="Import account from private key" data-izimodal-icon="icon-home">
<div class="modalBody">
<div class="modalBody">
<div class="form-group">
<label for="inputPrivateKey">Private Key:</label>
<input type="password" class="form-control" id="inputPrivateKey">
@@ -101,7 +101,7 @@
<input type="password" class="form-control" id="keyPasswordSecond">
</div>
<button type="button" class="btn btn-etho btn-dialog-confirm" id="btnImportFromPrivateKeyConfirm">Import</button>
</div>
</div>
</div>
<span id="nodestorage" style="display:none;">Loading</span>

View File

@@ -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 {