Skip to content

Typescript SDK to create and interact with Rosetta API implementations.

License

Notifications You must be signed in to change notification settings

fboucquez/rosetta-sdk-typescript

Repository files navigation

Rosetta

Rosetta SDK

Typescript SDK to create and interact with Rosetta API implementations (WORK IN PROGRESS!)

Version Downloads/week License Build Status Coverage Status Api Doc

Overview

The rosetta-sdk-typescript provides an easy to use and extend Express server ready to serve your Rosetta typescript implementation for your blockchain.

Much of the code in this repository is generated from the rosetta-specifications.

Documentation

Before diving into the SDK, we recommend taking a look at the Rosetta API Docs:

Packages

  • OpenApi: Auto-generated Rosetta types, including api clients and server service extension points. Don't modify this code!
  • Client: Low-level communication with any Rosetta server. Main class is RosettaRestClientFactory.
  • Server: Simplified Rosetta API server development. Main class is RosettaServer. This SDK uses and Express server integrated with express-openapi-validator.

This current SDK implementation is not complete, most GO's sdk packages should be implemented in typescript.

Usage

Install this package:

npm install rosetta-sdk-typescript@alpha

The following script shows how to create a Rosetta Express server:

import { RosettaServer } from './server';

// The factory you need to provide that creates the services connecting to your blockchain client/node
const apiServiceFactory = new MyBlockchainApiServiceFactory(); 

new RosettaServer({ apiServiceFactory }).start(8080).catch((e) => {
    console.error(e);
});

The following script shows how to create a Rosetta network client:

import { RosettaRestClientFactory } from 'rosetta-sdk-typescript';

const restClientFactory = new RosettaRestClientFactory({
    url: 'http://localhost:8080',
});

const networkClient = restClientFactory.network();
const networkList = await networkClient.networkList({
    metadataRequest: {},
});
console.log(JSON.stringify(networkList, null, 2));

Development

  • npm install to install dependencies
  • npm run gen to generate types and helpers
  • npm test to run tests
  • npm style:fix to pretty, index, and lint the source code (including generated code)

License

This project is available open source under the terms of the Apache 2.0 License.

© 2021 Fernando Boucquez

About

Typescript SDK to create and interact with Rosetta API implementations.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published