Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@muirglacier/jellyfish-api-core

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@muirglacier/jellyfish-api-core

A collection of TypeScript + JavaScript tools and libraries for DeFi Blockchain developers to build decentralized finance for Bitcoin

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

@muirglacier/jellyfish-api-core

@muirglacier/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 @muirglacier/testcontainers.

Keywords

FAQs

Package last updated on 10 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc