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

dauth2ton

v0.2.14

Published

## 提供接口

Downloads

8

Readme

封装toncnnect的调用

提供接口

  1. 获取sdk支持的钱包信息
getWallets = (): Promise<Wallet[]>

interface Wallet{
    name: string //钱包名字
    type: WalletType //钱包支持的类型
}


enum WalletType {
    desktop = 1,
    mobile = 2,
    extension = 4
}
  1. 设置当前钱包
setCurrentWallet = (wallet:Wallet):WalletUrlInfo

interface WalletUrlInfo{
    url: string //链接钱包的链接
    iconUrl: string//钱包的图标链接
}
  1. 打开当前钱包
open = (openType:WalletType):void

//因为一个钱包支持多种打开方式,所以需要指定当前打开类型
  1. 断开钱包链接
 close = () :void
  1. 查询钱包余额
queryWalletBalance = async(): Promise<string>

//避免精度丢失,使用string
  1. 调用钱包转账
 transfer = (to: string, amount:string, transferCb : SendTranscationCallback, errorCb : ErrorCallback)

//转账需要接收两个回调,一个转账成功回调,二个是转账出错回调
  1. 查询钱包地址
queryWalletAddress = () : string

使用方法

import { TonWalletConnector, WalletType, Wallet, WalletState , init} from 'dauth2ton'

init("test");//init("prod")

const tester = new TonWalletConnector(
  (state: WalletState | null) => {
    console.log(state)
    connected.value = state !== null
    tester.queryAddress()

   

    tester.getCurrentConnecWallet()
  },
  (err: Error) => {
    console.error(err)
  }
)


 tester.queryTonToUSDRate()

 ///withdraw

 前端 发起提现请求-》游戏后端,处理提现数量逻辑-》到infras->wowfish后端请求签名-》返回nonce和signture到游戏后端->游戏后端返回到游戏前端,传入

  tester.withdrawWow( 提现数量, nonce, signature).then((res) => {
        console.log("withdraw sucess", res)
      }).catch((er) => {
        console.log("withdraw faild", er)
      })

///消费wow

tester.consumeWow(消费数量, 附带信息(可以是订单号等))

 ///mint nft

 前端 发起提现请求-》游戏后端,处理提现数量逻辑 ,带上payload-》到infras->wowfish后端请求签名-》返回nonce、count、price、signture到游戏后端->游戏后端返回到游戏前端,传入

  tester.minNft( 购买类型, 购买数量, 价格, nonce, signature).then((res) => {
        console.log("withdraw sucess", res)
      }).catch((er) => {
        console.log("withdraw faild", er)
      })

  //前端提交到链上,链上成功后nfras->wowfish后端-》回调到游戏后端  payload 购买成功