当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript js.default.lt方法代码示例

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


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

示例1: co

BitGo.prototype.checkFunded = co(function *checkFunded() {
  // We are testing both BTC and ETH funds here, to make sure that
  // we don't spend for already 'failed' test runs (e.g., spending ETH when we don't have enough BTC)

  // Test we have enough ETH
  yield this.authenticateTestUser(this.testUserOTP());
  const testWalletId = BitGo.V2.TEST_ETH_WALLET_ID;

  const {
    tethWallet,
    tbtcWallet,
    unspentWallet,
    sweep1Wallet
  } = yield Promise.props({
    tethWallet: this.coin('teth').wallets().get({ id: testWalletId }),
    tbtcWallet: this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_WALLET1_ID }),
    unspentWallet:  this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_WALLET2_UNSPENTS_ID }),
    sweep1Wallet: this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_SWEEP1_ID }),
  });

  const spendableBalance = tethWallet.spendableBalanceString;

  let balance = new BigNumber(spendableBalance);

  // Check our balance is over 60000 (we spend 50000, add some cushion)
  if (balance.lt(60000)) {
    throw new Error(`The TETH wallet ${testWalletId} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }

  // Check we have enough in the wallet to run test suite
  tbtcWallet.should.have.property('spendableBalanceString');
  balance = new BigNumber(tbtcWallet.spendableBalanceString());

  // Check our balance is over 0.05 tBTC (we spend 0.04, add some cushion)
  let minimumBalance = 0.05 * 1e8;
  if (balance.lt(minimumBalance)) {
    throw new Error(`The TBTC wallet ${tbtcWallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }

  // Check we have enough in the wallet to run test suite
  unspentWallet.should.have.property('spendableBalanceString');
  balance = new BigNumber(unspentWallet.spendableBalanceString());

  // Check our balance is over 0.05 tBTC (we spend 0.04, add some cushion)
  minimumBalance = 0.05 * 1e8;
  if (balance.lt(minimumBalance)) {
    throw new Error(`The TBTC wallet ${unspentWallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }

  // Check we have enough in the wallet to run test suite
  sweep1Wallet.should.have.property('spendableBalanceString');
  balance = new BigNumber(sweep1Wallet.spendableBalanceString());

  // Since we will lose our unspents value to fees, make sure there is a large enough balance to continue
  minimumBalance = 0.05 * 1e8;

  if (balance.lt(minimumBalance)) {
    throw new Error(`The TBTC wallet ${sweep1Wallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
  }
});
开发者ID:BitGo,项目名称:BitGoJS,代码行数:60,代码来源:test_bitgo.ts

示例2: denormalizePrice

export function denormalizePrice(minPrice: string|number|BigNumber, maxPrice: string|number|BigNumber, normalizedPrice: string|number|BigNumber): BigNumber {
  const bnMinPrice: BigNumber = new BigNumber(minPrice, 10);
  const bnMaxPrice: BigNumber = new BigNumber(maxPrice, 10);
  const bnNormalizedPrice: BigNumber = new BigNumber(normalizedPrice, 10);
  if (bnMinPrice.gt(bnMaxPrice)) throw new Error("Minimum value larger than maximum value");
  if (bnNormalizedPrice.lt(0)) throw new Error("Normalized price is below 0");
  if (bnNormalizedPrice.gt(1)) throw new Error("Normalized price is above 1");
  return bnNormalizedPrice.times(bnMaxPrice.minus(bnMinPrice)).plus(bnMinPrice);
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:9,代码来源:denormalize-price.ts


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