當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript BigNumber.eq方法代碼示例

本文整理匯總了TypeScript中@0xproject/utils.BigNumber.eq方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript BigNumber.eq方法的具體用法?TypeScript BigNumber.eq怎麽用?TypeScript BigNumber.eq使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@0xproject/utils.BigNumber的用法示例。


在下文中一共展示了BigNumber.eq方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: _validateRemainingFillAmountNotZeroOrThrow

 private static _validateRemainingFillAmountNotZeroOrThrow(
     takerTokenAmount: BigNumber,
     unavailableTakerTokenAmount: BigNumber,
 ) {
     if (takerTokenAmount.eq(unavailableTakerTokenAmount)) {
         throw new Error(ExchangeContractErrs.OrderRemainingFillAmountZero);
     }
 }
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:8,代碼來源:order_validation_utils.ts

示例2: validateCancelOrderThrowIfInvalid

 public static validateCancelOrderThrowIfInvalid(
     order: Order,
     cancelTakerTokenAmount: BigNumber,
     unavailableTakerTokenAmount: BigNumber,
 ): void {
     if (cancelTakerTokenAmount.eq(0)) {
         throw new Error(ExchangeContractErrs.OrderCancelAmountZero);
     }
     if (order.takerTokenAmount.eq(unavailableTakerTokenAmount)) {
         throw new Error(ExchangeContractErrs.OrderAlreadyCancelledOrFilled);
     }
     const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
     if (order.expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {
         throw new Error(ExchangeContractErrs.OrderCancelExpired);
     }
 }
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:16,代碼來源:order_validation_utils.ts

示例3: validateFillOrderThrowIfInvalidAsync

    public async validateFillOrderThrowIfInvalidAsync(
        exchangeTradeEmulator: ExchangeTransferSimulator,
        signedOrder: SignedOrder,
        fillTakerTokenAmount: BigNumber,
        takerAddress: string,
        zrxTokenAddress: string,
    ): Promise<BigNumber> {
        if (fillTakerTokenAmount.eq(0)) {
            throw new Error(ExchangeContractErrs.OrderFillAmountZero);
        }
        const orderHash = utils.getOrderHashHex(signedOrder);
        if (!ZeroEx.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker)) {
            throw new Error(ZeroExError.InvalidSignature);
        }
        const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
        OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
            signedOrder.takerTokenAmount,
            unavailableTakerTokenAmount,
        );
        if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== takerAddress) {
            throw new Error(ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker);
        }
        OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
        const remainingTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
        const filledTakerTokenAmount = remainingTakerTokenAmount.lessThan(fillTakerTokenAmount)
            ? remainingTakerTokenAmount
            : fillTakerTokenAmount;
        await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
            exchangeTradeEmulator,
            signedOrder,
            filledTakerTokenAmount,
            takerAddress,
            zrxTokenAddress,
        );

        const wouldRoundingErrorOccur = await this._exchangeWrapper.isRoundingErrorAsync(
            filledTakerTokenAmount,
            signedOrder.takerTokenAmount,
            signedOrder.makerTokenAmount,
        );
        if (wouldRoundingErrorOccur) {
            throw new Error(ExchangeContractErrs.OrderFillRoundingError);
        }
        return filledTakerTokenAmount;
    }
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:45,代碼來源:order_validation_utils.ts


注:本文中的@0xproject/utils.BigNumber.eq方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。