Skip to content

Commit

Permalink
EthGetAccountsMethod implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Furter committed Apr 2, 2019
1 parent 824befc commit c62d864
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions packages/web3-eth/src/methods/EthGetAccountsMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
This file is part of web3.js.
web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file GetAccountsMethod.js
* @author Samuel Furter <samuel@ethereum.org>
* @date 2018
*/

import {GetAccountsMethod} from 'web3-core-method';

export default class EthGetAccountsMethod extends GetAccountsMethod {
/**
* @param {Utils} utils
* @param {Object} formatters
* @param {AbstractWeb3Module} moduleInstance
*
* @constructor
*/
constructor(utils, formatters, moduleInstance) {
super(utils, formatters, moduleInstance);
}

/**
* Sends a JSON-RPC call request
*
* @method execute
*
* @callback callback callback(error, result)
* @returns {Promise<Object|String>}
*/
execute() {
if (this.moduleInstance.accounts.wallet.accountsIndex > 0) {
let accounts = [];
for (let i = 0; i <= this.accountsIndex; i++) {
accounts.push(this.moduleInstance.accounts.wallet[i]);
}

return Promise.resolve(accounts);
}

return super.execute();
}
}

0 comments on commit c62d864

Please sign in to comment.