• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript bn.js.default类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中bn.js.default的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default类的具体用法?TypeScript js.default怎么用?TypeScript js.default使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了js.default类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getRevealersForMessage

 // Select revealers from all eligible revealers for a message
 async getRevealersForMessage(reward: BN, numRevealers: number) {
   const eligibleRevealers: Revealer[] = await this.getEligibleRevealers();
   const minReward: BN = reward.div(new BN(numRevealers + 1));
   const filteredAndOrderedRevealers: Revealer[] = eligibleRevealers
     .filter((revealer: Revealer) => minReward.gte(revealer.minReward))
     .sort((a, b) => a.stakePerMessage.sub(b.stakePerMessage).toNumber());
   return filteredAndOrderedRevealers.slice(0, numRevealers);
 }
开发者ID:coderwithattitude,项目名称:kimono,代码行数:9,代码来源:Kimono.ts


示例2: it

    it(`should pass ${testName}`, function(done) {
      let incoming = officalTests[testName].in
      // if we are testing a big number
      if (incoming[0] === '#') {
        const bn = new BN(incoming.slice(1))
        incoming = Buffer.from(bn.toArray())
      }

      const encoded = RLP.encode(incoming)
      assert.equal('0x' + encoded.toString('hex'), officalTests[testName].out.toLowerCase())
      done()
    })
开发者ID:ethereumjs,项目名称:rlp,代码行数:12,代码来源:official.spec.ts


示例3: makeTokenTransferSkeleton

export function makeTokenTransferSkeleton(recipientAddress: string, consensusHash: string,
                                          tokenType: string, tokenAmount: BN,
                                          scratchArea: string
) {
  /*
   Format:

    0     2  3              19         38          46                        80
    |-----|--|--------------|----------|-----------|-------------------------|
    magic op  consensus_hash token_type amount (BE) scratch area
                             (ns_id)

    output 0: token transfer code
    output 1: recipient address
  */
  if (scratchArea.length > 34) {
    throw new Error('Invalid scratch area: must be no more than 34 bytes')
  }

  const opReturnBuffer = Buffer.alloc(46 + scratchArea.length)

  const tokenTypeHex = Buffer.from(tokenType).toString('hex')
  const tokenTypeHexPadded = `00000000000000000000000000000000000000${tokenTypeHex}`.slice(-38)

  const tokenValueHex = tokenAmount.toString(16, 2)

  if (tokenValueHex.length > 16) {
    // exceeds 2**64; can't fit
    throw new Error(`Cannot send tokens: cannot fit ${tokenAmount.toString()} into 8 bytes`)
  }

  const tokenValueHexPadded = `0000000000000000${tokenValueHex}`.slice(-16)

  opReturnBuffer.write(opEncode('$'), 0, 3, 'ascii')
  opReturnBuffer.write(consensusHash, 3, consensusHash.length / 2, 'hex')
  opReturnBuffer.write(tokenTypeHexPadded, 19, tokenTypeHexPadded.length / 2, 'hex')
  opReturnBuffer.write(tokenValueHexPadded, 38, tokenValueHexPadded.length / 2, 'hex')
  opReturnBuffer.write(scratchArea, 46, scratchArea.length, 'ascii')

  const nullOutput = bitcoin.payments.embed({ data: [opReturnBuffer] }).output
  const tx = makeTXbuilder()

  tx.addOutput(nullOutput, 0)
  tx.addOutput(recipientAddress, DUST_MINIMUM)

  return tx.buildIncomplete()
}
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:47,代码来源:skeletons.ts


示例4: getEligibleRevealers

 // Return all eligible revealers from contract
 async getEligibleRevealers() {
   const eligibleRevealersCount: BN = (await this.kimono.getEligibleRevealersCount())[0];
   const eligibleRevealers: Revealer[] = new Array(
     eligibleRevealersCount.toNumber()
   ).fill(undefined);
   for (let i = 0; i < eligibleRevealersCount.toNumber(); i++) {
     const revealerAddress = (await this.kimono.eligibleRevealers(i))[0];
     const [
       publicKey,
       minReward,
       stakePerMessage
     ] = await this.kimono.revealerTable(revealerAddress);
     eligibleRevealers[i] = {
       address: revealerAddress,
       publicKey,
       minReward,
       stakePerMessage
     };
   }
   return eligibleRevealers;
 }
开发者ID:coderwithattitude,项目名称:kimono,代码行数:22,代码来源:Kimono.ts


示例5: bnToBytes

export function bnToBytes(bn: BN, length: number) {
  return hexToBytes(bn.toString(16, length));
}
开发者ID:coderwithattitude,项目名称:kimono,代码行数:3,代码来源:crypto.ts


示例6:

 .filter((revealer: Revealer) => minReward.gte(revealer.minReward))
开发者ID:coderwithattitude,项目名称:kimono,代码行数:1,代码来源:Kimono.ts



注:本文中的bn.js.default类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript boa-core.O类代码示例发布时间:2022-05-25
下一篇:
TypeScript bluebird-lst-c.resolve函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap