Compare commits

...
2 Commits
Author SHA1 Message Date
Chris Troutner 33e7bc2b52 Merge pull request #65 from Permissionless-Software-Foundation/ct-unstable
feat(txData): Renamed transaction JSON endpoint to txData
2022-01-29 07:39:47 -08:00
Chris Troutner a20f30ec1e feat(txData): Renamed transaction JSON endpoint to txData 2022-01-29 07:38:05 -08:00
4 changed files with 28 additions and 27 deletions
+10 -9
View File
@@ -64,9 +64,9 @@ class BCHRPC {
await this.rateLimit.limiter(rpcData.from)
return await this.broadcast(rpcData)
case 'transaction':
case 'txData':
await this.rateLimit.limiter(rpcData.from)
return await this.transaction(rpcData)
return await this.txData(rpcData)
case 'pubkey':
await this.rateLimit.limiter(rpcData.from)
@@ -115,7 +115,7 @@ class BCHRPC {
* - status: - HTTP Status Code
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"555","method":"bch","params":{ "endpoint": "transactions", "addresses": ["bitcoincash:qrl2nlsaayk6ekxn80pq0ks32dya8xfclyktem2mqj"], "sortOrder": "DESCENDING", "page": 0}}
* {"jsonrpc":"2.0","id":"555","method":"bch","params":{ "endpoint": "txHistory", "addresses": ["bitcoincash:qrl2nlsaayk6ekxn80pq0ks32dya8xfclyktem2mqj"], "sortOrder": "DESCENDING", "page": 0}}
*
* @apiSuccessExample {json} Success-Response:
* {
@@ -428,13 +428,14 @@ class BCHRPC {
}
/**
* @api {JSON} /bch Transaction
* @api {JSON} /bch Transaction Data
* @apiPermission public
* @apiName Transaction
* @apiName txData
* @apiGroup JSON BCH
* @apiDescription Get expanded transaction data for an array of transaction
* IDs. Each call is limited to 20 TXIDs or less.
* Given a transaction the endpoint will return an object with the
*
* Given a transaction ID, the endpoint will return an object with the
* following properties
*
* - jsonrpc: "" - jsonrpc version
@@ -459,7 +460,7 @@ class BCHRPC {
* - status: - HTTP Status Code
*
* @apiExample Example usage:
* {"jsonrpc":"2.0","id":"555","method":"bch","params":{ "endpoint": "transaction", "txids": ["01517ff1587fa5ffe6f5eb91c99cf3f2d22330cd7ee847e928ce90ca95bf781b"]}}
* {"jsonrpc":"2.0","id":"555","method":"bch","params":{ "endpoint": "txData", "txids": ["01517ff1587fa5ffe6f5eb91c99cf3f2d22330cd7ee847e928ce90ca95bf781b"]}}
*
* @apiSuccessExample {json} Success-Response:
* {
@@ -522,7 +523,7 @@ class BCHRPC {
* }
* }]
*/
async transaction (rpcData) {
async txData (rpcData) {
try {
const retObj = await this.useCases.bch.getTxData(rpcData)
return retObj
@@ -535,7 +536,7 @@ class BCHRPC {
success: false,
status: 422,
message: err.message,
endpoint: 'transaction'
endpoint: 'txData'
}
}
}
+4 -4
View File
@@ -76,7 +76,7 @@ class BCHUseCases {
success: false,
status: 422,
message: err.message,
endpoint: 'transactions'
endpoint: 'txHistory'
}
}
}
@@ -94,7 +94,7 @@ class BCHUseCases {
success: false,
status: 422,
message: 'Input txids must be an array of transaction IDs.',
endpoint: 'transaction'
endpoint: 'txData'
}
}
@@ -103,7 +103,7 @@ class BCHUseCases {
success: false,
status: 422,
message: 'Array input must be 20 elements or less.',
endpoint: 'transaction'
endpoint: 'txData'
}
}
@@ -132,7 +132,7 @@ class BCHUseCases {
success: false,
status: 422,
message: err.message,
endpoint: 'transaction'
endpoint: 'txData'
}
}
}
@@ -137,15 +137,15 @@ describe('#BCHRPC', () => {
assert.equal(result, true)
})
it('should route to the transaction method', async () => {
it('should route to the txData method', async () => {
// Mock dependencies
sandbox.stub(uut, 'transaction').resolves(true)
sandbox.stub(uut, 'txData').resolves(true)
// Generate the parsed data that the main router would pass to this
// endpoint.
const id = uid()
const rpcCall = jsonrpc.request(id, 'bch', {
endpoint: 'transaction'
endpoint: 'txData'
})
const jsonStr = JSON.stringify(rpcCall, null, 2)
const rpcData = jsonrpc.parse(jsonStr)
@@ -387,19 +387,19 @@ describe('#BCHRPC', () => {
})
})
describe('#transaction', () => {
describe('#txData', () => {
it('should route data to the use-case library', async () => {
// Generate the parsed data that the main router would pass to this
// endpoint.
const id = uid()
const rpcCall = jsonrpc.request(id, 'bch', {
endpoint: 'transaction',
endpoint: 'txData',
txid: 'testData'
})
const jsonStr = JSON.stringify(rpcCall, null, 2)
const rpcData = jsonrpc.parse(jsonStr)
const response = await uut.transaction(rpcData)
const response = await uut.txData(rpcData)
// console.log('response: ', response)
assert.equal(response.success, true)
@@ -416,19 +416,19 @@ describe('#BCHRPC', () => {
// endpoint.
const id = uid()
const rpcCall = jsonrpc.request(id, 'bch', {
endpoint: 'transaction',
endpoint: 'txData',
txid: 'testTxid'
})
const jsonStr = JSON.stringify(rpcCall, null, 2)
const rpcData = jsonrpc.parse(jsonStr)
const response = await uut.transaction(rpcData)
const response = await uut.txData(rpcData)
// console.log('response: ', response)
assert.equal(response.success, false)
assert.equal(response.status, 422)
assert.equal(response.message, 'Invalid data')
assert.equal(response.endpoint, 'transaction')
assert.equal(response.endpoint, 'txData')
})
})
@@ -95,7 +95,7 @@ describe('#bch-use-case', () => {
assert.equal(result.success, false)
assert.equal(result.status, 422)
assert.equal(result.message, 'Could not query Fulcrum indexer.')
assert.equal(result.endpoint, 'transactions')
assert.equal(result.endpoint, 'txHistory')
})
it('should return error if there is an error', async () => {
@@ -119,7 +119,7 @@ describe('#bch-use-case', () => {
assert.equal(result.success, false)
assert.equal(result.status, 422)
assert.equal(result.message, 'test error')
assert.equal(result.endpoint, 'transactions')
assert.equal(result.endpoint, 'txHistory')
})
})
@@ -159,7 +159,7 @@ describe('#bch-use-case', () => {
assert.equal(result.success, false)
assert.equal(result.status, 422)
assert.equal(result.endpoint, 'transaction')
assert.equal(result.endpoint, 'txData')
assert.equal(
result.message,
'Input txids must be an array of transaction IDs.'
@@ -183,7 +183,7 @@ describe('#bch-use-case', () => {
assert.equal(result.success, false)
assert.equal(result.status, 422)
assert.equal(result.endpoint, 'transaction')
assert.equal(result.endpoint, 'txData')
assert.equal(result.message, 'Array input must be 20 elements or less.')
})
@@ -208,7 +208,7 @@ describe('#bch-use-case', () => {
assert.equal(result.success, false)
assert.equal(result.status, 422)
assert.equal(result.endpoint, 'transaction')
assert.equal(result.endpoint, 'txData')
assert.equal(result.message, 'test error')
})
})