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


TypeScript assert.assert类代码示例

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


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

示例1: getOrdersAsync

 /**
  * Retrieve orders from the API
  * @param   requestOpts     Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
  * @return  The resulting SignedOrders that match the request
  */
 public async getOrdersAsync(requestOpts?: OrdersRequestOpts & PagedRequestOpts): Promise<SignedOrder[]> {
     if (!_.isUndefined(requestOpts)) {
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
     }
     const httpRequestOpts = {
         params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
     };
     const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, httpRequestOpts);
     const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
     return orders;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:17,代码来源:http_client.ts

示例2: getTokenPairsAsync

 /**
  * Retrieve token pair info from the API
  * @param   requestOpts     Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
  * @return  The resulting TokenPairsItems that match the request
  */
 public async getTokenPairsAsync(requestOpts?: TokenPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]> {
     if (!_.isUndefined(requestOpts)) {
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.tokenPairsRequestOptsSchema);
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
     }
     const httpRequestOpts = {
         params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
     };
     const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, httpRequestOpts);
     const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson);
     return tokenPairs;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:17,代码来源:http_client.ts

示例3: getOrderbookAsync

 /**
  * Retrieve an orderbook from the API
  * @param   request         An OrderbookRequest instance describing the specific orderbook to retrieve
  * @param   requestOpts     Options specifying page information, defaults to { page: 1, perPage: 100 }
  * @return  The resulting OrderbookResponse that matches the request
  */
 public async getOrderbookAsync(
     request: OrderbookRequest,
     requestOpts?: PagedRequestOpts,
 ): Promise<OrderbookResponse> {
     assert.doesConformToSchema('request', request, clientSchemas.orderBookRequestSchema);
     if (!_.isUndefined(requestOpts)) {
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
     }
     const httpRequestOpts = {
         params: _.defaults({}, request, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
     };
     const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, httpRequestOpts);
     const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
     return orderbook;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:21,代码来源:http_client.ts

示例4: submitOrderAsync

 /**
  * Submit a signed order to the API
  * @param   signedOrder     A SignedOrder instance to submit
  */
 public async submitOrderAsync(signedOrder: SignedOrder): Promise<void> {
     assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
     const requestOpts = {
         payload: signedOrder,
     };
     await this._requestAsync('/order', HttpRequestType.Post, requestOpts);
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:11,代码来源:http_client.ts

示例5: getFeesAsync

 /**
  * Retrieve fee information from the API
  * @param   request     A FeesRequest instance describing the specific fees to retrieve
  * @return  The resulting FeesResponse that matches the request
  */
 public async getFeesAsync(request: FeesRequest): Promise<FeesResponse> {
     assert.doesConformToSchema('request', request, clientSchemas.feesRequestSchema);
     const httpRequestOpts = {
         payload: request,
     };
     const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, httpRequestOpts);
     const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson);
     return fees;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:14,代码来源:http_client.ts

示例6: catch

        demandOption: false,
    })
    .option('export-environment', {
        alias: ['ee'],
        describe: 'The relative path to write the postman environment file used by the collection run',
        type: 'string',
        normalize: true,
        demandOption: false,
    })
    .example(
        "$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --environment 'path/to/custom/environment.json' --export-collection 'path/to/collection.json' --export-environment 'path/to/environment.json'",
        'Full usage example',
    ).argv;
// perform extra validation on command line arguments
try {
    assert.isWebUri('args', args.endpointUrl);
} catch (err) {
    logUtils.log(`${chalk.red(`Invalid url format:`)} ${args.endpointUrl}`);
    process.exit(1);
}
if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) {
    logUtils.log(`${chalk.red(`Unsupported network id:`)} ${args.networkId}`);
    logUtils.log(`${chalk.bold(`Supported network ids:`)} ${SUPPORTED_NETWORK_IDS}`);
    process.exit(1);
}
const mainAsync = async () => {
    const newmanReporterOptions = !_.isUndefined(args.output)
        ? {
              reporters: 'json',
              reporter: {
                  json: {
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:index.ts

示例7: parse

import { assert } from '@0xproject/assert';
import { schemas } from '@0xproject/json-schemas';
import * as _ from 'lodash';

import { OrderbookChannelMessage, OrderbookChannelMessageTypes } from '../types';

import { relayerResponseJsonParsers } from './relayer_response_json_parsers';

export const orderbookChannelMessageParser = {
    parse(utf8Data: string): OrderbookChannelMessage {
        const messageObj = JSON.parse(utf8Data);
        const type: string = _.get(messageObj, 'type');
        assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
        assert.isString('type', type);
        switch (type) {
            case OrderbookChannelMessageTypes.Snapshot: {
                assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema);
                const orderbookJson = messageObj.payload;
                const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(orderbookJson);
                return _.assign(messageObj, { payload: orderbook });
            }
            case OrderbookChannelMessageTypes.Update: {
                assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema);
                const orderJson = messageObj.payload;
                const order = relayerResponseJsonParsers.parseOrderJson(orderJson);
                return _.assign(messageObj, { payload: order });
            }
            default: {
                return {
                    type: OrderbookChannelMessageTypes.Unknown,
                    requestId: 0,
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:orderbook_channel_message_parser.ts

示例8: isValidSignature

import { ECSignature } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';

import { signatureUtils } from '../utils/signature_utils';

export const assert = {
    ...sharedAssert,
    isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
        const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress);
        this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`);
    },
    async isSenderAddressAsync(
        variableName: string,
        senderAddressHex: string,
        web3Wrapper: Web3Wrapper,
    ): Promise<void> {
        sharedAssert.isETHAddressHex(variableName, senderAddressHex);
        const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex);
        sharedAssert.assert(
            isSenderAddressAvailable,
            `Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
        );
    },
    async isUserAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise<void> {
        const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
        this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 provider');
    },
};
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:30,代码来源:assert.ts

示例9: constructor

 /**
  * Instantiates a new HttpClient instance
  * @param   url    The relayer API base HTTP url you would like to interact with
  * @return  An instance of HttpClient
  */
 constructor(url: string) {
     assert.isWebUri('url', url);
     this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:9,代码来源:http_client.ts

示例10: getOrderAsync

 /**
  * Retrieve a specific order from the API
  * @param   orderHash     An orderHash generated from the desired order
  * @return  The SignedOrder that matches the supplied orderHash
  */
 public async getOrderAsync(orderHash: string): Promise<SignedOrder> {
     assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
     const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get);
     const order = relayerResponseJsonParsers.parseOrderJson(responseJson);
     return order;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:11,代码来源:http_client.ts


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