Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added jsdoc, several tests and fix errors #3

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"semi": "error"
}
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
**/node_modules
.nyc_output/
coverage/
jsdoc/

.DS_Store
yarn.lock
package-lock.json
error.log
combined.log
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ Supported Rosetta Protocol Version: 1.4.1

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.

⚠️ WARNING ⚠️
Due to the lack of funding, I wasn't able to continue the work on `rosetta-node-sdk`.

## Motivation
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.

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

### ToDos
- [ ] Setup CI (`npm run test` will execute 313 tests)
- [ ] Setup CI (`npm run test` will execute 358 tests)
- [ ] Support `keys` (cryptographic API)
- [ ] Documentation
- [ ] Test Reconciler in live environment
16 changes: 16 additions & 0 deletions conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"plugins": [],
"recurseDepth": 10,
"source": {
"includePattern": "^(?!.*\\.(spec|test)\\.js$).*\\.js$"
},
"sourceType": "module",
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc","closure"]
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
}
}
2 changes: 1 addition & 1 deletion examples/basic/fetcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ const main = (async function () {

main().catch(e => {
console.error(e);
})
});
4 changes: 2 additions & 2 deletions examples/serverSkeleton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

const RosettaSDK = require('../../..');
const RosettaSDK = require('../../');

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

Expand Down Expand Up @@ -52,4 +52,4 @@ Server.register('/construction/derive', ServiceHandlers.Construction.constructio
Server.register('/construction/hash', ServiceHandlers.Construction.constructionHash);
Server.register('/construction/parse', ServiceHandlers.Construction.constructionParse);
Server.register('/construction/payloads', ServiceHandlers.Construction.constructionPayloads);
Server.register('/construction/preprocess', ServiceHandlers.Construction.constructionPreprocess);
Server.register('/construction/preprocess', ServiceHandlers.Construction.constructionPreprocess);
6 changes: 3 additions & 3 deletions examples/serverSkeleton/services/BlockService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

const RosettaSDK = require('../../../..');
const RosettaSDK = require('../../../');

/* Data API: Block */

/**
* Get a Block
* 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.
*
* blockRequest BlockRequest
* blockRequest BlockRequest
* returns BlockResponse
* */
const block = async (params) => {
Expand All @@ -39,7 +39,7 @@ const block = async (params) => {
* Get a Block Transaction
* 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).
*
* blockTransactionRequest BlockTransactionRequest
* blockTransactionRequest BlockTransactionRequest
* returns BlockTransactionResponse
* */
const blockTransaction = async (params) => {
Expand Down
8 changes: 4 additions & 4 deletions examples/serverSkeleton/services/ConstructionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

const RosettaSDK = require('../../../..');
const RosettaSDK = require('../../../');

/* Data API: Construction */

/**
* Get Transaction Construction Metadata
* 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.
*
* constructionMetadataRequest ConstructionMetadataRequest
* constructionMetadataRequest ConstructionMetadataRequest
* returns ConstructionMetadataResponse
* */
const constructionMetadata = async (params) => {
Expand All @@ -39,7 +39,7 @@ const constructionMetadata = async (params) => {
* Submit a Signed Transaction
* 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.
*
* constructionSubmitRequest ConstructionSubmitRequest
* constructionSubmitRequest ConstructionSubmitRequest
* returns ConstructionSubmitResponse
* */
const constructionSubmit = async (params) => {
Expand Down Expand Up @@ -142,5 +142,5 @@ module.exports = {
constructionPayloads,

/* /construction/preprocess */
constructionPreprocess,
constructionPreprocess,
};
6 changes: 3 additions & 3 deletions examples/serverSkeleton/services/MempoolService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

const RosettaSDK = require('../../../..');
const RosettaSDK = require('../../../');

/* Data API: Mempool */

/**
* Get All Mempool Transactions
* Get all Transaction Identifiers in the mempool
*
* mempoolRequest MempoolRequest
* mempoolRequest MempoolRequest
* returns MempoolResponse
* */
const mempool = async (params) => {
Expand All @@ -39,7 +39,7 @@ const mempool = async (params) => {
* Get a Mempool Transaction
* 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.
*
* mempoolTransactionRequest MempoolTransactionRequest
* mempoolTransactionRequest MempoolTransactionRequest
* returns MempoolTransactionResponse
* */
const mempoolTransaction = async (params) => {
Expand Down
8 changes: 4 additions & 4 deletions examples/serverSkeleton/services/NetworkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

const RosettaSDK = require('../../../..');
const RosettaSDK = require('../../../');


/* Data API: Network */
Expand All @@ -28,7 +28,7 @@ const RosettaSDK = require('../../../..');
* Get List of Available Networks
* This endpoint returns a list of NetworkIdentifiers that the Rosetta server can handle.
*
* metadataRequest MetadataRequest
* metadataRequest MetadataRequest
* returns NetworkListResponse
* */
const networkList = async (params) => {
Expand All @@ -40,7 +40,7 @@ const networkList = async (params) => {
* Get Network Options
* 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.
*
* networkRequest NetworkRequest
* networkRequest NetworkRequest
* returns NetworkOptionsResponse
* */
const networkOptions = async (params) => {
Expand All @@ -52,7 +52,7 @@ const networkOptions = async (params) => {
* Get Network Status
* This endpoint returns the current status of the network requested. Any NetworkIdentifier returned by /network/list should be accessible here.
*
* networkRequest NetworkRequest
* networkRequest NetworkRequest
* returns NetworkStatusResponse
* */
const networkStatus = async (params) => {
Expand Down
Loading