6.16.0-tokens-7 • Published 2 years ago

@jachaval/statics v6.16.0-tokens-7

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Goals

  • Provide an "encyclopedia" of all relevant constants which are sprinkled throughout the BitGo stack.
  • Separate static config data from dynamic config data
  • Strong typing for static config properties, with full type information for configuration items
  • Ability to export static configuration as JSON for consumption by non-javascript projects

Examples

Get the number of decimal places in a Bitcoin

JavaScript

const { coins } = require('@bitgo/statics');

const btc = coins.get('btc');
console.log(btc.decimalPlaces);

TypeScript

import { coins } from '@bitgo/statics';

const btc = coins.get('btc');
console.log(btc.decimalPlaces);

Get the contract address for the OmiseGo ERC20 Token

JavaScript

const { coins } = require('@bitgo/statics');

const omg = coins.get('omg');
console.log(omg.contractAddress);

TypeScript

import { coins, Erc20Coin } from '@bitgo/statics';

const omg = coins.get('omg');
if (omg instanceof Erc20Coin) {
  console.log(omg.contractAddress);
}

List full names of all defined coins

JavaScript

const { coins } = require('@bitgo/statics');

coins.forEach((coin) => {
  console.log(coin.fullName);
});

TypeScript

import { coins } from '@bitgo/statics';

coins.forEach((coin) => {
  console.log(coin.fullName);
});

Repo Status

  • UTXO and account base types are defined
  • Documentation is mostly source code comments and README examples
  • This library can be depended on, but expect some changes going forward

Project Structure

  • src/base.ts: Interfaces and enums used by coin implementation classes.
  • src/coins.ts: Coin definitions.
  • src/networks.ts: Network interfaces and implementation classes.
  • src/utxo.ts: Unspent Transaction Output (UTXO) based coin classes and factory function.
  • src/account.ts: Account-based coin classes and factory methods. Includes ERC20 factory functions.
  • src/errors.ts: Custom Error classes.

Installation + Building

To install the project locally, run the following steps:

$ # clone the project locally
$ git clone git@github.com:BitGo/statics.git

$ # npm install dependencies (optionally use node >8.6.0)
$ # (optionally) nvm install 8.6.0 -- required to run the linter which is executed pre-commit
$ # (optionally) nvm use 8.6.0
$ npm install

To build the project (from TypeScript to JavaScript):

$ npm run build

This builds the JavaScript and adds it to dist/src/. You will receive compilation errors if you have invalid syntax.

Tests

To run tests:

$ npm run test
6.16.0-tokens-6

2 years ago

6.16.0-tokens-7

2 years ago

6.16.0-tokens-2

2 years ago

6.16.0-tokens-1

2 years ago

6.16.0-tokens-4

2 years ago

6.15.0-tokens-2

2 years ago

6.15.0-tokens-1

2 years ago

6.15.0-stx-4

2 years ago

6.15.0-stx-3

2 years ago

6.15.0-stx-2

2 years ago

6.15.0-stx-1

2 years ago

6.15.0-avax-1

2 years ago

6.15.0-cspr-1

2 years ago

6.15.0-cspr-2

2 years ago

6.15.0-cspr-3

2 years ago

6.14.0-rc-2

3 years ago

6.14.0-rc-3

3 years ago

6.14.0-rc-4

3 years ago

6.12.0-rc-1

3 years ago

6.13.0-rc-2

3 years ago

6.13.0-rc-3

3 years ago

6.13.0-bs-1

3 years ago

6.13.0-rc-4

3 years ago

6.12.0-rc-0

3 years ago

6.12.0-beta-11

3 years ago

6.12.0-beta-10

3 years ago

6.12.0-beta-9

3 years ago

6.12.0-beta-8

3 years ago

6.12.0-beta-6

3 years ago

6.12.0-beta-4

3 years ago

6.12.0-beta-3

3 years ago

6.12.0-beta-5

3 years ago

6.12.0-beta-2

3 years ago

6.12.0-beta-1

3 years ago

6.11.0-beta-5

3 years ago

6.11.0-beta-4

3 years ago

6.11.0-beta-3

3 years ago

6.9.0-beta-1

3 years ago