0.0.17 • Published 3 years ago

crypto-plant-utils-test-stage v0.0.17

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

使用说明

####1. 纪元涨跌幅排名系列api

  import {EpochPriceRank as _EpochPriceRank,initializeEnv} from 'xxx'

  initializeEnv(97) // 97/56  必须先初始化环境,否则影响后续合约配置

  const EpochPriceRank = new _EpochPriceRank()

  // EpochPriceRank.funcRequestEpoch().then((res) => console.info(res))
  // EpochPriceRank.funcGetCurrentEpoch().then((res) => console.info(res))
  // EpochPriceRank.funcHistoryEpochsOf(0,0).then((res) => console.info(res))
  // EpochPriceRank.funcGetHistoryEpochAt(0).then((res) => console.info(res))
  // EpochPriceRank.funcGetAssetLen().then((res) => console.info(res))
  // EpochPriceRank.funcGetAssetsIDs().then((res) => console.info(res))
  // EpochPriceRank.funcGetResourceBalanceOf(account).then((res) => console.info(res))
(1) 开启一个新纪元

入口函数:EpochPriceRank.funcRequestEpoch(account)

需要参数:
account:string

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcRequestEpoch(account)

  // your code...
}

调用方式二:
EpochPriceRank.funcRequestEpoch(account).then((res) => {
  // your code...
})

返回值:true/false 开启纪元成功/失败
(2) 查询当前纪元状态

入口函数:EpochPriceRank.funcGetCurrentEpoch()

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetCurrentEpoch()

  // your code...
}

调用方式二:
EpochPriceRank.funcGetCurrentEpoch().then((res) => {
  // your code...
})

返回值:
{
    currBlockNumber:	当前区块编号,纪元倒计时区块可以使用
    current:
      {
        startBlock:	纪元开始区块
        endBlock:	纪元结束区块
        rank:	    涨幅排序第几的是最终税金获得者
        assetIdx:	rank的资产位置
        startPrice:	纪元开始时价格
        endPrice:	纪元结束时价格
        change:	涨跌幅
        epoch:	纪元编号
      }
}
(3) 批量查询历史纪元数据

入口函数:EpochPriceRank.funcHistoryEpochsOf(startIndex,endIndex)

需要参数:
startIndex: number
endIndex: number--------->默认0

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcHistoryEpochsOf(startIndex,endIndex)

  // your code...
}

调用方式二:
EpochPriceRank.funcHistoryEpochsOf(startIndex,endIndex).then((res) => {
  // your code...
})

返回值:
[{
    startBlock:	纪元开始区块
    endBlock:	纪元结束区块
    rank:	涨幅排序第几的是最终税金获得者
    assetIdx:	rank的资产位置
    startPrice:	纪元开始时价格
    endPrice:	纪元结束时价格
    change:	涨跌幅
    epoch:	纪元编号
}]
(4) 查询指定纪元信息

入口函数:EpochPriceRank.funcGetHistoryEpochAt(idx)

需要参数:
idx:number

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetHistoryEpochAt(idx)

  // your code...
}

调用方式二:
EpochPriceRank.funcGetHistoryEpochAt(idx).then((res) => {
  // your code...
})

返回值:
{
    startBlock:	纪元开始区块
    endBlock:	纪元结束区块
    rank:	涨幅排序第几的是最终税金获得者
    assetIdx:	rank的资产位置
    startPrice:	纪元开始时价格
    endPrice:	纪元结束时价格
    change:	涨跌幅
    epoch:	纪元编号
}
(5) 历史纪元总数

入口函数:EpochPriceRank.funcGetEpochLen()

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetEpochLen()

  // your code...
}

调用方式二:
EpochPriceRank.funcGetEpochLen().then((res) => {
  // your code...
})

返回值:
一个数字
(6) 查询资产数量

入口函数:EpochPriceRank.funcGetAssetLen()

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetAssetLen()

  // your code...
}

调用方式二:
EpochPriceRank.funcGetAssetLen().then((res) => {
  // your code...
})

返回值:
一个数字
(7) 查询所有的资产ID

入口函数:EpochPriceRank.funcGetAssets()

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetAssets()

  // your code...
}

调用方式二:
EpochPriceRank.funcGetAssets().then((res) => {
  // your code...
})

返回值:
[number,number,...]
(8) 查询用户资源余额

入口函数:EpochPriceRank.funcGetAssets(account)

需要参数:
account:string

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetAssets(account)

  // your code...
}

调用方式二:
EpochPriceRank.funcGetAssets(account).then((res) => {
  // your code...
})

返回值:
[number,number,...]
(9) 注册(生成游戏编号)

入口函数:EpochPriceRank.funcRegisterGameAcc(account)

需要参数:
account:string

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcRegisterGameAcc(account)

  // your code...
}

调用方式二:
EpochPriceRank.funcRegisterGameAcc(account).then((res) => {
  // your code...
})

返回值:
[hash, status]
(10) 查询用户类型和编号

入口函数:EpochPriceRank.funcGetPlayerInfo(account)

需要参数:
account:string

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetPlayerInfo(account)

  // your code...
}

调用方式二:
EpochPriceRank.funcGetPlayerInfo(account).then((res) => {
  // your code...
})

返回值:
{
    types:0/1/2/3, 
    playerNo:number
}
(11) 查询用户编号

入口函数:EpochPriceRank.funcGetPlayerNo(account)

需要参数:
account:string

调用方式一:
const func = async () => {
  const res = await EpochPriceRank.funcGetPlayerNo(account)

  // your code...
}

调用方式二:
EpochPriceRank.funcGetPlayerNo(account).then((res) => {
  // your code...
})

返回值:
一个数字
0.0.17

3 years ago

0.0.10

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.15

3 years ago

0.0.9

3 years ago

0.0.16

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.1

3 years ago