Skip to content
Snippets Groups Projects
Commit 11ecd391 authored by Johan Nordberg's avatar Johan Nordberg
Browse files

Add signedCall api method

parent d3011c92
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
}, },
"homepage": "https://github.com/steemit/steem-js#readme", "homepage": "https://github.com/steemit/steem-js#readme",
"dependencies": { "dependencies": {
"@steemit/rpc-auth": "^1.1.0",
"bigi": "^1.4.2", "bigi": "^1.4.2",
"bluebird": "^3.4.6", "bluebird": "^3.4.6",
"browserify-aes": "^1.0.6", "browserify-aes": "^1.0.6",
......
...@@ -15,6 +15,9 @@ import { ...@@ -15,6 +15,9 @@ import {
import { import {
jsonRpc jsonRpc
} from './transports/http'; } from './transports/http';
import {
sign as signRequest
} from '@steemit/rpc-auth';
class Steem extends EventEmitter { class Steem extends EventEmitter {
constructor(options = {}) { constructor(options = {}) {
...@@ -154,6 +157,23 @@ class Steem extends EventEmitter { ...@@ -154,6 +157,23 @@ class Steem extends EventEmitter {
.then(res => { callback(null, res) }, err => { callback(err) }); .then(res => { callback(null, res) }, err => { callback(err) });
} }
signedCall(method, params, account, key, callback) {
if (this._transportType !== 'http') {
callback(new Error('RPC methods can only be called when using http transport'));
return;
}
const id = ++this.seqNo;
let request;
try {
request = signRequest({method, params, id}, account, [key]);
} catch (error) {
callback(error);
return;
}
jsonRpc(this.options.uri, request)
.then(res => { callback(null, res) }, err => { callback(err) });
}
setOptions(options) { setOptions(options) {
Object.assign(this.options, options); Object.assign(this.options, options);
this._setLogger(options); this._setLogger(options);
......
...@@ -2,6 +2,16 @@ ...@@ -2,6 +2,16 @@
# yarn lockfile v1 # yarn lockfile v1
"@steemit/libcrypto@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@steemit/libcrypto/-/libcrypto-1.0.1.tgz#c31ab3e5deb667628169b3d54d746b015de31a79"
"@steemit/rpc-auth@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@steemit/rpc-auth/-/rpc-auth-1.1.0.tgz#4170c04d928ef37af5bdbde3f517ef74909480bd"
dependencies:
"@steemit/libcrypto" "^1.0.1"
abbrev@1: abbrev@1:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment