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

math-js-sdk

v1.0.9

Published

Javascript SDK for MathWallet

Downloads

17

Readme

math-js-sdk

Javascript SDK for MathWallet

Demo

https://medishares-cn.oss-cn-hangzhou.aliyuncs.com/demos/mathwallet-js-sdk/index.html

此链接用来演示如何使用math-js-sdk,您可以在麦子钱包DAPP浏览器中打开
This link is the demo of how to use the math-js-sdk. You can open it in the MathWallet DAPP Browser.

Installation

npm

Install

npm install math-js-sdk

Require module

var mathwallet = require('math-js-sdk');

html

Drop the dist/mathwallet.min.js bundle into your html project

<script src="path/to/mathwallet.min.js"></script>

Get instance

var mathwallet = window.mathwallet;

Usage

Note

注意: 此SDK需要在麦子钱包的DAPP浏览器中使用
Note: The SDK needs to be used in the MathWallet DAPP Browser.

Common

适用于麦子钱包DAPP浏览器的通用方法
Common method for MathWallet DAPP Browser

isMath

mathwallet.isMath();

Return

true

getAppInfo

获取用户麦子钱包信息
Get user MathWallet info

mathwallet.getAppInfo().then(console.log);

Return

{
  "name": "Math Wallet",
  "client": "iOS",
  "version": "1.9.3",
  "build": "25",
  "deviceId": "2FB1AD00-20C7-45FF-AE94-A2F30A02F8F6"
}

share

分享图片或链接到社交平台,如微信 Share to third app like Wechat.

// Image
mathwallet.shareTo(1,{
      "imageURL": "https://medishares-cn.oss-cn-hangzhou.aliyuncs.com/dapp/263R1568603688.jpg",
      // Extra Data
      // "activity": {
      //   "type": "event",
      //   "app": "app",
      //   "event": "share",
      //   "name": params.name,
      //   "data": params.data
      // }
      }
    ).then(console.log);
// Link
mathwallet.shareTo(2,{
      "title": "Math",
      "desc": "Math Wallet",
      "link": "https://www.mathwallet.org",
      "thumImage": "https://medishares-cn.oss-cn-hangzhou.aliyuncs.com/dapp/263R1568603688.jpg",
      // Extra Data
      // "activity": {
      //   "type": "event",
      //   "app": "app",
      //   "event": "share",
      //   "name": params.name,
      //   "data": params.data
      // }
      }
    ).then(console.log);
// Save to album
mathwallet.shareTo(3,{
      "imageURL": "https://medishares-cn.oss-cn-hangzhou.aliyuncs.com/dapp/263R1568603688.jpg"
      }
    ).then(console.log);

Return

{
  "result": 1
}

openUrl

打开一个新的浏览器窗口
Open a new webview tab

mathwallet.openUrl("http://www.mathwallet.org").then(console.log);

Return

{
  "result": 1
}

openThirdApp

打开第三方应用,如微信、KakaoTalk等
Open third app like Wechat, KakaoTalk.

mathwallet.openThirdApp("tel:110").then(console.log);

Return

{
  "result": 1
}

close

关闭当前窗口
Close window

mathwallet.close().then(console.log);

Return

{
  "result": 1
}

back

后退到上一页
Back to previous page

mathwallet.back().then(console.log);

Return

{
  "result": 1
}

fullScreen

设置是否全屏
Set full screen
0 - normal screen
1 - full screen

mathwallet.fullScreen(1).then(console.log);

Return

{
  "result": 1
}

orientation

设置屏幕方向
Set screen orientation
0 - portrait
1 - landscape

mathwallet.orientation(1).then(console.log);

Return

{
  "result": 1
}

getLanguage

获取用户APP语言
Get user app language

mathwallet.getLanguage().then(console.log);

Return

"cn"

getCurrentWalletType

获取用户当前钱包类型
Get user current wallet type

mathwallet.geCurrentWalletType().then(console.log);

Return

"BTC"

getCurrentWallet

获取用户当前钱包信息
Get user current wallet info

mathwallet.getCurrentWallet().then(console.log);

Return

{
  "blockchain":"EOS",
  "nickname":"medisharesbp",
  "address":"medisharesbp",
  "authority":"active"
}

walletPicker

钱包地址选取器(多地址弹框,由用户授权使用哪个账户)
Wallet Picker

mathwallet.walletPicker("ETH").then(console.log);

Return

{
  "nickname":"medisharesbp",
  "address":"medisharesbp"
}

getWalletList

获取用户某类型的钱包列表
Get user wallets of the type

mathwallet.getWalletList("EOS").then(console.log);

Return

[
  {
    "nickname":"medisharesbp",
    "address":"medisharesbp"
  },
  {
    "nickname":"medisharesbb",
    "address":"medisharesbb"
  }
]

postCustomMessage

发送其它自定义消息
For other custom action

mathwallet.postCustomMessage(method, payload);

BTC Wallet

麦子钱包DAPP浏览器中有关BTC钱包的方法
BTC wallet method for MathWallet DAPP Browser

BTC.transfer

发起BTC转账交易
Send BTC transaction

mathwallet.BTC.transfer(from, amount, to, memo).then(console.log);

OR

let transaction = {
  from : from,
  amount : amount,
  to : to,
  memo : memo
}
mathwallet.BTC.transfer(transaction).then(console.log);

Return

{
  "result":"trxid" // transaction hash
}

NEO Wallet

麦子钱包DAPP浏览器中有关NEO钱包的方法
NEO wallet method for MathWallet DAPP Browser

NEO.transfer

发起NEO转账交易
Send NEO transaction

mathwallet.NEO.transfer(from, amount, to, memo).then(console.log);

OR

let transaction = {
  from : from,
  to : to,
  amount : amount,
  contract : contract,
  precision : precision,
  symbol : symbol,
  memo : memo
}
mathwallet.NEO.transfer(transaction).then(console.log);

Return

{
  "result":"trxid" // transaction hash
}

EOS Wallet

麦子钱包DAPP浏览器中有关EOS钱包的方法
EOS wallet method for MathWallet DAPP Browser
注意: 麦子钱包已兼容Scatter,有关EOS的DAPP开发可直接使用Scatter
Note: MathWallet is already compatible with Scatter. You can use Scatter to build your EOS DAPP

EOS.init

在使用EOS相关方法前需要初始化EOS节点信息
Please initialize BP information before using the other method

let config = {
  "nodes":[

    // 0: testnet-node
    {
      "jsonRpc":"https:\/\/eostestnet.medishares.net",
      "chainID":"cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
    },

    // 1: testnet-node
    {
      "jsonRpc":"https:\/\/eosmainnet.medishares.net",
      "chainID":"aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"
    }

  ]
};
mathwallet.EOS.init(config);  //return true

EOS.getAccount

获取当前钱包账户信息,在使用与账户相关方法前需要先使用getAccount()方法
Get current account info, must use getAccount() before using the other method.

mathwallet.EOS.getAccount().then(console.log);

EOS.get_info

获取区块信息
Get block info

mathwallet.EOS.get_info().then(console.log);

EOS.abi_json_to_bin

JSON信息转为二进制数据
JSON to Bin

mathwallet.EOS.abi_json_to_bin(data).then(console.log);

EOS.signTransaction

签名交易
Sign transaction

mathwallet.EOS.signTransaction(transaction).then(console.log);

EOS.push_transaction & EOS.push_transaction_all

发起交易
Push transaction

mathwallet.EOS.push_transaction(transaction,signatures,compression).then(console.log);

OR

mathwallet.EOS.push_transaction_all(data).then(console.log);

EOS.customSignProvider

自定义签名提供者,用于类eos.js插件
Custom Sign Provider, for plugin like eos.js

// Eos.js
Eos({
  httpEndpoint: "https://path/to/node",
  chainId:      "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
  signProvider: mathwallet.EOS.customSignProvider,
});

EOS.getEos

获取已经初始化节点信息及签名提供者后的Eos.js实例,使用前需要先引入Eos.js插件
Get Eos.js instance which node httpEndpoint and signProvider have been initialized. Please include the eos.js plugin first.

<script src="http://path/to/eos.js"></script>
<script>
var eos = mathwallet.EOS.getEos();

//do something with eos.js
eos.getBlock(1);
</script>

Download Math Wallet 麦子钱包下载

http://mathwallet.org

如果您希望将您开发的DAPP加入麦子钱包,请通过邮箱联系我们 [email protected]

If you would like to list your DAPP in Math Wallet, please send your DAPP information to [email protected]