Stop exporting assertions from order-utils
This commit is contained in:
		@@ -1,6 +1,5 @@
 | 
				
			|||||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
 | 
					import { schemas, SchemaValidator } from '@0xproject/json-schemas';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    assert,
 | 
					 | 
				
			||||||
    generatePseudoRandomSalt,
 | 
					    generatePseudoRandomSalt,
 | 
				
			||||||
    getOrderHashHex,
 | 
					    getOrderHashHex,
 | 
				
			||||||
    isValidOrderHash,
 | 
					    isValidOrderHash,
 | 
				
			||||||
@@ -24,6 +23,7 @@ import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
 | 
				
			|||||||
import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
 | 
					import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
 | 
				
			||||||
import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
 | 
					import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
 | 
				
			||||||
import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types';
 | 
					import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types';
 | 
				
			||||||
 | 
					import { assert } from './utils/assert';
 | 
				
			||||||
import { constants } from './utils/constants';
 | 
					import { constants } from './utils/constants';
 | 
				
			||||||
import { decorators } from './utils/decorators';
 | 
					import { decorators } from './utils/decorators';
 | 
				
			||||||
import { utils } from './utils/utils';
 | 
					import { utils } from './utils/utils';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
import { schemas } from '@0xproject/json-schemas';
 | 
					import { schemas } from '@0xproject/json-schemas';
 | 
				
			||||||
import { assert } from '@0xproject/order-utils';
 | 
					 | 
				
			||||||
import { LogWithDecodedArgs } from '@0xproject/types';
 | 
					import { LogWithDecodedArgs } from '@0xproject/types';
 | 
				
			||||||
import { AbiDecoder, BigNumber } from '@0xproject/utils';
 | 
					import { AbiDecoder, BigNumber } from '@0xproject/utils';
 | 
				
			||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
					import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
				
			||||||
@@ -7,6 +6,7 @@ import * as _ from 'lodash';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { artifacts } from '../artifacts';
 | 
					import { artifacts } from '../artifacts';
 | 
				
			||||||
import { BlockRange, EventCallback, IndexedFilterValues, TransactionOpts, ZeroExError } from '../types';
 | 
					import { BlockRange, EventCallback, IndexedFilterValues, TransactionOpts, ZeroExError } from '../types';
 | 
				
			||||||
 | 
					import { assert } from '../utils/assert';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { ContractWrapper } from './contract_wrapper';
 | 
					import { ContractWrapper } from './contract_wrapper';
 | 
				
			||||||
import { EtherTokenContract, EtherTokenContractEventArgs, EtherTokenEvents } from './generated/ether_token';
 | 
					import { EtherTokenContract, EtherTokenContractEventArgs, EtherTokenEvents } from './generated/ether_token';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
import { schemas } from '@0xproject/json-schemas';
 | 
					import { schemas } from '@0xproject/json-schemas';
 | 
				
			||||||
import { assert, getOrderHashHex } from '@0xproject/order-utils';
 | 
					import { getOrderHashHex } from '@0xproject/order-utils';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    BlockParamLiteral,
 | 
					    BlockParamLiteral,
 | 
				
			||||||
    DecodedLogArgs,
 | 
					    DecodedLogArgs,
 | 
				
			||||||
@@ -31,6 +31,7 @@ import {
 | 
				
			|||||||
    OrderValues,
 | 
					    OrderValues,
 | 
				
			||||||
    ValidateOrderFillableOpts,
 | 
					    ValidateOrderFillableOpts,
 | 
				
			||||||
} from '../types';
 | 
					} from '../types';
 | 
				
			||||||
 | 
					import { assert } from '../utils/assert';
 | 
				
			||||||
import { decorators } from '../utils/decorators';
 | 
					import { decorators } from '../utils/decorators';
 | 
				
			||||||
import { ExchangeTransferSimulator } from '../utils/exchange_transfer_simulator';
 | 
					import { ExchangeTransferSimulator } from '../utils/exchange_transfer_simulator';
 | 
				
			||||||
