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

@perawallet/onramp

v1.1.1

Published

Pera Onramp lets users top up in just a few clicks, offering the best rates for ALGO and stablecoins. Easily integrate it into your dApp with JavaScript SDK.

Downloads

8,320

Readme

Pera Onramp Cover Image

@perawallet/onramp

Pera Onramp lets users top up in just a few clicks, offering the best rates for ALGO and stablecoins. Easily integrate it into your dApp with JavaScript SDK.

Quick Start

  1. Start by installing @perawallet/onramp
npm install --save @perawallet/onramp
  1. Create a PeraOnramp instance
import {PeraOnramp} from "@perawallet/onramp";

const peraOnramp = new PeraOnramp();
  1. Tie it to a user action, and start the flow
peraOnramp
  .addFunds({
    accountAddress // A valid Algorand account address
  })
  .then(() => {
    // Successfully added funds
  })
  .catch(() => {
    // Failed to add funds
  });

Options

| option | default | value | | | --------------- | ---------------------------- | ---------------------------- | -------- | | optInEnabled | false | boolean | optional | | availableAssets | ["ALGO", "USDC-A", "USDT-A"] | ["ALGO", "USDC-A", "USDT-A"] | optional |

Opt-in Flow

To be able to add funds to an Algorand account, the account needs to be opted-into to related asset (Except for Algo). Some users may not be opted in to USDC or USDT, in that case Pera Onramp also allows you to control your in-app opt-in flow by a simple configuration.

While creating a PeraOnramp instance, you can enable the opt-in functionality.

const peraOnramp = new PeraOnramp({
  // Enables the Opt-in flow
  optInEnabled: true
});

As a result of that configuration, users will be able to select the related asset they haven't opted-in to. The select action will fire an event that you can listen to it with peraOnramp.on()

peraOnramp.on({
  OPT_IN_REQUEST: ({accountAddress, assetID}) => {
    // You can close the modal, and reopen after opt-in done
    peraOnramp.close();

    // Create opt-in transactions, and send to wallet to sign
    console.log(accountAddress, assetID);
  }
});

Events

Besides the main addFunds promise, on method allows to subscribe couple of optional events.

| event | type | | | ------------------- | ---- | ------------------------------------------- | | OPT_IN_REQUEST | void | Once the users selects a non opted-in asset | | ADD_FUNDS_COMPLETED | void | Funds added successfully | | ADD_FUNDS_FAILED | void | Funds couldn't be added |

peraOnramp.on({
  OPT_IN_REQUEST: ({accountAddress, assetID}) => {
    // You can close the modal, and reopen after opt-in done
    peraOnramp.close();

    // Create opt-in transactions, and send to wallet to sign
    console.log(accountAddress, assetID);
  },
  ADD_FUNDS_COMPLETED: () => {
    // You may display a toast
  },
  ADD_FUNDS_FAILED: () => {
    // You may display a toast
  }
});

Methods

PeraOnramp.addFunds({ accountAddress }: AddFundsParams): Promise<PeraOnrampListenerPromiseResolve>

Starts the fund adding flow.

PeraOnramp.on(callbacks: Callbacks): void

Sets a listener for specific events and runs a callback.

PeraOnramp.close(): void

Closes the fund adding flow, and rejects the peraOnramp.addFunds promise if exists.

Contributing

All contributions are welcomed! To get more information about the details, please read the contribution guide first.