mirror of https://github.com/status-im/web3.js.git
moved personal to eth.personal
This commit is contained in:
parent
605a8754d6
commit
fbca18e394
|
@ -7,7 +7,6 @@ The web3.js library is a collection of modules which contain specific functional
|
|||
- The ``web3-eth`` is for the ethereum blockchain and smart contracts
|
||||
- The ``web3-shh`` is for the whisper protocol to communicate p2p and broadcast
|
||||
- The ``web3-bzz`` is for the swarm protocol, the decentralized file storage
|
||||
- The ``web3-personal`` is for ethereum account management
|
||||
|
||||
The following page will describe how to install and add web3.js to your project.
|
||||
You can find some extra examples in the :ref:`API-reference <api-reference>` and the `examples here <https://github.com/ethereum/web3.js/tree/master/examples>`_.
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
|
||||
net.id
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.net.getId([callback])
|
||||
web3.bzz.net.getId([callback])
|
||||
web3.shh.net.getId([callback])
|
||||
|
||||
Gets the current network ID.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
none
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise`` returns ``Number``: The network ID.
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.getId()
|
||||
.then(console.log);
|
||||
> 1
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
net.isListening
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.net.isListening([callback])
|
||||
web3.bzz.net.isListening([callback])
|
||||
web3.shh.net.isListening([callback])
|
||||
|
||||
Checks if the node is listening for peers.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
none
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise`` returns ``Boolean``
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.isListening()
|
||||
.then(console.log);
|
||||
> true
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
net.getPeerCount
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.net.getPeerCount([callback])
|
||||
web3.bzz.net.getPeerCount([callback])
|
||||
web3.shh.net.getPeerCount([callback])
|
||||
|
||||
Get the number of peers connected to.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
none
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise`` returns ``Number``
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.getPeerCount()
|
||||
.then(console.log);
|
||||
> 25
|
|
@ -31,11 +31,9 @@ Contents:
|
|||
web3-eth-subscribe
|
||||
web3-eth-contract
|
||||
web3-eth-iban
|
||||
web3-eth-net
|
||||
web3-shh
|
||||
web3-bzz
|
||||
web3-net
|
||||
web3-personal
|
||||
web3-admin
|
||||
|
||||
.. contract-object.rst
|
||||
|
||||
|
|
|
@ -28,7 +28,13 @@ For more see the `Swarm Docs <http://swarm-guide.readthedocs.io/en/latest/>`_.
|
|||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: package-core.rst
|
||||
.. include:: include_package-core.rst
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: include_package-net.rst
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
|
|
@ -10,36 +10,9 @@ Contains functions to receive information about the current network.
|
|||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
id
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
.. include:: include_package-net.rst
|
||||
|
||||
web3.eth.net.getId([callback])
|
||||
|
||||
Gets the current network ID.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
none
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise`` returns ``Number``: The network ID.
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.getId()
|
||||
.then(console.log);
|
||||
> 1
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
@ -76,68 +49,3 @@ Example
|
|||
> "main"
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
isListening
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.net.isListening([callback])
|
||||
|
||||
Checks if the node is listening for peers.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
none
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise`` returns ``Boolean``
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.isListening()
|
||||
.then(console.log);
|
||||
> true
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
getPeerCount
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.net.getPeerCount([callback])
|
||||
|
||||
Get the number of peers connected to.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
none
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise`` returns ``Number``
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.getPeerCount()
|
||||
.then(console.log);
|
||||
> 25
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
.. _eth-personal:
|
||||
|
||||
========
|
||||
web3.eth.personal
|
||||
========
|
||||
|
||||
|
||||
The ``web3-eth-personal`` package allows you to interact with the Ethereum node's accounts.
|
||||
|
||||
.. note:: Many of these functions send sensitive information, like password. Never call these functions over a unsecured Websocket or HTTP provider, as your password will be send in plain text!
|
||||
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var Personal = require('web3-eth-personal');
|
||||
|
||||
// "Personal.providers.givenProvider" will be set if in an Ethereum supported browser.
|
||||
var personal = new Personal(Personal.givenProvider || new Personal.providers.WebsocketProvider('ws://some.local-or-remote.node:8546'));
|
||||
|
||||
|
||||
// or using the web3 umbrella package
|
||||
|
||||
var Web3 = require('web3');
|
||||
var web3 = new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider('ws://some.local-or-remote.node:8546'));
|
||||
|
||||
// -> web3.eth.personal
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: include_package-core.rst
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
newAccount
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.personal.newAccount(password, [callback])
|
||||
|
||||
Creates a new account.
|
||||
|
||||
.. note:: Never call this function over a unsecured Websocket or HTTP provider, as your password will be send in plain text!
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
1. ``password`` - ``String``: The password to encrypt this account with.
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise`` returns ``Boolean``: ``true`` if the account was created, otherwise ``false``.
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
web3.eth.personal.newAccount('!@superpassword')
|
||||
.then(console.log);
|
||||
> true
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
// TODO
|
|
@ -73,6 +73,15 @@ For ``web3.eth.Iban`` see the :ref:`Iban reference documentation <eth-iban>`
|
|||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
personal
|
||||
=====================
|
||||
|
||||
For ``web3.eth.personal`` see the :ref:`personal reference documentation <eth-personal>`
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
net
|
||||
=====================
|
||||
|
||||
|
@ -82,7 +91,7 @@ For ``web3.eth.net`` see the :ref:`net reference documentation <eth-net>`
|
|||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: package-core.rst
|
||||
.. include:: include_package-core.rst
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
.. _shh:
|
||||
|
||||
========
|
||||
web3.*.net
|
||||
========
|
||||
|
||||
|
||||
The ``web3-net`` package allows you to interact with the Ethereum nodes network properties.
|
||||
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var Net = require('web3-net');
|
||||
|
||||
// "Personal.providers.givenProvider" will be set if in an Ethereum supported browser.
|
||||
var net = new Net(Net.givenProvider || new Net.providers.WebsocketProvider('ws://some.local-or-remote.node:8546'));
|
||||
|
||||
|
||||
// or using the web3 umbrella package
|
||||
|
||||
var Web3 = require('web3');
|
||||
var web3 = new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider('ws://some.local-or-remote.node:8546'));
|
||||
|
||||
// -> web3.eth.net
|
||||
// -> web3.bzz.net
|
||||
// -> web3.shh.net
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: include_package-core.rst
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: include_package-net.rst
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
|
@ -30,10 +30,16 @@ For more see `Whisper Overview <https://github.com/ethereum/wiki/wiki/Whisper-O
|
|||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: package-core.rst
|
||||
.. include:: include_package-core.rst
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: include_package-net.rst
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
post
|
||||
|
|
|
@ -12,7 +12,6 @@ The web3.js object is a umbrella package to house all ethereum related modules.
|
|||
var web3 = new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider('ws://some.local-or-remote.node:8546'));
|
||||
|
||||
> web3.eth
|
||||
> web3.personal
|
||||
> web3.shh
|
||||
> web3.bzz
|
||||
> web3.utils
|
||||
|
|
24
gulpfile.js
24
gulpfile.js
|
@ -49,17 +49,9 @@ var packages = [{
|
|||
expose: 'Eth',
|
||||
src: './packages/web3-eth/src/index.js'
|
||||
},{
|
||||
fileName: 'web3-personal',
|
||||
fileName: 'web3-eth-personal',
|
||||
expose: 'Personal',
|
||||
src: './packages/web3-personal/src/index.js'
|
||||
},{
|
||||
fileName: 'web3-shh',
|
||||
expose: 'Shh',
|
||||
src: './packages/web3-shh/src/index.js'
|
||||
},{
|
||||
fileName: 'web3-bzz',
|
||||
expose: 'Bzz',
|
||||
src: './packages/web3-bzz/src/index.js'
|
||||
src: './packages/web3-eth-personal/src/index.js'
|
||||
},{
|
||||
fileName: 'web3-eth-iban',
|
||||
expose: 'EthIban',
|
||||
|
@ -68,6 +60,18 @@ var packages = [{
|
|||
fileName: 'web3-eth-abi',
|
||||
expose: 'EthAbi',
|
||||
src: './packages/web3-eth-abi/src/index.js'
|
||||
},{
|
||||
fileName: 'web3-net',
|
||||
expose: 'Net',
|
||||
src: './packages/web3-net/src/index.js'
|
||||
},{
|
||||
fileName: 'web3-shh',
|
||||
expose: 'Shh',
|
||||
src: './packages/web3-shh/src/index.js'
|
||||
},{
|
||||
fileName: 'web3-bzz',
|
||||
expose: 'Bzz',
|
||||
src: './packages/web3-bzz/src/index.js'
|
||||
}];
|
||||
|
||||
var browserifyOptions = {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
"web3-core": "^1.0.0",
|
||||
"web3-core-method": "^1.0.0"
|
||||
"web3-core-method": "^1.0.0",
|
||||
"web3-net": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
var core = require('web3-core');
|
||||
var Method = require('web3-core-method');
|
||||
var Net = require('web3-net');
|
||||
|
||||
|
||||
var Bzz = function Bzz() {
|
||||
|
@ -37,6 +38,8 @@ var Bzz = function Bzz() {
|
|||
method.attachToObject(_this);
|
||||
method.setRequestManager(_this._requestManager);
|
||||
});
|
||||
|
||||
this.net = new Net(this.currentProvider);
|
||||
};
|
||||
|
||||
core.addProviders(Bzz);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"name": "web3-eth-net",
|
||||
"version": "1.0.0",
|
||||
"description": "Web3 module to interact with the Ethereum nodes networking properties.",
|
||||
"repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-eth-net",
|
||||
"license": "LGPL-3.0",
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
"web3-core": "^1.0.0",
|
||||
"web3-core-method": "^1.0.0",
|
||||
"web3-utils": "^1.0.0"
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
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 index.js
|
||||
* @author Fabian Vogelsteller <fabian@ethereum.org>
|
||||
* @date 2017
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var core = require('web3-core');
|
||||
var Method = require('web3-core-method');
|
||||
var utils = require('web3-utils');
|
||||
|
||||
|
||||
var Net = function () {
|
||||
var _this = this;
|
||||
|
||||
// sets _requestmanager
|
||||
core.packageInit(this, arguments);
|
||||
|
||||
|
||||
methods().forEach(function(method) {
|
||||
method.attachToObject(_this);
|
||||
method.setRequestManager(_this._requestManager);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
core.addProviders(Net);
|
||||
|
||||
|
||||
var methods = function () {
|
||||
|
||||
var getId = new Method({
|
||||
name: 'getId',
|
||||
call: 'net_version',
|
||||
params: 0,
|
||||
outputFormatter: utils.toNumber
|
||||
});
|
||||
|
||||
var isListening = new Method({
|
||||
name: 'isListening',
|
||||
call: 'net_listening',
|
||||
params: 0
|
||||
});
|
||||
|
||||
var getPeerCount = new Method({
|
||||
name: 'getPeerCount',
|
||||
call: 'net_peerCount',
|
||||
params: 0,
|
||||
outputFormatter: utils.toNumber
|
||||
});
|
||||
|
||||
|
||||
return [
|
||||
getId,
|
||||
isListening,
|
||||
getPeerCount
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
module.exports = Net;
|
||||
|
||||
|
|
@ -10,10 +10,11 @@
|
|||
"web3-core-helpers": "^1.0.0",
|
||||
"web3-core-subscriptions": "^1.0.0",
|
||||
"web3-core-method": "^1.0.0",
|
||||
"web3-eth-net": "^1.0.0",
|
||||
"web3-eth-iban": "^1.0.0",
|
||||
"web3-eth-abi": "^1.0.0",
|
||||
"web3-eth-contract": "^1.0.0",
|
||||
"web3-eth-personal": "^1.0.0",
|
||||
"web3-net": "^1.0.0",
|
||||
"web3-utils": "^1.0.0",
|
||||
"underscore": "^1.8.3"
|
||||
}
|
||||
|
|
|
@ -26,9 +26,11 @@ var _ = require('underscore');
|
|||
var core = require('web3-core');
|
||||
var helpers = require('web3-core-helpers');
|
||||
var Subscriptions = require('web3-core-subscriptions').subscriptions;
|
||||
var utils = require('web3-utils');
|
||||
var Method = require('web3-core-method');
|
||||
var Net = require('web3-eth-net');
|
||||
var utils = require('web3-utils');
|
||||
var Net = require('web3-net');
|
||||
|
||||
var Personal = require('web3-eth-personal');
|
||||
var abi = require('web3-eth-abi');
|
||||
var Contract = require('web3-eth-contract');
|
||||
var Iban = require('web3-eth-iban');
|
||||
|
@ -73,8 +75,12 @@ var Eth = function Eth() {
|
|||
method.setRequestManager(_this._requestManager, _this); // second param means is Eth (necessary for promiEvent)
|
||||
});
|
||||
|
||||
// add net
|
||||
this.net = new Net(this.currentProvider);
|
||||
|
||||
// add personal
|
||||
this.personal = new Personal(this.currentProvider);
|
||||
|
||||
// add contract
|
||||
this.Contract = Contract;
|
||||
this.Contract.prototype._eth = this;
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"name": "web3-personal",
|
||||
"version": "1.0.0",
|
||||
"description": "Web3 module to interact with the Ethereum blockchain accounts stored in the node.",
|
||||
"repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-personal",
|
||||
"license": "LGPL-3.0",
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
"web3-core": "^1.0.0",
|
||||
"web3-core-helpers": "^1.0.0",
|
||||
"web3-core-method": "^1.0.0",
|
||||
"web3-utils": "^1.0.0"
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
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 index.js
|
||||
* @author Fabian Vogelsteller <fabian@ethereum.org>
|
||||
* @date 2017
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var core = require('web3-core');
|
||||
var Method = require('web3-core-method');
|
||||
var utils = require('web3-utils');
|
||||
|
||||
var formatters = require('web3-core-helpers').formatters;
|
||||
|
||||
|
||||
var Personal = function Personal() {
|
||||
var _this = this;
|
||||
|
||||
// sets _requestmanager
|
||||
core.packageInit(this, arguments);
|
||||
|
||||
|
||||
methods().forEach(function(method) {
|
||||
method.attachToObject(_this);
|
||||
method.setRequestManager(_this._requestManager);
|
||||
});
|
||||
};
|
||||
|
||||
core.addProviders(Personal);
|
||||
|
||||
|
||||
var methods = function () {
|
||||
|
||||
var getAccounts = new Method({
|
||||
name: 'getAccounts',
|
||||
call: 'personal_listAccounts',
|
||||
params: 0,
|
||||
outputFormatter: utils.toChecksumAddress
|
||||
});
|
||||
|
||||
var newAccount = new Method({
|
||||
name: 'newAccount',
|
||||
call: 'personal_newAccount',
|
||||
params: 1,
|
||||
inputFormatter: [null],
|
||||
outputFormatter: utils.toChecksumAddress
|
||||
});
|
||||
|
||||
var unlockAccount = new Method({
|
||||
name: 'unlockAccount',
|
||||
call: 'personal_unlockAccount',
|
||||
params: 3,
|
||||
inputFormatter: [formatters.inputAddressFormatter, null, null]
|
||||
});
|
||||
|
||||
var sendTransaction = new Method({
|
||||
name: 'sendTransaction',
|
||||
call: 'personal_sendTransaction',
|
||||
params: 2,
|
||||
inputFormatter: [formatters.inputTransactionFormatter, null]
|
||||
});
|
||||
|
||||
var lockAccount = new Method({
|
||||
name: 'lockAccount',
|
||||
call: 'personal_lockAccount',
|
||||
params: 1,
|
||||
inputFormatter: [formatters.inputAddressFormatter]
|
||||
});
|
||||
|
||||
|
||||
return [
|
||||
getAccounts,
|
||||
newAccount,
|
||||
unlockAccount,
|
||||
sendTransaction,
|
||||
lockAccount
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
module.exports = Personal;
|
||||
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
"web3-core": "^1.0.0",
|
||||
"web3-core-helpers": "^1.0.0",
|
||||
"web3-core-method": "^1.0.0",
|
||||
"web3-core-subscriptions": "^1.0.0"
|
||||
"web3-core-subscriptions": "^1.0.0",
|
||||
"web3-net": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
var core = require('web3-core');
|
||||
var Subscriptions = require('web3-core-subscriptions').subscriptions;
|
||||
var Method = require('web3-core-method');
|
||||
|
||||
var formatters = require('web3-core-helpers').formatters;
|
||||
var Net = require('web3-net');
|
||||
|
||||
|
||||
var Shh = function Shh() {
|
||||
|
@ -41,6 +41,8 @@ var Shh = function Shh() {
|
|||
method.attachToObject(_this);
|
||||
method.setRequestManager(_this._requestManager);
|
||||
});
|
||||
|
||||
this.net = new Net(this.currentProvider);
|
||||
};
|
||||
|
||||
core.addProviders(Shh);
|
||||
|
|
13
src/index.js
13
src/index.js
|
@ -32,8 +32,8 @@ var version = require('../lerna.json');
|
|||
var core = require('../packages/web3-core');
|
||||
|
||||
var Eth = require('../packages/web3-eth');
|
||||
var Net = require('../packages/web3-eth-net');
|
||||
var Personal = require('../packages/web3-personal');
|
||||
var Net = require('../packages/web3-net');
|
||||
var Personal = require('../packages/web3-eth-personal');
|
||||
var Shh = require('../packages/web3-shh');
|
||||
var Bzz = require('../packages/web3-bzz');
|
||||
|
||||
|
@ -59,7 +59,6 @@ var Web3 = function Web3() {
|
|||
|
||||
|
||||
this.eth = new Eth(this);
|
||||
this.personal = new Personal(this); // move to -> web3.eth.accounts
|
||||
this.shh = new Shh(this);
|
||||
this.bzz = new Bzz(this);
|
||||
|
||||
|
@ -67,10 +66,16 @@ var Web3 = function Web3() {
|
|||
|
||||
this.setProvider = function (provider) {
|
||||
this._requestManager.setProvider(provider);
|
||||
|
||||
this.eth.setProvider(provider);
|
||||
this.eth.net.setProvider(provider);
|
||||
this.eth.personal.setProvider(provider);
|
||||
|
||||
this.shh.setProvider(provider);
|
||||
this.shh.net.setProvider(provider);
|
||||
|
||||
this.bzz.setProvider(provider);
|
||||
this.personal.setProvider(provider);
|
||||
this.bzz.net.setProvider(provider);
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -41,6 +41,16 @@ describe('eth', function() {
|
|||
u.propertyExists(eth, 'givenProvider');
|
||||
u.propertyExists(eth, 'defaultBlock');
|
||||
u.propertyExists(eth, 'defaultAccount');
|
||||
|
||||
u.propertyExists(eth, 'net');
|
||||
u.methodExists(eth.net, 'getId');
|
||||
u.methodExists(eth.net, 'isListening');
|
||||
u.methodExists(eth.net, 'getPeerCount');
|
||||
|
||||
u.propertyExists(eth, 'personal');
|
||||
u.methodExists(eth.personal, 'sendTransaction');
|
||||
u.methodExists(eth.personal, 'newAccount');
|
||||
u.methodExists(eth.personal, 'unlockAccount');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -9,4 +9,4 @@ var tests = [{
|
|||
call: 'personal_listAccounts'
|
||||
}];
|
||||
|
||||
testMethod.runTests('personal', method, tests);
|
||||
testMethod.runTests(['eth','personal'], method, tests);
|
||||
|
|
|
@ -17,4 +17,4 @@ var tests = [{
|
|||
call: 'personal_'+ method
|
||||
}];
|
||||
|
||||
testMethod.runTests('personal', method, tests);
|
||||
testMethod.runTests(['eth','personal'], method, tests);
|
||||
|
|
|
@ -11,5 +11,5 @@ var tests = [{
|
|||
call: 'personal_newAccount'
|
||||
}];
|
||||
|
||||
testMethod.runTests('personal', method, tests);
|
||||
testMethod.runTests(['eth','personal'], method, tests);
|
||||
|
||||
|
|
|
@ -57,5 +57,5 @@ var tests = [{
|
|||
call: 'personal_'+ method
|
||||
}];
|
||||
|
||||
testMethod.runTests('personal', method, tests);
|
||||
testMethod.runTests(['eth','personal'], method, tests);
|
||||
|
||||
|
|
|
@ -17,4 +17,4 @@ var tests = [{
|
|||
call: 'personal_'+ method
|
||||
}];
|
||||
|
||||
testMethod.runTests('personal', method, tests);
|
||||
testMethod.runTests(['eth','personal'], method, tests);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var chai = require('chai');
|
||||
var assert = chai.assert;
|
||||
var u = require('./helpers/test.utils.js');
|
||||
var Personal = require('../packages/web3-personal');
|
||||
var Personal = require('../packages/web3-eth-personal');
|
||||
var personal = new Personal();
|
||||
|
||||
describe('web3.net', function() {
|
||||
|
@ -11,5 +11,10 @@ describe('web3.net', function() {
|
|||
u.methodExists(personal, 'unlockAccount');
|
||||
u.methodExists(personal, 'lockAccount');
|
||||
u.methodExists(personal, 'sendTransaction');
|
||||
|
||||
u.propertyExists(personal, 'net');
|
||||
u.methodExists(personal.net, 'getId');
|
||||
u.methodExists(personal.net, 'isListening');
|
||||
u.methodExists(personal.net, 'getPeerCount');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,10 @@ describe('shh', function() {
|
|||
u.methodExists(shh, 'newGroup');
|
||||
u.methodExists(shh, 'addToGroup');
|
||||
u.methodExists(shh, 'subscribe');
|
||||
u.propertyExists(shh, 'net');
|
||||
u.methodExists(shh.net, 'getId');
|
||||
u.methodExists(shh.net, 'isListening');
|
||||
u.methodExists(shh.net, 'getPeerCount');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ describe('web3', function() {
|
|||
u.propertyExists(web3, 'eth');
|
||||
u.propertyExists(web3, 'bzz');
|
||||
u.propertyExists(web3, 'shh');
|
||||
u.propertyExists(web3, 'personal');
|
||||
|
||||
u.propertyExists(web3, 'utils');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue