Skip to content

Commit b116762

Browse files
authored
Merge pull request #3 from elli-kolisnichenko/1.4.1
Added jsdoc, several tests and fix errors
2 parents 276216c + 7bd6902 commit b116762

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3479
-5513
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2+
"parser": "babel-eslint",
23
"parserOptions": {
34
"ecmaVersion": 8,
45
"sourceType": "module"
56
},
67
"rules": {
78
"semi": "error"
89
}
9-
}
10+
}

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
**/node_modules
2+
.nyc_output/
3+
coverage/
4+
jsdoc/
5+
6+
.DS_Store
7+
yarn.lock
8+
package-lock.json
9+
error.log
10+
combined.log

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ Supported Rosetta Protocol Version: 1.4.1
2020

2121
This project is a port of the official Go reference implementation. All features, except a [few exceptions](docs/api_limitations.md), have been ported to JS.
2222

23-
⚠️ WARNING ⚠️
24-
Due to the lack of funding, I wasn't able to continue the work on `rosetta-node-sdk`.
25-
2623
## Motivation
2724
Coinbase's [Official Go Reference Implementation](https://github.com/coinbase/rosetta-sdk-go.git) is a thouroughly tested and wonderful SDK Implementation. However, as many developers are better suited to use NodeJS/Javascript, DigiByte decided to port the reference implementation to NodeJS while maintaining support for all it's core components.
2825

@@ -82,7 +79,6 @@ const {
8279
- **version** - Specifies the version of this SDK. This semver is equal to the Rosetta API SDK for convencience.
8380

8481
### ToDos
85-
- [ ] Setup CI (`npm run test` will execute 313 tests)
82+
- [ ] Setup CI (`npm run test` will execute 358 tests)
8683
- [ ] Support `keys` (cryptographic API)
87-
- [ ] Documentation
8884
- [ ] Test Reconciler in live environment

conf.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"plugins": [],
3+
"recurseDepth": 10,
4+
"source": {
5+
"includePattern": "^(?!.*\\.(spec|test)\\.js$).*\\.js$"
6+
},
7+
"sourceType": "module",
8+
"tags": {
9+
"allowUnknownTags": true,
10+
"dictionaries": ["jsdoc","closure"]
11+
},
12+
"templates": {
13+
"cleverLinks": false,
14+
"monospaceLinks": false
15+
}
16+
}

examples/basic/fetcher/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ const main = (async function () {
5454

5555
main().catch(e => {
5656
console.error(e);
57-
})
57+
});

examples/serverSkeleton/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../../..');
22+
const RosettaSDK = require('../../');
2323

2424
const ServiceHandlers = require('./services');
2525

