87 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-02-05 23:37:30 +01:00
/*
2015-10-08 15:34:07 +08:00
This file is part of web3.js.
2015-02-05 23:37:30 +01:00
2015-10-08 15:34:07 +08:00
web3.js is free software: you can redistribute it and/or modify
2015-02-05 23:37:30 +01:00
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.
2015-10-08 15:34:07 +08:00
web3.js is distributed in the hope that it will be useful,
2015-02-05 23:37:30 +01:00
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
2015-10-08 15:34:07 +08:00
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
2015-02-05 23:37:30 +01:00
*/
/** @file shh.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
2015-08-06 18:25:41 +02:00
var Method = require('../method');
var formatters = require('../formatters');
2015-10-08 08:41:55 +02:00
var Filter = require('../filter');
var watches = require('./watches');
2015-02-27 12:41:07 +01:00
2015-10-07 04:32:32 +02:00
var Shh = function (web3) {
this._requestManager = web3._requestManager;
2015-10-08 04:09:51 +02:00
var self = this;
methods().forEach(function(method) {
method.attachToObject(self);
method.setRequestManager(self._requestManager);
2015-10-08 04:09:51 +02:00
});
2015-10-07 04:32:32 +02:00
};
2015-10-08 08:41:55 +02:00
Shh.prototype.filter = function (fil, callback) {
return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
2015-10-08 08:41:55 +02:00
};
2015-10-08 04:09:51 +02:00
var methods = function () {
var post = new Method({
name: 'post',
call: 'shh_post',
params: 1,
inputFormatter: [formatters.inputPostFormatter]
});
var newIdentity = new Method({
name: 'newIdentity',
call: 'shh_newIdentity',
params: 0
});
var hasIdentity = new Method({
name: 'hasIdentity',
call: 'shh_hasIdentity',
params: 1
});
var newGroup = new Method({
name: 'newGroup',
call: 'shh_newGroup',
params: 0
});
var addToGroup = new Method({
name: 'addToGroup',
call: 'shh_addToGroup',
params: 0
});
return [
post,
newIdentity,
hasIdentity,
newGroup,
addToGroup
];
};
2015-10-07 04:32:32 +02:00
module.exports = Shh;
2015-02-05 23:37:30 +01:00