0.0.7 • Published 1 day ago

dauth2ton v0.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
1 day ago

封装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 'tonconnect'

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()
0.0.7

1 day ago

0.0.6

1 day ago

0.0.5

4 days ago

0.0.4

12 days ago

0.0.3

13 days ago

0.0.2

15 days ago

0.0.1

15 days ago