Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

steem

Package Overview
Dependencies
Maintainers
2
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

steem - npm Package Compare versions

Comparing version 0.3.9 to 0.3.11

examples/steem.js

24

doc/README.md

@@ -487,2 +487,26 @@ # Documentation

});
```
### UpVote
```js
steem.broadcast.upvote(username, password, author, permlink, weight, function(err, result) {
console.log(err, result);
});
```
### DownVote
```js
steem.broadcast.downvote(username, password, author, permlink, weight, function(err, result) {
console.log(err, result);
});
```
### Comment
```js
steem.broadcast.comment(username, password, parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata, function(err, result) {
console.log(err, result);
});
```
### Transfer
```js
steem.broadcast.transfer(username, password, from, to, amount, memo, function(err, result) {
console.log(err, result);
});
```

2

examples/server.js

@@ -27,4 +27,4 @@ var steem = require('./../index');

if (!err && result[1].author == 'fabien') {
console.log(result);
console.log(err, result);
}
});

@@ -1,1 +0,1 @@

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var Steem=require("./steem.js");steem=new Steem},{"./steem.js":2}],2:[function(require,module,exports){var Steem=function(url){this.url=url||"wss://steemit.com/wspa";this.apiIds={database_api:0,login_api:1,follow_api:2,network_broadcast_api:4};this.ws=new WebSocket(this.url);this.id=0;this.reqs=[];this.isOpen=false;this.ws.addEventListener("close",function(){this.isOpen=false}.bind(this))};Steem.prototype.open=function(callback){if(!this.isOpen){this.ws.addEventListener("open",function(){this.isOpen=true;callback()}.bind(this))}else{callback()}};Steem.prototype.iterate=function(){this.id++;var id=this.id;this.reqs.push(id);return id};Steem.prototype.getApi=function(api,callback){if(this.apiIds[api]||this.apiIds[api]===0){callback("",this.apiIds[api])}else{this.getApiByName(api,function(err,result){this.apiIds[api]=result;callback("",result)}.bind(this))}};Steem.prototype.send=function(api,data,callback){data.id=data.id||0;data.params=data.params||[];this.open(function(){var call={};call.id=data.id;call.method="call";call.params=[this.apiIds[api],data.method,data.params];this.ws.send(JSON.stringify(call))}.bind(this));this.ws.addEventListener("message",function(msg){var data=JSON.parse(msg.data);var err=data.error&&data.error.data&&data.error.data.stack?data.error.data.stack:"";callback(err,data)}.bind(this));this.ws.addEventListener("error",function(error){callback(error,null)})};Steem.prototype.setSubscribeCallback=function(cb,clearFilter,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"set_subscribe_callback",params:[cb,clearFilter]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.setPendingTransactionCallback=function(cb,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"set_pending_transaction_callback",params:[cb]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.setBlockAppliedCallback=function(cb,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"set_block_applied_callback",params:[cb]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.cancelAllSubscriptions=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"cancel_all_subscriptions"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getTrendingTags=function(afterTag,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_trending_tags",params:[afterTag,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByTrending=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_trending",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByCreated=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_created",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByActive=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_active",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByCashout=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_cashout",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByPayout=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_payout",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByVotes=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_votes",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByChildren=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_children",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByHot=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_hot",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByFeed=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_feed",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getBlockHeader=function(blockNum,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_block_header",params:[blockNum]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getBlock=function(blockNum,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_block",params:[blockNum]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getState=function(path,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_state",params:[path]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getTrendingCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_trending_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getBestCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_best_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getActiveCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_active_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getRecentCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_recent_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getConfig=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_config"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDynamicGlobalProperties=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_dynamic_global_properties"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getChainProperties=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_chain_properties"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getFeedHistory=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_feed_history"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getCurrentMedianHistoryPrice=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_current_median_history_price"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getWitnessSchedule=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_recent_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getHardforkVersion=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_hardfork_version"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getNextScheduledHardfork=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_next_scheduled_hardfork"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getKeyReferences=function(key,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_key_references",params:[key]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getAccounts=function(names,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_accounts",params:[names]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getAccountReferences=function(accountId,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_references",params:[accountId]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.lookupAccountNames=function(accountNames,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"lookup_account_names",params:[accountNames]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.lookupAccounts=function(lowerBoundName,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"lookup_accounts",params:[lowerBoundName,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getAccountCount=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_count"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getConversionRequests=function(accountName,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_conversion_requests",params:[accountName]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getAccountHistory=function(account,from,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_history",params:[account,from,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getOwnerHistory=function(account,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_owner_history",params:[account]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getRecoveryRequest=function(account,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_recovery_request",params:[account]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getOrderBook=function(limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"getOrderBook",params:[limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getOpenOrders=function(owner,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_open_orders",params:[owner]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getLiquidityQueue=function(startAccount,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_liquidity_queue",params:[startAccount,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getTransactionHex=function(trx,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_transaction_hex",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getTransaction=function(trxId,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_transaction",params:[trxId]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getRequiredSignatures=function(trx,availableKeys,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_required_signatures",params:[trx,availableKeys]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getPotentialSignatures=function(trx,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_potential_signatures",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.verifyAuthority=function(trx,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"verify_authority",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.verifyAccountAuthority=function(nameOrId,signers,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"verify_account_authority",params:[nameOrId,signers]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getActiveVotes=function(author,permlink,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_active_votes",params:[author,permlink]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getAccountVotes=function(voter,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_votes",params:[voter]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getContent=function(author,permlink,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_content",params:[author,permlink]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getContentReplies=function(parent,parentPermlink,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_content_replies",params:[parent,parentPermlink]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getDiscussionsByAuthorBeforeDate=function(author,startPermlink,beforeDate,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_author_before_date",params:[author,startPermlink,beforeDate,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getRepliesByLastUpdate=function(startAuthor,startPermlink,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_replies_by_last_update",params:[startAuthor,startPermlink,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getWitnesses=function(witnessIds,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witnesses",params:[witnessIds]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getWitnessByAccount=function(accountName,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witness_by_account",params:[accountName]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getWitnessesByVote=function(from,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witnesses_by_vote",params:[from,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.lookupWitnessAccounts=function(lowerBoundName,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"lookup_witness_accounts",params:[lowerBoundName,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getWitnessCount=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witness_count"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getActiveWitnesses=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_active_witnesses"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getMinerQueue=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_miner_queue"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.login=function(username,password,callback){var iterator=this.iterate();this.send("login_api",{id:iterator,method:"login",params:[username,password]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getApiByName=function(apiName,callback){var iterator=this.iterate();this.send("login_api",{id:iterator,method:"get_api_by_name",params:[apiName]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getFollowers=function(following,startFollower,followType,limit,callback){var iterator=this.iterate();this.send("follow_api",{id:iterator,method:"get_followers",params:[following,startFollower,followType,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.getFollowing=function(follower,startFollowing,followType,limit,callback){var iterator=this.iterate();this.send("follow_api",{id:iterator,method:"get_following",params:[follower,startFollowing,followType,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.broadcastTransaction=function(trx,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_transaction",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.broadcastTransactionSynchronous=function(trx,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_transaction_synchronous",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.broadcastBlock=function(b,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_block",params:[b]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.broadcastTransactionWithCallback=function(confirmationCallback,trx,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_transaction_with_callback",params:[confirmationCallback,trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.prototype.streamBlockNumber=function(callback){var current="";var self=this;setInterval(function(){self.getDynamicGlobalProperties(function(err,result){var blockId=result.head_block_number;if(blockId!=current){current=blockId;callback(null,current)}})},200)};Steem.prototype.streamBlock=function(callback){var current="";var last="";var self=this;this.streamBlockNumber(function(err,id){current=id;if(current!=last){last=current;self.getBlock(current,function(err,result){callback(null,result)})}})};Steem.prototype.streamTransactions=function(callback){this.streamBlock(function(err,result){if(!!result){result.transactions.forEach(function(transaction){callback(null,transaction)})}})};Steem.prototype.streamOperations=function(callback){this.streamBlock(function(err,result){if(!!result){result.transactions.forEach(function(transaction){transaction.operations.forEach(function(operation){callback(null,operation)})})}})};module.exports=Steem},{}]},{},[1]);
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var isNode=require("detect-node");if(isNode)var WS=require("ws");var Steem={url:"wss://steemit.com/wspa",apiIds:{database_api:0,login_api:1,follow_api:2,network_broadcast_api:4},id:0,reqs:[],isOpen:false,isReady:false};Steem.setWebSocket=function(url){this.url=url};Steem.init=function(callback){if(!this.isReady){if(isNode){this.ws=new WS(this.url);this.ws.setMaxListeners(0)}else this.ws=new WebSocket(this.url);this.ws.addEventListener("close",function(){this.isOpen=false}.bind(this));this.isReady=true}if(!this.isOpen){this.ws.addEventListener("open",function(){this.isOpen=true;this.getApiByName("database_api",function(){});this.getApiByName("login_api",function(){});this.getApiByName("follow_api",function(){});this.getApiByName("network_broadcast_api",function(){});callback()}.bind(this))}else{callback()}};Steem.iterate=function(){this.id++;var id=this.id;this.reqs.push(id);return id};Steem.getApi=function(api,callback){if(this.apiIds[api]||this.apiIds[api]===0){callback("",this.apiIds[api])}else{this.getApiByName(api,function(err,result){this.apiIds[api]=result;callback("",result)}.bind(this))}};Steem.send=function(api,data,callback){data.id=data.id||0;data.params=data.params||[];this.init(function(){var call={};call.id=data.id;call.method="call";call.params=[this.apiIds[api],data.method,data.params];this.ws.send(JSON.stringify(call))}.bind(this));this.ws.addEventListener("message",function(msg){var data=JSON.parse(msg.data);var err=data.error&&data.error.data&&data.error.data.stack?data.error.data.stack:"";callback(err,data)}.bind(this));this.ws.addEventListener("error",function(error){callback(error,null)})};Steem.setSubscribeCallback=function(cb,clearFilter,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"set_subscribe_callback",params:[callback,clearFilter]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.setPendingTransactionCallback=function(cb,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"set_pending_transaction_callback",params:[cb]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.setBlockAppliedCallback=function(cb,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"set_block_applied_callback",params:[cb]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.cancelAllSubscriptions=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"cancel_all_subscriptions"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getTrendingTags=function(afterTag,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_trending_tags",params:[afterTag,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByTrending=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_trending",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByCreated=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_created",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByActive=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_active",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByCashout=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_cashout",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByPayout=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_payout",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByVotes=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_votes",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByChildren=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_children",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByHot=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_hot",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByFeed=function(query,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_feed",params:[query]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getBlockHeader=function(blockNum,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_block_header",params:[blockNum]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getBlock=function(blockNum,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_block",params:[blockNum]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getState=function(path,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_state",params:[path]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getTrendingCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_trending_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getBestCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_best_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getActiveCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_active_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getRecentCategories=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_recent_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getConfig=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_config"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDynamicGlobalProperties=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_dynamic_global_properties"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getChainProperties=function(after,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_chain_properties"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getFeedHistory=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_feed_history"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getCurrentMedianHistoryPrice=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_current_median_history_price"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getWitnessSchedule=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_recent_categories",params:[after,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getHardforkVersion=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_hardfork_version"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getNextScheduledHardfork=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_next_scheduled_hardfork"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getKeyReferences=function(key,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_key_references",params:[key]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getAccounts=function(names,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_accounts",params:[names]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getAccountReferences=function(accountId,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_references",params:[accountId]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.lookupAccountNames=function(accountNames,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"lookup_account_names",params:[accountNames]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.lookupAccounts=function(lowerBoundName,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"lookup_accounts",params:[lowerBoundName,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getAccountCount=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_count"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getConversionRequests=function(accountName,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_conversion_requests",params:[accountName]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getAccountHistory=function(account,from,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_history",params:[account,from,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getOwnerHistory=function(account,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_owner_history",params:[account]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getRecoveryRequest=function(account,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_recovery_request",params:[account]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getOrderBook=function(limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"getOrderBook",params:[limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getOpenOrders=function(owner,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_open_orders",params:[owner]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getLiquidityQueue=function(startAccount,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_liquidity_queue",params:[startAccount,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getTransactionHex=function(trx,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_transaction_hex",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getTransaction=function(trxId,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_transaction",params:[trxId]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getRequiredSignatures=function(trx,availableKeys,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_required_signatures",params:[trx,availableKeys]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getPotentialSignatures=function(trx,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_potential_signatures",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.verifyAuthority=function(trx,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"verify_authority",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.verifyAccountAuthority=function(nameOrId,signers,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"verify_account_authority",params:[nameOrId,signers]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getActiveVotes=function(author,permlink,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_active_votes",params:[author,permlink]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getAccountVotes=function(voter,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_account_votes",params:[voter]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getContent=function(author,permlink,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_content",params:[author,permlink]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getContentReplies=function(parent,parentPermlink,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_content_replies",params:[parent,parentPermlink]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getDiscussionsByAuthorBeforeDate=function(author,startPermlink,beforeDate,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_discussions_by_author_before_date",params:[author,startPermlink,beforeDate,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getRepliesByLastUpdate=function(startAuthor,startPermlink,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_replies_by_last_update",params:[startAuthor,startPermlink,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getWitnesses=function(witnessIds,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witnesses",params:[witnessIds]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getWitnessByAccount=function(accountName,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witness_by_account",params:[accountName]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getWitnessesByVote=function(from,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witnesses_by_vote",params:[from,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.lookupWitnessAccounts=function(lowerBoundName,limit,callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"lookup_witness_accounts",params:[lowerBoundName,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getWitnessCount=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_witness_count"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getActiveWitnesses=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_active_witnesses"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getMinerQueue=function(callback){var iterator=this.iterate();this.send("database_api",{id:iterator,method:"get_miner_queue"},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.login=function(username,password,callback){var iterator=this.iterate();this.send("login_api",{id:iterator,method:"login",params:[username,password]},function(err,data){if(iterator==data.id){this.getApiByName("network_broadcast_api",function(){});callback(err,data.result)}}.bind(this))};Steem.getApiByName=function(apiName,callback){var iterator=this.iterate();this.send("login_api",{id:iterator,method:"get_api_by_name",params:[apiName]},function(err,data){if(iterator==data.id){this.apiIds[apiName]=data.result;callback(err,data.result)}}.bind(this))};Steem.getFollowers=function(following,startFollower,followType,limit,callback){var iterator=this.iterate();this.send("follow_api",{id:iterator,method:"get_followers",params:[following,startFollower,followType,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.getFollowing=function(follower,startFollowing,followType,limit,callback){var iterator=this.iterate();this.send("follow_api",{id:iterator,method:"get_following",params:[follower,startFollowing,followType,limit]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.broadcastTransaction=function(trx,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_transaction",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.broadcastTransactionSynchronous=function(trx,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_transaction_synchronous",params:[trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.broadcastBlock=function(b,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_block",params:[b]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.broadcastTransactionWithCallback=function(confirmationCallback,trx,callback){var iterator=this.iterate();this.send("network_broadcast_api",{id:iterator,method:"broadcast_transaction_with_callback",params:[confirmationCallback,trx]},function(err,data){if(iterator==data.id)callback(err,data.result)})};Steem.streamBlockNumber=function(callback){var current="";var self=this;setInterval(function(){self.getDynamicGlobalProperties(function(err,result){var blockId=result.head_block_number;if(blockId!=current){current=blockId;callback(null,current)}})},200)};Steem.streamBlock=function(callback){var current="";var last="";var self=this;this.streamBlockNumber(function(err,id){current=id;if(current!=last){last=current;self.getBlock(current,function(err,result){callback(null,result)})}})};Steem.streamTransactions=function(callback){this.streamBlock(function(err,result){if(!!result){result.transactions.forEach(function(transaction){callback(null,transaction)})}})};Steem.streamOperations=function(callback){this.streamBlock(function(err,result){if(!!result){result.transactions.forEach(function(transaction){transaction.operations.forEach(function(operation){callback(null,operation)})})}})};module.exports=Steem},{"detect-node":5,ws:4}],2:[function(require,module,exports){steem={api:require("./api"),formatter:require("./formatter")}},{"./api":1,"./formatter":3}],3:[function(require,module,exports){module.exports={reputation:function(reputation){if(reputation==null)return reputation;reputation=parseInt(reputation);var rep=String(reputation);var neg=rep.charAt(0)==="-";rep=neg?rep.substring(1):rep;var str=rep;var leadingDigits=parseInt(str.substring(0,4));var log=Math.log(leadingDigits)/Math.log(10);var n=str.length-1;var out=n+(log-parseInt(log));if(isNaN(out))out=0;out=Math.max(out-9,0);out=(neg?-1:1)*out;out=out*9+25;out=parseInt(out);return out},vestToSteem:function(vestingShares,totalVestingShares,totalVestingFundSteem){return parseFloat(totalVestingFundSteem)*(parseFloat(vestingShares)/parseFloat(totalVestingShares))},commentPermlink:function(parentAuthor,parentPermlink){var timeStr=(new Date).toISOString().replace(/[^a-zA-Z0-9]+/g,"");parentPermlink=parentPermlink.replace(/(-\d{8}t\d{9}z)/g,"");return"re-"+parentAuthor+"-"+parentPermlink+"-"+timeStr},amount:function(amount,asset){return amount.toFixed(3)+" "+asset}}},{}],4:[function(require,module,exports){},{}],5:[function(require,module,exports){(function(global){module.exports=false;try{module.exports=Object.prototype.toString.call(global.process)==="[object process]"}catch(e){}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[2]);

@@ -1,2 +0,3 @@

var WebSocket = require('ws');
var isNode = require('detect-node');
if (isNode) var WS = require('ws');

@@ -23,4 +24,7 @@ var Steem = {

if (!this.isReady) {
this.ws = new WebSocket(this.url);
this.ws.setMaxListeners(0);
if (isNode) {
this.ws = new WS(this.url);
this.ws.setMaxListeners(0);
} else
this.ws = new WebSocket(this.url);
this.ws.addEventListener('close', function() {

@@ -96,3 +100,3 @@ this.isOpen = false;

'method': 'set_subscribe_callback',
'params': [cb, clearFilter]
'params': [callback, clearFilter]
}, function(err, data) {

@@ -1006,2 +1010,2 @@ if (iterator == data.id) callback(err, data.result);

module.exports = Steem;
module.exports = Steem;
var moment = require('moment'),
steemAuth = require('steemauth'),
steemAuth = require('../../steemauth/index.js'),
steemApi = require('./api');
formatter = require('./formatter');
/*
vote: 0,
comment: 1,
transfer: 2,
TODO
transfer_to_vesting: 3,
withdraw_vesting: 4,
limit_order_create: 5,
limit_order_cancel: 6,
feed_publish: 7,
convert: 8,
account_create: 9,
account_update: 10,
witness_update: 11,
account_witness_vote: 12,
account_witness_proxy: 13,
pow: 14,
custom: 15,
report_over_production: 16,
delete_comment: 17,
custom_json: 18,
comment_options: 19,
set_withdraw_vesting_route: 20,
limit_order_create2: 21,
challenge_authority: 22,
prove_authority: 23,
request_account_recovery: 24,
recover_account: 25,
change_recovery_account: 26,
escrow_transfer: 27,
escrow_dispute: 28,
escrow_release: 29,
fill_convert_request: 30,
comment_reward: 31,
curate_reward: 32,
liquidity_reward: 33,
interest: 34,
fill_vesting_withdraw: 35,
fill_order: 36,
comment_payout: 37
*/
module.exports = {
send: function(username, password, tx, privKeys, callback) {
steemApi.login(username, password, function() {
send: function(tx, privKeys, callback) {
steemApi.login('', '', function() {
steemApi.getDynamicGlobalProperties(function(err, result) {

@@ -30,6 +74,52 @@ tx.expiration = moment.utc(result.timestamp).add(15, 'second').format().replace('Z', '');

var privKeys = steemAuth.getPrivateKeys(username, password, ['posting']);
this.send(username, password, tx, privKeys, function(err, result) {
this.send(tx, privKeys, function(err, result) {
callback(err, result);
})
},
upvote: function(username, password, author, permlink, weight, callback) {
weight = weight || 10000;
vote(username, password, author, permlink, weight, function(err, result) {
callback(err, result);
})
},
downvote: function(username, password, author, permlink, weight, callback) {
weight = weight || 10000;
vote(username, password, author, permlink, -Math.abs(weight), function(err, result) {
callback(err, result);
})
},
comment: function(username, password, parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata, callback) {
permlink = permlink || formatter.commentPermlink(parentAuthor, parentPermlink);
var tx = {
extensions: [],
operations: [['comment', {
parent_author: parentAuthor,
parent_permlink: parentPermlink,
author: author,
permlink: permlink,
title: title,
body: body,
json_metadata: JSON.stringify(jsonMetadata)
}]]
};
var privKeys = steemAuth.getPrivateKeys(username, password, ['posting']);
this.send(tx, privKeys, function(err, result) {
callback(err, result);
})
},
transfer: function(username, password, from, to, amount, memo, callback) {
var tx = {
extensions: [],
operations: [['transfer', {
from: from,
to: to,
amount: amount,
memo: memo
}]]
};
var privKeys = steemAuth.getPrivateKeys(username, password, ['active']);
this.send(tx, privKeys, function(err, result) {
callback(err, result);
})
}
};

@@ -1,4 +0,4 @@

module.exports = {
steem = {
api: require('./api'),
formatter: require('./formatter'),
};
};

@@ -22,3 +22,11 @@ module.exports = {

return parseFloat(totalVestingFundSteem) * (parseFloat(vestingShares) / parseFloat(totalVestingShares));
},
commentPermlink: function(parentAuthor, parentPermlink) {
var timeStr = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '');
parentPermlink = parentPermlink.replace(/(-\d{8}t\d{9}z)/g, '');
return 're-' + parentAuthor + '-' + parentPermlink + '-' + timeStr;
},
amount: function(amount, asset) {
return amount.toFixed(3) + ' ' + asset;
}
};
{
"name": "steem",
"version": "0.3.9",
"version": "0.3.11",
"description": "Steem.js the JavaScript API for Steem blockchain",

@@ -8,4 +8,7 @@ "main": "index.js",

"test": "node test.js",
"build": "browserify lib/browser.js -o | uglifyjs > lib/steem.min.js && browserify lib/browser.js -o | uglifyjs > examples/steem.min.js"
"build": "browserify lib/browser.js -o examples/steem.js && uglifyjs examples/steem.js -o examples/steem.min.js && uglifyjs examples/steem.js -o steem.min.js"
},
"browser": {
"ws": false
},
"repository": {

@@ -28,4 +31,5 @@ "type": "git",

"dependencies": {
"detect-node": "^2.0.3",
"moment": "^2.14.1",
"steemauth": "0.0.4",
"steemauth": "0.0.13",
"ws": "^1.1.1"

@@ -32,0 +36,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc