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

popup-js-sdk

v0.0.7

Published

popup js sdk for dapp developer

Downloads

4

Readme

popup-js-sdk

js sdk for popup DApp market.

Whate is popup-js-sdk?

popup-js-sdk provided to developers who need to develop DApps in the popup DApp market. It provides an interface method for querying accounts and executing smart contract methods.

How to use popup-js-sdk

Installation

nodejs

npm install popup-js-sdk

Usage

import Popup from 'popup-js-sdk'

...

let popup = new Popup();
popup.setProvider(new popup.providers.HttpProvider('http://127.0.0.1:2345'));

Modules

  • popup.local.* is for calling popup local methods. eg: popup.local.accountList is get all account list.
  • popup.sero.* is for calling gero node rpc when execute smart contract. eg: popup.sero.call().

If you need to call gero other rpc interfaces directly, you can use sero-web3

npm install sero-web3

Document

popup.local.*

Data Struct

  • PK is the address of the account, can be used as a tag for the account, not as a transfer from address.
  • MainPKr can be used as a common address, call and execute smart contract.
  • MainOldPKr has Deprecated.
  • Balance is a map. key = currency ,value = Minimum unit amount.
  • PkrBase58 is Dynamic collection address. Refresh every time a transaction occurs.
let accounts = popup.local.accountList();

Result:

[{
	"PK": "kvaztfuz3ZS6sNcksQYZpdGC1rUwcuv1aPkuzkLdgeNSvq5FQiURuBsqghLCY3MkxZLNm7WQ9yV2ib2UWoRpJys",
	"MainPKr": "fHBQfR5t9j3D4CsKQG78sQ3Qzdz9SS6m3XsgvgkNcpKjD1TMBEVmcJ4vhDUpkZrvPtE47DnzxRjz4Gk7xMaGZfxstnMeBjZF1dWeQaC3dxLrPPa4wQoGdXeJuihdTKwxf5K",
	"MainOldPKr": "2QwcGasRUYwF3BdTDFh2gLAMYdayBRLqVhiKrBi7apqB1ftZmaUtLYN8AdTY87K3mGW2EZgh1tVCizzdy1HWM8fGBP9ZErPKawPUPexaVXqZqSa1uPbNXb5c755H1kCUn7c3",
	"Balance": {
		"SERO": 88999438296000000000
	},
	"UtxoNums": {
		"SERO": 2
	},
	"PkrBase58": "TXSgCTk7vVRDkVxmiPiWBakQtcrf5FJKcyRvGmfHh1SXBUnzopi6fqohd8K4ZCyEmvkVwzdZC2AdotcZh2B3XcnXZHRkUxrZQ76u1tzf1CURjtbchDbs4ZNRjTB86nvBGWK"
}, {
	"PK": "4xxrya2a8g6QLQuQBtdpyF49axHTnkUeDjomfk5zqG7eDZubPPubHMVkPqggZ9iE8Zy6WQVD7riRcX8TSfihs3nq",
	"MainPKr": "22ogQ9vrpiPxBgTep59koxnNzRmHAY2zi94EKp3VAhjo4r7bzETxbgqTfgUqHuuFAe5on4iagFAhXVfaooLH5JMLEhKSmzucPvHftgefGVTzAfDJLs53Pw7YnP2rcSSStxoT",
	"MainOldPKr": "Wubp9ZYJPdxLyyesrth4j3AsZVouNgt5NNgCBHiwqhUpN1ZhbmTLRWViUwxzvhpezKDgXi5ck7iXm3bjwLAHfRnSTC8FMhRTqPLvUs6vbXKXQ9VMpDefHLR4PDDLVotkbd9",
	"Balance": {},
	"UtxoNums": {},
	"PkrBase58": "22ogQ9vrpiPxBgTep59koxnNzRmHAY2zi94EKp3VAhjo4r7bzETxbgqTfgUqHuuFAe5on4iagFAhXVfaooLH5JMLEhKSmzucPvHftgefGVTzAfDJLs53Pw7YnP2rcSSStxoT"
}]
let account = popup.local.accountDetail(`pk`);

Result:

{
	"PK": "kvaztfuz3ZS6sNcksQYZpdGC1rUwcuv1aPkuzkLdgeNSvq5FQiURuBsqghLCY3MkxZLNm7WQ9yV2ib2UWoRpJys",
	"MainPKr": "fHBQfR5t9j3D4CsKQG78sQ3Qzdz9SS6m3XsgvgkNcpKjD1TMBEVmcJ4vhDUpkZrvPtE47DnzxRjz4Gk7xMaGZfxstnMeBjZF1dWeQaC3dxLrPPa4wQoGdXeJuihdTKwxf5K",
	"MainOldPKr": "2QwcGasRUYwF3BdTDFh2gLAMYdayBRLqVhiKrBi7apqB1ftZmaUtLYN8AdTY87K3mGW2EZgh1tVCizzdy1HWM8fGBP9ZErPKawPUPexaVXqZqSa1uPbNXb5c755H1kCUn7c3",
	"Balance": {
		"SERO": 88999438296000000000
	},
	"UtxoNums": {
		"SERO": 2
	},
	"PkrBase58": "TXSgCTk7vVRDkVxmiPiWBakQtcrf5FJKcyRvGmfHh1SXBUnzopi6fqohd8K4ZCyEmvkVwzdZC2AdotcZh2B3XcnXZHRkUxrZQ76u1tzf1CURjtbchDbs4ZNRjTB86nvBGWK",
}

popup.sero.*

Here need install serojs to pack and unpack data.

npm install serojs

// you can use remix solidity complie to web3deploy to get abi. and deploy with gero to get contract address.
let contractAddress = "54ZJqe8orGqAucdFqcZRupMa1WFeL6e5raCUw7FcBit9G9GZ5JFHXhNEKkhBPWRDEf1kDRLbX3qiPqSJ5H5Kasit";
let contract = serojs.callContract(abi, contractAddress);

// execute contract methods
execute(method, args) {
        let that = this;
        try{
            let packData = contract.packData(method, args);
            let executeData = {
                from: that.state.fromPKr,
                to: contractAddress,
                value: "0x0",//SERO
                data: packData,
                gas_price: "0x"+new BigNumber("1000000000").toString(16),
            };
            executeData["gas"] = popup.sero.estimateGas(executeData);
            let res = popup.local.executeContract(executeData);

            return res;
        }catch (e) {
            alert(e.message);
        }
    }

// call contract methods
call(method, args) {
    let that = this;
    try{
        let packData = contract.packData(method, args);
        let callParams = {
            from: that.state.fromPKr,
            to: contractAddress,
            data: packData
        }
        console.log(callParams);
        let callData = popup.sero.call(callParams, "latest");
        if (callData !== "0x") {
            let res = contract.unPackData(method, callData);
            return res;
        }
        return "";
    }catch (e) {
        alert(e.message);
    }
}

More Info

Please refer to the example directory