Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
DRY things up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Sep 15, 2020
1 parent 47058ca commit c390f0d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/subproviders/geth_api_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,11 @@ GethApiDouble.prototype.evm_mine.minLength = 1;
*/
GethApiDouble.prototype.evm_unlockUnknownAccount = function(address, callback) {
// check if given address is already unlocked
if (this.state.unlocked_accounts[address.toLowerCase()] !== true) {
if (this.state.personal_accounts[address.toLowerCase()] !== true) {
address = address.toLowerCase();
if (this.state.unlocked_accounts[address] !== true) {
if (this.state.personal_accounts[address] !== true) {
// unlock the account
this.state.unlocked_accounts[address.toLowerCase()] = true;
this.state.unlocked_accounts[address] = true;
return callback(null, true);

} else {
Expand All @@ -609,13 +610,14 @@ GethApiDouble.prototype.evm_unlockUnknownAccount = function(address, callback) {
*/
GethApiDouble.prototype.evm_lockUnknownAccount = function(address, callback) {
// Checks if given address is already unlocked
if (this.state.unlocked_accounts[address.toLowerCase()]) {
if (this.state.personal_accounts[address.toLowerCase()]) {
address = address.toLowerCase();
if (this.state.unlocked_accounts[address]) {
if (this.state.personal_accounts[address]) {
// if the account is known to the `personal` namespace we may not lock it
return callback(new Error("cannot lock known/personal account"))
} else {
// unlock the account
delete this.state.unlocked_accounts[address.toLowerCase()];
delete this.state.unlocked_accounts[address];
return callback(null, true);
}
}
Expand Down

0 comments on commit c390f0d

Please sign in to comment.