@dashevo/dashd-rpc
Advanced tools
Comparing version 18.0.2 to 18.2.0
@@ -68,2 +68,4 @@ /* eslint-disable */ | ||
const self = this; | ||
const path = request.path; | ||
delete request.path; | ||
request = JSON.stringify(request); | ||
@@ -74,3 +76,3 @@ const auth = Buffer.from(`${self.user}:${self.pass}`).toString('base64'); | ||
host: self.host, | ||
path: '/', | ||
path, | ||
method: 'POST', | ||
@@ -318,6 +320,19 @@ port: self.port, | ||
return function () { | ||
let limit = arguments.length - 1; | ||
let path = '/'; | ||
let slicedArguments = slice(arguments); | ||
const length = slicedArguments.length; | ||
// The last optional parameter of requested method is a wallet name. We don't want to pass it to core, | ||
// that's why we remove it. And since the latest parameter here is a callback, we use length - 2, | ||
// instead of length - 1 | ||
if (length > 0 && typeof slicedArguments[length - 2] === 'object' && slicedArguments[length - 2].wallet) { | ||
path = '/wallet/' + slicedArguments[length - 2].wallet; | ||
slicedArguments.splice(length - 2, 1); | ||
} | ||
let limit = slicedArguments.length - 1; | ||
if (this.batchedCalls) { | ||
limit = arguments.length; | ||
limit = slicedArguments.length; | ||
} | ||
@@ -327,3 +342,3 @@ | ||
if (argMap[i]) { | ||
arguments[i] = argMap[i](arguments[i]); | ||
slicedArguments[i] = argMap[i](slicedArguments[i]); | ||
} | ||
@@ -334,5 +349,6 @@ } | ||
this.batchedCalls.push({ | ||
path, | ||
jsonrpc: '2.0', | ||
method: methodName, | ||
params: slice(arguments), | ||
params: slice(slicedArguments), | ||
id: getRandomId(), | ||
@@ -342,4 +358,5 @@ }); | ||
rpc.call(this, { | ||
path, | ||
method: methodName, | ||
params: slice(arguments, 0, arguments.length - 1), | ||
params: slice(slicedArguments, 0, slicedArguments.length - 1), | ||
id: getRandomId(), | ||
@@ -346,0 +363,0 @@ }, arguments[arguments.length - 1]); |
{ | ||
"name": "@dashevo/dashd-rpc", | ||
"description": "Dash Client Library to connect to Dash Core (dashd) via RPC", | ||
"version": "18.0.2", | ||
"version": "18.2.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Stephen Pair", |
@@ -556,2 +556,31 @@ 'use strict'; | ||
}); | ||
it('should call wallet method and receive the response', (done) => { | ||
var client = new RpcClient({ | ||
user: 'user', | ||
pass: 'pass', | ||
host: 'localhost', | ||
port: 8332, | ||
rejectUnauthorized: true, | ||
disableAgent: true | ||
}); | ||
var requestStub = sinon.stub(client.protocol, 'request').callsFake(function(options, callback){ | ||
var res = new FakeResponse(); | ||
var req = new FakeRequest(); | ||
setImmediate(function(){ | ||
res.emit('data', '{}'); | ||
res.emit('end'); | ||
}); | ||
callback(res); | ||
return req; | ||
}); | ||
client.getBalance('n28S35tqEMbt6vNad7A5K3mZ7vdn8dZ86X', 6, { wallet: 'default' }, function(error, parsedBuf) { | ||
requestStub.restore(); | ||
should.not.exist(error); | ||
should.exist(parsedBuf); | ||
done(); | ||
}); | ||
}); | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34491
877