Skip to content

Commit

Permalink
Add support of rc_api.find_rc_accounts (#498)
Browse files Browse the repository at this point in the history
* Add rc_api.find_rc_accounts

* Revert format

* Revert format

* remove console.debug
  • Loading branch information
DoctorLai committed Nov 20, 2023
1 parent c71fb59 commit 436af86
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
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);
});
});
});
});

0 comments on commit 436af86

Please sign in to comment.