0.1.0 • Published 2 years ago

@beamo/web-sdk v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@beamo/web-sdk

A web SDK for user to connect on Beamo.

Install

npm i @beamo/web-sdk --save

Usage

import { BeamoWebSDK } from '@beamo/web-sdk';

export const useConnectBeamo = () => {
  const showOnrampWidget = (el, options) =>
    new Promise((resolve, reject) => {
      const beamoInstance = new BeamoWebSDK(el, options);

      beamoInstance.on('TX_EVENTS', (e) => {
        if (e.type === 'BEAMO_WIDGET_TX_COMPLETED') {
          resolve('SUCCEEDED');
        }
      });
      beamoInstance.on('WIDGET_EVENTS', (e) => {
        if (e.type === 'BEAMO_WIDGET_CLOSE_REQUEST_CONFIRMED') {
          resolve('CLOSED');
        } else if (e.type.includes('FAILED')) {
          reject(e.type);
        }
      });
      beamoInstance.show();
    });

  document.getElementById('test').addEventListener('click', async () => {
    const res = await showOnrampWidget(document.getElementById('iframeWrap'), {
      email: 'xxx@gmail.com',
      relation: 'SEND_CRYPTO',
      account: 'acct_xxxx',
    });

    document.getElementById('result').innerHTML = res;
  });
};

Development

We use pnpm as our package manager.

Dev

We use vite

npm run dev

Build

We use rollup to build sdk.

Production

This will use https://connect.beamo.co for the iframe.

npm run build

Testing

Use npm pack to test your packages locally

if you are not testing the package, you don't have to excute npm run build:dev

This will use http://localhost:3000 for the iframe, so you should run dashboard project also.

npm run build:dev

npm pack --pack-destination [your local package position]

Open another project to test the sdk package:

npm install [your local package position]

Deploy

You should run npm build first.

0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago