2.0.0-rc.21 • Published 5 months ago

@q-dev/q-js-sdk v2.0.0-rc.21

Weekly downloads
-
License
LGPL-3.0
Repository
-
Last release
5 months ago

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:

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

2.0.0-rc.21

5 months ago

2.0.0-rc.20

7 months ago

2.0.0-rc.19

7 months ago

2.0.0-rc.18

7 months ago

2.0.0-rc.2

11 months ago

2.0.0-rc.3

11 months ago

2.0.0-rc.17

7 months ago

2.0.0-rc.4

11 months ago

2.0.0-rc.5

11 months ago

2.0.0-rc.16

7 months ago

2.0.0-rc.13

9 months ago

2.0.0-rc.0

11 months ago

2.0.0-rc.14

7 months ago

2.0.0-rc.1

11 months ago

2.0.0-rc.11

10 months ago

2.0.0-rc.12

9 months ago

1.7.0

11 months ago

1.5.2

11 months ago

1.6.0

11 months ago

1.5.1

11 months ago

1.5.0

11 months ago

2.0.0-rc.6

11 months ago

2.0.0-rc.7

11 months ago

2.0.0-rc.8

11 months ago

2.0.0-rc.9

11 months ago

1.4.0

2 years ago

1.0.0

3 years ago

0.9.5

3 years ago