Coder Social home page Coder Social logo

medibloc / panacea-js Goto Github PK

View Code? Open in Web Editor NEW
5.0 7.0 1.0 996 KB

Official client-side JavaScript library for the MediBloc platform.

License: Apache License 2.0

JavaScript 0.17% TypeScript 99.45% Shell 0.38%
blockchain sdk panacea medibloc

panacea-js's Introduction

Panacea Javascript SDK

The panacea-js is the official Panacea Javascript SDK written in Typescript, powered by CosmJS.

The panacea-js extends the CosmJS in order to provide Panacea-specific features (AOL, DID, and so on). So, it exposes CosmJS basic functions as they are, such as connectWithSigner and sendTokens.

Usage

Installation

yarn add @medibloc/panacea-js \
  @cosmjs/[email protected] \
  @cosmjs/[email protected] \
  [email protected]

Examples

A list of examples can be found at the example.md.

Contribution

Install dependencies and build the project.

yarn install
yarn build

To run simple unit tests,

yarn test

To run integration tests with panacea-core, start a panacea-core daemon first.

docker run --rm -d \
  -e CHAIN_ID="chain-1" \
  -e MNEMONIC="..." \
  -p 26657:26657 \
  -v $(pwd)/scripts:/root/scripts \
  --name core \
  ghcr.io/medibloc/panacea-core:master \
  bash /root/scripts/panacea-core/init.sh

Then, the integration tests can be run with the following environment variables.

PANACEAD_ENABLED=true \
TENDERMINT_URL="http://localhost:26657" \
CHAIN_ID="chain-1" \
MNEMONIC="..." \
yarn test

For more details, please see the CI script.

License

Apache-2.0 License

panacea-js's People

Contributors

cl9200 avatar dependabot[bot] avatar eunsol-lee avatar ggomma avatar gyuguen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ngvalidator

panacea-js's Issues

Need a way to check if TxResponse is successful

BroadcastReq req = new BroadcastReq(tx, "block");
TxResponse res = client.broadcast(req);

When the broadcast mode is block, the TxResponse could contain an error message if tx is failed:

TxResponse[height=0,txHash=34CD44AD255B896F8B9C34EE89E00E0C8E3A7B305BF825515BD88174E07E1239,code=4,data=<null>,rawLog={"codespace":"sdk","code":4,"message":"signature verification failed; verify correct account sequence and chain-id"},info=<null>,gasWanted=<null>,gasUsed=20421,codespace=<null>,timestamp=<null>,tx=<null>]

If it's not okay to make broadcast() throws an Exception in this case, we need to provide the way to check if tx was successful, at least.

Wrap responses using proper classes

Except DID operations, all responses are Javascript plain objects.
It's not good to handle breaking changes from CosmosSDK REST API. Also, it's not good for usability.

Define proper Typescript classes and wrap all responses.

Web3 Keystore compatibility

There is already a TODO:

// TODO @ggomma check compatibility with old panacea-js

This code uses

However, Web3 Secret Storage Definition says the cipher algorithm should be aes-128-ctr, not aes-256-ctr.

All minimally-compliant implementations must support the AES-128-CTR algorithm

On the contrary, panacea-core uses

I would suggest that the cipher algorithm of panacea-js should be replaced with aes-128-ctr.
Also, for the compatibility with panacea-core, we need to decided the KDF (pbkdf2 vs scrypt).

If panacea-js has being used for many services, the backward-compatibility would be a critical issue.
If it's the problem, I can modify panacea-core because the keystore is used only for DID in panacea-core. There's no backward-compatibility issue. But still, the cipher algorithm should be aes-128-ctr.

Migrate to Typescript

Tx Messages are getting complicated, especially DID stuff.
For better/safe maintainability, I'd suggest to migration from Javascript to Typescript.

The code base is not small. So, let's start with small stuff by keeping the backward-compatibility.
For example, most class constructors are accepting an any or a Record<string,any>.
We might need to keep them as they are, because some clients are using those constructors.

Behind the scene, we can prepare the ultimate type-safe version gradually.
Then, we can deploy the brand-new version when it's ready.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.