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

@rsksmart/bridges-core-sdk

v0.3.3

Published

Core module of all the RSK bridges SDKs that contains common functionality

Downloads

202

Readme

Bridges Core SDK

This is the core module shared by all the bridges in the monorepo. This has common functionality such as logic to call the blockchain, HTTP client configuration, common valitadions and the configuration objects to initialize each bridges product.

Initialization

This repo also contains a submodule which can be imported with the path @rsksmart/bridges-core-sdk/initialization. That helps the user to initialize multiple bridges at once (have in count that every bridge package still provides its own contructor and ways to initialize it specificly).

To use core initialization you need to use the init() function, provide the common configuration fields, and in the bridges field add all the keys for the bridges you want to initialize, for each key the value that you'll provide is the specific configuration for that bridge or {} if you want to initialize that bridge with its default configuration


    // this would initialize flyover with custom config and tokenbridge with default config
    const { flyover, tokenbridge } = await init({
      network: 'Regtest',
      allowInsecureConnections: true,
      bridges: {
        flyover: {
          captchaTokenResolver: async () => Promise.resolve('')
        },
        tokenbridge: {}
      }
    })

Drawbacks

One advantage of using initialization module is that you can lazy load the bridges. If you provide an unexisting bridge name the funciton will return and error. Also if you provide an existing bridge name but you don't have that package installed on your project the function will return and error.

This comes with one drawback, even when the SDK ensures that any lazy loaded bridge error is catched, you can find problems with some code bundlers that don't support external dependencies dynamic importing. If your bundler doesn't support that and you can't fix it via bundler configuration the only solution that you have is to install all the bridges packages even if you're not using them all. If your bundler does suport external dependency dynamic importing then you shouldn't have any problem.

Connect to RSK

If you need to connect to RSK to execute some operation then you need to create an RSKConnection and provide it to your bridge object

    const rsk = await BlockchainConnection.createUsingStandard(window.ethereum)
    const flyover = new Flyover({ rskConnection: rsk, network: 'Regtest' })

or you can set it after creation

    const rsk = await BlockchainConnection.createUsingStandard(window.ethereum)
    await flyover.connectToRsk(rsk)

There are multiple ways to create the connection, all of them are specified in the BlockchainConnection class JSDocs

Application Programming Interface

To see the full API of this package please refer to the the docs folder of this project