import { OrderStateUtils } from '../utils/order_state_utils';
 | 
					import { OrderStateUtils } from '../utils/order_state_utils';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,9 @@
 | 
				
			|||||||
import { assert } from '@0xproject/order-utils';
 | 
					 | 
				
			||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
					import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
				
			||||||
import * as _ from 'lodash';
 | 
					import * as _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { artifacts } from '../artifacts';
 | 
					import { artifacts } from '../artifacts';
 | 
				
			||||||
import { Token, TokenMetadata } from '../types';
 | 
					import { Token, TokenMetadata } from '../types';
 | 
				
			||||||
 | 
					import { assert } from '../utils/assert';
 | 
				
			||||||
import { constants } from '../utils/constants';
 | 
					import { constants } from '../utils/constants';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { ContractWrapper } from './contract_wrapper';
 | 
					import { ContractWrapper } from './contract_wrapper';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
import { assert } from '@0xproject/order-utils';
 | 
					 | 
				
			||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
					import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
				
			||||||
import * as _ from 'lodash';
 | 
					import * as _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { artifacts } from '../artifacts';
 | 
					import { artifacts } from '../artifacts';
 | 
				
			||||||
 | 
					import { assert } from '../utils/assert';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { ContractWrapper } from './contract_wrapper';
 | 
					import { ContractWrapper } from './contract_wrapper';
 | 
				
			||||||
import { TokenTransferProxyContract } from './generated/token_transfer_proxy';
 | 
					import { TokenTransferProxyContract } from './generated/token_transfer_proxy';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
import { schemas } from '@0xproject/json-schemas';
 | 
					import { schemas } from '@0xproject/json-schemas';
 | 
				
			||||||
import { assert } from '@0xproject/order-utils';
 | 
					 | 
				
			||||||
import { LogWithDecodedArgs } from '@0xproject/types';
 | 
					import { LogWithDecodedArgs } from '@0xproject/types';
 | 
				
			||||||
import { AbiDecoder, BigNumber } from '@0xproject/utils';
 | 
					import { AbiDecoder, BigNumber } from '@0xproject/utils';
 | 
				
			||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
					import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
				
			||||||
@@ -7,6 +6,7 @@ import * as _ from 'lodash';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { artifacts } from '../artifacts';
 | 
					import { artifacts } from '../artifacts';
 | 
				
			||||||
import { BlockRange, EventCallback, IndexedFilterValues, MethodOpts, TransactionOpts, ZeroExError } from '../types';
 | 
					import { BlockRange, EventCallback, IndexedFilterValues, MethodOpts, TransactionOpts, ZeroExError } from '../types';
 | 
				
			||||||
 | 
					import { assert } from '../utils/assert';
 | 
				
			||||||
import { constants } from '../utils/constants';
 | 
					import { constants } from '../utils/constants';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { ContractWrapper } from './contract_wrapper';
 | 
					import { ContractWrapper } from './contract_wrapper';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
import { assert } from '@0xproject/order-utils';
 | 
					 | 
				
			||||||
import { BlockParamLiteral, LogEntry } from '@0xproject/types';
 | 
					import { BlockParamLiteral, LogEntry } from '@0xproject/types';
 | 
				
			||||||
import { intervalUtils } from '@0xproject/utils';
 | 
					import { intervalUtils } from '@0xproject/utils';
 | 
				
			||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
					import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
				
			||||||
import * as _ from 'lodash';
 | 
					import * as _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { EventWatcherCallback, ZeroExError } from '../types';
 | 
					import { EventWatcherCallback, ZeroExError } from '../types';
 | 
				
			||||||
 | 
					import { assert } from '../utils/assert';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
 | 
					const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
import { schemas } from '@0xproject/json-schemas';
 | 
					import { schemas } from '@0xproject/json-schemas';
 | 
				
			||||||
import { assert } from '@0xproject/order-utils';
 | 
					 | 
				
			||||||
import { BlockParamLiteral, LogWithDecodedArgs, SignedOrder } from '@0xproject/types';
 | 
					import { BlockParamLiteral, LogWithDecodedArgs, SignedOrder } from '@0xproject/types';
 | 
				
			||||||
