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

dl-base-sdk

v1.0.1-1

Published

This SDK is intended to build for the convinience of developers whose want to interact with our Sabay Stellar's network.

Downloads

6

Readme

Dragon Lotto Base SDK

This SDK is intended to build for the convinience of developers whose want to interact with our Sabay Stellar's network.

Features

  • Initialize an account based on the provided seed (Create or Load the exists account)
  • Top-up (Request top-up from provider)
  • Check Balance (Custom & Native assets)
  • Clear the custom asset

Installation

Using npm:

npm install dl-base-sdk

Examples

Create a new account or load an existing one from the network.

import { Account, Server } from 'dl-base-sdk';

const seed = 'some-unique-seed';
const development = true; // this is in a development environment

// const server = Server.loadProductionServer(); // production
const server = Server.loadTestServer(); // development

const account = new Account(seed, server, development);

// the address that would consider as a parent of user's account
const source = 'GCSYLEFISTDRFXBMWYKEFWPKM73PGBDUCGJTIS3TLTC3LQ67TJSFEZ3P';
const passphrase = 'sabay';

account
    .init()
    .sources(source)
    .passPhrase(passphrase)
    .submit()
    .then(result => {
        // handle result
    })
    .catch(error => {
        // handle error
    });

Response:

{
    "status": "xxx",
    "message": "xxx",
    "body": [
        {
            "balance": "xxx",
            "buying_liabilities": "xxx",
            "selling_liabilities": "xxx",
            "limit": "xxx",
            "asset_type": "xxx",
            "asset_code": "xxx",
            "asset_issuer": "xxx",
        },
        {
            "balance": "xxx",
            "buying_liabilities": "xxx",
            "selling_liabilities": "xxx",
            "limit": "xxx",
            "asset_type": "native",
            "asset_code": "xxx",
            "asset_issuer": "xxx",
        }
    ]
}

Request a top-up for an account by sending a small amout of lumens (0.0000001) to the fund provider.

import { Account, Server } from 'dl-base-sdk';

const seed = 'some-unique-seed';
const development = true; // this is in a development environment

// const server = Server.loadProductionServer(); // production
const server = Server.loadTestServer(); // development

const account = new Account(seed, server, development);

// the address of fund provider
const source = 'GCSYLEFISTDRFXBMWYKEFWPKM73PGBDUCGJTIS3TLTC3LQ67TJSFEZ3P';
const reference_id = 'some_unique_reference'; // limit 28-byte

account
    .topUp()
    .sources(source)
    .reference(reference_id)
    .submit()
    .then(result => {
        // handle result
    })
    .catch(error => {
        // handle error
    });

On success, this doesn't mean the account get the fund. The client just make a request to top-up to the server of provider. Client itself still need to wait until the server receive the request and send back the fund.

Response:

{
    "status": "xxx",
    "message": "xxx",
    "body": [
        {
            "hash": "xxx",
            "ledger": "xxx",
            "envelope_xdr": "xxx",
            "result_xdr": "xxx",
            "result_meta_xdr": "native",
            "offerResults": "xxx"
        }
    ]
}

To check an account's balance:

import { Account, Server } from 'dl-base-sdk';

const seed = 'some-unique-seed';
const development = true; // this is in a development environment

// const server = Server.loadProductionServer(); // production
const server = Server.loadTestServer(); // development

const account = new Account(seed, server, development);

const passphrase = 'sabay';
const asset_code = 'LTC';

// example 1
//
// get blace of native and default custom asset
account
    .getBalances(passphrase)
    .then(result => {
        // handle result
    })
    .catch(error => {
        // handle error
    });
    
// example 2
//
// get blace of native and other custom asset
account
    .getBalances(passphrase, asset_code)
    .then(result => {
        // handle result
    })
    .catch(error => {
        // handle error
    });

Response:

{
    "status": "xxx",
    "message": "xxx",
    "body": [
        {
            "balance": "xxx",
            "buying_liabilities": "xxx",
            "selling_liabilities": "xxx",
            "limit": "xxx",
            "asset_type": "xxx",
            "asset_code": "xxx",
            "asset_issuer": "xxx",
        },
        {
            "balance": "xxx",
            "buying_liabilities": "xxx",
            "selling_liabilities": "xxx",
            "limit": "xxx",
            "asset_type": "native",
            "asset_code": "xxx",
            "asset_issuer": "xxx",
        }
    ]
}

Clearing an asset:

import { Account, Server } from 'dl-base-sdk';

const seed = 'some-unique-seed';
const development = true; // this is in a development environment

// const server = Server.loadProductionServer(); // production
const server = Server.loadTestServer(); // development

const account = new Account(seed, server, development);

// the adress where all the fund will be sent to
const source = 'GCSYLEFISTDRFXBMWYKEFWPKM73PGBDUCGJTIS3TLTC3LQ67TJSFEZ3P';
const user_id = 'some_user_id';
const passphrase = 'sabay';

// example 1
//
// to clear all the remaining assets back to its own provider
// with the default address and asset_code that has set in the SDK
account
    .clear()
    .sources(source)
    .reference(user_id)
    .passPhrase(passphrase)
    .submit()
    .then(result => {
        // return the details of remaining balances of native and custom asset
    })
    .catch(error => {
        // handle error
    });
    
// example 2
//
// to clear only some amount of asset
// with custom address and asset_code
const amount = 5;
const asset_code = 'LTC';
const asset_issuer = 'GCIE6MTOWK37MQGJVLS3QSO67KTU2VUPWWH4D5336UL6YERDPT23U2IJ';

account
    .clear(amount, asset_code, asset_issuer)
    .sources(source)
    .reference(user_id)
    .passPhrase(passphrase)
    .submit()
    .then(result => {
        // return the details of remaining balances of native and custom asset
    })
    .catch(error => {
        // handle error
    });    

Response:

{
    "status": "xxx",
    "message": "xxx",
    "body": [
        {
            "balance": "xxx",
            "buying_liabilities": "xxx",
            "selling_liabilities": "xxx",
            "limit": "xxx",
            "asset_type": "xxx",
            "asset_code": "xxx",
            "asset_issuer": "xxx",
        },
        {
            "balance": "xxx",
            "buying_liabilities": "xxx",
            "selling_liabilities": "xxx",
            "limit": "xxx",
            "asset_type": "native",
            "asset_code": "xxx",
            "asset_issuer": "xxx",
        }
    ]
}