npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@q-dev/q-js-sdk

v2.0.0-rc.21

Published

Typescript Library to interact with Q System Contracts

Downloads

34

Readme

DocumentationSystem ContractsQ Blockchain

npm npm min zipped size license pipeline status

Installation

Install package as dependency:

npm install --save @q-dev/q-js-sdk

or

yarn add @q-dev/q-js-sdk

Requirements

Usage

Initialize contract registry:

const contractRegistry = new ContractRegistryInstance(web3)

Retrieve SDK version

import { Web3Adapter, Web3Factory, Web3 } from '@q-dev/q-js-sdk'

const web3 = Web3Factory.createFromMnemonic('<YOUR_RPC_URL>', '<MNEMONIC>')
const adapter = new Web3Adapter(web3)
const SDK_VERSION = adapter.SDK_VERSION

Obtain system contract instances

const validators = await contractRegistry.validators()

Call contract getter

const longList = await validators.getLongList()

Submit contract transaction

To be able to process various transaction events, use PromiEvent

const { promiEvent } = await validators.commitStake({from: '<USER_ADDRESS>', value: '<COMMIT_AMOUNT>'})
/**
 * We do not wait for the transaction to complete. 
 * This gives us the opportunity to subscribe to PromiEvent events
 */
promiEvent
  .once('sending', (payload) => { ... })
  .once('sent', (payload) => { ... })
  .once('transactionHash', (hash) => { ... })
  .once('receipt', (receipt) => { ... })
  .on('confirmation', (confNumber, receipt, latestBlockHash) => { ... })
  .on('error', (error) => { ... })

await promiEvent

Local development

Install packages

npm install

Generate types

npm run generate-types

If generate-types indicates 0 matching files (on Windows machines) you can try the adapted script npm run generate-types-win

Contribute

Make sure to run pre-commit script before commit

npm run pre-commit

You may check conformity between system-contracts and sdk via abi-conformity-check. But remember, we don't need all methods from each contract. Most of them are used by the system.

npm run abi-conformity-check

Update ABI files

Download latest abi files, for a specific system contracts tag:

  • Devnet
  • Master
  • Custom tag: https://gitlab.com/q-dev/system-contracts/-/jobs/artifacts/<TAG_NAME>/download?job=extract-abi

Then call

./update-abis.sh <path/to/abi.zip>

Run tests

You may run tests via

npm run test

Get access to private Gitlab registry

Log in to GitLab NPM package registry. You need a gitlab personal access token with read_api option enabled. This can be created via GitLab User Settings / Access Tokens.

npm config set '//gitlab.com/api/v4/packages/npm/:_authToken' <YOUR_ACCESS_TOKEN>

Furthermore you need to tell npm that all q-dev packages should be resolved via private gitlab registry. Create a file .npmrc with the following content:

@q-dev:registry=https://gitlab.com/api/v4/packages/npm/

Code of Conduct

This project and everyone participating in it is governed by the Q JS SDK Code of Conduct. By participating, you are expected to uphold this code.

Resources

License

LGPL-3.0