diff --git a/.gitignore b/.gitignore index 7785ceea21245296e623c241aade82501f2061a8..2621e29e777421a5aa5e8311a8c8f4455eb16928 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ scr .save *.css.map *.css +dev.js # Logs logs diff --git a/dev.js b/dev.js new file mode 100644 index 0000000000000000000000000000000000000000..2dbf94b11bb20c65fbcffb4736a5061102d9d9c1 --- /dev/null +++ b/dev.js @@ -0,0 +1,22 @@ +var Steem = require('./lib/steem'), + steem = new Steem(); + +steem.login('******', '****************', function(err, result) { + console.log(result); + var trx = { + expiration: '2016-08-13T05:44:15', + extensions: [], + operations: [['vote', { + voter: '******', + author: 'calaber24p', + permlink: '5zebtb-the-future-the-possibility-of-capturing-memories-and-reliving-them', + weight: 100 + }]], + ref_block_num: 40289, + ref_block_prefix: 3483617648, + signatures: ['10f7ce6fc9f5bc99fe789af9e464ff62e6b676622611abd22ed332f20649797b13e0ff85a1be1b72bc26f2ba0d4bf6eStef'] + }; + steem.broadcastTransaction(trx, function(err, result) { + console.log(err, result); + }); +}); \ No newline at end of file diff --git a/lib/steem.js b/lib/steem.js index 9eb67244f777af5302ee445b324d1b3ed9371817..0a627c11c6c728290768e8a1dba47aa2e45b385c 100644 --- a/lib/steem.js +++ b/lib/steem.js @@ -51,18 +51,16 @@ Steem.prototype.send = function(api, data, callback) { data.id = data.id || 0; data.params = data.params || []; this.open(function(){ - this.getApi(api, function(err, apiId) { - var call = {}; - call.id = data.id; - call.method = 'call'; - call.params = [apiId, data.method, data.params]; - this.ws.send(JSON.stringify(call)); - }.bind(this)); + 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 || ''; + var err = (data.error && data.error.data && data.error.data.stack)? data.error.data.stack : ''; callback(err, data); }.bind(this)); @@ -861,7 +859,7 @@ Steem.prototype.getFollowers = function(following, startFollower, followType, li this.send('follow_api', { 'id': iterator, 'method': 'get_followers', - 'params': [following, startFollower, limit] + 'params': [following, startFollower, followType, limit] }, function(err, data) { if (iterator == data.id) callback(err, data.result); }); @@ -873,7 +871,7 @@ Steem.prototype.getFollowing = function(follower, startFollowing, followType, li this.send('follow_api', { 'id': iterator, 'method': 'get_following', - 'params': [follower, startFollowing, limit] + 'params': [follower, startFollowing, followType, limit] }, function(err, data) { if (iterator == data.id) callback(err, data.result); }); diff --git a/package.json b/package.json index eaa456459f424acb25e7f62f6e5c882c6269d807..37dfdf7c0eb2ba2964077f9e261bdf764138c430 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steem", - "version": "0.2.19", + "version": "0.2.20", "description": "Steem.js the JavaScript API for Steem blockchain", "main": "index.js", "scripts": { diff --git a/test.js b/test.js index 7f734d458c539ffe4b1e2edeeddd0633c93607eb..7ac322470b3ad26fc6cf9b4ce01aca7c2f3a918b 100644 --- a/test.js +++ b/test.js @@ -1,23 +1,22 @@ var Steem = require('./lib/steem'), steem = new Steem(); -steem.login('******', '****************', function(err, result) { - console.log(result); - var trx = { - expiration: '2016-08-13T05:44:15', - extensions: [], - operations: [['vote', { - voter: '******', - author: 'calaber24p', - permlink: '5zebtb-the-future-the-possibility-of-capturing-memories-and-reliving-them', - weight: 100 - }]], - ref_block_num: 40289, - ref_block_prefix: 3483617648, - signatures: ['10f7ce6fc9f5bc99fe789af9e464ff62e6b676622611abd22ed332f20649797b13e0ff85a1be1b72bc26f2ba0d4bf6e'] - }; - steem.broadcastTransaction(trx, function(err, result) { - console.log(err, result); - }); +steem.getAccountCount(function(err, result) { + console.log(err, result); }); +steem.getAccounts(['dan'], function(err, result) { + console.log(err, result); +}); + +steem.getState('trending/steemit', function(err, result) { + console.log(err, result); +}); + +steem.getFollowing('ned', 0, 'blog', 10, function(err, result) { + console.log(err, result); +}); + +steem.getFollowers('dan', 0, 'blog', 10, function(err, result) { + console.log(err, result); +}); \ No newline at end of file