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

Add support of rc_api.find_rc_accounts #498

Merged
merged 4 commits into from
Nov 20, 2023
Merged
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
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ $ npm install steem --save

## RPC Servers
https://api.steemit.com By Default<br/>
https://node.steem.ws<br/>
https://this.piston.rocks<br/>

## Examples
### Broadcast Vote
Expand Down Expand Up @@ -107,7 +105,7 @@ steem.api.setOptions({
The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements.

## Contributions
Patches are welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them. If you would like to contribute, but don't know what to work on, check the issues list or on Steemit Chat channel #steemjs https://steemit.chat/channel/steemjs.
Patches are welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them. If you would like to contribute, but don't know what to work on, check the issues list.

## Issues
When you find issues, please report them!
Expand Down
10 changes: 8 additions & 2 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ class Steem extends EventEmitter {
const methodParams = method.params || [];

this[`${methodName}With`] = (options, callback) => {
let params;
if (!method.is_object) {
params = methodParams.map(param => options[param]);
} else {
params = options;
}
return this.send(method.api, {
method: method.method,
params: methodParams.map(param => options[param])
params: params
}, callback);
};

Expand All @@ -46,7 +52,7 @@ class Steem extends EventEmitter {
return this[`${methodName}With`](options, callback);
};

this[`${methodName}WithAsync`] = Promise.promisify(this[`${methodName}With`]);
this[`${methodName}WithAsync`] = Promise.promisify(this[`${methodName}With`]);
this[`${methodName}Async`] = Promise.promisify(this[methodName]);
});
this.callAsync = Promise.promisify(this.call);
Expand Down
8 changes: 7 additions & 1 deletion src/api/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,5 +510,11 @@ export default [
"api": "condenser_api",
"method": "get_nai_pool",
"params": []
}
},
{
"api": "rc_api",
"method": "find_rc_accounts",
"params": ["accounts"],
"is_object": true
},
];
12 changes: 12 additions & 0 deletions test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,16 @@ describe('steem.api:', function () {
it('does not retry non-retriable operations');
});

describe('getRC', () => {
describe('getting a RC of an account', () => {
it('works', async () => {
const result = await steem.api.findRcAccountsAsync(["justinsunsteemit"]);
result.should.have.properties("rc_accounts");
result["rc_accounts"][0].should.have.properties("rc_manabar");
});
it('clears listeners', async () => {
steem.api.listeners('message').should.have.lengthOf(0);
});
});
});
});