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


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

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


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

示例1: constructor

 constructor(scope: { roundFees?: number, roundRewards: number[] }, private slots: Slots) {
   this.roundFees    = Math.floor(scope.roundFees) || 0;
   this.roundRewards = scope.roundRewards || [];
   this.fees = new Bignum(this.roundFees.toPrecision(15)).dividedBy(this.slots.delegates)
     .integerValue(BigNumber.ROUND_FLOOR);
   this.feesRemaining = new Bignum(this.roundFees.toPrecision(15)).minus(this.fees.times(this.slots.delegates));
 }
开发者ID:RiseVision,项目名称:rise-node,代码行数:7,代码来源:RoundChanges.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

示例3: getFee

// This is a public API that can be called directly.
// This is not used by the `prepare*` methods. See `src/transaction/utils.ts`
async function getFee(
  this: RippleAPI,
  cushion?: number
): Promise<string> {
  if (cushion === undefined) {
    cushion = this._feeCushion
  }
  if (cushion === undefined) {
    cushion = 1.2
  }

  const serverInfo = (await this.request('server_info')).info
  const baseFeeXrp = new BigNumber(serverInfo.validated_ledger.base_fee_xrp)
  let fee = baseFeeXrp.times(serverInfo.load_factor).times(cushion)

  // Cap fee to `this._maxFeeXRP`
  fee = BigNumber.min(fee, this._maxFeeXRP)
  // Round fee to 6 decimal places
  return (new BigNumber(fee.toFixed(6))).toString(10)
}
开发者ID:ripple,项目名称:ripple-lib,代码行数:22,代码来源:serverinfo.ts

示例4: BigNumber

    const x = new BigNumber(1.23)
    x.shift(3)                      // '1230'
    x.shift(-3)                     // '0.00123'
}

{
    const x = new BigNumber(16)
    x.squareRoot()                  // '4'
    const y = new BigNumber(3)
    y.sqrt()                        // '1.73205080756887729353'
}

{
    0.6 * 3                           // 1.7999999999999998
    const x = new BigNumber(0.6)
    const y = x.times(3)              // '1.8'
    new BigNumber('7e+500').times(y)  // '1.26e+501'
    x.times('-a', 16)                 // '-6'
}

{
    const x = new BigNumber(9876.54321)

    x.toDigits()                          // '9876.5'
    x.toDigits(6)                         // '9876.54'
    x.toDigits(6, BigNumber.ROUND_UP)     // '9876.55'
    x.toDigits(2)                         // '9900'
    x.toDigits(2, 1)                      // '9800'
    x                                     // '9876.54321'
}
开发者ID:felixfbecker,项目名称:typed-bignumber.js,代码行数:30,代码来源:test.ts

示例5: BigNumber

    .spread(function(addressDetails, feeDetails, serverDetails, keys) {
      const openLedgerFee = new BigNumber(feeDetails.body.result.drops.open_ledger_fee);
      const baseReserve = new BigNumber(serverDetails.body.result.info.validated_ledger.reserve_base_xrp).times(self.getBaseFactor());
      const reserveDelta = new BigNumber(serverDetails.body.result.info.validated_ledger.reserve_inc_xrp).times(self.getBaseFactor());
      const currentLedger = serverDetails.body.result.info.validated_ledger.seq;
      const sequenceId = addressDetails.body.result.account_data.Sequence;
      const balance = new BigNumber(addressDetails.body.result.account_data.Balance);
      const signerLists = addressDetails.body.result.account_data.signer_lists;
      const accountFlags = addressDetails.body.result.account_data.Flags;

      // make sure there is only one signer list set
      if (signerLists.length !== 1) {
        throw new Error('unexpected set of signer lists');
      }

      // make sure the signers are user, backup, bitgo
      const userAddress = rippleKeypairs.deriveAddress(keys[0].getPublicKeyBuffer().toString('hex'));
      const backupAddress = rippleKeypairs.deriveAddress(keys[1].getPublicKeyBuffer().toString('hex'));

      const signerList = signerLists[0];
      if (signerList.SignerQuorum !== 2) {
        throw new Error('invalid minimum signature count');
      }
      const foundAddresses = {};

      const signerEntries = signerList.SignerEntries;
      if (signerEntries.length !== 3) {
        throw new Error('invalid signer list length');
      }
      for (const { SignerEntry } of signerEntries) {
        const weight = SignerEntry.SignerWeight;
        const address = SignerEntry.Account;
        if (weight !== 1) {
          throw new Error('invalid signer weight');
        }

        // if it's a dupe of an address we already know, block
        if (foundAddresses[address] >= 1) {
          throw new Error('duplicate signer address');
        }
        foundAddresses[address] = (foundAddresses[address] || 0) + 1;
      }

      if (foundAddresses[userAddress] !== 1) {
        throw new Error('unexpected incidence frequency of user signer address');
      }
      if (foundAddresses[backupAddress] !== 1) {
        throw new Error('unexpected incidence frequency of user signer address');
      }

      // make sure the flags disable the master key and enforce destination tags
      const USER_KEY_SETTING_FLAG = 65536;
      const MASTER_KEY_DEACTIVATION_FLAG = 1048576;
      const REQUIRE_DESTINATION_TAG_FLAG = 131072;
      if ((accountFlags & USER_KEY_SETTING_FLAG) !== 0) {
        throw new Error('a custom user key has been set');
      }
      if ((accountFlags & MASTER_KEY_DEACTIVATION_FLAG) !== MASTER_KEY_DEACTIVATION_FLAG) {
        throw new Error('the master key has not been deactivated');
      }
      if ((accountFlags & REQUIRE_DESTINATION_TAG_FLAG) !== REQUIRE_DESTINATION_TAG_FLAG) {
        throw new Error('the destination flag requirement has not been activated');
      }

      // recover the funds
      const reserve = baseReserve.plus(reserveDelta.times(5));
      const recoverableBalance = balance.minus(reserve);

      const rawDestination = params.recoveryDestination;
      const destinationDetails = url.parse(rawDestination);
      const queryDetails = querystring.parse(destinationDetails.query);
      const destinationAddress = destinationDetails.pathname;
      let destinationTag = undefined;

      if (Array.isArray(queryDetails.dt)) {
        // if queryDetails.dt is an array, that means dt was given multiple times, which is not valid
        throw new InvalidAddressError(`destination tag can appear at most once, but ${queryDetails.dt.length} destination tags were found`);
      }

      const parsedTag = parseInt(queryDetails.dt, 10);
      if (Number.isInteger(parsedTag)) {
        destinationTag = parsedTag;
      }

      const transaction = {
        TransactionType: 'Payment',
        Account: params.rootAddress, // source address
        Destination: destinationAddress,
        DestinationTag: destinationTag,
        Amount: recoverableBalance.toFixed(0),
        Flags: 2147483648,
        LastLedgerSequence: currentLedger + 1000000, // give it 1 million ledgers' time (~1 month, suitable for KRS)
        Fee: openLedgerFee.times(3).toFixed(0), // the factor three is for the multisigning
        Sequence: sequenceId
      };
      const txJSON = JSON.stringify(transaction);

      if (isUnsignedSweep) {
        return txJSON;
      }
//.........这里部分代码省略.........
开发者ID:BitGo,项目名称:BitGoJS,代码行数:101,代码来源:xrp.ts

示例6: decimalToFixedPoint

export function decimalToFixedPoint(decimalValue: BigNumber, conversionFactor: BigNumber): BigNumber {
  return decimalValue.times(conversionFactor);
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:3,代码来源:convert-fixed-point-to-decimal.ts


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