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

@savitar.exchange/swap-sdk

v1.0.21

Published

Savitar Swap SDK

Downloads

16

Readme

Swap Widget

Demo: https://swap.savitar.io/widget

For direct API connection, please see https://doc.savitar.io/api/

Index

  1. Install

  2. Quick Start

  3. Configurations

  4. Advanced

  5. About

Install

NPM

npm install --save @savitar.exchange/swap-sdk

or

yarn add @savitar.exchange/swap-sdk

or

<script src="https://cdn.jsdelivr.net/npm/@savitar.exchange/swap-sdk/dist/bundle.min.js"></script>

Quick Start

In embedded mode, we strongly recommend to show the widget in a minimum 390px (min-width) x 400px (min-height) element to ensure best compatibility with banks 3DSecure pages."

Initialize the client

var Swap = require('swap-sdk');
// OR
import * as Swap from 'swap-sdk';

new Swap.Widget({
    type: 'modal',
    lang: 'en', // default langage - string - ['en', 'fr']
}).init()

Mode modal

This mode loads an overlay on the click of a button or a link with id buttonId.

new Swap.Widget({
    type: 'modal',
    buttonId: 'swap-button',
})
.init()

Mode embed

This mode loads the widget in the DOM node of your choice parametrized with embedContainerId

new Swap.Widget({
    type: 'embed',
    embedContainerId: 'swap-widget',
})
.init()

Configurations

List of parameters of Swap.Widget config:

new Swap.Widget({
    type: 'embed',
    embedContainerId: 'swap-widget',
    config: {
      // input parameters here
    }
})
.init()

For wallets

  • email (optional): User email - string- default null
  • email_editable (optional): Allow user to change predefined email- bool - default true
  • currency (optional): Currency of the order - string- default null
  • order_type (optional): buy | sell - string- default buy
  • amount (optional): Amount of the order - float- default 25
  • amount_currency (optional): Currency of amount - string - default eur
  • amount_editable (optional): Allow user to modify amount - bool - default true
  • delivery_address (optional): Address to send ordered coins - string - default null
  • hide_confirm (optional): Hide payment confirmation (data @events) ( true | false ) - bool - default false
  • ref_code (optional): Referral ID for comissions - string - default null
  • font_family (optional): Google Font name - string - default null
  • primary_color (optional): Primary color (text or hex) - string - default null
  • secondary_color (optional): Secondary color (text or hex) - string - default null

IOV

Buy a domain

  • payment_type: iov,
  • email (optional): User email - string - default null
  • email_editable (optional): Allow user to change predefined email - bool - default true
  • delivery_address (optional): Owner of the domain - string - default null
  • broker_address (optional): Register commission address - string - default null
  • hide_confirm (optional): Hide payment confirmation (data @events) ( true | false ) - bool - default false
  • iov_domain (optional): Set default Starname domain - string - default null
  • ref_code (optional): Referral ID for comissions - string - default null
  • font_family (optional): Google Font name - string - default null
  • primary_color (optional): Primary color (text or hex) - string - default null
  • secondary_color (optional): Secondary color (text or hex) - string - default null

Buy IOVs

  • currency: IOV - string
  • email (optional): User email - string - default null
  • email_editable (optional): Allow user to change predefined email - bool - default true
  • amount (optional): Amount of the order - float - default 25
  • amount_currency (optional): IOV or EUR - string - default EUR
  • amount_editable (optional): Allow user to modify amount - bool - default true
  • delivery_address (optional): Address to send ordered coins - string - default null
  • hide_confirm (optional): Hide payment confirmation (data @events) ( true | false ) - bool - default false
  • ref_code (optional): Referral ID for comissions - string - default null
  • font_family (optional): Google Font name - string - default null
  • primary_color (optional): Primary color (text or hex) - string - default null
  • secondary_color (optional): Secondary color (text or hex) - string - default null

Buttons

Pay button with simple configuration

Attributes

  • svt-currency: Currency of order - string - default null
  • svt-email (optional): User email - string - default null
  • svt-email-editable (optional): Allow user to change predefined email - bool - default true
  • svt-amount (optional): Amount to order - float - default 25
  • svt-amount-editable (optional): Allow user to modify amount - bool
  • svt-amount-currency (optional): Currency of amount (ex: btc) - string - default eur
  • svt-order-type (optional): buy | sell - string - default buy
  • svt-delivery-address (optional): Address to send ordered coins - string - default null
  • svt-payment-type (optional): Payment type of widget (merchant / exchange / iov ) - string - default null
  • svt-hide-confirm (optional): Hide payment confirmation (data @events) ( true | false ) - bool - default false
  • svt-iov-domain (optional): Set default Starname domain - string - default null
  • svt-ref-code (optional): Referral ID for comissions - string - default null
  • svt-font-family (optional): Google Font name - string - default null
  • svt-primary-color (optional): Primary color (text or hex) - string - default null
  • svt-secondary-color (optional): Secondary color (text or hex) - string - default null
Example
JS
const widget = new Swap.Widget({
    payButtons: true,
    payButtonsStyle: true
})

widget.init()
HTML
<button type='svt-btn' svt-amount='50' svt-currency='usdt' svt-email='[email protected]' svt-order-type='buy'>Pay now !</button>
<button type='svt-btn' svt-amount='1' svt-currency='btc' svt-amount-currency='btc' />
<button type='svt-btn' svt-amount='50' svt-currency='btc' svt-delivery-address='367pVvSShqKzBZBA4eqHLwHB41g9NAphTd' />
<button type='svt-btn' svt-currency='xtz' />
<button type='svt-btn' svt-payment-type='iov' svt-email='[email protected]' svt-email-editable='false' >Buy Starname<button/>
<button type='svt-btn' svt-email='[email protected]' svt-currency='iov' svt-amount='100'/>
<button type='svt-btn' svt-order-type='sell' svt-currency='iov' svt-amount='100'/>
Options
  • type: modal or embed - string
  • payButtons: true or false - Enable click events on swap buttons - bool
  • payButtonsStyle: true or false - Enable auto styling of buttons - bool
  • embedContainerId: swap-embed - Embed container id - string
  • iframeContainerClass: swap-widget-container - iFrame container class - string
  • buttonId: swap-init - Modal button id - string
  • config: Widget configuration - object
Example
const opts = {
        type: 'modal',
        buttonId: 'swap-init',
        config: {
            email: '[email protected]',
            email_editable: true,
            currency: 'btc',
            amount: 200,
            amount_editable: false,
            delivery_address: '1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX'
        }
}

Advanced

Callbacks

    const widget = new Swap.Widget().init()

    widget
    .on('ready', () => {
      // widget has loaded
    })
    .on('close', () => {
      // user has closed widget
    })
    .on('success', (data) => {
      // user has successfully paid
    })
    .on('failure', (data) => {
      // payment failure
    })

Methods

Init modal in your script

    const widget = new Swap.Widget({
        type:'modal'
    }).init()

    widget
    .openModal()

About

Website: https://swap.savitar.io