4.0.7 • Published 10 months ago

@defichain/jellyfish-api-core v4.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@defichain/jellyfish-api-core

@defichain/jellyfish-api-core is a protocol agnostic DeFiChain client implementation with APIs separated into their category.

Features

  • Promise<T> first implementation to prevent callback hell.
  • Numeric precision aware JSON parsing with options of lossless, bignumber or number.
  • Implementation in TypeScript with strongly typed interfaces and exported as *.d.ts too.
  • Raw RPC call is available with client.call('getbalance', [], 'bignumber')

Usage Example

const result = await client.mining.getMiningInfo()
// or
client.mining.getMiningInfo().then((result) => {
  console.log(result)
}).catch((err) => {
  console.log('panic!')
}).finally(() => {
  console.log('cleanup')
})

Development

ApiClient being an abstract class allows the ability to adapt to any protocol when introduced (e.g. ws, https) while being simple to use. This implementation structure can be observed in ContainerAdapterClient where it is used to test jellyfish-api-core implementations.

RPC categories are grouped into jellyfish-api-core/src/category/*.ts (e.g. category/mining.ts) this allows a protocol agnostic implementation of the RPC. All concerns are grouped within one ts file for better developer experience of browsing and maintaining the code.

ApiError encapsulate RPC errors from DeFiChain within a structure. This allows for instanceof or type of error handling with rich structure.

JellyfishJSON allows parsing of JSON with 'lossless', 'bignumber' and 'number' numeric precision.

  • 'lossless' uses LosslessJSON that parses numeric values as LosslessNumber. With LosslessNumber, one can perform regular numeric operations, and it will throw an error when this would result in losing information.
  • 'bignumber' parse all numeric values as 'BigNumber' using bignumber.js library.
  • 'number' parse all numeric values as 'Number' and precision will be loss if it exceeds IEEE-754 standard.
  • 'PrecisionPath' provides path based precision mapping, specifying 'bignumber' will automatically map all Number in that path as 'bignumber'. Otherwise, it will default to number, This applies deeply.

Testing

jest

As the RPC is implemented on jellyfish-api-core, all testing of RPC implementation should be done on jellyfish-api-core. ContainerAdapterClient is created to facilitate testing via an adapter implementation with all RPCs proxied into a @defichain/testcontainers.

4.0.7

10 months ago

4.0.6

11 months ago

4.0.5

1 year ago

4.0.0-beta.11.1

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

3.37.0

1 year ago

4.0.0-beta.14.1

1 year ago

4.0.0-beta.5

1 year ago

4.0.0-beta.4

1 year ago

4.0.0-beta.3

1 year ago

3.34.0

1 year ago

4.0.0-rc.1.2

1 year ago

4.0.0-rc.1.1

1 year ago

4.0.0-beta.14

1 year ago

4.0.0-beta.11

1 year ago

4.0.0-beta.10

1 year ago

4.0.0-rc.1

1 year ago

4.0.0-beta10.1

1 year ago

3.39.1

1 year ago

3.33.0

1 year ago

3.32.0

2 years ago

3.31.1

2 years ago

3.31.0

2 years ago

3.30.2

2 years ago

3.30.3

2 years ago

3.30.4

2 years ago

3.29.3

2 years ago

3.29.2

2 years ago

3.30.0

2 years ago

3.30.1

2 years ago

3.29.1

2 years ago

3.29.0

2 years ago

3.24.0

2 years ago

3.24.2

2 years ago

3.24.1

2 years ago

3.14.0

2 years ago

3.13.0

2 years ago

3.25.0

2 years ago

3.22.0

2 years ago

3.19.0

2 years ago

3.19.1

2 years ago

3.23.1

2 years ago

3.23.0

2 years ago

3.23.2

2 years ago

3.20.0

2 years ago

3.20.1

2 years ago

3.17.0

2 years ago

3.28.0

2 years ago

3.28.2

2 years ago

3.28.1

2 years ago

3.21.1

2 years ago

3.21.0

2 years ago

3.21.2

2 years ago

3.18.0

2 years ago

3.15.0

2 years ago

3.26.0

2 years ago

3.26.2

2 years ago

3.26.1

2 years ago

3.16.0

2 years ago

3.27.0

2 years ago

2.69.0

2 years ago

3.2.0

2 years ago

3.12.0

2 years ago

2.68.0

2 years ago

3.1.0

2 years ago

3.9.0

2 years ago

2.70.0

2 years ago

3.10.1

2 years ago

3.8.0

2 years ago

3.10.0

2 years ago

3.0.0

2 years ago

3.11.0

2 years ago

3.7.1

2 years ago

3.7.0

2 years ago

3.6.1

2 years ago

3.6.0

2 years ago

3.5.3

2 years ago

3.5.2

2 years ago

3.5.1

2 years ago

3.5.0

2 years ago

3.4.0

2 years ago

3.4.1

2 years ago

3.3.0

2 years ago

2.67.0

2 years ago

2.67.1

2 years ago

2.67.2

2 years ago

2.66.0

2 years ago

2.65.0

2 years ago

2.64.1

2 years ago

2.57.0

2 years ago

2.57.1

2 years ago

2.60.0

2 years ago

2.56.0

2 years ago

2.56.1

2 years ago

2.55.0

2 years ago

2.55.1

2 years ago

2.54.5

2 years ago

2.64.0

2 years ago

2.63.0

2 years ago

2.59.0

2 years ago

2.62.0

2 years ago

2.58.0

2 years ago

2.61.0

2 years ago

2.46.0

3 years ago

2.53.0

2 years ago

2.49.0

2 years ago

2.52.1

2 years ago

2.52.2

2 years ago

2.52.0

2 years ago

2.45.11

3 years ago

2.48.0

2 years ago

2.51.0

2 years ago

2.47.0

3 years ago

2.47.1

3 years ago

2.54.0

2 years ago

2.54.1

2 years ago

2.54.2

2 years ago

2.50.0

2 years ago

2.54.3

2 years ago

2.54.4

2 years ago

2.45.9

3 years ago

2.45.6

3 years ago

2.45.5

3 years ago

2.45.8

3 years ago

2.45.7

3 years ago

2.45.4

3 years ago

2.45.10

3 years ago

2.45.0

3 years ago

2.45.2

3 years ago

2.45.1

3 years ago

2.45.3

3 years ago

2.44.0

3 years ago

2.43.0

3 years ago

2.42.5

3 years ago

2.42.4

3 years ago

2.42.6

3 years ago

2.38.0

3 years ago

2.41.0

3 years ago

2.37.0

3 years ago

2.40.0

3 years ago

2.36.0

3 years ago

2.39.0

3 years ago

2.35.0

3 years ago

2.42.1

3 years ago

2.42.0

3 years ago

2.42.3

3 years ago

2.42.2

3 years ago

2.34.0

3 years ago

2.33.0

3 years ago

2.32.0

3 years ago

2.32.1

3 years ago

2.31.1

3 years ago

2.30.0

3 years ago

2.29.0

3 years ago

2.31.0

3 years ago

2.27.0

3 years ago

2.22.0

3 years ago

2.26.0

3 years ago

2.21.2

3 years ago

2.21.1

3 years ago

2.25.0

3 years ago

2.25.2

3 years ago

2.25.1

3 years ago

2.28.4

3 years ago

2.28.1

3 years ago

2.28.0

3 years ago

2.28.3

3 years ago

2.28.2

3 years ago

2.24.0

3 years ago

2.23.0

3 years ago

2.11.0

3 years ago

2.19.0

3 years ago

2.15.0

3 years ago

2.10.1

3 years ago

2.18.3

3 years ago

2.18.1

3 years ago

2.18.2

3 years ago

2.18.0

3 years ago

2.14.1

3 years ago

2.10.5

3 years ago

2.14.2

3 years ago

2.10.3

3 years ago

2.14.0

3 years ago

2.10.4

3 years ago

2.21.0

3 years ago

2.17.0

3 years ago

2.17.1

3 years ago

2.13.0

3 years ago

2.20.0

3 years ago

2.12.0

3 years ago

2.16.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

0.55.0

3 years ago

2.8.0

3 years ago

2.0.0

3 years ago

2.9.1

3 years ago

2.3.0

3 years ago

2.10.0

3 years ago

2.7.0

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.2.0

3 years ago

2.6.0

3 years ago

2.7.3

3 years ago

2.1.1

3 years ago

2.5.0

3 years ago

2.9.0

3 years ago

0.54.1

3 years ago

2.1.0

3 years ago

0.51.0

3 years ago

0.54.0

3 years ago

0.52.0

3 years ago

0.50.0

3 years ago

0.49.2

3 years ago

0.49.5

3 years ago

0.49.3

3 years ago

0.49.4

3 years ago

0.49.1

3 years ago

0.49.0

3 years ago

0.48.1

3 years ago

0.46.2

3 years ago

0.46.0

3 years ago

0.46.1

3 years ago

0.47.1

3 years ago

0.47.0

3 years ago

0.45.3

3 years ago

0.45.2

3 years ago

0.45.1

3 years ago

0.45.0

3 years ago

0.44.0

3 years ago

0.43.0

3 years ago

0.41.0

3 years ago

0.42.0

3 years ago

0.40.0

3 years ago

0.39.0

3 years ago

0.38.0

3 years ago

0.37.0

3 years ago

0.36.0

3 years ago

0.34.3

3 years ago

0.35.0

3 years ago

0.34.2

3 years ago

0.34.1

3 years ago

0.34.0

3 years ago

0.33.0

3 years ago

0.32.0

3 years ago

0.31.0

3 years ago

0.30.0

3 years ago

0.29.1

3 years ago

0.29.0

3 years ago

0.28.0

3 years ago

0.27.0

3 years ago

0.26.0

3 years ago

0.25.0

3 years ago

0.24.0

3 years ago

0.23.0

3 years ago

0.22.0

3 years ago

0.21.0

3 years ago

0.20.0

3 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.17.0

4 years ago

0.15.0

4 years ago

0.16.0

4 years ago

0.11.0

4 years ago

0.10.1

4 years ago

0.12.0

4 years ago

0.13.0

4 years ago

0.14.0

4 years ago

0.9.0

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.23

4 years ago

0.0.24

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.1.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.0.11

4 years ago