aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/0x.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-28 17:05:36 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-04-02 17:34:29 +0800
commit4d9029bb0e3b215efdf165704c80d3bacef0e85a (patch)
tree8f699dcd0a7b5fba3c31c065a62d640407bba8c3 /packages/0x.js/src/0x.ts
parentbc49dde4d5d24b9a8b01459bde061f9b23fb5898 (diff)
downloaddexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar
dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.gz
dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.bz2
dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.lz
dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.xz
dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.zst
dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.zip
Add metacoin example project
Diffstat (limited to 'packages/0x.js/src/0x.ts')
-rw-r--r--packages/0x.js/src/0x.ts52
1 files changed, 10 insertions, 42 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index b82cc820f..87d8ffd39 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -58,7 +58,6 @@ export class ZeroEx {
*/
public proxy: TokenTransferProxyWrapper;
private _web3Wrapper: Web3Wrapper;
- private _abiDecoder: AbiDecoder;
/**
* Verifies that the elliptic curve signature `signature` was generated
* by signing `data` with the private key corresponding to the `signerAddress` address.
@@ -167,21 +166,22 @@ export class ZeroEx {
]);
const artifactJSONs = _.values(artifacts);
const abiArrays = _.map(artifactJSONs, artifact => artifact.abi);
- this._abiDecoder = new AbiDecoder(abiArrays);
const defaults = {
gasPrice: config.gasPrice,
};
this._web3Wrapper = new Web3Wrapper(provider, defaults);
+ _.forEach(abiArrays, abi => {
+ this._web3Wrapper.abiDecoder.addABI(abi);
+ });
this.proxy = new TokenTransferProxyWrapper(
this._web3Wrapper,
config.networkId,
config.tokenTransferProxyContractAddress,
);
- this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this._abiDecoder, this.proxy);
+ this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this.proxy);
this.exchange = new ExchangeWrapper(
this._web3Wrapper,
config.networkId,
- this._abiDecoder,
this.token,
config.exchangeContractAddress,
config.zrxContractAddress,
@@ -191,7 +191,7 @@ export class ZeroEx {
config.networkId,
config.tokenRegistryContractAddress,
);
- this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this._abiDecoder, this.token);
+ this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this.token);
}
/**
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
@@ -285,44 +285,12 @@ export class ZeroEx {
pollingIntervalMs = 1000,
timeoutMs?: number,
): Promise<TransactionReceiptWithDecodedLogs> {
- let timeoutExceeded = false;
- if (timeoutMs) {
- setTimeout(() => (timeoutExceeded = true), timeoutMs);
- }
-
- const txReceiptPromise = new Promise(
- (resolve: (receipt: TransactionReceiptWithDecodedLogs) => void, reject) => {
- const intervalId = intervalUtils.setAsyncExcludingInterval(
- async () => {
- if (timeoutExceeded) {
- intervalUtils.clearAsyncExcludingInterval(intervalId);
- return reject(ZeroExError.TransactionMiningTimeout);
- }
-
- const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash);
- if (!_.isNull(transactionReceipt)) {
- intervalUtils.clearAsyncExcludingInterval(intervalId);
- const logsWithDecodedArgs = _.map(
- transactionReceipt.logs,
- this._abiDecoder.tryToDecodeLogOrNoop.bind(this._abiDecoder),
- );
- const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = {
- ...transactionReceipt,
- logs: logsWithDecodedArgs,
- };
- resolve(transactionReceiptWithDecodedLogArgs);
- }
- },
- pollingIntervalMs,
- (err: Error) => {
- intervalUtils.clearAsyncExcludingInterval(intervalId);
- reject(err);
- },
- );
- },
+ const transactionReceiptWithDecodedLogs = await this._web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ pollingIntervalMs,
+ timeoutMs,
);
- const txReceipt = await txReceiptPromise;
- return txReceipt;
+ return transactionReceiptWithDecodedLogs;
}
/**
* Instantiates and returns a new OrderStateWatcher instance.