@@ -52,4 +52,4 @@ Server.register('/construction/derive', ServiceHandlers.Construction.constructio
5252
Server.register('/construction/hash', ServiceHandlers.Construction.constructionHash);
5353
Server.register('/construction/parse', ServiceHandlers.Construction.constructionParse);
5454
Server.register('/construction/payloads', ServiceHandlers.Construction.constructionPayloads);
55-
Server.register('/construction/preprocess', ServiceHandlers.Construction.constructionPreprocess);
55+
Server.register('/construction/preprocess', ServiceHandlers.Construction.constructionPreprocess);

examples/serverSkeleton/services/BlockService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../../../..');
22+
const RosettaSDK = require('../../../');
2323

2424
/* Data API: Block */
2525

2626
/**
2727
* Get a Block
2828
* Get a block by its Block Identifier. If transactions are returned in the same call to the node as fetching the block, the response should include these transactions in the Block object. If not, an array of Transaction Identifiers should be returned so /block/transaction fetches can be done to get all transaction information.
2929
*
30-
* blockRequest BlockRequest
30+
* blockRequest BlockRequest
3131
* returns BlockResponse
3232
* */
3333
const block = async (params) => {
@@ -39,7 +39,7 @@ const block = async (params) => {
3939
* Get a Block Transaction
4040
* Get a transaction in a block by its Transaction Identifier. This endpoint should only be used when querying a node for a block does not return all transactions contained within it. All transactions returned by this endpoint must be appended to any transactions returned by the /block method by consumers of this data. Fetching a transaction by hash is considered an Explorer Method (which is classified under the Future Work section). Calling this endpoint requires reference to a BlockIdentifier because transaction parsing can change depending on which block contains the transaction. For example, in Bitcoin it is necessary to know which block contains a transaction to determine the destination of fee payments. Without specifying a block identifier, the node would have to infer which block to use (which could change during a re-org). Implementations that require fetching previous transactions to populate the response (ex: Previous UTXOs in Bitcoin) may find it useful to run a cache within the Rosetta server in the /data directory (on a path that does not conflict with the node).
4141
*
42-
* blockTransactionRequest BlockTransactionRequest
42+
* blockTransactionRequest BlockTransactionRequest
4343
* returns BlockTransactionResponse
4444
* */
4545
const blockTransaction = async (params) => {

examples/serverSkeleton/services/ConstructionService.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../../../..');
22+
const RosettaSDK = require('../../../');
2323

2424
/* Data API: Construction */
2525

2626
/**
2727
* Get Transaction Construction Metadata
2828
* Get any information required to construct a transaction for a specific network. Metadata returned here could be a recent hash to use, an account sequence number, or even arbitrary chain state. It is up to the client to correctly populate the options object with any network-specific details to ensure the correct metadata is retrieved. It is important to clarify that this endpoint should not pre-construct any transactions for the client (this should happen in the SDK). This endpoint is left purposely unstructured because of the wide scope of metadata that could be required. In a future version of the spec, we plan to pass an array of Rosetta Operations to specify which metadata should be received and to create a transaction in an accompanying SDK. This will help to insulate the client from chain-specific details that are currently required here.
2929
*
30-
* constructionMetadataRequest ConstructionMetadataRequest
30+
* constructionMetadataRequest ConstructionMetadataRequest
3131
* returns ConstructionMetadataResponse
3232
* */
3333
const constructionMetadata = async (params) => {
@@ -39,7 +39,7 @@ const constructionMetadata = async (params) => {
3939
* Submit a Signed Transaction
4040
* Submit a pre-signed transaction to the node. This call should not block on the transaction being included in a block. Rather, it should return immediately with an indication of whether or not the transaction was included in the mempool. The transaction submission response should only return a 200 status if the submitted transaction could be included in the mempool. Otherwise, it should return an error.
4141
*
42-
* constructionSubmitRequest ConstructionSubmitRequest
42+
* constructionSubmitRequest ConstructionSubmitRequest
4343
* returns ConstructionSubmitResponse
4444
* */
4545
const constructionSubmit = async (params) => {
@@ -142,5 +142,5 @@ module.exports = {
142142
constructionPayloads,
143143

144144
/* /construction/preprocess */
145-
constructionPreprocess,
145+
constructionPreprocess,
146146
};

examples/serverSkeleton/services/MempoolService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../../../..');
22+
const RosettaSDK = require('../../../');
2323

2424
/* Data API: Mempool */
2525

2626
/**
2727
* Get All Mempool Transactions
2828
* Get all Transaction Identifiers in the mempool
2929
*
30-
* mempoolRequest MempoolRequest
30+
* mempoolRequest MempoolRequest
3131
* returns MempoolResponse
3232
* */
3333
const mempool = async (params) => {
@@ -39,7 +39,7 @@ const mempool = async (params) => {
3939
* Get a Mempool Transaction
4040
* Get a transaction in the mempool by its Transaction Identifier. This is a separate request than fetching a block transaction (/block/transaction) because some blockchain nodes need to know that a transaction query is for something in the mempool instead of a transaction in a block. Transactions may not be fully parsable until they are in a block (ex: may not be possible to determine the fee to pay before a transaction is executed). On this endpoint, it is ok that returned transactions are only estimates of what may actually be included in a block.
4141
*
42-
* mempoolTransactionRequest MempoolTransactionRequest
42+
* mempoolTransactionRequest MempoolTransactionRequest
4343
* returns MempoolTransactionResponse
4444
* */
4545
const mempoolTransaction = async (params) => {

examples/serverSkeleton/services/NetworkService.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../../../..');
22+
const RosettaSDK = require('../../../');
2323

2424

2525
/* Data API: Network */
@@ -28,7 +28,7 @@ const RosettaSDK = require('../../../..');
2828
* Get List of Available Networks
2929
* This endpoint returns a list of NetworkIdentifiers that the Rosetta server can handle.
3030
*
31-
* metadataRequest MetadataRequest
31+
* metadataRequest MetadataRequest
3232
* returns NetworkListResponse
3333
* */
3434
const networkList = async (params) => {
@@ -40,7 +40,7 @@ const networkList = async (params) => {
4040
* Get Network Options
4141
* This endpoint returns the version information and allowed network-specific types for a NetworkIdentifier. Any NetworkIdentifier returned by /network/list should be accessible here. Because options are retrievable in the context of a NetworkIdentifier, it is possible to define unique options for each network.
4242
*
43-
* networkRequest NetworkRequest
43+
* networkRequest NetworkRequest
4444
* returns NetworkOptionsResponse
4545
* */
4646
const networkOptions = async (params) => {
@@ -52,7 +52,7 @@ const networkOptions = async (params) => {
5252
* Get Network Status
5353
* This endpoint returns the current status of the network requested. Any NetworkIdentifier returned by /network/list should be accessible here.
5454
*
55-
* networkRequest NetworkRequest
55+
* networkRequest NetworkRequest
5656
* returns NetworkStatusResponse
5757
* */
5858
const networkStatus = async (params) => {

0 commit comments

Comments
 (0)