Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added resteem functionality to Responder #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions dist/responder.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,33 @@ var Responder = function () {

return _steem2.default.broadcast.voteAsync(wif, this.responderUsername, targetUsername, targetPermlink, votingWeight);
}
}, {
key: 'resteem',
value: function resteem() {
var targetUsername = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.targetUsername;
var targetPermlink = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.targetPermlink;

this._throwErrorIfNoKey();
this._throwErrorIfNoPermlink(targetPermlink);

var wif = this.postingKey || this.activeKey;

var action = JSON.stringify(['reblog'], {
account: this.responserUsername,
author: targetUsername,
permlink: targetPermlink
});

return _steem2.default.broadcast.customJsonAsync(wif, [], [this.responderUsername], 'follow', action);
}
}, {
key: 'resteemOnMemo',
value: function resteemOnMemo() {
var customTargetUsername = extractUsernameFromLink(this.transferMemo);
var customTarget = extractPermlinkFromLink(this.transferMemo);

return this.resteem(customTargetUsername, customTarget);
}
}, {
key: 'upvoteOnMemo',
value: function upvoteOnMemo() {
Expand Down
31 changes: 31 additions & 0 deletions src/responder.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,37 @@ export default class Responder {
);
}

resteem(
targetUsername = this.targetUsername,
targetPermlink = this.targetPermlink
) {
this._throwErrorIfNoKey();
this._throwErrorIfNoPermlink(targetPermlink);

const wif = this.postingKey || this.activeKey;

const action = JSON.stringify(['reblog'], {
account: this.responserUsername,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in "responder"

author: targetUsername,
permlink: targetPermlink
})

return steem.broadcast.customJsonAsync(
wif,
[],
[this.responderUsername],
'follow',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the id for transaction is "follow" ? I don't remember exactly but I think it should be a random string like a uuid. since the new commit in node from the second execution it returns this error:

Unhandled rejection RPCError: Assert Exception:_callbacks.find( txid ) == _callbacks.end(): Transaction is a duplicate
    at new RPCError (/Users/p0o/dev/steem-bot-tests/steem-bot/node_modules/steem/lib/api/transports/http.js:39:106)
    at /Users/p0o/dev/steem-bot-tests/steem-bot/node_modules/steem/lib/api/transports/http.js:74:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

action
)
}

resteemOnMemo() {
const customTargetUsername = extractUsernameFromLink(this.transferMemo)
const customTarget = extractPermlinkFromLink(this.transferMemo)

return this.resteem(customTargetUsername, customTarget)
}

upvoteOnMemo(votingPercentage = 100.0) {
const customTargetUsername = extractUsernameFromLink(this.transferMemo);
const customTargetPermlink = extractPermlinkFromLink(this.transferMemo);
Expand Down