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

ebakus-web-wallet-loader

v0.1.4

Published

The Ebakus wallet loader library creates an iframe and loads the web wallet library in there. It can accept custom configurations for the wallet (i.e. load custom tokens) and act as an interface between the dApp and the web wallet iframe. This way a user

Downloads

13

Readme

Ebakus Wallet Loader

The wallet library creates an iframe and loads the web wallet library in there. It can accept custom configurations for the wallet (i.e. load custom tokens) and act as an interface between the dApp and the web wallet iframe. This way a user can use his wallet to interface with any ebakus dApp she wants without having to create new keys and manage multiple accounts.

You can check how it looks like inside an existing dApp.

The boilerplate

The best way to start is to use the dApp Boilerplate, where you can see how you can use the wallet loader library to programatically:

  • Send transactions
  • Deploy contracts
  • Interact with smart contracts
  • Configure custom tokens

Contact us at [email protected].

Have fun!

Load package

Using npm

npm install --save ebakus-web-wallet-loader

and use it like:

import ebakusWallet from 'ebakus-web-wallet-loader'

ebakusWallet.init() // you have to load the wallet once

With a script tag from your site

In your dApp page you have to include our Wallet Loader script.

Load it from CDN:

<script src="https://unpkg.com/ebakus-web-wallet-loader" />

or copy it to your site:

<script src="./dist/wallet-loader.min.js" />

The script will expose window.ebakusWallet. You can also have a look at the example page.

You will have to init the loader once using:

ebakusWallet.init()

API

The dApp can communicate with the wallet through the loader API.

Events

ebakusLoaded

When loader has finished loading with the wallet loading it will dispatch the ebakusLoaded event.

window.addEventListener(
  'ebakusLoaded',
  ev => {
    console.warn('Ebakus Wallet loaded')
  },
  false
)

ebakusCurrentProviderEndpoint

Every time the user switches the connected node the wallet will dispatch the ebakusCurrentProviderEndpoint event.

window.addEventListener(
  'ebakusCurrentProviderEndpoint',
  ({ detail: endpoint }) => {
    console.log('The web3 provider wallet is connected is:', endpoint)

    // for a new web3 instance
    web3 = Web3Ebakus(new Web3(endpoint))

    // or for using an existing one
    // web3.setProvider(endpoint)
  },
  false
)

ebakusConnectionStatus

Every time the wallet connection with the node changes it will dispatch the ebakusConnectionStatus event.

window.addEventListener(
  'ebakusConnectionStatus',
  ({ detail: connectionStatus }) => {
    console.warn('The wallet connection status changed to', connectionStatus)
  },
  false
)

ebakusAccount

Every time switches account in the wallet it will dispatch the ebakusAccount event.

window.addEventListener(
  'ebakusAccount',
  ({ detail: address }) => {
    console.warn('The wallet account address changed to', address)
  },
  false
)

ebakusBalance

On wallet balance change it will dispatch the ebakusBalance event.

window.addEventListener(
  'ebakusBalance',
  ({ detail: balance }) => {
    console.warn('The new user balance is', web3.utils.toWei(balance))
  },
  false
)

ebakusStaked

On wallet staked amount change it will dispatch the ebakusStaked event.

window.addEventListener(
  'ebakusStaked',
  ({ detail: staked }) => {
    console.warn('The new user staked amount is', web3.utils.toWei(staked))
  },
  false
)

Methods

ebakusWallet.init(options)

The init method can be used in order to pass custom configuration for the actual wallet. You can:

  • point the walletLoader to your own instance of the Ebakus Wallet
  • set custom tokens for your dApp
// loading custom token to wallet
ebakusWallet.init({
  // walletEndpoint: 'https://wallet.ebakus.test'  // this is the default and can be ommitted
  tokens: [
    {
      contract_address: '0xa679d48c57320e9f0eadb043c3ea3f8dcd97ed01',
      symbol: 'SIM',
      decimals: 18,
    },
  ],
})

window.addEventListener(
  'ebakusLoaded',
  ev => {
    console.warn('Ebakus Wallet loaded')
  },
  false
)

ebakusWallet.isWalletFrameLoaded()

The isWalletFrameLoaded method returns if the wallet frame has finished loading.

if (ebakusWallet.isWalletFrameLoaded()) {
  // do something
}

ebakusWallet.getCurrentProviderEndpoint()

The getCurrentProviderEndpoint method returns the wallet used web3 endpoint so as the dApp can connect to the same provider.

ebakusWallet.getCurrentProviderEndpoint().then(endpoint => {
  console.log('The web3 provider wallet is connected is:', endpoint)

  // for a new web3 instance
  web3 = Web3Ebakus(new Web3(endpoint))

  // or for using an existing one
  // web3.setProvider(endpoint)
})

ebakusWallet.unlockWallet()

The unlockWallet method will ask your user to unlock the wallet in case it is locked. This is not needed most times as the wallet will ask on the first wallet interaction, when needed.

ebakusWallet.unlockWallet()

ebakusWallet.getAccount()

The getAccount method returns the wallet address or an exception if no account address exists.

ebakusWallet
  .getAccount()
  .then(address => {
    console.log('Your wallet address is:', address)
  })
  .catch(err => {
    console.error('Error reason:', err)
    ebakusWallet.unlockWallet()
  })

ebakusWallet.getBalance()

The getBalance method returns the wallet balance.

ebakusWallet.getBalance().then(balance => console.log)

ebakusWallet.getStaked()

The getStaked method returns the wallet staked amount.

ebakusWallet.getStaked().then(staked => console.log)

ebakusWallet.sendTransaction(tx)

The sendTransaction method will ask user to confirm, sign and send the transaction at the network through the wallet.

ebakusWallet.sendTransaction(/* tx object */).then(receipt => console.log)

ebakusWallet.unloadWallet()

The unloadWallet method will remove the wallet instance already loaded in the dApp. You can then call init again when needed.

ebakusWallet.unloadWallet()

Development

Install dependencies

npm install

Compile for development (with hot-reload support)

npm start

Compile and minify for production

npm run build