fallback-falooda 0.1.0
Install from the command line:
Learn more about npm packages
$ npm install @leapwallet/fallback-falooda@0.1.0
Install via package.json:
"@leapwallet/fallback-falooda": "0.1.0"
About this version
This is a JavaScript library that implements a blockchain node fallback system. It currently supports blockchain nodes from the NEAR and Cosmos ecosystem.
- Platforms: Node.js, Browsers supporting ES6 or higher, React Native
- Module systems: ECMAScript Modules
- Programming languages: ES6 (JavaScript, TypeScript, etc. which target ES6 or higher)
- Static types: TypeScript definitions bundled
Here's how it works. When you write a program that uses a blockchain node such as https://rpc.mainnet.near.org
, the program will regularly fail to function as expected because the blockchain node is down, rate limited your program, etc. This is why docs from NEAR, etc. state that your program should fall back to other blockchain nodes. Writing such a fallback system is repetitive and time-consuming. This library acts as a reusable fallback system for all your programs that rely on blockchain nodes. Here's the flow:
-
Import this library into your program.
-
Optionally, specify which blockchains you want to use (such as NEAR and Cosmos Hub), the URLs of the blockchain nodes you want to use (such as
https://rpc.mainnet.near.org
), and how often you want the fallback system to check the health of the blockchain nodes (such as every 10s). -
The library will periodically check the health of each blockchain's nodes.
Let's consider an example. You told the library to monitor the blockchains NEAR and Cosmos Hub every 10s. For NEAR, you supplied the URLS
N1
,N2
, andN3
. For Cosmos Hub, you specified the URLSC1
andC2
. As soon as the library is told to start, it'll assign the first URL passed for each blockchain (N1
for NEAR, andC1
for Cosmos Hub) as the "healthy" URL regardless of whether they're actually healthy. It'll then immediately check the health of URLs for NEAR and Cosmos Hub. For NEAR, it'll checkN1
, see that it's down, checkN2
, see that it's up, reassign NEAR's "healthy" URL toN2
, wait ten seconds, and repeat this process until told to stop. For Cosmos Hub, it'll checkC1
, see that it's down, checkC2
, see that it's down, not reassign the "healthy" URL since there aren't any (C1
will continue to be used as the "healthy" URL), wait ten seconds, and repeat this process until told to stop. -
Whenever you need to use a blockchain's node, access its URL via the variable exposed by this library.
- Since this package is privately published, you'll need to authenticate to the registry. Create a personal access token with the
repo
andread:packages
scopes. - Create a file named
.npmrc
(this must not be committed to your VCS but these steps must be followed by anyone using your project so that they can download this dependency) with the contents//npm.pkg.github.com/:_authToken=<TOKEN>
, where<TOKEN>
is your personal access token. - Log in to the registry using the token you just generated as the password:
yarn login --registry https://npm.pkg.github.com --scope @leapwallet
. - Now, you can install the package as you normally would have:
yarn add @leapwallet/fallback-falooda
-
Here's the latest version's documentation. To view a previous version's documentation, find the relevant release, download docs.zip from Assets, unzip it, and open
docs/index.html
in your browser. -
If you're using this
-
Never import APIs from nested files.
For example, this is correct:
import { Fallback } from '@leapwallet/fallback-falooda/dist/browser/src';
For example, this is incorrect:
import Fallback from '@leapwallet/fallback-falooda/dist/browser/src/fallback';
-
On the browser, import APIs from
@leapwallet/fallback-falooda/dist/browser/src
. -
On Node.js, import APIs from
@leapwallet/fallback-falooda/dist/node/src
. -
On React Native, I'm not sure whether to import APIs from
@leapwallet/fallback-falooda/dist/browser/src
or@leapwallet/fallback-falooda/dist/node/src
. Please send a PR to update this doc if you find out.
Details
- fallback-falooda
- leapwallet
- almost 2 years ago
- UNLICENSED
- 11 dependencies
Assets
- fallback-falooda-0.1.0.tgz
Download activity
- Total downloads 402
- Last 30 days 0
- Last week 0
- Today 0