npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@brightunion/sdk

v1.5.9

Published

Brightjs is a set of javascript tools to interact with the Bright Union's risk platform aggregator's protocol on Ethereum, Binance Smart Chain and Polygon blockchains.

Downloads

386

Readme

Bright Union SDK

The Bright Union SDK is a set of javascript utilities that enables an easy integration of the Bright Union's multi-chain protocol into any web project.

This SDK will give you access to the Bright Union aggregator contract that combines risk coverage services from:

A swagger API documentation can be found here.

Prerequisites

  • Node v14+
  • Blockchain client node provider:
    • infura, quicknode, anyblock etc...

Prerequisites for Nexus Quotation

Quotation support for Nexus provider is only allowed by white-listing your URL, please contact us for support and we will add your app to Nexus supported URL's. Not doing so, will cause Nexus quotations throwing 403 error. Other quotations from other providers will load.

Installation

npm install @brightunion/sdk

Available methods

Get the full catalog from all our distributors

getCatalog()

Get quotes from distributors

getQuotes( <amount> , <currency> , <period> , <productId> )

Get a quote from a distributor

getQuoteFrom( <distributorName>, <amount>, <currency>, <period>, <productId>)

Buy previously queried quote

buyQuote(<preExistingQuote>)

Get details on purchased covers from a distributor

getCoversFrom(<DistributorName>)

Get details on purchased covers from all distributors

getAllCovers()

Basic Use

const BrightClient = require('@Brightunion/SDK');

const brightClient= new BrightClient({ <web3_instance> });

// Initialize the client
await brightClient.initialize();

// Get catalog of all risk covers available
const catalog = brightClient.getCatalog();

// Get quotes for a catalog item from all risk providers available
const quotes = brightClient.getQuotes( <amount> , <currency>, <period>, <catalog_item> )

// Buy quoted cover
brightClient.buyQuote( <quote> ).then(data => {
  // Transaction done
})

// Get purchased covers from all distributors
const coversAll = await brightClient.getAllCovers();

Quote and buy a specific cover product

const BrightClient = require('@Brightunion/SDK');B

const brightClient= new BrightClient({ <web3_instance> });

// Initialize the client
await brightClient.initialize();


// Define a Catalog Item from a supported insurance distributor
// INSURACE catalog item example
const catalogItemInsurace = { productId: <Insurace_product_id> };
// BRIDGE catalog item example
const catalogItemBridge = { bridgeProductAddress: <Bridge_product_address> };
// NEXUS catalog item example
const catalogItemNexus = { nexusCoverable: <Nexus_product_address> };

// Get quote from specific distributor on a catalog item
const quote = await brightClient.getQuoteFrom( <distributorName>, <amount> , <currency>, <period>, <catalog_item>);

// Buy quoted cover
brightClient.buyQuote( <quote> ).then(data => {
  // Transaction done
})

Multiple Quotation and Buy

Quote and buy multiple covers in one transaction. Currently supported only for covers from Insurace.


const BrightClient = require('@Brightunion/SDK');B

const brightClient= new BrightClient({ <web3_instance> });

// Initialize the client
await brightClient.initialize();

// Get catalog of all risk covers available
const catalog = brightClient.getCatalog();

// Get  multiple quotes
const quotesArray = await brightClient.getMultipleQuotes([catalog[0], catalog[1], catalog[3]]);
// Buy multiple quotes
await brightClient.buyQuotes(quotesArray).then(data => {
  // Transaction done
});

Provider Network Switch

When provider (Metamask, Trust, WalletConnect etc.) network is switched, new Bright Client should be initialized with the new instance of Web3.


const brightClient= new BrightClient({ <web3_instance> });

// Initialize the client
await brightClient.initialize();

Events

Events are fired before the main function returns the final response

brightClient.events.on(<eventName> , ()=> {})

Events which are currently supported are for methods related to Quotation and Buy

  • "quote"
  • "buy"

Examples of event subscriptions

brightClient.events.on("buy" , (data)=> {})

brightClient.events.on("quote" , (data)=> {})