Move zeroEx.exchange.getAvailableContractAddressesAsync to zeroEx.getAvailableExchangeContractAddressesAsync and zeroEx.exchange.getProxyAuthorizedContractAddressesAsync to zeroEx.getProxyAuthorizedExchangeContractAddressesAsync
This commit is contained in:
		
							
								
								
									
										44
									
								
								src/0x.ts
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								src/0x.ts
									
									
									
									
									
								
							@@ -20,6 +20,7 @@ import {ECSignature, ZeroExError, Order, SignedOrder, Web3Provider} from './type
 | 
				
			|||||||
import {orderHashSchema} from './schemas/order_hash_schema';
 | 
					import {orderHashSchema} from './schemas/order_hash_schema';
 | 
				
			||||||
import {orderSchema} from './schemas/order_schemas';
 | 
					import {orderSchema} from './schemas/order_schemas';
 | 
				
			||||||
import {SchemaValidator} from './utils/schema_validator';
 | 
					import {SchemaValidator} from './utils/schema_validator';
 | 
				
			||||||
 | 
					import {ExchangeArtifactsByName} from './exchange_artifacts_by_name';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Customize our BigNumber instances
 | 
					// Customize our BigNumber instances
 | 
				
			||||||
bigNumberConfigs.configure();
 | 
					bigNumberConfigs.configure();
 | 
				
			||||||