import { AbiDecoder, intervalUtils } from '@0xproject/utils';
 | 
					import { AbiDecoder, intervalUtils } from '@0xproject/utils';
 | 
				
			||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
					import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
				
			||||||
@@ -34,6 +33,7 @@ import {
 | 
				
			|||||||
    OrderStateWatcherConfig,
 | 
					    OrderStateWatcherConfig,
 | 
				
			||||||
    ZeroExError,
 | 
					    ZeroExError,
 | 
				
			||||||
} from '../types';
 | 
					} from '../types';
 | 
				
			||||||
 | 
					import { assert } from '../utils/assert';
 | 
				
			||||||
import { OrderStateUtils } from '../utils/order_state_utils';
 | 
					import { OrderStateUtils } from '../utils/order_state_utils';
 | 
				
			||||||
import { utils } from '../utils/utils';
 | 
					import { utils } from '../utils/utils';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										31
									
								
								packages/0x.js/src/utils/assert.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								packages/0x.js/src/utils/assert.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					import { assert as sharedAssert } from '@0xproject/assert';
 | 
				
			||||||
 | 
					// We need those two unused imports because they're actually used by sharedAssert which gets injected here
 | 
				
			||||||
 | 
					// tslint:disable-next-line:no-unused-variable
 | 
				
			||||||
 | 
					import { Schema } from '@0xproject/json-schemas';
 | 
				
			||||||
 | 
					// tslint:disable-next-line:no-unused-variable
 | 
				
			||||||
 | 
					import { ECSignature } from '@0xproject/types';
 | 
				
			||||||
 | 
					import { BigNumber } from '@0xproject/utils';
 | 
				
			||||||
 | 
					import { Web3Wrapper } from '@0xproject/web3-wrapper';
 | 
				
			||||||
 | 
					import * as _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { isValidSignature } from '@0xproject/order-utils';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const assert = {
 | 
				
			||||||
 | 
					    ...sharedAssert,
 | 
				
			||||||
 | 
					    isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
 | 
				
			||||||
 | 
					        const isValid = isValidSignature(orderHash, ecSignature, signerAddress);
 | 
				
			||||||
 | 
					        this.assert(isValid, `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`,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -12,10 +12,6 @@ import { isValidSignature } from './signature_utils';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export const assert = {
 | 
					export const assert = {
 | 
				
			||||||
    ...sharedAssert,
 | 
					    ...sharedAssert,
 | 
				
			||||||
    isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
 | 
					 | 
				
			||||||
        const isValid = isValidSignature(orderHash, ecSignature, signerAddress);
 | 
					 | 
				
			||||||
        this.assert(isValid, `Expected order with hash '${orderHash}' to have a valid signature`);
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    async isSenderAddressAsync(
 | 
					    async isSenderAddressAsync(
 | 
				
			||||||
        variableName: string,
 | 
					        variableName: string,
 | 
				
			||||||
        senderAddressHex: string,
 | 
					        senderAddressHex: string,
 | 
				
			||||||
@@ -28,8 +24,4 @@ export const assert = {
 | 
				
			|||||||
            `Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
 | 
					            `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');
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,5 @@ export { getOrderHashHex, isValidOrderHash } from './order_hash';
 | 
				
			|||||||
export { isValidSignature, signOrderHashAsync } from './signature_utils';
 | 
					export { isValidSignature, signOrderHashAsync } from './signature_utils';
 | 
				
			||||||
export { orderFactory } from './order_factory';
 | 
					export { orderFactory } from './order_factory';
 | 
				
			||||||
export { generatePseudoRandomSalt } from './salt';
 | 
					export { generatePseudoRandomSalt } from './salt';
 | 
				
			||||||
export { assert } from './assert';
 | 
					 | 
				
			||||||
export { constants } from './constants';
 | 
					export { constants } from './constants';
 | 
				
			||||||
export { OrderError } from './types';
 | 
					export { OrderError } from './types';
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user