3.0.3 • Published 2 months ago

@glif/filecoin-number v3.0.3

Weekly downloads
333
License
(Apache-2.0 OR MI...
Repository
github
Last release
2 months ago

Filecoin number

A wrapper class built around javascript's bignumber. Most questions are best answered from the bignumber readme and docs.

FilecoinNumber Usage

import { FilecoinNumber, Converter } from '@glif/filecoin-number'

// pass a valid bignumber argument, and a denomination ('fil', 'picofil', or 'attofil') to the constructor.
const filecoinNumber = new FilecoinNumber('10000', 'attofil')

// filecoinNumber is an instance of BigNumber, so you can use it as such
filecoinNumber.multiply(7)

// it comes with 2 additional instance methods for showing the filecoin number as a string in attofil or fil
const inPicoFil = filecoinNumber.toPicoFil()
const inAttoFil = filecoinNumber.toAttoFil()
const inFil = filecoinNumber.toFil()

Converter Usage

// Use the Converter to convert currencies
const optionalConfig = {
  apiURL: 'https://coinmarketproxy.com',
  apiKey: 'RIP Kobe',
}

const USDConverter = new Converter('USD', optionalConfig)

await USDConverter.cacheConversionRate()

const USD = USDConverter.fromFIL(1)
const FIL = USDConverter.toFIL(1)

// fromFIL and toFIL take numbers, strings, BigNumbers, and FilecoinNumbers as valid args
const USD = USDConverter.fromFIL(1)
const USD = USDConverter.fromFIL('1')
const USD = USDConverter.fromFIL(new BigNumber(1))
const USD = USDConverter.fromFIL(new FilecoinNumber('1', 'fil'))

Running tests locally

We use an APIADDR environment variable in the tests. You can either: (a) add the APIADDR environment variable locally, or (b) use a secrets.js file to export private information

3.0.3

2 months ago

3.0.2

3 months ago

3.0.0

4 months ago

2.0.74

5 months ago

2.0.71

5 months ago

2.0.72

5 months ago

2.0.70

7 months ago

2.0.68

9 months ago

2.0.69

9 months ago

2.0.67

11 months ago

2.0.66

11 months ago

2.0.64

11 months ago

2.0.65

11 months ago

2.0.62

11 months ago

2.0.63

11 months ago

2.0.60

12 months ago

2.0.57

1 year ago

2.0.56

1 year ago

2.0.53

1 year ago

2.0.54

1 year ago

2.0.51

1 year ago

2.0.52

1 year ago

2.0.50

1 year ago

2.0.39

1 year ago

2.0.48

1 year ago

2.0.49

1 year ago

2.0.47

1 year ago

2.0.45

1 year ago

2.0.34

1 year ago

2.0.5

2 years ago

2.0.1

2 years ago

2.0.0-beta.16

2 years ago

2.0.0-alpha.11

2 years ago

2.0.0-alpha.10

2 years ago

2.0.0-beta.0

2 years ago

2.0.0-alpha.13

2 years ago

1.1.0

3 years ago

1.1.0-beta.19

3 years ago

1.1.0-beta.17

3 years ago

1.1.0-beta.14

3 years ago

1.1.0-beta.11

3 years ago

1.1.0-beta.10

3 years ago

1.1.0-beta.9

3 years ago

1.1.0-beta.7

3 years ago

1.1.0-beta.2

3 years ago

1.1.0-beta.1

3 years ago

1.1.0-beta.0

3 years ago

1.0.0-beta.5

4 years ago

1.0.0-beta.1

4 years ago

1.0.0-lerna.4

4 years ago

1.0.0-lerna.2

4 years ago