@@ -158,7 +159,7 @@ export class ZeroEx {
 | 
				
			|||||||
        this._web3Wrapper = new Web3Wrapper(provider);
 | 
					        this._web3Wrapper = new Web3Wrapper(provider);
 | 
				
			||||||
        this.token = new TokenWrapper(this._web3Wrapper);
 | 
					        this.token = new TokenWrapper(this._web3Wrapper);
 | 
				
			||||||
        this.proxy = new ProxyWrapper(this._web3Wrapper);
 | 
					        this.proxy = new ProxyWrapper(this._web3Wrapper);
 | 
				
			||||||
        this.exchange = new ExchangeWrapper(this._web3Wrapper, this.token, this.proxy);
 | 
					        this.exchange = new ExchangeWrapper(this._web3Wrapper, this.token);
 | 
				
			||||||
        this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper);
 | 
					        this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper);
 | 
				
			||||||
        this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token);
 | 
					        this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -254,4 +255,45 @@ export class ZeroEx {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return ecSignature;
 | 
					        return ecSignature;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Returns the ethereum addresses of all available exchange contracts
 | 
				
			||||||
 | 
					     * on the network that the provided web3 instance is connected to
 | 
				
			||||||
 | 
					     * @return  The ethereum addresses of all available exchange contracts.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public async getAvailableExchangeContractAddressesAsync(): Promise<string[]> {
 | 
				
			||||||
 | 
					        const networkId = await this._web3Wrapper.getNetworkIdIfExistsAsync();
 | 
				
			||||||
 | 
					        if (_.isUndefined(networkId)) {
 | 
				
			||||||
 | 
					            return [];
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            const exchangeArtifacts = _.values(ExchangeArtifactsByName);
 | 
				
			||||||
 | 
					            const networkSpecificExchangeArtifacts = _.compact(_.map(
 | 
				
			||||||
 | 
					                exchangeArtifacts, exchangeArtifact => exchangeArtifact.networks[networkId]));
 | 
				
			||||||
 | 
					            const exchangeAddresses = _.map(
 | 
				
			||||||
 | 
					                networkSpecificExchangeArtifacts,
 | 
				
			||||||
 | 
					                networkSpecificExchangeArtifact => networkSpecificExchangeArtifact.address,
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            return exchangeAddresses;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Returns the ethereum addresses of all available exchange contracts
 | 
				
			||||||
 | 
					     * on the network that the provided web3 instance is connected to
 | 
				
			||||||
 | 
					     * that are currently authorized on the Proxy contract
 | 
				
			||||||
 | 
					     * @return  The ethereum addresses of all available and authorized exchange contract.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public async getProxyAuthorizedExchangeContractAddressesAsync(): Promise<string[]> {
 | 
				
			||||||
 | 
					        const exchangeContractAddresses = await this.getAvailableExchangeContractAddressesAsync();
 | 
				
			||||||
 | 
					        const proxyAuthorizedExchangeContractAddresses = [];
 | 
				
			||||||
 | 
					        for (const exchangeContractAddress of exchangeContractAddresses) {
 | 
				
			||||||
 | 
					            const isAuthorized = await this._isExchangeContractAddressProxyAuthorizedAsync(exchangeContractAddress);
 | 
				
			||||||
 | 
					            if (isAuthorized) {
 | 
				
			||||||
 | 
					                proxyAuthorizedExchangeContractAddresses.push(exchangeContractAddress);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return proxyAuthorizedExchangeContractAddresses;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    private async _isExchangeContractAddressProxyAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
 | 
				
			||||||
 | 
					        const isAuthorized = await this.proxy.isAuthorizedAsync(exchangeContractAddress);
 | 
				
			||||||
 | 
					        return isAuthorized;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,6 @@ import {utils} from '../utils/utils';
 | 
				
			|||||||
import {eventUtils} from '../utils/event_utils';
 | 
					import {eventUtils} from '../utils/event_utils';
 | 
				
			||||||
import {ContractWrapper} from './contract_wrapper';
 | 
					import {ContractWrapper} from './contract_wrapper';
 | 
				
			||||||
import {ProxyWrapper} from './proxy_wrapper';
 | 
					import {ProxyWrapper} from './proxy_wrapper';
 | 
				
			||||||
import {ExchangeArtifactsByName} from '../exchange_artifacts_by_name';
 | 
					 | 
				
			||||||
import {ecSignatureSchema} from '../schemas/ec_signature_schema';
 | 
					import {ecSignatureSchema} from '../schemas/ec_signature_schema';
 | 
				
			||||||
import {signedOrdersSchema} from '../schemas/signed_orders_schema';
 | 
					import {signedOrdersSchema} from '../schemas/signed_orders_schema';
 | 
				
			||||||
import {subscriptionOptsSchema} from '../schemas/subscription_opts_schema';
 | 
					import {subscriptionOptsSchema} from '../schemas/subscription_opts_schema';
 | 
				
			||||||
@@ -50,6 +49,7 @@ import {signedOrderSchema, orderSchema} from '../schemas/order_schemas';
 | 
				
			|||||||
import {constants} from '../utils/constants';
 | 
					import {constants} from '../utils/constants';
 | 
				
			||||||
import {TokenWrapper} from './token_wrapper';
 | 
					import {TokenWrapper} from './token_wrapper';
 | 
				
			||||||
import {decorators} from '../utils/decorators';
 | 
					import {decorators} from '../utils/decorators';
 | 
				
			||||||
 | 
					import {ExchangeArtifactsByName} from '../exchange_artifacts_by_name';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This class includes all the functionality related to calling methods and subscribing to
 | 
					 * This class includes all the functionality related to calling methods and subscribing to
 | 
				
			||||||
@@ -67,7 +67,6 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
    private _exchangeContractByAddress: ExchangeContractByAddress;
 | 
					    private _exchangeContractByAddress: ExchangeContractByAddress;
 | 
				
			||||||
    private _exchangeLogEventEmitters: ContractEventEmitter[];
 | 
					    private _exchangeLogEventEmitters: ContractEventEmitter[];
 | 
				
			||||||
    private _tokenWrapper: TokenWrapper;
 | 
					    private _tokenWrapper: TokenWrapper;
 | 
				
			||||||
    private _proxyWrapper: ProxyWrapper;
 | 
					 | 
				
			||||||
    private static _getOrderAddressesAndValues(order: Order): [OrderAddresses, OrderValues] {
 | 
					    private static _getOrderAddressesAndValues(order: Order): [OrderAddresses, OrderValues] {
 | 
				
			||||||
        const orderAddresses: OrderAddresses = [
 | 
					        const orderAddresses: OrderAddresses = [
 | 
				
			||||||
            order.maker,
 | 
					            order.maker,
 | 
				
			||||||
@@ -86,10 +85,9 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
        ];
 | 
					        ];
 | 
				
			||||||
        return [orderAddresses, orderValues];
 | 
					        return [orderAddresses, orderValues];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper, proxyWrapper: ProxyWrapper) {
 | 
					    constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper) {
 | 
				
			||||||
        super(web3Wrapper);
 | 
					        super(web3Wrapper);
 | 
				
			||||||
        this._tokenWrapper = tokenWrapper;
 | 
					        this._tokenWrapper = tokenWrapper;
 | 
				
			||||||
        this._proxyWrapper = proxyWrapper;
 | 
					 | 
				
			||||||
        this._exchangeLogEventEmitters = [];
 | 
					        this._exchangeLogEventEmitters = [];
 | 
				
			||||||
        this._exchangeContractByAddress = {};
 | 
					        this._exchangeContractByAddress = {};
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -609,43 +607,6 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
        this._exchangeLogEventEmitters.push(eventEmitter);
 | 
					        this._exchangeLogEventEmitters.push(eventEmitter);
 | 
				
			||||||
        return eventEmitter;
 | 
					        return eventEmitter;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Returns the ethereum addresses of all available exchange contracts
 | 
					 | 
				
			||||||
     * on the network that the provided web3 instance is connected to
 | 
					 | 
				
			||||||
     * @return  The ethereum addresses of all available exchange contracts.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public async getAvailableContractAddressesAsync(): Promise<string[]> {
 | 
					 | 
				
			||||||
        const networkId = await this._web3Wrapper.getNetworkIdIfExistsAsync();
 | 
					 | 
				
			||||||
        if (_.isUndefined(networkId)) {
 | 
					 | 
				
			||||||
            return [];
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            const exchangeArtifacts = _.values(ExchangeArtifactsByName);
 | 
					 | 
				
			||||||
            const networkSpecificExchangeArtifacts = _.compact(_.map(
 | 
					 | 
				
			||||||
                exchangeArtifacts, exchangeArtifact => exchangeArtifact.networks[networkId]));
 | 
					 | 
				
			||||||
            const exchangeAddresses = _.map(
 | 
					 | 
				
			||||||
                networkSpecificExchangeArtifacts,
 | 
					 | 
				
			||||||
                networkSpecificExchangeArtifact => networkSpecificExchangeArtifact.address,
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
            return exchangeAddresses;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Returns the ethereum addresses of all available exchange contracts
 | 
					 | 
				
			||||||
     * on the network that the provided web3 instance is connected to
 | 
					 | 
				
			||||||
     * that are currently authorized on the Proxy contract
 | 
					 | 
				
			||||||
     * @return  The ethereum addresses of all available and authorized exchange contract.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public async getProxyAuthorizedContractAddressesAsync(): Promise<string[]> {
 | 
					 | 
				
			||||||
        const exchangeContractAddresses = await this.getAvailableContractAddressesAsync();
 | 
					 | 
				
			||||||
        const proxyAuthorizedExchangeContractAddresses = [];
 | 
					 | 
				
			||||||
        for (const exchangeContractAddress of exchangeContractAddresses) {
 | 
					 | 
				
			||||||
            const isAuthorized = await this._isExchangeContractAddressProxyAuthorizedAsync(exchangeContractAddress);
 | 
					 | 
				
			||||||
            if (isAuthorized) {
 | 
					 | 
				
			||||||
                proxyAuthorizedExchangeContractAddresses.push(exchangeContractAddress);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return proxyAuthorizedExchangeContractAddresses;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Stops watching for all exchange events
 | 
					     * Stops watching for all exchange events
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -659,10 +620,6 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
        await this.stopWatchingAllEventsAsync();
 | 
					        await this.stopWatchingAllEventsAsync();
 | 
				
			||||||
        this._exchangeContractByAddress = {};
 | 
					        this._exchangeContractByAddress = {};
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    private async _isExchangeContractAddressProxyAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
 | 
					 | 
				
			||||||
        const isAuthorized = await this._proxyWrapper.isAuthorizedAsync(exchangeContractAddress);
 | 
					 | 
				
			||||||
        return isAuthorized;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    private async _isValidSignatureUsingContractCallAsync(dataHex: string, ecSignature: ECSignature,
 | 
					    private async _isValidSignatureUsingContractCallAsync(dataHex: string, ecSignature: ECSignature,
 | 
				
			||||||
                                                          signerAddressHex: string,
 | 
					                                                          signerAddressHex: string,
 | 
				
			||||||
                                                          exchangeContractAddress: string): Promise<boolean> {
 | 
					                                                          exchangeContractAddress: string): Promise<boolean> {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,17 +6,18 @@ import * as BigNumber from 'bignumber.js';
 | 
				
			|||||||
import * as Sinon from 'sinon';
 | 
					import * as Sinon from 'sinon';
 | 
				
			||||||
import {ZeroEx, Order} from '../src';
 | 
					import {ZeroEx, Order} from '../src';
 | 
				
			||||||
import {constants} from './utils/constants';
 | 
					import {constants} from './utils/constants';
 | 
				
			||||||
 | 
					import {assert} from '../src/utils/assert';
 | 
				
			||||||
import {web3Factory} from './utils/web3_factory';
 | 
					import {web3Factory} from './utils/web3_factory';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
chaiSetup.configure();
 | 
					chaiSetup.configure();
 | 
				
			||||||
const expect = chai.expect;
 | 
					const expect = chai.expect;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('ZeroEx library', () => {
 | 
					describe('ZeroEx library', () => {
 | 
				
			||||||
 | 
					    const web3 = web3Factory.create();
 | 
				
			||||||
 | 
					    const zeroEx = new ZeroEx(web3.currentProvider);
 | 
				
			||||||
    describe('#setProvider', () => {
 | 
					    describe('#setProvider', () => {
 | 
				
			||||||
        it('overrides provider in nested web3s and invalidates contractInstances', async () => {
 | 
					        it('overrides provider in nested web3s and invalidates contractInstances', async () => {
 | 
				
			||||||
            const web3 = web3Factory.create();
 | 
					            const [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
 | 
				
			||||||
            const zeroEx = new ZeroEx(web3.currentProvider);
 | 
					 | 
				
			||||||
            const [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
 | 
					 | 
				
			||||||
            // Instantiate the contract instances with the current provider
 | 
					            // Instantiate the contract instances with the current provider
 | 
				
			||||||
            await (zeroEx.exchange as any)._getExchangeContractAsync(exchangeContractAddress);
 | 
					            await (zeroEx.exchange as any)._getExchangeContractAsync(exchangeContractAddress);
 | 
				
			||||||
            await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
 | 
					            await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
 | 
				
			||||||
@@ -51,11 +52,9 @@ describe('ZeroEx library', () => {
 | 
				
			|||||||
            s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
 | 
					            s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
 | 
					        const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
 | 
				
			||||||
        const web3 = web3Factory.create();
 | 
					 | 
				
			||||||
        const zeroEx = new ZeroEx(web3.currentProvider);
 | 
					 | 
				
			||||||
        let exchangeContractAddress: string;
 | 
					        let exchangeContractAddress: string;
 | 
				
			||||||
        before(async () => {
 | 
					        before(async () => {
 | 
				
			||||||
            [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
 | 
					            [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        it('should return false if the data doesn\'t pertain to the signature & address', async () => {
 | 
					        it('should return false if the data doesn\'t pertain to the signature & address', async () => {
 | 
				
			||||||
            expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false();
 | 
					            expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false();
 | 
				
			||||||
@@ -148,9 +147,6 @@ describe('ZeroEx library', () => {
 | 
				
			|||||||
            expirationUnixTimestampSec: new BigNumber(0),
 | 
					            expirationUnixTimestampSec: new BigNumber(0),
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        it('calculates the order hash', async () => {
 | 
					        it('calculates the order hash', async () => {
 | 
				
			||||||
            const web3 = web3Factory.create();
 | 
					 | 
				
			||||||
            const zeroEx = new ZeroEx(web3.currentProvider);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            const orderHash = zeroEx.getOrderHashHex(order);
 | 
					            const orderHash = zeroEx.getOrderHashHex(order);
 | 
				
			||||||
            expect(orderHash).to.be.equal(expectedOrderHash);
 | 
					            expect(orderHash).to.be.equal(expectedOrderHash);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@@ -158,8 +154,6 @@ describe('ZeroEx library', () => {
 | 
				
			|||||||
    describe('#signOrderHashAsync', () => {
 | 
					    describe('#signOrderHashAsync', () => {
 | 
				
			||||||
        let stubs: Sinon.SinonStub[] = [];
 | 
					        let stubs: Sinon.SinonStub[] = [];
 | 
				
			||||||
        let makerAddress: string;
 | 
					        let makerAddress: string;
 | 
				
			||||||
        const web3 = web3Factory.create();
 | 
					 | 
				
			||||||
        const zeroEx = new ZeroEx(web3.currentProvider);
 | 
					 | 
				
			||||||
        before(async () => {
 | 
					        before(async () => {
 | 
				
			||||||
            const availableAddreses = await zeroEx.getAvailableAddressesAsync();
 | 
					            const availableAddreses = await zeroEx.getAvailableAddressesAsync();
 | 
				
			||||||
            makerAddress = availableAddreses[0];
 | 
					            makerAddress = availableAddreses[0];
 | 
				
			||||||
@@ -222,4 +216,22 @@ describe('ZeroEx library', () => {
 | 
				
			|||||||
            expect(ecSignature).to.deep.equal(expectedECSignature);
 | 
					            expect(ecSignature).to.deep.equal(expectedECSignature);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					    describe('#getAvailableExchangeContractAddressesAsync', () => {
 | 
				
			||||||
 | 
					        it('returns the exchange contract addresses', async () => {
 | 
				
			||||||
 | 
					            const exchangeAddresses = await zeroEx.getAvailableExchangeContractAddressesAsync();
 | 
				
			||||||
 | 
					            _.map(exchangeAddresses, exchangeAddress => {
 | 
				
			||||||
 | 
					                assert.isETHAddressHex('exchangeAddress', exchangeAddress);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    describe('#getProxyAuthorizedExchangeContractAddressesAsync', () => {
 | 
				
			||||||
 | 
					        it('returns the Proxy authorized exchange contract addresses', async () => {
 | 
				
			||||||
 | 
					            const exchangeAddresses = await zeroEx.getProxyAuthorizedExchangeContractAddressesAsync();
 | 
				
			||||||
 | 
					            for (const exchangeAddress of exchangeAddresses) {
 | 
				
			||||||
 | 
					                assert.isETHAddressHex('exchangeAddress', exchangeAddress);
 | 
				
			||||||
 | 
					                const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(exchangeAddress);
 | 
				
			||||||
 | 
					                expect(isAuthorized).to.be.true();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ describe('Artifacts', () => {
 | 
				
			|||||||
            await (zeroEx.token as any)._getProxyAddressAsync();
 | 
					            await (zeroEx.token as any)._getProxyAddressAsync();
 | 
				
			||||||
        }).timeout(TIMEOUT);
 | 
					        }).timeout(TIMEOUT);
 | 
				
			||||||
        it('exchange contract is deployed', async () => {
 | 
					        it('exchange contract is deployed', async () => {
 | 
				
			||||||
            const exchangeContractAddresses = await zeroEx.exchange.getAvailableContractAddressesAsync();
 | 
					            const exchangeContractAddresses = await zeroEx.getAvailableExchangeContractAddressesAsync();
 | 
				
			||||||
            expect(exchangeContractAddresses).to.have.lengthOf.above(0);
 | 
					            expect(exchangeContractAddresses).to.have.lengthOf.above(0);
 | 
				
			||||||
        }).timeout(TIMEOUT);
 | 
					        }).timeout(TIMEOUT);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ describe('ExchangeWrapper', () => {
 | 
				
			|||||||
    before(async () => {
 | 
					    before(async () => {
 | 
				
			||||||
        web3 = web3Factory.create();
 | 
					        web3 = web3Factory.create();
 | 
				
			||||||
        zeroEx = new ZeroEx(web3.currentProvider);
 | 
					        zeroEx = new ZeroEx(web3.currentProvider);
 | 
				
			||||||
        [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
 | 
					        [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
 | 
				
			||||||
        userAddresses = await promisify(web3.eth.getAccounts)();
 | 
					        userAddresses = await promisify(web3.eth.getAccounts)();
 | 
				
			||||||
        tokens = await zeroEx.tokenRegistry.getTokensAsync();
 | 
					        tokens = await zeroEx.tokenRegistry.getTokensAsync();
 | 
				
			||||||
        tokenUtils = new TokenUtils(tokens);
 | 
					        tokenUtils = new TokenUtils(tokens);
 | 
				
			||||||
@@ -819,22 +819,4 @@ describe('ExchangeWrapper', () => {
 | 
				
			|||||||
            expect(orderHash).to.equal(orderHashFromContract);
 | 
					            expect(orderHash).to.equal(orderHashFromContract);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    describe('#getAvailableContractAddressesAsync', () => {
 | 
					 | 
				
			||||||
        it('returns the exchange contract addresses', async () => {
 | 
					 | 
				
			||||||
            const exchangeAddresses = await zeroEx.exchange.getAvailableContractAddressesAsync();
 | 
					 | 
				
			||||||
            _.map(exchangeAddresses, exchangeAddress => {
 | 
					 | 
				
			||||||
                assert.isETHAddressHex('exchangeAddress', exchangeAddress);
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    describe('#getProxyAuthorizedContractAddressesAsync', () => {
 | 
					 | 
				
			||||||
        it('returns the Proxy authorized exchange contract addresses', async () => {
 | 
					 | 
				
			||||||
            const exchangeAddresses = await zeroEx.exchange.getProxyAuthorizedContractAddressesAsync();
 | 
					 | 
				
			||||||
            for (const exchangeAddress of exchangeAddresses) {
 | 
					 | 
				
			||||||
                assert.isETHAddressHex('exchangeAddress', exchangeAddress);
 | 
					 | 
				
			||||||
                const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(exchangeAddress);
 | 
					 | 
				
			||||||
                expect(isAuthorized).to.be.true();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ describe('ProxyWrapper', () => {
 | 
				
			|||||||
    before(async () => {
 | 
					    before(async () => {
 | 
				
			||||||
        const web3 = web3Factory.create();
 | 
					        const web3 = web3Factory.create();
 | 
				
			||||||
        zeroEx = new ZeroEx(web3.currentProvider);
 | 
					        zeroEx = new ZeroEx(web3.currentProvider);
 | 
				
			||||||
        [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
 | 
					        [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    describe('#isAuthorizedAsync', () => {
 | 
					    describe('#isAuthorizedAsync', () => {
 | 
				
			||||||
        it('should return false if the address is not authorized', async () => {
 | 
					        it('should return false if the address is not authorized', async () => {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user