aboutsummaryrefslogtreecommitdiffstats
path: root/src/0x.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/0x.ts')
-rw-r--r--src/0x.ts44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/0x.ts b/src/0x.ts
index 49bd31f2d..7e6c38c36 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -20,6 +20,7 @@ import {ECSignature, ZeroExError, Order, SignedOrder, Web3Provider} from './type
import {orderHashSchema} from './schemas/order_hash_schema';
import {orderSchema} from './schemas/order_schemas';
import {SchemaValidator} from './utils/schema_validator';
+import {ExchangeArtifactsByName} from './exchange_artifacts_by_name';
// Customize our BigNumber instances
bigNumberConfigs.configure();
@@ -158,7 +159,7 @@ export class ZeroEx {
this._web3Wrapper = new Web3Wrapper(provider);
this.token = new TokenWrapper(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.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token);
}
@@ -254,4 +255,45 @@ export class ZeroEx {
}
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;
+ }
}
r suite for all kinds of nifty' href='/~lantw44/cgit/freebsd-ports/commit/sysutils/lcdproc/Makefile?id=74c4e9504235b100b0611c067ea69e9e566c7b14'>74c4e9504235
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33








                                                                    
                 





                                                         
                                                                        







                         
                                                                          






                                                                           
# New ports collection makefile for:    lcdproc
# Date created:             Sat Jun  1 20:03:41 EDT 2002
# Whom:                 pat
#
# $FreeBSD$
#

PORTNAME=   lcdproc
PORTVERSION=    0.4.3
PORTREVISION=   1
CATEGORIES= sysutils
MASTER_SITES=   http://lcdproc.omnipotent.net/download/ \
        ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}

MAINTAINER= ports@FreeBSD.org
COMMENT=    A client/server suite for all kinds of nifty LCD devices

ONLY_FOR_ARCHS= i386
GNU_CONFIGURE=  yes

MAN1=       lcdproc.1
MAN8=       LCDd.8

pre-patch:
    @${SED} -e 's|%%PREFIX%%|${PREFIX}|g' ${FILESDIR}/LCDd.sh.sample \
        > ${WRKSRC}/LCDd.sh.sample

post-install:
    @${INSTALL_DATA} ${WRKSRC}/LCDd.conf ${PREFIX}/etc/LCDd.conf.sample
    @${INSTALL_SCRIPT} ${WRKSRC}/LCDd.sh.sample ${PREFIX}/etc/rc.d

.include <bsd.port.mk>