Add zeroEx.etherToken.getContractAddressifExists
This commit is contained in:
		@@ -34,7 +34,7 @@ const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export class ContractWrapper {
 | 
					export class ContractWrapper {
 | 
				
			||||||
    protected _web3Wrapper: Web3Wrapper;
 | 
					    protected _web3Wrapper: Web3Wrapper;
 | 
				
			||||||
    private _networkId: number;
 | 
					    protected _networkId: number;
 | 
				
			||||||
    private _abiDecoder?: AbiDecoder;
 | 
					    private _abiDecoder?: AbiDecoder;
 | 
				
			||||||
    private _blockAndLogStreamerIfExists: BlockAndLogStreamer | undefined;
 | 
					    private _blockAndLogStreamerIfExists: BlockAndLogStreamer | undefined;
 | 
				
			||||||
    private _blockAndLogStreamInterval: NodeJS.Timer;
 | 
					    private _blockAndLogStreamInterval: NodeJS.Timer;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -163,6 +163,15 @@ export class EtherTokenWrapper extends ContractWrapper {
 | 
				
			|||||||
    public unsubscribeAll(): void {
 | 
					    public unsubscribeAll(): void {
 | 
				
			||||||
        super.unsubscribeAll();
 | 
					        super.unsubscribeAll();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Retrieves the Ethereum address of the EtherToken contract deployed on the network
 | 
				
			||||||
 | 
					     * that the user-passed web3 provider is connected to. If it's an unknown private network - undefined is returned.
 | 
				
			||||||
 | 
					     * @returns The Ethereum address of the EtherToken contract or undefined.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public getContractAddressIfExists(): string | undefined {
 | 
				
			||||||
 | 
					        const contractAddress = artifacts.EtherTokenArtifact.networks[this._networkId].address;
 | 
				
			||||||
 | 
					        return contractAddress;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    private _invalidateContractInstance(): void {
 | 
					    private _invalidateContractInstance(): void {
 | 
				
			||||||
        this.unsubscribeAll();
 | 
					        this.unsubscribeAll();
 | 
				
			||||||
        this._etherTokenContractsByAddress = {};
 | 
					        this._etherTokenContractsByAddress = {};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,7 +61,7 @@ describe('EtherTokenWrapper', () => {
 | 
				
			|||||||
        tokens = await zeroEx.tokenRegistry.getTokensAsync();
 | 
					        tokens = await zeroEx.tokenRegistry.getTokensAsync();
 | 
				
			||||||
        userAddresses = await zeroEx.getAvailableAddressesAsync();
 | 
					        userAddresses = await zeroEx.getAvailableAddressesAsync();
 | 
				
			||||||
        addressWithETH = userAddresses[0];
 | 
					        addressWithETH = userAddresses[0];
 | 
				
			||||||
        wethContractAddress = (zeroEx.etherToken as any)._getContractAddress(artifacts.EtherTokenArtifact);
 | 
					        wethContractAddress = zeroEx.etherToken.getContractAddressIfExists() as string;
 | 
				
			||||||
        depositWeiAmount = (zeroEx as any)._web3Wrapper.toWei(new BigNumber(5));
 | 
					        depositWeiAmount = (zeroEx as any)._web3Wrapper.toWei(new BigNumber(5));
 | 
				
			||||||
        decimalPlaces = 7;
 | 
					        decimalPlaces = 7;
 | 
				
			||||||
        addressWithoutFunds = userAddresses[1];
 | 
					        addressWithoutFunds = userAddresses[1];
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user