Coder Social home page Coder Social logo

magiziz / encointer-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from encointer/encointer-js

0.0 1.0 0.0 564 KB

javascript npm packages for encointer

License: GNU General Public License v3.0

JavaScript 4.11% TypeScript 95.60% Nix 0.29%

encointer-js's Introduction

Encointer JS

Encointer JavaScript API monorepo

Contains

Installation

yarn add @encointer/node-api @encointer/worker-api

Usage example

import { EncointerWorker } from '@encointer/worker-api';
import { options } from '@encointer/node-api'

import { ApiPromise } from '@polkadot/api';
import { WsProvider } from '@polkadot/rpc-provider';

communityId = '3LjCHdiNbNLKEtwGtBf6qHGZnfKFyjLu9v3uxVgDL35C';

/// In async function
// connect to Encointer node
const api = await ApiPromise.create({
    ...options({
        /// additional types
    }),
    provider: new WsProvider(nodeAddr)
});

// Get first worker endpoint from registry
const workerEndpoint = await api.query.substrateeRegistry.enclaveRegistry(1)

// Create worker
const worker = new EncointerWorker(workerEndpoint, { api });

// Get public data from worker
const total = await worker.getTotalIssuance(communityId);

console.log('Total issuance:', total);

const bob = keyring.addFromUri('//Bob', { name: 'Bob default' });

// Query balance from worker
const balance = worker.getBalance(bob, communityId);

console.log('Bob owns:', balance);

Publish to npm

// will prompt you to select version to increase, e.g. major, minor, patch etc. (Creates git tag!)
lerna version --force-publish

// apply changes from package.json to */build/package.json 
yarn build

// publish all changes from the build directory to npm
lerna publish from-package --contents build

The lerna commands have been added as scripts to the package.json.

WARN When the packages are linked in the js_encointer_service and yarn install is run, it will create a node_modules folder inside the build folder. Do NOT publish this one. However, with the above sequence, this will be fine, as yarn build cleans the build directory first.

encointer-js's People

Contributors

demyanrogozhin avatar clangenb avatar brenzi avatar

Watchers

James Cloos avatar

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.