From 59fed02a8b044703f569d94ff9dda889812a71b0 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Sep 2017 12:07:17 +0200 Subject: Remove truffle-contract from deps --- package.json | 3 +-- yarn.lock | 56 ++++---------------------------------------------------- 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index 90b6d9120..1167b0ca1 100644 --- a/package.json +++ b/package.json @@ -85,9 +85,9 @@ "types-bn": "^0.0.1", "types-ethereumjs-util": "^0.0.5", "typescript": "^2.4.1", - "web3_beta": "ethereum/web3.js#1.0", "web3-provider-engine": "^13.0.1", "web3-typescript-typings": "^0.3.2", + "web3_beta": "ethereum/web3.js#1.0", "webpack": "^3.1.0" }, "dependencies": { @@ -100,7 +100,6 @@ "find-versions": "^2.0.0", "lodash": "^4.17.4", "publish-release": "^1.3.3", - "truffle-contract": "^2.0.1", "web3": "^0.20.0" } } diff --git a/yarn.lock b/yarn.lock index 84699dd1a..ac48a749f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"0x-json-schemas@^0.3.0": - version "0.3.0" - resolved "https://registry.yarnpkg.com/0x-json-schemas/-/0x-json-schemas-0.3.0.tgz#88d67cfc7fe34697a43a3a72f47f958f1f681d0b" +"0x-json-schemas@^0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/0x-json-schemas/-/0x-json-schemas-0.4.0.tgz#93cfa771c6418b3ce67f97595beff3e4b67bc28b" dependencies: jsonschema "^1.2.0" @@ -835,10 +835,6 @@ block-stream@*: dependencies: inherits "~2.0.0" -bn.js@4.11.6: - version "4.11.6" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" - bn.js@4.11.7, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.10.0, bn.js@^4.11.3, bn.js@^4.11.7, bn.js@^4.4.0, bn.js@^4.8.0: version "4.11.7" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.7.tgz#ddb048e50d9482790094c13eb3fcfc833ce7ab46" @@ -1566,10 +1562,6 @@ crypto-js@^3.1.4: version "3.1.8" resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.8.tgz#715f070bf6014f2ae992a98b3929258b713f08d5" -crypto-js@^3.1.9-1: - version "3.1.9-1" - resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.9-1.tgz#fda19e761fc077e01ffbfdc6e9fdfc59e8806cd8" - currently-unhandled@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" @@ -2045,14 +2037,6 @@ ethereumjs-wallet@^0.6.0: utf8 "^2.1.1" uuid "^2.0.1" -ethjs-abi@0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/ethjs-abi/-/ethjs-abi-0.1.8.tgz#cd288583ed628cdfadaf8adefa3ba1dbcbca6c18" - dependencies: - bn.js "4.11.6" - js-sha3 "0.5.5" - number-to-bn "1.7.0" - ethjs-util@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.4.tgz#1c8b6879257444ef4d3f3fbbac2ded12cd997d93" @@ -3096,10 +3080,6 @@ istanbul-reports@^1.1.1: dependencies: handlebars "^4.0.3" -js-sha3@0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.5.tgz#baf0c0e8c54ad5903447df96ade7a4a1bca79a4a" - js-sha3@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.3.1.tgz#86122802142f0828502a0d1dee1d95e253bb0243" @@ -3909,13 +3889,6 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" -number-to-bn@1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/number-to-bn/-/number-to-bn-1.7.0.tgz#bb3623592f7e5f9e0030b1977bd41a0c53fe1ea0" - dependencies: - bn.js "4.11.6" - strip-hex-prefix "1.0.0" - nyc@^11.0.1: version "11.0.3" resolved "https://registry.yarnpkg.com/nyc/-/nyc-11.0.3.tgz#0c28bc669a851621709bf7a08503034bee3812b6" @@ -5410,27 +5383,6 @@ trim@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/trim/-/trim-0.0.1.tgz#5858547f6b290757ee95cccc666fb50084c460dd" -truffle-blockchain-utils@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/truffle-blockchain-utils/-/truffle-blockchain-utils-0.0.1.tgz#07a58e55bb0555a64208c9119c0b04ffe1464aa4" - dependencies: - web3 "^0.18.0" - -truffle-contract-schema@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/truffle-contract-schema/-/truffle-contract-schema-0.0.5.tgz#5e9d20bd0bf2a27fe94310748249d484eee49961" - dependencies: - crypto-js "^3.1.9-1" - -truffle-contract@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/truffle-contract/-/truffle-contract-2.0.1.tgz#f83e3f18d8044027f2a9ee7c33767ba10fd39dd8" - dependencies: - ethjs-abi "0.1.8" - truffle-blockchain-utils "0.0.1" - truffle-contract-schema "0.0.5" - web3 "^0.18.0" - truffle-hdwallet-provider@^0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/truffle-hdwallet-provider/-/truffle-hdwallet-provider-0.0.3.tgz#0e1de02104b73d3875e1cf7093305b4ea8a2d843" @@ -5734,7 +5686,7 @@ web3@^0.16.0: utf8 "^2.1.1" xmlhttprequest "*" -web3@^0.18.0, web3@^0.18.2: +web3@^0.18.2: version "0.18.4" resolved "https://registry.yarnpkg.com/web3/-/web3-0.18.4.tgz#81ec1784145491f2eaa8955b31c06049e07c5e7d" dependencies: -- cgit From 9818eb2835a8c06006514c44340c95c709f4aa9f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Sep 2017 14:45:01 +0200 Subject: Use custom contract abstraction --- src/contract.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/contract.ts diff --git a/src/contract.ts b/src/contract.ts new file mode 100644 index 000000000..b4a54ca09 --- /dev/null +++ b/src/contract.ts @@ -0,0 +1,28 @@ +import * as Web3 from 'web3'; +import * as _ from 'lodash'; +import promisify = require('es6-promisify'); + +export class Contract implements Web3.ContractInstance { + public address: string; + public abi: Web3.ContractAbi; + private contract: A; + [name: string]: any; + constructor(web3ContractInstance: A) { + this.contract = web3ContractInstance; + this.address = web3ContractInstance.address; + this.abi = web3ContractInstance.abi; + const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === 'function'); + _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { + const cbStyleFunction = web3ContractInstance[functionAbi.name]; + this[functionAbi.name] = promisify(cbStyleFunction, web3ContractInstance); + if (functionAbi.constant) { + const cbStyleCallFunction = web3ContractInstance[functionAbi.name].call; + this[functionAbi.name].call = promisify(cbStyleCallFunction, web3ContractInstance); + } else { + const cbStyleEstimateGasFunction = web3ContractInstance[functionAbi.name].estimateGas; + this[functionAbi.name].estimateGas = + promisify(cbStyleEstimateGasFunction, web3ContractInstance); + } + }); + } +} -- cgit From 1c2d4cbb1af9a5d4442857def622dc8068086953 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Sep 2017 16:57:22 +0200 Subject: Fix tests descriptions --- test/token_wrapper_test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts index 88833e612..e4223ffc7 100644 --- a/test/token_wrapper_test.ts +++ b/test/token_wrapper_test.ts @@ -356,7 +356,7 @@ describe('TokenWrapper', () => { // we do need both. A hack is to make the top-level a sync fn w/ a done callback and then // wrap the rest of the test in an async block // Source: https://github.com/mochajs/mocha/issues/2407 - it('Should receive the Transfer event when an order is filled', (done: DoneCallback) => { + it('Should receive the Transfer event when tokens are transfered', (done: DoneCallback) => { (async () => { const zeroExEvent = await zeroEx.token.subscribeAsync( tokenAddress, TokenEvents.Transfer, subscriptionOpts, indexFilterValues); @@ -372,7 +372,7 @@ describe('TokenWrapper', () => { await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount); })().catch(done); }); - it('Should receive the Approval event when an order is cancelled', (done: DoneCallback) => { + it('Should receive the Approval event when allowance is being set', (done: DoneCallback) => { (async () => { const zeroExEvent = await zeroEx.token.subscribeAsync( tokenAddress, TokenEvents.Approval, subscriptionOpts, indexFilterValues); -- cgit From 1ad395cf86b2006c09bdae814607c2baf9790b91 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Sep 2017 18:14:48 +0200 Subject: Make the functions immidiately return txHash instead of awaiting for a transaction to be mined --- package.json | 2 +- src/0x.ts | 1 - src/artifacts/EtherToken.json | 2 +- src/contract.ts | 28 +++++--- src/contract_wrappers/contract_wrapper.ts | 47 ++----------- src/contract_wrappers/ether_token_wrapper.ts | 4 +- src/contract_wrappers/exchange_wrapper.ts | 76 ++++++++++------------ src/contract_wrappers/token_registry_wrapper.ts | 4 +- .../token_transfer_proxy_wrapper.ts | 4 +- src/contract_wrappers/token_wrapper.ts | 4 +- src/globals.d.ts | 20 ++---- src/types.ts | 29 +++------ src/web3_wrapper.ts | 28 ++++++++ test/exchange_wrapper_test.ts | 64 +++++------------- test/utils/blockchain_lifecycle.ts | 3 + yarn.lock | 6 +- 16 files changed, 139 insertions(+), 183 deletions(-) diff --git a/package.json b/package.json index 1167b0ca1..909769220 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "types-ethereumjs-util": "^0.0.5", "typescript": "^2.4.1", "web3-provider-engine": "^13.0.1", - "web3-typescript-typings": "^0.3.2", + "web3-typescript-typings": "^0.4.1", "web3_beta": "ethereum/web3.js#1.0", "webpack": "^3.1.0" }, diff --git a/src/0x.ts b/src/0x.ts index ba222f2c9..3cf672a1b 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -3,7 +3,6 @@ import * as BigNumber from 'bignumber.js'; import {SchemaValidator, schemas} from '0x-json-schemas'; import {bigNumberConfigs} from './bignumber_config'; import * as ethUtil from 'ethereumjs-util'; -import contract = require('truffle-contract'); import findVersions = require('find-versions'); import compareVersions = require('compare-versions'); import {Web3Wrapper} from './web3_wrapper'; diff --git a/src/artifacts/EtherToken.json b/src/artifacts/EtherToken.json index eca348530..54b5a032e 100644 --- a/src/artifacts/EtherToken.json +++ b/src/artifacts/EtherToken.json @@ -391,4 +391,4 @@ }, "schema_version": "0.0.5", "updated_at": 1503318938233 -} \ No newline at end of file +} diff --git a/src/contract.ts b/src/contract.ts index b4a54ca09..0c76571cc 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -2,27 +2,37 @@ import * as Web3 from 'web3'; import * as _ from 'lodash'; import promisify = require('es6-promisify'); -export class Contract implements Web3.ContractInstance { +export class Contract implements Web3.ContractInstance { public address: string; public abi: Web3.ContractAbi; - private contract: A; + private contract: Web3.ContractInstance; [name: string]: any; - constructor(web3ContractInstance: A) { + constructor(web3ContractInstance: Web3.ContractInstance) { this.contract = web3ContractInstance; this.address = web3ContractInstance.address; this.abi = web3ContractInstance.abi; + this.populateEvents(); + this.populateFunctions(); + } + private populateFunctions(): void { const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === 'function'); _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { - const cbStyleFunction = web3ContractInstance[functionAbi.name]; - this[functionAbi.name] = promisify(cbStyleFunction, web3ContractInstance); + const cbStyleFunction = this.contract[functionAbi.name]; + this[functionAbi.name] = promisify(cbStyleFunction, this.contract); if (functionAbi.constant) { - const cbStyleCallFunction = web3ContractInstance[functionAbi.name].call; - this[functionAbi.name].call = promisify(cbStyleCallFunction, web3ContractInstance); + const cbStyleCallFunction = this.contract[functionAbi.name].call; + this[functionAbi.name].call = promisify(cbStyleCallFunction, this.contract); } else { - const cbStyleEstimateGasFunction = web3ContractInstance[functionAbi.name].estimateGas; + const cbStyleEstimateGasFunction = this.contract[functionAbi.name].estimateGas; this[functionAbi.name].estimateGas = - promisify(cbStyleEstimateGasFunction, web3ContractInstance); + promisify(cbStyleEstimateGasFunction, this.contract); } }); } + private populateEvents(): void { + const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === 'event'); + _.forEach(eventsAbi, (eventAbi: Web3.EventAbi) => { + this[eventAbi.name] = this.contract[eventAbi.name]; + }); + } } diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts index 28df82cee..3de26148f 100644 --- a/src/contract_wrappers/contract_wrapper.ts +++ b/src/contract_wrappers/contract_wrapper.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; -import contract = require('truffle-contract'); +import * as Web3 from 'web3'; import {Web3Wrapper} from '../web3_wrapper'; -import {ZeroExError, Artifact, ContractInstance} from '../types'; +import {ZeroExError} from '../types'; import {utils} from '../utils/utils'; export class ContractWrapper { @@ -11,43 +11,10 @@ export class ContractWrapper { this._web3Wrapper = web3Wrapper; this._gasPrice = gasPrice; } - protected async _instantiateContractIfExistsAsync(artifact: Artifact, address?: string): Promise { - const c = await contract(artifact); - c.defaults({ - gasPrice: this._gasPrice, - }); - const providerObj = this._web3Wrapper.getCurrentProvider(); - c.setProvider(providerObj); - - const networkIdIfExists = await this._web3Wrapper.getNetworkIdIfExistsAsync(); - const artifactNetworkConfigs = _.isUndefined(networkIdIfExists) ? - undefined : - artifact.networks[networkIdIfExists]; - let contractAddress; - if (!_.isUndefined(address)) { - contractAddress = address; - } else if (!_.isUndefined(artifactNetworkConfigs)) { - contractAddress = artifactNetworkConfigs.address.toLowerCase(); - } - - if (!_.isUndefined(contractAddress)) { - const doesContractExist = await this._web3Wrapper.doesContractExistAtAddressAsync(contractAddress); - if (!doesContractExist) { - throw new Error(ZeroExError.ContractDoesNotExist); - } - } - - try { - const contractInstance = _.isUndefined(address) ? await c.deployed() : await c.at(address); - return contractInstance; - } catch (err) { - const errMsg = `${err}`; - if (_.includes(errMsg, 'not been deployed to detected network')) { - throw new Error(ZeroExError.ContractDoesNotExist); - } else { - utils.consoleLog(`Notice: Error encountered: ${err} ${err.stack}`); - throw new Error(ZeroExError.UnhandledError); - } - } + protected async _instantiateContractIfExistsAsync(artifact: Artifact, + address?: string): Promise { + const contractInstance = + await this._web3Wrapper.getContractInstanceFromArtifactAsync(artifact, address); + return contractInstance; } } diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts index 3c282510f..a2486b15e 100644 --- a/src/contract_wrappers/ether_token_wrapper.ts +++ b/src/contract_wrappers/ether_token_wrapper.ts @@ -71,7 +71,9 @@ export class EtherTokenWrapper extends ContractWrapper { if (!_.isUndefined(this._etherTokenContractIfExists)) { return this._etherTokenContractIfExists; } - const contractInstance = await this._instantiateContractIfExistsAsync((EtherTokenArtifacts as any)); + const contractInstance = await this._instantiateContractIfExistsAsync( + EtherTokenArtifacts as any as Artifact, + ); this._etherTokenContractIfExists = contractInstance as EtherTokenContract; return this._etherTokenContractIfExists; } diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index d09df236b..1196394e9 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -141,12 +141,12 @@ export class ExchangeWrapper extends ContractWrapper { * @param takerAddress The user Ethereum address who would like to fill this order. * Must be available via the supplied Web3.Provider * passed to 0x.js. - * @return The amount of the order that was filled (in taker token baseUnits). + * @return Transaction hash. */ @decorators.contractCallErrorHandler public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber.BigNumber, shouldThrowOnInsufficientBalanceOrAllowance: boolean, - takerAddress: string): Promise { + takerAddress: string): Promise { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance); @@ -169,7 +169,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.fillOrder( + const txHash: string = await exchangeInstance.fillOrder( orderAddresses, orderValues, fillTakerTokenAmount, @@ -182,10 +182,7 @@ export class ExchangeWrapper extends ContractWrapper { gas, }, ); - this._throwErrorLogsAsErrors(response.logs); - const logFillArgs = response.logs[0].args as LogFillContractEventArgs; - const filledTakerTokenAmount = new BigNumber(logFillArgs.filledTakerTokenAmount); - return filledTakerTokenAmount; + return txHash; } /** * Sequentially and atomically fills signedOrders up to the specified takerTokenFillAmount. @@ -201,12 +198,12 @@ export class ExchangeWrapper extends ContractWrapper { * @param takerAddress The user Ethereum address who would like to fill these * orders. Must be available via the supplied Web3.Provider * passed to 0x.js. - * @return The amount of the orders that was filled (in taker token baseUnits). + * @return Transaction hash. */ @decorators.contractCallErrorHandler public async fillOrdersUpToAsync(signedOrders: SignedOrder[], fillTakerTokenAmount: BigNumber.BigNumber, shouldThrowOnInsufficientBalanceOrAllowance: boolean, - takerAddress: string): Promise { + takerAddress: string): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); const takerTokenAddresses = _.map(signedOrders, signedOrder => signedOrder.takerTokenAddress); assert.hasAtMostOneUniqueValue(takerTokenAddresses, @@ -222,7 +219,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrder, fillTakerTokenAmount, takerAddress); } if (_.isEmpty(signedOrders)) { - return new BigNumber(0); // no-op + throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); } const orderAddressesValuesAndSignatureArray = _.map(signedOrders, signedOrder => { @@ -251,7 +248,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.fillOrdersUpTo( + const txHash = await exchangeInstance.fillOrdersUpTo( orderAddressesArray, orderValuesArray, fillTakerTokenAmount, @@ -264,13 +261,7 @@ export class ExchangeWrapper extends ContractWrapper { gas, }, ); - this._throwErrorLogsAsErrors(response.logs); - let filledTakerTokenAmount = new BigNumber(0); - _.each(response.logs, log => { - filledTakerTokenAmount = filledTakerTokenAmount.plus( - (log.args as LogFillContractEventArgs).filledTakerTokenAmount); - }); - return filledTakerTokenAmount; + return txHash; } /** * Batch version of fillOrderAsync. @@ -288,11 +279,12 @@ export class ExchangeWrapper extends ContractWrapper { * @param takerAddress The user Ethereum address who would like to fill * these orders. Must be available via the supplied * Web3.Provider passed to 0x.js. + * @return Transaction hash. */ @decorators.contractCallErrorHandler public async batchFillOrdersAsync(orderFillRequests: OrderFillRequest[], shouldThrowOnInsufficientBalanceOrAllowance: boolean, - takerAddress: string): Promise { + takerAddress: string): Promise { assert.doesConformToSchema('orderFillRequests', orderFillRequests, schemas.orderFillRequestsSchema); const exchangeContractAddresses = _.map( orderFillRequests, @@ -307,7 +299,7 @@ export class ExchangeWrapper extends ContractWrapper { orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount, takerAddress); } if (_.isEmpty(orderFillRequests)) { - return; // no-op + throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); } const orderAddressesValuesAmountsAndSignatureArray = _.map(orderFillRequests, orderFillRequest => { @@ -337,7 +329,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.batchFillOrders( + const txHash = await exchangeInstance.batchFillOrders( orderAddressesArray, orderValuesArray, fillTakerTokenAmounts, @@ -350,7 +342,7 @@ export class ExchangeWrapper extends ContractWrapper { gas, }, ); - this._throwErrorLogsAsErrors(response.logs); + return txHash; } /** * Attempts to fill a specific amount of an order. If the entire amount specified cannot be filled, @@ -360,10 +352,11 @@ export class ExchangeWrapper extends ContractWrapper { * @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill. * @param takerAddress The user Ethereum address who would like to fill this order. * Must be available via the supplied Web3.Provider passed to 0x.js. + * @return Transaction hash. */ @decorators.contractCallErrorHandler public async fillOrKillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber.BigNumber, - takerAddress: string): Promise { + takerAddress: string): Promise { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); @@ -385,7 +378,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.fillOrKillOrder( + const txHash = await exchangeInstance.fillOrKillOrder( orderAddresses, orderValues, fillTakerTokenAmount, @@ -397,7 +390,7 @@ export class ExchangeWrapper extends ContractWrapper { gas, }, ); - this._throwErrorLogsAsErrors(response.logs); + return txHash; } /** * Batch version of fillOrKill. Allows a taker to specify a batch of orders that will either be atomically @@ -405,10 +398,11 @@ export class ExchangeWrapper extends ContractWrapper { * @param orderFillOrKillRequests An array of objects that conform to the OrderFillOrKillRequest interface. * @param takerAddress The user Ethereum address who would like to fill there orders. * Must be available via the supplied Web3.Provider passed to 0x.js. + * @return Transaction hash. */ @decorators.contractCallErrorHandler public async batchFillOrKillAsync(orderFillOrKillRequests: OrderFillOrKillRequest[], - takerAddress: string): Promise { + takerAddress: string): Promise { assert.doesConformToSchema('orderFillOrKillRequests', orderFillOrKillRequests, schemas.orderFillOrKillRequestsSchema); const exchangeContractAddresses = _.map( @@ -419,7 +413,7 @@ export class ExchangeWrapper extends ContractWrapper { ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress); await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); if (_.isEmpty(orderFillOrKillRequests)) { - return; // no-op + throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); } const exchangeInstance = await this._getExchangeContractAsync(); for (const request of orderFillOrKillRequests) { @@ -452,7 +446,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const response: ContractResponse = await exchangeInstance.batchFillOrKillOrders( + const txHash = await exchangeInstance.batchFillOrKillOrders( orderAddresses, orderValues, fillTakerTokenAmounts, @@ -464,18 +458,18 @@ export class ExchangeWrapper extends ContractWrapper { gas, }, ); - this._throwErrorLogsAsErrors(response.logs); + return txHash; } /** * Cancel a given fill amount of an order. Cancellations are cumulative. * @param order An object that conforms to the Order or SignedOrder interface. * The order you would like to cancel. * @param cancelTakerTokenAmount The amount (specified in taker tokens) that you would like to cancel. - * @return The amount of the order that was cancelled (in taker token baseUnits). + * @return Transaction hash. */ @decorators.contractCallErrorHandler public async cancelOrderAsync( - order: Order|SignedOrder, cancelTakerTokenAmount: BigNumber.BigNumber): Promise { + order: Order|SignedOrder, cancelTakerTokenAmount: BigNumber.BigNumber): Promise { assert.doesConformToSchema('order', order, schemas.orderSchema); assert.isBigNumber('takerTokenCancelAmount', cancelTakerTokenAmount); await assert.isSenderAddressAsync('order.maker', order.maker, this._web3Wrapper); @@ -492,7 +486,7 @@ export class ExchangeWrapper extends ContractWrapper { from: order.maker, }, ); - const response: ContractResponse = await exchangeInstance.cancelOrder( + const txHash = await exchangeInstance.cancelOrder( orderAddresses, orderValues, cancelTakerTokenAmount, @@ -501,19 +495,17 @@ export class ExchangeWrapper extends ContractWrapper { gas, }, ); - this._throwErrorLogsAsErrors(response.logs); - const logFillArgs = response.logs[0].args as LogCancelContractEventArgs; - const cancelledTakerTokenAmount = new BigNumber(logFillArgs.cancelledTakerTokenAmount); - return cancelledTakerTokenAmount; + return txHash; } /** * Batch version of cancelOrderAsync. Atomically cancels multiple orders in a single transaction. * All orders must be from the same maker. * @param orderCancellationRequests An array of objects that conform to the OrderCancellationRequest * interface. + * @return Transaction hash. */ @decorators.contractCallErrorHandler - public async batchCancelOrdersAsync(orderCancellationRequests: OrderCancellationRequest[]): Promise { + public async batchCancelOrdersAsync(orderCancellationRequests: OrderCancellationRequest[]): Promise { assert.doesConformToSchema('orderCancellationRequests', orderCancellationRequests, schemas.orderCancellationRequestsSchema); const exchangeContractAddresses = _.map( @@ -532,7 +524,7 @@ export class ExchangeWrapper extends ContractWrapper { ); } if (_.isEmpty(orderCancellationRequests)) { - return; // no-op + throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); } const exchangeInstance = await this._getExchangeContractAsync(); const orderAddressesValuesAndTakerTokenCancelAmounts = _.map(orderCancellationRequests, cancellationRequest => { @@ -552,7 +544,7 @@ export class ExchangeWrapper extends ContractWrapper { from: maker, }, ); - const response: ContractResponse = await exchangeInstance.batchCancelOrders( + const txHash = await exchangeInstance.batchCancelOrders( orderAddresses, orderValues, cancelTakerTokenAmounts, @@ -561,7 +553,7 @@ export class ExchangeWrapper extends ContractWrapper { gas, }, ); - this._throwErrorLogsAsErrors(response.logs); + return txHash; } /** * Subscribe to an event type emitted by the Exchange smart contract @@ -730,7 +722,9 @@ export class ExchangeWrapper extends ContractWrapper { if (!_.isUndefined(this._exchangeContractIfExists)) { return this._exchangeContractIfExists; } - const contractInstance = await this._instantiateContractIfExistsAsync((ExchangeArtifacts as any)); + const contractInstance = await this._instantiateContractIfExistsAsync( + (ExchangeArtifacts as any), + ); this._exchangeContractIfExists = contractInstance as ExchangeContract; return this._exchangeContractIfExists; } diff --git a/src/contract_wrappers/token_registry_wrapper.ts b/src/contract_wrappers/token_registry_wrapper.ts index 822e69460..1550bfa3e 100644 --- a/src/contract_wrappers/token_registry_wrapper.ts +++ b/src/contract_wrappers/token_registry_wrapper.ts @@ -101,7 +101,9 @@ export class TokenRegistryWrapper extends ContractWrapper { if (!_.isUndefined(this._tokenRegistryContractIfExists)) { return this._tokenRegistryContractIfExists; } - const contractInstance = await this._instantiateContractIfExistsAsync((TokenRegistryArtifacts as any)); + const contractInstance = await this._instantiateContractIfExistsAsync( + TokenRegistryArtifacts as any as Artifact, + ); this._tokenRegistryContractIfExists = contractInstance as TokenRegistryContract; return this._tokenRegistryContractIfExists; } diff --git a/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/src/contract_wrappers/token_transfer_proxy_wrapper.ts index da17d79ff..2b4b32961 100644 --- a/src/contract_wrappers/token_transfer_proxy_wrapper.ts +++ b/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -44,7 +44,9 @@ export class TokenTransferProxyWrapper extends ContractWrapper { if (!_.isUndefined(this._tokenTransferProxyContractIfExists)) { return this._tokenTransferProxyContractIfExists; } - const contractInstance = await this._instantiateContractIfExistsAsync((TokenTransferProxyArtifacts as any)); + const contractInstance = await this._instantiateContractIfExistsAsync( + TokenTransferProxyArtifacts as any as Artifact, + ); this._tokenTransferProxyContractIfExists = contractInstance as TokenTransferProxyContract; return this._tokenTransferProxyContractIfExists; } diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index f7070f1f4..e98744cbc 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -267,7 +267,9 @@ export class TokenWrapper extends ContractWrapper { if (!_.isUndefined(tokenContract)) { return tokenContract; } - const contractInstance = await this._instantiateContractIfExistsAsync((TokenArtifacts as any), tokenAddress); + const contractInstance = await this._instantiateContractIfExistsAsync( + TokenArtifacts as any as Artifact, tokenAddress, + ); tokenContract = contractInstance as TokenContract; this._tokenContractsByAddress[tokenAddress] = tokenContract; return tokenContract; diff --git a/src/globals.d.ts b/src/globals.d.ts index 9230ab02d..6f5f13b4e 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -33,23 +33,11 @@ declare module '*.json' { /* tslint:enable */ } -// truffle-contract declarations -declare interface ContractInstance { - address: string; -} -declare interface ContractFactory { - setProvider: (providerObj: any) => void; - deployed: () => ContractInstance; - // Both any's are Web3.CallData, but I was unable to import it in this file - defaults: (config: any) => any; - at: (address: string) => ContractInstance; -} declare interface Artifact { - networks: {[networkId: number]: any}; -} -declare function contract(artifacts: Artifact): ContractFactory; -declare module 'truffle-contract' { - export = contract; + abi: any; + networks: {[networkId: number]: { + address: string; + }}; } // find-version declarations diff --git a/src/types.ts b/src/types.ts index 2400a9a60..9f8ba9729 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,6 +14,7 @@ export enum ZeroExError { InsufficientWEthBalanceForWithdrawal = 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL', InvalidJump = 'INVALID_JUMP', OutOfGas = 'OUT_OF_GAS', + NoNetworkId = 'NO_NETWORK_ID', } /** @@ -60,7 +61,7 @@ export interface ExchangeContract extends ContractInstance { fillOrder: { (orderAddresses: OrderAddresses, orderValues: OrderValues, fillTakerTokenAmount: BigNumber.BigNumber, shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number, r: string, s: string, txOpts?: TxOpts): Promise; + v: number, r: string, s: string, txOpts?: TxOpts): Promise; estimateGas: (orderAddresses: OrderAddresses, orderValues: OrderValues, fillTakerTokenAmount: BigNumber.BigNumber, shouldThrowOnInsufficientBalanceOrAllowance: boolean, @@ -69,7 +70,7 @@ export interface ExchangeContract extends ContractInstance { batchFillOrders: { (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmounts: BigNumber.BigNumber[], shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number[], r: string[], s: string[], txOpts?: TxOpts): Promise; + v: number[], r: string[], s: string[], txOpts?: TxOpts): Promise; estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmounts: BigNumber.BigNumber[], shouldThrowOnInsufficientBalanceOrAllowance: boolean, @@ -78,7 +79,7 @@ export interface ExchangeContract extends ContractInstance { fillOrdersUpTo: { (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmount: BigNumber.BigNumber, shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number[], r: string[], s: string[], txOpts?: TxOpts): Promise; + v: number[], r: string[], s: string[], txOpts?: TxOpts): Promise; estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmount: BigNumber.BigNumber, shouldThrowOnInsufficientBalanceOrAllowance: boolean, @@ -86,28 +87,28 @@ export interface ExchangeContract extends ContractInstance { }; cancelOrder: { (orderAddresses: OrderAddresses, orderValues: OrderValues, cancelTakerTokenAmount: BigNumber.BigNumber, - txOpts?: TxOpts): Promise; + txOpts?: TxOpts): Promise; estimateGas: (orderAddresses: OrderAddresses, orderValues: OrderValues, cancelTakerTokenAmount: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; }; batchCancelOrders: { (orderAddresses: OrderAddresses[], orderValues: OrderValues[], cancelTakerTokenAmounts: BigNumber.BigNumber[], - txOpts?: TxOpts): Promise; + txOpts?: TxOpts): Promise; estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], cancelTakerTokenAmounts: BigNumber.BigNumber[], txOpts?: TxOpts) => Promise; }; fillOrKillOrder: { (orderAddresses: OrderAddresses, orderValues: OrderValues, fillTakerTokenAmount: BigNumber.BigNumber, - v: number, r: string, s: string, txOpts?: TxOpts): Promise; + v: number, r: string, s: string, txOpts?: TxOpts): Promise; estimateGas: (orderAddresses: OrderAddresses, orderValues: OrderValues, fillTakerTokenAmount: BigNumber.BigNumber, v: number, r: string, s: string, txOpts?: TxOpts) => Promise; }; batchFillOrKillOrders: { (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmounts: BigNumber.BigNumber[], - v: number[], r: string[], s: string[], txOpts: TxOpts): Promise; + v: number[], r: string[], s: string[], txOpts: TxOpts): Promise; estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmounts: BigNumber.BigNumber[], v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; @@ -209,6 +210,7 @@ export enum ExchangeContractErrs { InsufficientRemainingFillAmount = 'INSUFFICIENT_REMAINING_FILL_AMOUNT', MultipleTakerTokensInFillUpToDisallowed = 'MULTIPLE_TAKER_TOKENS_IN_FILL_UP_TO_DISALLOWED', BatchOrdersMustHaveSameExchangeAddress = 'BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS', + BatchOrdersMustHaveAtLeastOneItem = 'BATCH_ORDERS_MUST_HAVE_AT_LEAST_ONE_ITEM', } export interface ContractResponse { @@ -351,10 +353,7 @@ export type AsyncMethod = (...args: any[]) => Promise; export interface ContractInstance { address: string; -} - -export interface Artifact { - networks: {[networkId: number]: any}; + abi: Web3.ContractAbi; } export interface ContractEventEmitter { @@ -373,14 +372,6 @@ export interface ExchangeContractByAddress { [address: string]: ExchangeContract; } -export interface ContractArtifact { - networks: { - [networkId: number]: { - address: string; - }; - }; -} - export interface JSONRPCPayload { params: any[]; method: string; diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts index 61bac45c9..129017e7c 100644 --- a/src/web3_wrapper.ts +++ b/src/web3_wrapper.ts @@ -2,6 +2,8 @@ import * as _ from 'lodash'; import * as Web3 from 'web3'; import * as BigNumber from 'bignumber.js'; import promisify = require('es6-promisify'); +import {ZeroExError} from './types'; +import {Contract} from './contract'; export class Web3Wrapper { private web3: Web3; @@ -41,6 +43,27 @@ export class Web3Wrapper { return undefined; } } + public async getContractInstanceFromArtifactAsync(artifact: Artifact, + address?: string): Promise { + if (_.isUndefined(address)) { + const networkIdIfExists = await this.getNetworkIdIfExistsAsync(); + if (_.isUndefined(networkIdIfExists)) { + throw new Error(ZeroExError.NoNetworkId); + } + if (_.isUndefined(artifact.networks[networkIdIfExists])) { + throw new Error(ZeroExError.ContractNotDeployedOnNetwork); + } + address = artifact.networks[networkIdIfExists].address.toLowerCase(); + } + const doesContractExist = await this.doesContractExistAtAddressAsync(address); + if (!doesContractExist) { + throw new Error(ZeroExError.ContractDoesNotExist); + } + const contractInstance = this.getContractInstance( + artifact.abi, address, + ); + return contractInstance; + } public toWei(ethAmount: BigNumber.BigNumber): BigNumber.BigNumber { const balanceWei = this.web3.toWei(ethAmount, 'ether'); return balanceWei; @@ -68,6 +91,11 @@ export class Web3Wrapper { const addresses: string[] = await promisify(this.web3.eth.getAccounts)(); return addresses; } + private getContractInstance(abi: Web3.ContractAbi, address: string): A { + const web3ContractInstance = this.web3.eth.contract(abi).at(address); + const contractInstance = new Contract(web3ContractInstance) as any as A; + return contractInstance; + } private async getNetworkAsync(): Promise { const networkId = await promisify(this.web3.version.getNetwork)(); return networkId; diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 90ac37387..15e957ee1 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -196,34 +196,6 @@ describe('ExchangeWrapper', () => { expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)) .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount)); }); - it('should return filled amount', async () => { - const signedOrder = await fillScenarios.createFillableSignedOrderAsync( - makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, - ); - const partialFillAmount = new BigNumber(3); - const filledAmount = await zeroEx.exchange.fillOrderAsync( - signedOrder, partialFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); - expect(filledAmount).to.be.bignumber.equal(partialFillAmount); - }); - it('should return the partially filled amount \ - if the fill amount specified is greater then the amount available', async () => { - const signedOrder = await fillScenarios.createFillableSignedOrderAsync( - makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, - ); - const partialFillAmount = new BigNumber(3); - await zeroEx.exchange.fillOrderAsync( - signedOrder, partialFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); - const missingBalance = new BigNumber(1); - const totalBalance = partialFillAmount.plus(missingBalance); - await zeroEx.token.transferAsync(takerTokenAddress, coinbase, takerAddress, missingBalance); - await zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, totalBalance); - await zeroEx.token.transferAsync(makerTokenAddress, coinbase, makerAddress, missingBalance); - await zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, totalBalance); - const remainingFillAmount = fillableAmount.minus(partialFillAmount); - const filledAmount = await zeroEx.exchange.fillOrderAsync( - signedOrder, partialFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); - expect(filledAmount).to.be.bignumber.equal(remainingFillAmount); - }); it('should fill the valid orders with fees', async () => { const makerFee = new BigNumber(1); const takerFee = new BigNumber(2); @@ -231,8 +203,9 @@ describe('ExchangeWrapper', () => { makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress, fillableAmount, feeRecipient, ); - await zeroEx.exchange.fillOrderAsync( + const txHash = await zeroEx.exchange.fillOrderAsync( signedOrder, fillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); + await blockchainLifecycle.waitUntilMinedAsync(txHash); expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient)) .to.be.bignumber.equal(makerFee.plus(takerFee)); }); @@ -265,13 +238,15 @@ describe('ExchangeWrapper', () => { ]; }); describe('successful batch fills', () => { - it('should no-op for an empty batch', async () => { - await zeroEx.exchange.batchFillOrdersAsync( - [], shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); + it('should throw if a batch is empty', async () => { + return expect(zeroEx.exchange.batchFillOrdersAsync( + [], shouldThrowOnInsufficientBalanceOrAllowance, takerAddress), + ).to.be.rejectedWith(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); }); it('should successfully fill multiple orders', async () => { - await zeroEx.exchange.batchFillOrdersAsync( + const txHash = await zeroEx.exchange.batchFillOrdersAsync( orderFillBatch, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); + await blockchainLifecycle.waitUntilMinedAsync(txHash); const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillTakerAmount); @@ -298,26 +273,22 @@ describe('ExchangeWrapper', () => { signedOrders = [signedOrder, anotherSignedOrder]; }); describe('successful batch fills', () => { - it('should no-op for an empty batch', async () => { - await zeroEx.exchange.fillOrdersUpToAsync( - [], fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); + it('should throw if a batch is empty', async () => { + return expect(zeroEx.exchange.fillOrdersUpToAsync( + [], fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress), + ).to.be.rejectedWith(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); }); it('should successfully fill up to specified amount', async () => { - await zeroEx.exchange.fillOrdersUpToAsync( + const txHash = await zeroEx.exchange.fillOrdersUpToAsync( signedOrders, fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, ); + await blockchainLifecycle.waitUntilMinedAsync(txHash); const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillableAmount); const remainingFillAmount = fillableAmount.minus(1); expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount); }); - it('should return filled amount', async () => { - const filledTakerTokenAmount = await zeroEx.exchange.fillOrdersUpToAsync( - signedOrders, fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, - ); - expect(filledTakerTokenAmount).to.be.bignumber.equal(fillUpToAmount); - }); }); }); }); @@ -344,14 +315,11 @@ describe('ExchangeWrapper', () => { describe('#cancelOrderAsync', () => { describe('successful cancels', () => { it('should cancel an order', async () => { - await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); + const txHash = await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); + await blockchainLifecycle.waitUntilMinedAsync(txHash); const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex); expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); }); - it('should return cancelled amount', async () => { - const cancelledAmount = await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); - expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); - }); }); }); describe('#batchCancelOrdersAsync', () => { diff --git a/test/utils/blockchain_lifecycle.ts b/test/utils/blockchain_lifecycle.ts index 50eb57b95..b4f742e63 100644 --- a/test/utils/blockchain_lifecycle.ts +++ b/test/utils/blockchain_lifecycle.ts @@ -17,4 +17,7 @@ export class BlockchainLifecycle { throw new Error(`Snapshot with id #${this.snapshotId} failed to revert`); } } + public async waitUntilMinedAsync(txHash: string): Promise { + return undefined; + } } diff --git a/yarn.lock b/yarn.lock index ac48a749f..73452ac1f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5671,9 +5671,9 @@ web3-provider-engine@^8.4.0: xhr "^2.2.0" xtend "^4.0.1" -web3-typescript-typings@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.3.2.tgz#75f65fe452e35e2b96192908199dbb7a9ab5bcc3" +web3-typescript-typings@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.4.1.tgz#077f5c042c1d2625b4cabedad88b9e9427b38fb3" dependencies: bignumber.js "^4.0.2" -- cgit From 2577d8f66267e618e633483277f1afe828764797 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Sep 2017 18:23:12 +0200 Subject: Use Web3.ContractInstance type --- src/types.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/types.ts b/src/types.ts index 9f8ba9729..e90c6fab4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -40,7 +40,7 @@ export interface ContractEventObj { } export type CreateContractEvent = (indexFilterValues: IndexedFilterValues, subscriptionOpts: SubscriptionOpts) => ContractEventObj; -export interface ExchangeContract extends ContractInstance { +export interface ExchangeContract extends Web3.ContractInstance { isValidSignature: { call: (signerAddressHex: string, dataHex: string, v: number, r: string, s: string, txOpts?: TxOpts) => Promise; @@ -124,7 +124,7 @@ export interface ExchangeContract extends ContractInstance { }; } -export interface TokenContract extends ContractInstance { +export interface TokenContract extends Web3.ContractInstance { Transfer: CreateContractEvent; Approval: CreateContractEvent; balanceOf: { @@ -139,7 +139,7 @@ export interface TokenContract extends ContractInstance { approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; } -export interface TokenRegistryContract extends ContractInstance { +export interface TokenRegistryContract extends Web3.ContractInstance { getTokenMetaData: { call: (address: string) => Promise; }; @@ -160,12 +160,12 @@ export interface TokenRegistryContract extends ContractInstance { }; } -export interface EtherTokenContract extends ContractInstance { +export interface EtherTokenContract extends Web3.ContractInstance { deposit: (txOpts: TxOpts) => Promise; withdraw: (amount: BigNumber.BigNumber, txOpts: TxOpts) => Promise; } -export interface TokenTransferProxyContract extends ContractInstance { +export interface TokenTransferProxyContract extends Web3.ContractInstance { getAuthorizedAddresses: { call: () => Promise; }; @@ -213,10 +213,6 @@ export enum ExchangeContractErrs { BatchOrdersMustHaveAtLeastOneItem = 'BATCH_ORDERS_MUST_HAVE_AT_LEAST_ONE_ITEM', } -export interface ContractResponse { - logs: ContractEvent[]; -} - export interface ContractEvent { logIndex: number; transactionIndex: number; @@ -351,11 +347,6 @@ export interface OrderFillRequest { export type AsyncMethod = (...args: any[]) => Promise; -export interface ContractInstance { - address: string; - abi: Web3.ContractAbi; -} - export interface ContractEventEmitter { watch: (eventCallback: EventCallback) => void; stopWatchingAsync: () => Promise; -- cgit From 6325a038188293658ad3d209cb95a2741911f5b9 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Sep 2017 18:48:18 +0200 Subject: Temporarily remove web3_beta, cause it breaks installation and tests --- package.json | 1 - test/utils/web3_factory.ts | 6 - test/web3_beta_test.ts | 16 - yarn.lock | 746 ++------------------------------------------- 4 files changed, 24 insertions(+), 745 deletions(-) delete mode 100644 test/web3_beta_test.ts diff --git a/package.json b/package.json index 909769220..c24aae90a 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,6 @@ "typescript": "^2.4.1", "web3-provider-engine": "^13.0.1", "web3-typescript-typings": "^0.4.1", - "web3_beta": "ethereum/web3.js#1.0", "webpack": "^3.1.0" }, "dependencies": { diff --git a/test/utils/web3_factory.ts b/test/utils/web3_factory.ts index 4785fa858..b20070c74 100644 --- a/test/utils/web3_factory.ts +++ b/test/utils/web3_factory.ts @@ -6,7 +6,6 @@ import ProviderEngine = require('web3-provider-engine'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); import * as Web3 from 'web3'; -import * as Web3_beta from 'web3_beta'; import {constants} from './constants'; import {EmptyWalletSubProvider} from '../../src/subproviders/empty_wallet_subprovider'; @@ -29,9 +28,4 @@ export const web3Factory = { provider.start(); return provider; }, - getProviderBeta(): Web3.Provider { - const rpcUrl = `http://${constants.RPC_HOST}:${constants.RPC_PORT}`; - const providerBeta = new Web3_beta.providers.HttpProvider(rpcUrl); - return providerBeta; - }, }; diff --git a/test/web3_beta_test.ts b/test/web3_beta_test.ts deleted file mode 100644 index e34812243..000000000 --- a/test/web3_beta_test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as chai from 'chai'; -import {chaiSetup} from './utils/chai_setup'; -import 'mocha'; -import {ZeroEx, Order, SubscriptionOpts, TokenEvents, ContractEvent} from '../src'; -import {web3Factory} from './utils/web3_factory'; - -chaiSetup.configure(); -const expect = chai.expect; - -describe('ZeroEx with beta web3', () => { - const web3_beta_provider = web3Factory.getProviderBeta(); - const zeroEx = new ZeroEx(web3_beta_provider); - it('is able to make a call using a beta provider', async () => { - await zeroEx.tokenRegistry.getTokenAddressesAsync(); - }); -}); diff --git a/yarn.lock b/yarn.lock index 73452ac1f..30487b0af 100644 --- a/yarn.lock +++ b/yarn.lock @@ -62,13 +62,6 @@ version "2.3.2" resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-2.3.2.tgz#1e1e99e67162d78e2db17816892bf93bf5209885" -JSONStream@^1.0.4: - version "1.3.1" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.1.tgz#707f761e01dae9e16f1bcf93703b78c70966579a" - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - abbrev@1: version "1.1.0" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" @@ -93,10 +86,6 @@ acorn@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.1.tgz#53fe161111f912ab999ee887a90a0bc52822fd75" -add-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" - aes-js@^0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d" @@ -133,10 +122,6 @@ amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" -ansi-escapes@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" - ansi-regex@^1.0.0, ansi-regex@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-1.1.1.tgz#41c847194646375e6a1a5d10c3ca054ef9fc980d" @@ -153,12 +138,6 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" - dependencies: - color-convert "^1.9.0" - anymatch@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" @@ -219,10 +198,6 @@ array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" -array-ify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" - array-map@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/array-map/-/array-map-0.0.0.tgz#88a2bab73d1cf7bcd5c1b118a003f66f665fa662" @@ -231,13 +206,7 @@ array-reduce@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b" -array-union@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" - dependencies: - array-uniq "^1.0.1" - -array-uniq@^1.0.0, array-uniq@^1.0.1: +array-uniq@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" @@ -297,7 +266,7 @@ async@^0.9.0: version "0.9.2" resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" -async@^1.4.0, async@^1.4.2, async@^1.5.0: +async@^1.4.0, async@^1.4.2: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" @@ -985,10 +954,6 @@ builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" -byline@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/byline/-/byline-5.0.0.tgz#741c5216468eadc457b03410118ad77de8c1ddb1" - cache-base@^0.8.4: version "0.8.5" resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-0.8.5.tgz#60ceb3504021eceec7011fd3384b7f4e95729bfa" @@ -1091,14 +1056,6 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" - dependencies: - ansi-styles "^3.1.0" - escape-string-regexp "^1.0.5" - supports-color "^4.0.0" - check-error@^1.0.1, check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -1128,10 +1085,6 @@ chownr@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" -ci-info@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534" - cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" @@ -1149,20 +1102,10 @@ class-utils@^0.3.4: lazy-cache "^2.0.2" static-extend "^0.1.1" -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" - dependencies: - restore-cursor "^2.0.0" - cli-width@^1.0.1: version "1.1.1" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-1.1.1.tgz#a4d293ef67ebb7b88d4a4d42c0ccf00c4d1e366d" -cli-width@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" - cliui@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" @@ -1179,21 +1122,10 @@ cliui@^3.2.0: strip-ansi "^3.0.1" wrap-ansi "^2.0.0" -clone@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149" - clone@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.1.tgz#d217d1e961118e3ac9a4b8bba3285553bf647cdb" -cmd-shim@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/cmd-shim/-/cmd-shim-2.0.2.tgz#6fcbda99483a8fd15d7d30a196ca69d688a2efdb" - dependencies: - graceful-fs "^4.1.2" - mkdirp "~0.5.0" - co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -1217,37 +1149,16 @@ collection-visit@^0.2.1: map-visit "^0.1.5" object-visit "^0.3.4" -color-convert@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a" - dependencies: - color-name "^1.1.1" - -color-name@^1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - colors@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" -columnify@^1.5.4: - version "1.5.4" - resolved "https://registry.yarnpkg.com/columnify/-/columnify-1.5.4.tgz#4737ddf1c7b69a8a7c340570782e947eec8e78bb" - dependencies: - strip-ansi "^3.0.0" - wcwidth "^1.0.0" - combined-stream@^1.0.5, combined-stream@~1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" dependencies: delayed-stream "~1.0.0" -command-join@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/command-join/-/command-join-2.0.0.tgz#52e8b984f4872d952ff1bdc8b98397d27c7144cf" - commander@2.9.0, commander@^2.9.0: version "2.9.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" @@ -1258,13 +1169,6 @@ commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" -compare-func@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" - dependencies: - array-ify "^1.0.0" - dot-prop "^3.0.0" - compare-versions@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.0.1.tgz#e60915b7fb294e29bbb60869188762beeb871443" @@ -1277,14 +1181,6 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.4.10: - version "1.6.0" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" - dependencies: - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - console-browserify@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" @@ -1299,165 +1195,6 @@ constants-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" -conventional-changelog-angular@^1.3.4: - version "1.4.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.4.0.tgz#118b9f7d41a3d99500bfb6bea1f3525e055e8b9b" - dependencies: - compare-func "^1.3.1" - github-url-from-git "^1.4.0" - q "^1.4.1" - read-pkg-up "^2.0.0" - -conventional-changelog-atom@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/conventional-changelog-atom/-/conventional-changelog-atom-0.1.1.tgz#d40a9b297961b53c745e5d1718fd1a3379f6a92f" - dependencies: - q "^1.4.1" - -conventional-changelog-cli@^1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/conventional-changelog-cli/-/conventional-changelog-cli-1.3.2.tgz#33abf2b5720a9b094df38e81741ccb502e1a4125" - dependencies: - add-stream "^1.0.0" - conventional-changelog "^1.1.4" - lodash "^4.1.0" - meow "^3.7.0" - tempfile "^1.1.1" - -conventional-changelog-codemirror@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.1.0.tgz#7577a591dbf9b538e7a150a7ee62f65a2872b334" - dependencies: - q "^1.4.1" - -conventional-changelog-core@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-1.9.0.tgz#de5dfbc091847656508d4a389e35c9a1bc49e7f4" - dependencies: - conventional-changelog-writer "^1.1.0" - conventional-commits-parser "^1.0.0" - dateformat "^1.0.12" - get-pkg-repo "^1.0.0" - git-raw-commits "^1.2.0" - git-remote-origin-url "^2.0.0" - git-semver-tags "^1.2.0" - lodash "^4.0.0" - normalize-package-data "^2.3.5" - q "^1.4.1" - read-pkg "^1.1.0" - read-pkg-up "^1.0.1" - through2 "^2.0.0" - -conventional-changelog-ember@^0.2.6: - version "0.2.6" - resolved "https://registry.yarnpkg.com/conventional-changelog-ember/-/conventional-changelog-ember-0.2.6.tgz#8b7355419f5127493c4c562473ab2fc792f1c2b6" - dependencies: - q "^1.4.1" - -conventional-changelog-eslint@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-eslint/-/conventional-changelog-eslint-0.1.0.tgz#a52411e999e0501ce500b856b0a643d0330907e2" - dependencies: - q "^1.4.1" - -conventional-changelog-express@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-express/-/conventional-changelog-express-0.1.0.tgz#55c6c841c811962036c037bdbd964a54ae310fce" - dependencies: - q "^1.4.1" - -conventional-changelog-jquery@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz#0208397162e3846986e71273b6c79c5b5f80f510" - dependencies: - q "^1.4.1" - -conventional-changelog-jscs@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz#0479eb443cc7d72c58bf0bcf0ef1d444a92f0e5c" - dependencies: - q "^1.4.1" - -conventional-changelog-jshint@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-jshint/-/conventional-changelog-jshint-0.1.0.tgz#00cab8e9a3317487abd94c4d84671342918d2a07" - dependencies: - compare-func "^1.3.1" - q "^1.4.1" - -conventional-changelog-writer@^1.1.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-1.4.1.tgz#3f4cb4d003ebb56989d30d345893b52a43639c8e" - dependencies: - compare-func "^1.3.1" - conventional-commits-filter "^1.0.0" - dateformat "^1.0.11" - handlebars "^4.0.2" - json-stringify-safe "^5.0.1" - lodash "^4.0.0" - meow "^3.3.0" - semver "^5.0.1" - split "^1.0.0" - through2 "^2.0.0" - -conventional-changelog@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-1.1.4.tgz#108bc750c2a317e200e2f9b413caaa1f8c7efa3b" - dependencies: - conventional-changelog-angular "^1.3.4" - conventional-changelog-atom "^0.1.0" - conventional-changelog-codemirror "^0.1.0" - conventional-changelog-core "^1.9.0" - conventional-changelog-ember "^0.2.6" - conventional-changelog-eslint "^0.1.0" - conventional-changelog-express "^0.1.0" - conventional-changelog-jquery "^0.1.0" - conventional-changelog-jscs "^0.1.0" - conventional-changelog-jshint "^0.1.0" - -conventional-commits-filter@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/conventional-commits-filter/-/conventional-commits-filter-1.0.0.tgz#6fc2a659372bc3f2339cf9ffff7e1b0344b93039" - dependencies: - is-subset "^0.1.1" - modify-values "^1.0.0" - -conventional-commits-parser@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-1.3.0.tgz#e327b53194e1a7ad5dc63479ee9099a52b024865" - dependencies: - JSONStream "^1.0.4" - is-text-path "^1.0.0" - lodash "^4.2.1" - meow "^3.3.0" - split2 "^2.0.0" - through2 "^2.0.0" - trim-off-newlines "^1.0.0" - -conventional-commits-parser@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-2.0.0.tgz#71d01910cb0a99aeb20c144e50f81f4df3178447" - dependencies: - JSONStream "^1.0.4" - is-text-path "^1.0.0" - lodash "^4.2.1" - meow "^3.3.0" - split2 "^2.0.0" - through2 "^2.0.0" - trim-off-newlines "^1.0.0" - -conventional-recommended-bump@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/conventional-recommended-bump/-/conventional-recommended-bump-1.0.1.tgz#56b8ae553a8a1152fa069e767599e1f6948bd36c" - dependencies: - concat-stream "^1.4.10" - conventional-commits-filter "^1.0.0" - conventional-commits-parser "^2.0.0" - git-raw-commits "^1.2.0" - git-semver-tags "^1.2.1" - meow "^3.3.0" - object-assign "^4.0.1" - convert-source-map@^1.1.0, convert-source-map@^1.3.0: version "1.5.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" @@ -1574,12 +1311,6 @@ d@1: dependencies: es5-ext "^0.10.9" -dargs@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17" - dependencies: - number-is-nan "^1.0.0" - dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" @@ -1590,13 +1321,6 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -dateformat@^1.0.11, dateformat@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" - dependencies: - get-stdin "^4.0.1" - meow "^3.3.0" - debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" @@ -1617,10 +1341,6 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" -dedent@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" - deep-eql@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-2.0.2.tgz#b1bac06e56f0a76777686d50c9feb75c2ed7679a" @@ -1641,12 +1361,6 @@ default-require-extensions@^1.0.0: dependencies: strip-bom "^2.0.0" -defaults@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - dependencies: - clone "^1.0.2" - deferred-leveldown@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-1.2.1.tgz#5d25c3310f5fe909946f6240dc9f90dd109a71ef" @@ -1697,10 +1411,6 @@ detect-indent@^4.0.0: dependencies: repeating "^2.0.0" -detect-indent@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" - diff@3.2.0, diff@^3.1.0, diff@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" @@ -1725,12 +1435,6 @@ domain-browser@^1.1.1: version "1.1.7" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" -dot-prop@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" - dependencies: - is-obj "^1.0.0" - drbg.js@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/drbg.js/-/drbg.js-1.0.1.tgz#3e36b6c42b37043823cdbc332d58f31e2445480b" @@ -1745,7 +1449,7 @@ duplexer2@~0.0.2: dependencies: readable-stream "~1.1.9" -duplexer@^0.1.1, duplexer@~0.1.1: +duplexer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" @@ -1802,7 +1506,7 @@ errno@^0.1.3, errno@~0.1.1: dependencies: prr "~0.0.0" -error-ex@^1.2.0, error-ex@^1.3.1: +error-ex@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" dependencies: @@ -2085,18 +1789,6 @@ execa@^0.5.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execa@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.8.0.tgz#d8d76bbc1b55217ed190fd6dd49d3c774ecfc8da" - dependencies: - cross-spawn "^5.0.1" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" - expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -2135,14 +1827,6 @@ extend@~3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" -external-editor@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.4.tgz#1ed9199da9cbfe2ef2f7a31b2fde8b0d12368972" - dependencies: - iconv-lite "^0.4.17" - jschardet "^1.4.2" - tmp "^0.0.31" - extglob@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" @@ -2189,12 +1873,6 @@ figures@^1.3.5: escape-string-regexp "^1.0.5" object-assign "^4.1.0" -figures@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" - dependencies: - escape-string-regexp "^1.0.5" - file-type@^3.6.0: version "3.9.0" resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" @@ -2315,7 +1993,7 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" -fs-extra@^4.0.0, fs-extra@^4.0.1: +fs-extra@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.1.tgz#7fc0c6c8957f983f57f306a24e5b9ddd8d0dd880" dependencies: @@ -2390,20 +2068,6 @@ get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" -get-pkg-repo@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz#c73b489c06d80cc5536c2c853f9e05232056972d" - dependencies: - hosted-git-info "^2.1.4" - meow "^3.3.0" - normalize-package-data "^2.3.0" - parse-github-repo-url "^1.3.0" - through2 "^2.0.0" - -get-port@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/get-port/-/get-port-3.2.0.tgz#dd7ce7de187c06c8bf353796ac71e099f0980ebc" - get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" @@ -2419,10 +2083,6 @@ get-stream@^2.2.0: object-assign "^4.0.1" pinkie-promise "^2.0.0" -get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - get-value@^2.0.3, get-value@^2.0.5, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -2443,44 +2103,10 @@ ghauth@^2.0.0: read "~1.0.5" xtend "~4.0.0" -git-raw-commits@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-1.2.0.tgz#0f3a8bfd99ae0f2d8b9224d58892975e9a52d03c" - dependencies: - dargs "^4.0.1" - lodash.template "^4.0.2" - meow "^3.3.0" - split2 "^2.0.0" - through2 "^2.0.0" - -git-remote-origin-url@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz#5282659dae2107145a11126112ad3216ec5fa65f" - dependencies: - gitconfiglocal "^1.0.0" - pify "^2.3.0" - -git-semver-tags@^1.2.0, git-semver-tags@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-1.2.1.tgz#6ccd2a52e735b736748dc762444fcd9588e27490" - dependencies: - meow "^3.3.0" - semver "^5.0.1" - -gitconfiglocal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" - dependencies: - ini "^1.3.2" - github-from-package@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" -github-url-from-git@^1.4.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/github-url-from-git/-/github-url-from-git-1.5.0.tgz#f985fedcc0a9aa579dc88d7aff068d55cc6251a0" - github-url-to-object@^1.4.2: version "1.6.0" resolved "https://registry.yarnpkg.com/github-url-to-object/-/github-url-to-object-1.6.0.tgz#891ef7fbbfaba8fed71510acdb1b4e9346a970dc" @@ -2511,7 +2137,7 @@ glob@7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@^7.1.2, glob@~7.1.2: +glob@^7.0.0, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@~7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -2533,16 +2159,6 @@ globals@^9.0.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" -globby@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" - dependencies: - array-union "^1.0.1" - glob "^7.0.3" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -2555,7 +2171,7 @@ growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" -handlebars@^4.0.2, handlebars@^4.0.3, handlebars@^4.0.6: +handlebars@^4.0.3, handlebars@^4.0.6: version "4.0.10" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" dependencies: @@ -2595,10 +2211,6 @@ has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" -has-flag@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" - has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" @@ -2696,7 +2308,7 @@ hyperquest@~1.2.0: duplexer2 "~0.0.2" through2 "~0.6.3" -iconv-lite@^0.4.17, iconv-lite@~0.4.13: +iconv-lite@~0.4.13: version "0.4.18" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" @@ -2737,7 +2349,7 @@ inherits@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" -ini@^1.3.2, ini@~1.3.0: +ini@~1.3.0: version "1.3.4" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" @@ -2754,25 +2366,6 @@ inquirer@^0.8.2: rx "^2.4.3" through "^2.3.6" -inquirer@^3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.2.2.tgz#c2aaede1507cc54d826818737742d621bef2e823" - dependencies: - ansi-escapes "^2.0.0" - chalk "^2.0.0" - cli-cursor "^2.1.0" - cli-width "^2.0.0" - external-editor "^2.0.4" - figures "^2.0.0" - lodash "^4.3.0" - mute-stream "0.0.7" - run-async "^2.2.0" - rx-lite "^4.0.8" - rx-lite-aggregates "^4.0.8" - string-width "^2.1.0" - strip-ansi "^4.0.0" - through "^2.3.6" - interpret@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" @@ -2817,12 +2410,6 @@ is-callable@^1.1.1, is-callable@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" -is-ci@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e" - dependencies: - ci-info "^1.0.0" - is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -2928,20 +2515,12 @@ is-number@^3.0.0: dependencies: kind-of "^3.0.2" -is-obj@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" - is-odd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-1.0.0.tgz#3b8a932eb028b3775c39bb09e91767accdb69088" dependencies: is-number "^3.0.0" -is-plain-obj@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" - is-plain-object@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.3.tgz#c15bf3e4b66b62d72efaf2925848663ecbc619b6" @@ -2956,10 +2535,6 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" -is-promise@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" - is-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" @@ -2974,20 +2549,10 @@ is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" -is-subset@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6" - is-symbol@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" -is-text-path@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" - dependencies: - text-extensions "^1.0.0" - is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -3099,10 +2664,6 @@ jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" -jschardet@^1.4.2: - version "1.5.1" - resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.5.1.tgz#c519f629f86b3a5bedba58a88d311309eec097f9" - jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" @@ -3139,7 +2700,7 @@ json-stable-stringify@^1.0.1: dependencies: jsonify "~0.0.0" -json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: +json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" @@ -3167,10 +2728,6 @@ jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" -jsonparse@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" - jsonpointer@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" @@ -3247,46 +2804,6 @@ lcov-parse@0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" -lerna@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/lerna/-/lerna-2.1.1.tgz#1d563926204dca11e56d637cac16587d66aa264a" - dependencies: - async "^1.5.0" - chalk "^2.1.0" - cmd-shim "^2.0.2" - columnify "^1.5.4" - command-join "^2.0.0" - conventional-changelog-cli "^1.3.2" - conventional-recommended-bump "^1.0.1" - dedent "^0.7.0" - execa "^0.8.0" - find-up "^2.1.0" - fs-extra "^4.0.1" - get-port "^3.2.0" - glob "^7.1.2" - globby "^6.1.0" - graceful-fs "^4.1.11" - inquirer "^3.2.2" - is-ci "^1.0.10" - load-json-file "^3.0.0" - lodash "^4.17.4" - minimatch "^3.0.4" - npmlog "^4.1.2" - p-finally "^1.0.0" - path-exists "^3.0.0" - read-cmd-shim "^1.0.1" - read-pkg "^2.0.0" - rimraf "^2.6.1" - safe-buffer "^5.1.1" - semver "^5.4.1" - signal-exit "^3.0.2" - strong-log-transformer "^1.0.6" - temp-write "^3.3.0" - write-file-atomic "^2.3.0" - write-json-file "^2.2.0" - write-pkg "^3.1.0" - yargs "^8.0.2" - level-codec@~6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/level-codec/-/level-codec-6.1.0.tgz#f5df0a99582f76dac43855151ab6f4e4d0d60045" @@ -3344,15 +2861,6 @@ load-json-file@^2.0.0: pify "^2.0.0" strip-bom "^3.0.0" -load-json-file@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-3.0.0.tgz#7eb3735d983a7ed2262ade4ff769af5369c5c440" - dependencies: - graceful-fs "^4.1.2" - parse-json "^3.0.0" - pify "^2.0.0" - strip-bom "^3.0.0" - loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" @@ -3395,10 +2903,6 @@ lodash._isiterateecall@^3.0.0: version "3.0.9" resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" -lodash._reinterpolate@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" - lodash.assign@^4.0.3, lodash.assign@^4.0.6: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" @@ -3427,24 +2931,11 @@ lodash.keys@^3.0.0: lodash.isarguments "^3.0.0" lodash.isarray "^3.0.0" -lodash.template@^4.0.2: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" - dependencies: - lodash._reinterpolate "~3.0.0" - lodash.templatesettings "^4.0.0" - -lodash.templatesettings@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316" - dependencies: - lodash._reinterpolate "~3.0.0" - lodash@^3.3.1, lodash@^3.6.0: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" -lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: +lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.2.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -3492,12 +2983,6 @@ ltgt@~2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.1.3.tgz#10851a06d9964b971178441c23c9e52698eece34" -make-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.0.0.tgz#97a011751e91dd87cfadef58832ebb04936de978" - dependencies: - pify "^2.3.0" - map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -3558,7 +3043,7 @@ memorystream@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" -meow@^3.1.0, meow@^3.3.0, meow@^3.7.0: +meow@^3.1.0, meow@^3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" dependencies: @@ -3681,10 +3166,6 @@ minimist@1.2.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@~1.2 version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -minimist@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.1.0.tgz#99df657a52574c21c9057497df742790b2b4c0de" - mixin-deep@^1.1.3: version "1.2.0" resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.2.0.tgz#d02b8c6f8b6d4b8f5982d3fd009c4919851c3fe2" @@ -3714,14 +3195,6 @@ mocha@^3.4.1: mkdirp "0.5.1" supports-color "3.1.2" -modify-values@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.0.tgz#e2b6cdeb9ce19f99317a53722f3dbf5df5eaaab2" - -moment@^2.6.0: - version "2.18.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" - ms@0.7.2: version "0.7.2" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" @@ -3734,7 +3207,7 @@ mute-stream@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.4.tgz#a9219960a6d5d5d046597aee51252c6655f7177e" -mute-stream@0.0.7, mute-stream@~0.0.4: +mute-stream@~0.0.4: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" @@ -3843,7 +3316,7 @@ nopt@^4.0.1: abbrev "1" osenv "^0.1.4" -normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.3.5: +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: version "2.4.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" dependencies: @@ -3876,7 +3349,7 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -npmlog@^4.0.1, npmlog@^4.0.2, npmlog@^4.1.2: +npmlog@^4.0.1, npmlog@^4.0.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" dependencies: @@ -3974,12 +3447,6 @@ once@^1.3.0, once@^1.3.1, once@^1.3.3, once@^1.4.0: dependencies: wrappy "1" -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" - dependencies: - mimic-fn "^1.0.0" - opn-cli@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/opn-cli/-/opn-cli-3.1.0.tgz#f819ae6cae0b411bd0149b8560fe6c88adad20f8" @@ -4026,7 +3493,7 @@ os-locale@^2.0.0: lcid "^1.0.0" mem "^1.1.0" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -4065,10 +3532,6 @@ parse-asn1@^5.0.0: evp_bytestokey "^1.0.0" pbkdf2 "^3.0.3" -parse-github-repo-url@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.0.tgz#286c53e2c9962e0641649ee3ac9508fca4dd959c" - parse-glob@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" @@ -4091,12 +3554,6 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" -parse-json@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-3.0.0.tgz#fa6f47b18e23826ead32f263e744d0e1e847fb13" - dependencies: - error-ex "^1.3.1" - pascalcase@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" @@ -4324,10 +3781,6 @@ punycode@^1.2.4, punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" -q@^1.4.1: - version "1.5.0" - resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1" - qs@~6.3.0: version "6.3.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" @@ -4366,12 +3819,6 @@ rc@^1.1.6, rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -read-cmd-shim@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-1.0.1.tgz#2d5d157786a37c055d22077c32c53f8329e91c7b" - dependencies: - graceful-fs "^4.1.2" - read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -4386,7 +3833,7 @@ read-pkg-up@^2.0.0: find-up "^2.0.0" read-pkg "^2.0.0" -read-pkg@^1.0.0, read-pkg@^1.1.0: +read-pkg@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" dependencies: @@ -4426,7 +3873,7 @@ readable-stream@^1.0.33, readable-stream@~1.1.9: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6, readable-stream@^2.2.9: +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.6, readable-stream@^2.2.9: version "2.3.3" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" dependencies: @@ -4628,13 +4075,6 @@ resolve@^1.1.6, resolve@^1.3.2, resolve@~1.3.3: dependencies: path-parse "^1.0.5" -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" - dependencies: - onetime "^2.0.0" - signal-exit "^3.0.2" - resumer@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" @@ -4664,27 +4104,11 @@ rlp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.0.0.tgz#9db384ff4b89a8f61563d92395d8625b18f3afb0" -run-async@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" - dependencies: - is-promise "^2.1.0" - -rx-lite-aggregates@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" - dependencies: - rx-lite "*" - -rx-lite@*, rx-lite@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" - rx@^2.4.3: version "2.5.3" resolved "https://registry.yarnpkg.com/rx/-/rx-2.5.3.tgz#21adc7d80f02002af50dae97fd9dbf248755f566" -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" @@ -4737,10 +4161,6 @@ semver-regex@^1.0.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" -semver@^5.0.1, semver@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" - semver@~5.1.0: version "5.1.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.1.1.tgz#a3292a373e6f3e0798da0b20641b9a9c5bc47e19" @@ -4900,18 +4320,6 @@ solc@^0.4.2: semver "^5.3.0" yargs "^4.7.1" -sort-keys@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" - dependencies: - is-plain-obj "^1.0.0" - -sort-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-2.0.0.tgz#658535584861ec97d730d6cf41822e1f56684128" - dependencies: - is-plain-obj "^1.0.0" - source-list-map@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" @@ -4980,24 +4388,12 @@ split-string@^2.1.0: dependencies: extend-shallow "^2.0.1" -split2@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/split2/-/split2-2.1.1.tgz#7a1f551e176a90ecd3345f7246a0cfe175ef4fd0" - dependencies: - through2 "^2.0.2" - split@0.3: version "0.3.3" resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" dependencies: through "2" -split@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9" - dependencies: - through "2" - sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -5064,7 +4460,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0, string-width@^2.1.0: +string-width@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.0.tgz#030664561fc146c9423ec7d978fe2457437fe6d0" dependencies: @@ -5149,16 +4545,6 @@ strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" -strong-log-transformer@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/strong-log-transformer/-/strong-log-transformer-1.0.6.tgz#f7fb93758a69a571140181277eea0c2eb1301fa3" - dependencies: - byline "^5.0.0" - duplexer "^0.1.1" - minimist "^0.1.0" - moment "^2.6.0" - through "^2.3.4" - supports-color@3.1.2, supports-color@^3.1.0, supports-color@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" @@ -5169,12 +4555,6 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.1.tgz#65a4bb2631e90e02420dba5554c375a4754bb836" - dependencies: - has-flag "^2.0.0" - tapable@^0.2.5, tapable@~0.2.5: version "0.2.6" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.6.tgz#206be8e188860b514425375e6f1ae89bfb01fd8d" @@ -5236,10 +4616,6 @@ tar@^2.2.1: fstream "^1.0.2" inherits "2" -temp-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/temp-dir/-/temp-dir-1.0.0.tgz#0a7c0ea26d3a39afa7e0ebea9c1fc0bc4daa011d" - temp-write@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/temp-write/-/temp-write-2.1.0.tgz#59890918e0ef09d548aaa342f4bd3409d8404e96" @@ -5251,24 +4627,6 @@ temp-write@^2.1.0: pinkie-promise "^2.0.0" uuid "^2.0.1" -temp-write@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/temp-write/-/temp-write-3.3.0.tgz#c1a96de2b36061342eae81f44ff001aec8f615a9" - dependencies: - graceful-fs "^4.1.2" - is-stream "^1.1.0" - make-dir "^1.0.0" - pify "^2.2.0" - temp-dir "^1.0.0" - uuid "^3.0.1" - -tempfile@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/tempfile/-/tempfile-1.1.1.tgz#5bcc4eaecc4ab2c707d8bc11d99ccc9a2cb287f2" - dependencies: - os-tmpdir "^1.0.0" - uuid "^2.0.1" - test-exclude@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26" @@ -5283,11 +4641,7 @@ text-encoding@0.6.4: version "0.6.4" resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" -text-extensions@^1.0.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.5.0.tgz#d1cb2d14b5d0bc45bfdca8a08a473f68c7eb0cbc" - -through2@^2.0.0, through2@^2.0.1, through2@^2.0.2: +through2@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" dependencies: @@ -5308,7 +4662,7 @@ through2@~0.6.3: readable-stream ">=1.0.33-1 <1.1.0-0" xtend ">=4.0.0 <4.1.0-0" -through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6, through@~2.3, through@~2.3.1, through@~2.3.4, through@~2.3.8: +through@2, through@^2.3.6, through@~2.3, through@~2.3.1, through@~2.3.4, through@~2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" @@ -5318,12 +4672,6 @@ timers-browserify@^2.0.2: dependencies: setimmediate "^1.0.4" -tmp@^0.0.31: - version "0.0.31" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" - dependencies: - os-tmpdir "~1.0.1" - to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -5371,10 +4719,6 @@ trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" -trim-off-newlines@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" - trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" @@ -5453,10 +4797,6 @@ type-detect@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.3.tgz#0e3f2670b44099b0b46c284d136a7ef49c74c2ea" -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - typedoc-default-themes@^0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.5.0.tgz#6dc2433e78ed8bea8e887a3acde2f31785bd6227" @@ -5591,7 +4931,7 @@ uuid@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" -uuid@^3.0.0, uuid@^3.0.1: +uuid@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" @@ -5622,12 +4962,6 @@ watchpack@^1.3.1: chokidar "^1.4.3" graceful-fs "^4.1.2" -wcwidth@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - dependencies: - defaults "^1.0.3" - web3-provider-engine@^13.0.1: version "13.1.1" resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-13.1.1.tgz#ce6ce592cecd60209ae652193c508f65d15f08f0" @@ -5706,12 +5040,6 @@ web3@^0.20.0: xhr2 "*" xmlhttprequest "*" -web3_beta@ethereum/web3.js#1.0: - version "1.0.0-beta.18" - resolved "https://codeload.github.com/ethereum/web3.js/tar.gz/eff0a026b8259ccbf2eec9fe9a8785e494addb80" - dependencies: - lerna "^2.0.0" - webpack-sources@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" @@ -5805,32 +5133,6 @@ write-file-atomic@^1.1.4: imurmurhash "^0.1.4" slide "^1.1.5" -write-file-atomic@^2.0.0, write-file-atomic@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - signal-exit "^3.0.2" - -write-json-file@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/write-json-file/-/write-json-file-2.2.0.tgz#51862506bbb3b619eefab7859f1fd6c6d0530876" - dependencies: - detect-indent "^5.0.0" - graceful-fs "^4.1.2" - make-dir "^1.0.0" - pify "^2.0.0" - sort-keys "^1.1.1" - write-file-atomic "^2.0.0" - -write-pkg@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/write-pkg/-/write-pkg-3.1.0.tgz#030a9994cc9993d25b4e75a9f1a1923607291ce9" - dependencies: - sort-keys "^2.0.0" - write-json-file "^2.2.0" - xhr2@*: version "0.1.4" resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.1.4.tgz#7f87658847716db5026323812f818cadab387a5f" @@ -5928,7 +5230,7 @@ yargs@^6.0.0: y18n "^3.2.1" yargs-parser "^4.2.0" -yargs@^8.0.1, yargs@^8.0.2: +yargs@^8.0.1: version "8.0.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360" dependencies: -- cgit From c9e490bdaec53e3a93b5da8daaaf0b1d87d9de76 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 4 Sep 2017 19:08:14 +0200 Subject: Implement zeroEx.awaitTransactionMined --- src/0x.ts | 14 ++++++++++++++ src/web3_wrapper.ts | 4 ++++ test/exchange_wrapper_test.ts | 8 ++++---- test/utils/blockchain_lifecycle.ts | 3 --- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/0x.ts b/src/0x.ts index 3cf672a1b..e92c92e1f 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -1,5 +1,6 @@ import * as _ from 'lodash'; import * as BigNumber from 'bignumber.js'; +import * as Web3 from 'web3'; import {SchemaValidator, schemas} from '0x-json-schemas'; import {bigNumberConfigs} from './bignumber_config'; import * as ethUtil from 'ethereumjs-util'; @@ -248,4 +249,17 @@ export class ZeroEx { throw new Error(ZeroExError.InvalidSignature); } + public async awaitTransactionMined(txHash: string, + pollingIntervalMs: number = 500): Promise { + const txReceiptPromise = new Promise((resolve: (receipt: Web3.TransactionReceipt) => void, reject) => { + const intervalId = setInterval(async () => { + const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash); + if (!_.isNull(transactionReceipt)) { + clearInterval(intervalId); + resolve(transactionReceipt); + } + }, pollingIntervalMs); + }); + return txReceiptPromise; + } } diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts index 129017e7c..f3fe8a00b 100644 --- a/src/web3_wrapper.ts +++ b/src/web3_wrapper.ts @@ -27,6 +27,10 @@ export class Web3Wrapper { const nodeVersion = await promisify(this.web3.version.getNode)(); return nodeVersion; } + public async getTransactionReceiptAsync(txHash: string): Promise { + const transactionReceipt = await promisify(this.web3.eth.getTransactionReceipt)(txHash); + return transactionReceipt; + } public getCurrentProvider(): Web3.Provider { return this.web3.currentProvider; } diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 15e957ee1..99e61a751 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -205,7 +205,7 @@ describe('ExchangeWrapper', () => { ); const txHash = await zeroEx.exchange.fillOrderAsync( signedOrder, fillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); - await blockchainLifecycle.waitUntilMinedAsync(txHash); + await zeroEx.awaitTransactionMined(txHash); expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient)) .to.be.bignumber.equal(makerFee.plus(takerFee)); }); @@ -246,7 +246,7 @@ describe('ExchangeWrapper', () => { it('should successfully fill multiple orders', async () => { const txHash = await zeroEx.exchange.batchFillOrdersAsync( orderFillBatch, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); - await blockchainLifecycle.waitUntilMinedAsync(txHash); + await zeroEx.awaitTransactionMined(txHash); const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillTakerAmount); @@ -282,7 +282,7 @@ describe('ExchangeWrapper', () => { const txHash = await zeroEx.exchange.fillOrdersUpToAsync( signedOrders, fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, ); - await blockchainLifecycle.waitUntilMinedAsync(txHash); + await zeroEx.awaitTransactionMined(txHash); const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillableAmount); @@ -316,7 +316,7 @@ describe('ExchangeWrapper', () => { describe('successful cancels', () => { it('should cancel an order', async () => { const txHash = await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); - await blockchainLifecycle.waitUntilMinedAsync(txHash); + await zeroEx.awaitTransactionMined(txHash); const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex); expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); }); diff --git a/test/utils/blockchain_lifecycle.ts b/test/utils/blockchain_lifecycle.ts index b4f742e63..50eb57b95 100644 --- a/test/utils/blockchain_lifecycle.ts +++ b/test/utils/blockchain_lifecycle.ts @@ -17,7 +17,4 @@ export class BlockchainLifecycle { throw new Error(`Snapshot with id #${this.snapshotId} failed to revert`); } } - public async waitUntilMinedAsync(txHash: string): Promise { - return undefined; - } } -- cgit From 2b547f94a44dfed029b5559b743344d5998fa3bc Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 10:07:16 +0200 Subject: Change non-exhange contracts to also return txHash --- src/0x.ts | 4 +-- src/contract_wrappers/ether_token_wrapper.ts | 12 +++++--- src/contract_wrappers/exchange_wrapper.ts | 1 - src/contract_wrappers/token_wrapper.ts | 43 +++++++++++++++++++--------- src/types.ts | 10 +++---- test/ether_token_wrapper_test.ts | 6 ++-- test/exchange_wrapper_test.ts | 8 +++--- test/token_wrapper_test.ts | 3 +- 8 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/0x.ts b/src/0x.ts index e92c92e1f..4a1d605a2 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -249,8 +249,8 @@ export class ZeroEx { throw new Error(ZeroExError.InvalidSignature); } - public async awaitTransactionMined(txHash: string, - pollingIntervalMs: number = 500): Promise { + public async awaitTransactionMinedAsync(txHash: string, + pollingIntervalMs: number = 500): Promise { const txReceiptPromise = new Promise((resolve: (receipt: Web3.TransactionReceipt) => void, reject) => { const intervalId = setInterval(async () => { const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash); diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts index a2486b15e..ba0cd05d8 100644 --- a/src/contract_wrappers/ether_token_wrapper.ts +++ b/src/contract_wrappers/ether_token_wrapper.ts @@ -23,8 +23,9 @@ export class EtherTokenWrapper extends ContractWrapper { * for ETH. * @param amountInWei Amount of ETH in Wei the caller wishes to deposit. * @param depositor The hex encoded user Ethereum address that would like to make the deposit. + * @return Transaction hash. */ - public async depositAsync(amountInWei: BigNumber.BigNumber, depositor: string): Promise { + public async depositAsync(amountInWei: BigNumber.BigNumber, depositor: string): Promise { assert.isBigNumber('amountInWei', amountInWei); await assert.isSenderAddressAsync('depositor', depositor, this._web3Wrapper); @@ -32,18 +33,20 @@ export class EtherTokenWrapper extends ContractWrapper { assert.assert(ethBalanceInWei.gte(amountInWei), ZeroExError.InsufficientEthBalanceForDeposit); const wethContract = await this._getEtherTokenContractAsync(); - await wethContract.deposit({ + const txHash = await wethContract.deposit({ from: depositor, value: amountInWei, }); + return txHash; } /** * Withdraw ETH to the withdrawer's address from the wrapped ETH smart contract in exchange for the * equivalent number of wrapped ETH tokens. * @param amountInWei Amount of ETH in Wei the caller wishes to withdraw. * @param withdrawer The hex encoded user Ethereum address that would like to make the withdrawl. + * @return Transaction hash. */ - public async withdrawAsync(amountInWei: BigNumber.BigNumber, withdrawer: string): Promise { + public async withdrawAsync(amountInWei: BigNumber.BigNumber, withdrawer: string): Promise { assert.isBigNumber('amountInWei', amountInWei); await assert.isSenderAddressAsync('withdrawer', withdrawer, this._web3Wrapper); @@ -52,9 +55,10 @@ export class EtherTokenWrapper extends ContractWrapper { assert.assert(WETHBalanceInBaseUnits.gte(amountInWei), ZeroExError.InsufficientWEthBalanceForWithdrawal); const wethContract = await this._getEtherTokenContractAsync(); - await wethContract.withdraw(amountInWei, { + const txHash = await wethContract.withdraw(amountInWei, { from: withdrawer, }); + return txHash; } /** * Retrieves the Wrapped Ether token contract address diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 1196394e9..3b94bb22c 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -21,7 +21,6 @@ import { IndexedFilterValues, CreateContractEvent, ContractEventObj, - ContractResponse, OrderCancellationRequest, OrderFillRequest, LogErrorContractEventArgs, diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index e98744cbc..9c72455f1 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -60,9 +60,10 @@ export class TokenWrapper extends ContractWrapper { * for spenderAddress. * @param spenderAddress The hex encoded user Ethereum address who will be able to spend the set allowance. * @param amountInBaseUnits The allowance amount you would like to set. + * @return Transaction hash. */ public async setAllowanceAsync(tokenAddress: string, ownerAddress: string, spenderAddress: string, - amountInBaseUnits: BigNumber.BigNumber): Promise { + amountInBaseUnits: BigNumber.BigNumber): Promise { await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper); assert.isETHAddressHex('spenderAddress', spenderAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -74,10 +75,11 @@ export class TokenWrapper extends ContractWrapper { // TODO: Debug issue in testrpc and submit a PR, then remove this hack const networkIdIfExists = await this._web3Wrapper.getNetworkIdIfExistsAsync(); const gas = networkIdIfExists === constants.TESTRPC_NETWORK_ID ? ALLOWANCE_TO_ZERO_GAS_AMOUNT : undefined; - await tokenContract.approve(spenderAddress, amountInBaseUnits, { + const txHash = await tokenContract.approve(spenderAddress, amountInBaseUnits, { from: ownerAddress, gas, }); + return txHash; } /** * Sets the spender's allowance to an unlimited number of baseUnits on behalf of the owner address. @@ -88,12 +90,14 @@ export class TokenWrapper extends ContractWrapper { * @param ownerAddress The hex encoded user Ethereum address who would like to set an allowance * for spenderAddress. * @param spenderAddress The hex encoded user Ethereum address who will be able to spend the set allowance. + * @return Transaction hash. */ public async setUnlimitedAllowanceAsync(tokenAddress: string, ownerAddress: string, - spenderAddress: string): Promise { - await this.setAllowanceAsync( + spenderAddress: string): Promise { + const txHash = await this.setAllowanceAsync( tokenAddress, ownerAddress, spenderAddress, this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, ); + return txHash; } /** * Retrieves the owners allowance in baseUnits set to the spender's address. @@ -102,7 +106,8 @@ export class TokenWrapper extends ContractWrapper { * you would like to retrieve. * @param spenderAddress The hex encoded user Ethereum address who can spend the allowance you are fetching. */ - public async getAllowanceAsync(tokenAddress: string, ownerAddress: string, spenderAddress: string) { + public async getAllowanceAsync(tokenAddress: string, ownerAddress: string, + spenderAddress: string): Promise { assert.isETHAddressHex('ownerAddress', ownerAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -117,7 +122,7 @@ export class TokenWrapper extends ContractWrapper { * @param tokenAddress The hex encoded contract Ethereum address where the ERC20 token is deployed. * @param ownerAddress The hex encoded user Ethereum address whose proxy contract allowance we are retrieving. */ - public async getProxyAllowanceAsync(tokenAddress: string, ownerAddress: string) { + public async getProxyAllowanceAsync(tokenAddress: string, ownerAddress: string): Promise { assert.isETHAddressHex('ownerAddress', ownerAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -132,15 +137,17 @@ export class TokenWrapper extends ContractWrapper { * @param ownerAddress The hex encoded user Ethereum address who is setting an allowance * for the Proxy contract. * @param amountInBaseUnits The allowance amount specified in baseUnits. + * @return Transaction hash. */ public async setProxyAllowanceAsync(tokenAddress: string, ownerAddress: string, - amountInBaseUnits: BigNumber.BigNumber): Promise { + amountInBaseUnits: BigNumber.BigNumber): Promise { assert.isETHAddressHex('ownerAddress', ownerAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); const proxyAddress = await this._getProxyAddressAsync(); - await this.setAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, amountInBaseUnits); + const txHash = await this.setAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, amountInBaseUnits); + return txHash; } /** * Sets the 0x proxy contract's allowance to a unlimited number of a tokens' baseUnits on behalf @@ -150,9 +157,13 @@ export class TokenWrapper extends ContractWrapper { * @param tokenAddress The hex encoded contract Ethereum address where the ERC20 token is deployed. * @param ownerAddress The hex encoded user Ethereum address who is setting an allowance * for the Proxy contract. + * @return Transaction hash. */ - public async setUnlimitedProxyAllowanceAsync(tokenAddress: string, ownerAddress: string): Promise { - await this.setProxyAllowanceAsync(tokenAddress, ownerAddress, this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS); + public async setUnlimitedProxyAllowanceAsync(tokenAddress: string, ownerAddress: string): Promise { + const txHash = await this.setProxyAllowanceAsync( + tokenAddress, ownerAddress, this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, + ); + return txHash; } /** * Transfers `amountInBaseUnits` ERC20 tokens from `fromAddress` to `toAddress`. @@ -160,9 +171,10 @@ export class TokenWrapper extends ContractWrapper { * @param fromAddress The hex encoded user Ethereum address that will send the funds. * @param toAddress The hex encoded user Ethereum address that will receive the funds. * @param amountInBaseUnits The amount (specified in baseUnits) of the token to transfer. + * @return Transaction hash. */ public async transferAsync(tokenAddress: string, fromAddress: string, toAddress: string, - amountInBaseUnits: BigNumber.BigNumber): Promise { + amountInBaseUnits: BigNumber.BigNumber): Promise { assert.isETHAddressHex('tokenAddress', tokenAddress); await assert.isSenderAddressAsync('fromAddress', fromAddress, this._web3Wrapper); assert.isETHAddressHex('toAddress', toAddress); @@ -175,9 +187,10 @@ export class TokenWrapper extends ContractWrapper { throw new Error(ZeroExError.InsufficientBalanceForTransfer); } - await tokenContract.transfer(toAddress, amountInBaseUnits, { + const txHash = await tokenContract.transfer(toAddress, amountInBaseUnits, { from: fromAddress, }); + return txHash; } /** * Transfers `amountInBaseUnits` ERC20 tokens from `fromAddress` to `toAddress`. @@ -190,10 +203,11 @@ export class TokenWrapper extends ContractWrapper { * `fromAddress` must have set an allowance to the `senderAddress` * before this call. * @param amountInBaseUnits The amount (specified in baseUnits) of the token to transfer. + * @return Transaction hash. */ public async transferFromAsync(tokenAddress: string, fromAddress: string, toAddress: string, senderAddress: string, amountInBaseUnits: BigNumber.BigNumber): - Promise { + Promise { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isETHAddressHex('fromAddress', fromAddress); assert.isETHAddressHex('toAddress', toAddress); @@ -212,9 +226,10 @@ export class TokenWrapper extends ContractWrapper { throw new Error(ZeroExError.InsufficientBalanceForTransfer); } - await tokenContract.transferFrom(fromAddress, toAddress, amountInBaseUnits, { + const txHash = await tokenContract.transferFrom(fromAddress, toAddress, amountInBaseUnits, { from: senderAddress, }); + return txHash; } /** * Subscribe to an event type emitted by the Token contract. diff --git a/src/types.ts b/src/types.ts index e90c6fab4..1aabe6e4f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -133,10 +133,10 @@ export interface TokenContract extends Web3.ContractInstance { allowance: { call: (ownerAddress: string, allowedAddress: string) => Promise; }; - transfer: (toAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; + transfer: (toAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; transferFrom: (fromAddress: string, toAddress: string, amountInBaseUnits: BigNumber.BigNumber, - txOpts?: TxOpts) => Promise; - approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; + txOpts?: TxOpts) => Promise; + approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; } export interface TokenRegistryContract extends Web3.ContractInstance { @@ -161,8 +161,8 @@ export interface TokenRegistryContract extends Web3.ContractInstance { } export interface EtherTokenContract extends Web3.ContractInstance { - deposit: (txOpts: TxOpts) => Promise; - withdraw: (amount: BigNumber.BigNumber, txOpts: TxOpts) => Promise; + deposit: (txOpts: TxOpts) => Promise; + withdraw: (amount: BigNumber.BigNumber, txOpts: TxOpts) => Promise; } export interface TokenTransferProxyContract extends Web3.ContractInstance { diff --git a/test/ether_token_wrapper_test.ts b/test/ether_token_wrapper_test.ts index 601800cd1..f50aac48b 100644 --- a/test/ether_token_wrapper_test.ts +++ b/test/ether_token_wrapper_test.ts @@ -52,7 +52,8 @@ describe('EtherTokenWrapper', () => { expect(preETHBalance).to.be.bignumber.gt(0); expect(preWETHBalance).to.be.bignumber.equal(0); - await zeroEx.etherToken.depositAsync(depositWeiAmount, addressWithETH); + const txHash = await zeroEx.etherToken.depositAsync(depositWeiAmount, addressWithETH); + await zeroEx.awaitTransactionMinedAsync(txHash); const postETHBalanceInWei = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH); const postWETHBalanceInBaseUnits = await zeroEx.token.getBalanceAsync(wethContractAddress, addressWithETH); @@ -86,7 +87,8 @@ describe('EtherTokenWrapper', () => { expect(gasCost).to.be.bignumber.lte(MAX_REASONABLE_GAS_COST_IN_WEI); expect(preWETHBalance).to.be.bignumber.equal(depositWeiAmount); - await zeroEx.etherToken.withdrawAsync(depositWeiAmount, addressWithETH); + const txHash = await zeroEx.etherToken.withdrawAsync(depositWeiAmount, addressWithETH); + await zeroEx.awaitTransactionMinedAsync(txHash); const postETHBalance = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH); const postWETHBalanceInBaseUnits = await zeroEx.token.getBalanceAsync(wethContractAddress, addressWithETH); diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 99e61a751..990a4dca6 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -205,7 +205,7 @@ describe('ExchangeWrapper', () => { ); const txHash = await zeroEx.exchange.fillOrderAsync( signedOrder, fillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); - await zeroEx.awaitTransactionMined(txHash); + await zeroEx.awaitTransactionMinedAsync(txHash); expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient)) .to.be.bignumber.equal(makerFee.plus(takerFee)); }); @@ -246,7 +246,7 @@ describe('ExchangeWrapper', () => { it('should successfully fill multiple orders', async () => { const txHash = await zeroEx.exchange.batchFillOrdersAsync( orderFillBatch, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); - await zeroEx.awaitTransactionMined(txHash); + await zeroEx.awaitTransactionMinedAsync(txHash); const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillTakerAmount); @@ -282,7 +282,7 @@ describe('ExchangeWrapper', () => { const txHash = await zeroEx.exchange.fillOrdersUpToAsync( signedOrders, fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, ); - await zeroEx.awaitTransactionMined(txHash); + await zeroEx.awaitTransactionMinedAsync(txHash); const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillableAmount); @@ -316,7 +316,7 @@ describe('ExchangeWrapper', () => { describe('successful cancels', () => { it('should cancel an order', async () => { const txHash = await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); - await zeroEx.awaitTransactionMined(txHash); + await zeroEx.awaitTransactionMinedAsync(txHash); const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex); expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); }); diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts index e4223ffc7..68dca0769 100644 --- a/test/token_wrapper_test.ts +++ b/test/token_wrapper_test.ts @@ -58,7 +58,8 @@ describe('TokenWrapper', () => { const toAddress = addressWithoutFunds; const preBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress); expect(preBalance).to.be.bignumber.equal(0); - await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount); + const txHash = await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount); + await zeroEx.awaitTransactionMinedAsync(txHash); const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress); return expect(postBalance).to.be.bignumber.equal(transferAmount); }); -- cgit From 5d57a2f0e958fb36edcbe1ddfd7520406e615195 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 10:22:22 +0200 Subject: Increase timeout --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c24aae90a..2f4bf41ee 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "pretest:umd": "run-s clean build:umd:dev build:commonjs", "substitute_umd_bundle": "npm run remove_src_files_not_used_by_tests; shx mv _bundles/* lib/src", "remove_src_files_not_used_by_tests": "find ./lib/src \\( -path ./lib/src/utils -o -path ./lib/src/subproviders -o -path ./lib/src/schemas -o -path \"./lib/src/types.*\" \\) -prune -o -type f -print | xargs rm", - "run_mocha": "mocha lib/test/**/*_test.js --timeout 4000 --bail" + "run_mocha": "mocha lib/test/**/*_test.js --timeout 5000 --bail" }, "config": { "artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken", -- cgit From 96d2a55effa6666c1b8d90594ca5607dcc1bce8e Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 10:29:51 +0200 Subject: Add TransationReceipt as a public exported type --- src/0x.ts | 12 +++++++++--- src/index.ts | 1 + src/types.ts | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/0x.ts b/src/0x.ts index 4a1d605a2..86976c4ab 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -16,7 +16,7 @@ import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper'; import {EtherTokenWrapper} from './contract_wrappers/ether_token_wrapper'; import {TokenWrapper} from './contract_wrappers/token_wrapper'; import {TokenTransferProxyWrapper} from './contract_wrappers/token_transfer_proxy_wrapper'; -import {ECSignature, ZeroExError, Order, SignedOrder, Web3Provider, ZeroExConfig} from './types'; +import {ECSignature, ZeroExError, Order, SignedOrder, Web3Provider, ZeroExConfig, TransactionReceipt} from './types'; // Customize our BigNumber instances bigNumberConfigs.configure(); @@ -249,9 +249,15 @@ export class ZeroEx { throw new Error(ZeroExError.InvalidSignature); } + /** + * Waits for transaction to be mined and returns the transaction receipt + * @param txHash Transaction hash + * @param pollingIntervalMs How often (in ms) should we check if the transaction is mined. + * @return Web3.TransactionReceipt + */ public async awaitTransactionMinedAsync(txHash: string, - pollingIntervalMs: number = 500): Promise { - const txReceiptPromise = new Promise((resolve: (receipt: Web3.TransactionReceipt) => void, reject) => { + pollingIntervalMs: number = 500): Promise { + const txReceiptPromise = new Promise((resolve: (receipt: TransactionReceipt) => void, reject) => { const intervalId = setInterval(async () => { const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash); if (!_.isNull(transactionReceipt)) { diff --git a/src/index.ts b/src/index.ts index 6d6e4484c..44bd53547 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,4 +30,5 @@ export { ContractEventArgs, Web3Provider, ZeroExConfig, + TransactionReceipt, } from './types'; diff --git a/src/types.ts b/src/types.ts index 1aabe6e4f..b65ffda73 100644 --- a/src/types.ts +++ b/src/types.ts @@ -371,3 +371,5 @@ export interface JSONRPCPayload { export interface ZeroExConfig { gasPrice?: BigNumber.BigNumber; // Gas price to use with every transaction } + +export type TransactionReceipt = Web3.TransactionReceipt; -- cgit From 876032a8a71f9eedbf3394727dbc0ea513100836 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 10:42:00 +0200 Subject: Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22bac9224..934fc24d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +v0.13.0 - _TBD, 2017_ + * Made all the functions submitting transactions to the network to immediately return transaction hash (#151) + * Added `zeroEx.awaitTransactionMinedAsync` (#151) + v0.12.1 - _September 2, 2017_ * Added the support for web3@1.x.x provider (#142) * Added the optional `zeroExConfig` parameter to the constructor of `ZeroEx` (#139) -- cgit From a12df1c73a97b3ba18ab53c1b25be39b837f6240 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 11:38:28 +0200 Subject: Fix gasPrice regression --- src/0x.ts | 15 ++++++----- src/contract.ts | 34 +++++++++++++++++++++++-- src/contract_wrappers/contract_wrapper.ts | 4 +-- src/contract_wrappers/ether_token_wrapper.ts | 4 +-- src/contract_wrappers/exchange_wrapper.ts | 4 +-- src/contract_wrappers/token_registry_wrapper.ts | 4 +-- src/contract_wrappers/token_wrapper.ts | 4 +-- src/web3_wrapper.ts | 6 +++-- 8 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/0x.ts b/src/0x.ts index 86976c4ab..fd7d9b5a5 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -170,13 +170,16 @@ export class ZeroEx { // We re-assign the send method so that Web3@1.0 providers work with 0x.js (provider as any).sendAsync = (provider as any).send; } - this._web3Wrapper = new Web3Wrapper(provider); const gasPrice = _.isUndefined(config) ? undefined : config.gasPrice; - this.token = new TokenWrapper(this._web3Wrapper, gasPrice); - this.proxy = new TokenTransferProxyWrapper(this._web3Wrapper, gasPrice); - this.exchange = new ExchangeWrapper(this._web3Wrapper, this.token, gasPrice); - this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper, gasPrice); - this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token, gasPrice); + const defaults = { + gasPrice, + }; + this._web3Wrapper = new Web3Wrapper(provider, defaults); + this.token = new TokenWrapper(this._web3Wrapper); + this.proxy = new TokenTransferProxyWrapper(this._web3Wrapper); + this.exchange = new ExchangeWrapper(this._web3Wrapper, this.token); + this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper); + this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token); } /** * Sets a new web3 provider for 0x.js. Updating the provider will stop all diff --git a/src/contract.ts b/src/contract.ts index 0c76571cc..3592e0e71 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -6,11 +6,13 @@ export class Contract implements Web3.ContractInstance { public address: string; public abi: Web3.ContractAbi; private contract: Web3.ContractInstance; + private defaults: Partial; [name: string]: any; - constructor(web3ContractInstance: Web3.ContractInstance) { + constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial) { this.contract = web3ContractInstance; this.address = web3ContractInstance.address; this.abi = web3ContractInstance.abi; + this.defaults = defaults; this.populateEvents(); this.populateFunctions(); } @@ -18,11 +20,12 @@ export class Contract implements Web3.ContractInstance { const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === 'function'); _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { const cbStyleFunction = this.contract[functionAbi.name]; - this[functionAbi.name] = promisify(cbStyleFunction, this.contract); if (functionAbi.constant) { + this[functionAbi.name] = promisify(cbStyleFunction, this.contract); const cbStyleCallFunction = this.contract[functionAbi.name].call; this[functionAbi.name].call = promisify(cbStyleCallFunction, this.contract); } else { + this[functionAbi.name] = this.promisifyWithDefaultParams(cbStyleFunction); const cbStyleEstimateGasFunction = this.contract[functionAbi.name].estimateGas; this[functionAbi.name].estimateGas = promisify(cbStyleEstimateGasFunction, this.contract); @@ -35,4 +38,31 @@ export class Contract implements Web3.ContractInstance { this[eventAbi.name] = this.contract[eventAbi.name]; }); } + private promisifyWithDefaultParams(fn: (...args: any[]) => void): (...args: any[]) => Promise { + const promisifiedWithDefaultParams = (...args: any[]) => { + const promise = new Promise((resolve, reject) => { + const lastArg = args[args.length - 1]; + let txData: Partial = {}; + if (_.isObject(lastArg) && !_.isArray(lastArg) && !lastArg.isBigNumber) { + txData = args.pop(); + } + txData = { + ...txData, + ...this.defaults, + }; + const callback = (err: Error, data: any) => { + if (_.isNull(err)) { + resolve(data); + } else { + reject(err); + } + }; + args.push(txData); + args.push(callback); + fn.apply(this.contract, args); + }); + return promise; + }; + return promisifiedWithDefaultParams; + } } diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts index 3de26148f..ca19342f3 100644 --- a/src/contract_wrappers/contract_wrapper.ts +++ b/src/contract_wrappers/contract_wrapper.ts @@ -6,10 +6,8 @@ import {utils} from '../utils/utils'; export class ContractWrapper { protected _web3Wrapper: Web3Wrapper; - private _gasPrice?: BigNumber.BigNumber; - constructor(web3Wrapper: Web3Wrapper, gasPrice?: BigNumber.BigNumber) { + constructor(web3Wrapper: Web3Wrapper) { this._web3Wrapper = web3Wrapper; - this._gasPrice = gasPrice; } protected async _instantiateContractIfExistsAsync(artifact: Artifact, address?: string): Promise { diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts index ba0cd05d8..4c19b3caa 100644 --- a/src/contract_wrappers/ether_token_wrapper.ts +++ b/src/contract_wrappers/ether_token_wrapper.ts @@ -13,8 +13,8 @@ import * as EtherTokenArtifacts from '../artifacts/EtherToken.json'; export class EtherTokenWrapper extends ContractWrapper { private _etherTokenContractIfExists?: EtherTokenContract; private _tokenWrapper: TokenWrapper; - constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper, gasPrice?: BigNumber.BigNumber) { - super(web3Wrapper, gasPrice); + constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper) { + super(web3Wrapper); this._tokenWrapper = tokenWrapper; } /** diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 3b94bb22c..324c92062 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -72,8 +72,8 @@ export class ExchangeWrapper extends ContractWrapper { ]; return [orderAddresses, orderValues]; } - constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper, gasPrice?: BigNumber.BigNumber) { - super(web3Wrapper, gasPrice); + constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper) { + super(web3Wrapper); this._tokenWrapper = tokenWrapper; this._orderValidationUtils = new OrderValidationUtils(tokenWrapper, this); this._exchangeLogEventEmitters = []; diff --git a/src/contract_wrappers/token_registry_wrapper.ts b/src/contract_wrappers/token_registry_wrapper.ts index 1550bfa3e..57c9ca93d 100644 --- a/src/contract_wrappers/token_registry_wrapper.ts +++ b/src/contract_wrappers/token_registry_wrapper.ts @@ -11,8 +11,8 @@ import * as TokenRegistryArtifacts from '../artifacts/TokenRegistry.json'; */ export class TokenRegistryWrapper extends ContractWrapper { private _tokenRegistryContractIfExists?: TokenRegistryContract; - constructor(web3Wrapper: Web3Wrapper, gasPrice?: BigNumber.BigNumber) { - super(web3Wrapper, gasPrice); + constructor(web3Wrapper: Web3Wrapper) { + super(web3Wrapper); } /** * Retrieves all the tokens currently listed in the Token Registry smart contract diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 9c72455f1..944f0fb42 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -31,8 +31,8 @@ export class TokenWrapper extends ContractWrapper { public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; private _tokenContractsByAddress: {[address: string]: TokenContract}; private _tokenLogEventEmitters: ContractEventEmitter[]; - constructor(web3Wrapper: Web3Wrapper, gasPrice?: BigNumber.BigNumber) { - super(web3Wrapper, gasPrice); + constructor(web3Wrapper: Web3Wrapper) { + super(web3Wrapper); this._tokenContractsByAddress = {}; this._tokenLogEventEmitters = []; } diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts index f3fe8a00b..a0923bef9 100644 --- a/src/web3_wrapper.ts +++ b/src/web3_wrapper.ts @@ -7,10 +7,12 @@ import {Contract} from './contract'; export class Web3Wrapper { private web3: Web3; + private defaults: Partial; private networkIdIfExists?: number; - constructor(provider: Web3.Provider) { + constructor(provider: Web3.Provider, defaults: Partial) { this.web3 = new Web3(); this.web3.setProvider(provider); + this.defaults = defaults; } public setProvider(provider: Web3.Provider) { delete this.networkIdIfExists; @@ -97,7 +99,7 @@ export class Web3Wrapper { } private getContractInstance(abi: Web3.ContractAbi, address: string): A { const web3ContractInstance = this.web3.eth.contract(abi).at(address); - const contractInstance = new Contract(web3ContractInstance) as any as A; + const contractInstance = new Contract(web3ContractInstance, this.defaults) as any as A; return contractInstance; } private async getNetworkAsync(): Promise { -- cgit From f6a945dfe4844d243ef67042b33e9ade2fc60308 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 12:52:00 +0200 Subject: Fix the comment at awaitTransactionMinedAsync --- src/0x.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/0x.ts b/src/0x.ts index fd7d9b5a5..e1ba796c8 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -253,10 +253,10 @@ export class ZeroEx { throw new Error(ZeroExError.InvalidSignature); } /** - * Waits for transaction to be mined and returns the transaction receipt + * Waits for a transaction to be mined and returns the transaction receipt. * @param txHash Transaction hash * @param pollingIntervalMs How often (in ms) should we check if the transaction is mined. - * @return Web3.TransactionReceipt + * @return TransactionReceipt */ public async awaitTransactionMinedAsync(txHash: string, pollingIntervalMs: number = 500): Promise { -- cgit From b5c6c9196290314a875f89b88178b1be4b0db7d0 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 12:52:44 +0200 Subject: Increase the default polling interval to 1000 --- src/0x.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/0x.ts b/src/0x.ts index e1ba796c8..209b2704d 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -259,7 +259,7 @@ export class ZeroEx { * @return TransactionReceipt */ public async awaitTransactionMinedAsync(txHash: string, - pollingIntervalMs: number = 500): Promise { + pollingIntervalMs: number = 1000): Promise { const txReceiptPromise = new Promise((resolve: (receipt: TransactionReceipt) => void, reject) => { const intervalId = setInterval(async () => { const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash); -- cgit From e05dfab1fca9eb108848c98da9dbf671a59d17f3 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 13:14:27 +0200 Subject: Add explaining comment --- src/contract.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/contract.ts b/src/contract.ts index 3592e0e71..ebda31e65 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -7,6 +7,8 @@ export class Contract implements Web3.ContractInstance { public abi: Web3.ContractAbi; private contract: Web3.ContractInstance; private defaults: Partial; + // This class instance is going to be populated with functions and events depending on the ABI + // and we don't know their types in advance [name: string]: any; constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial) { this.contract = web3ContractInstance; -- cgit From 9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 13:43:46 +0200 Subject: Rename x.call -> x.callAsync x() -> x.sendTransactionAsync() x.estimateGas() -> x.estimateGasAsync() --- src/contract.ts | 14 +- src/contract_wrappers/ether_token_wrapper.ts | 4 +- src/contract_wrappers/exchange_wrapper.ts | 42 +++--- src/contract_wrappers/token_registry_wrapper.ts | 12 +- .../token_transfer_proxy_wrapper.ts | 4 +- src/contract_wrappers/token_wrapper.ts | 17 ++- src/types.ts | 149 ++++++++++++--------- 7 files changed, 132 insertions(+), 110 deletions(-) diff --git a/src/contract.ts b/src/contract.ts index ebda31e65..9dfb04446 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -21,16 +21,18 @@ export class Contract implements Web3.ContractInstance { private populateFunctions(): void { const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === 'function'); _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { - const cbStyleFunction = this.contract[functionAbi.name]; if (functionAbi.constant) { - this[functionAbi.name] = promisify(cbStyleFunction, this.contract); const cbStyleCallFunction = this.contract[functionAbi.name].call; - this[functionAbi.name].call = promisify(cbStyleCallFunction, this.contract); + this[functionAbi.name] = { + callAsync: promisify(cbStyleCallFunction, this.contract), + }; } else { - this[functionAbi.name] = this.promisifyWithDefaultParams(cbStyleFunction); + const cbStyleFunction = this.contract[functionAbi.name]; const cbStyleEstimateGasFunction = this.contract[functionAbi.name].estimateGas; - this[functionAbi.name].estimateGas = - promisify(cbStyleEstimateGasFunction, this.contract); + this[functionAbi.name] = { + estimateGasAsync: promisify(cbStyleEstimateGasFunction, this.contract), + sendTransactionAsync: this.promisifyWithDefaultParams(cbStyleFunction), + }; } }); } diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts index 4c19b3caa..d31069b22 100644 --- a/src/contract_wrappers/ether_token_wrapper.ts +++ b/src/contract_wrappers/ether_token_wrapper.ts @@ -33,7 +33,7 @@ export class EtherTokenWrapper extends ContractWrapper { assert.assert(ethBalanceInWei.gte(amountInWei), ZeroExError.InsufficientEthBalanceForDeposit); const wethContract = await this._getEtherTokenContractAsync(); - const txHash = await wethContract.deposit({ + const txHash = await wethContract.deposit.sendTransactionAsync({ from: depositor, value: amountInWei, }); @@ -55,7 +55,7 @@ export class EtherTokenWrapper extends ContractWrapper { assert.assert(WETHBalanceInBaseUnits.gte(amountInWei), ZeroExError.InsufficientWEthBalanceForWithdrawal); const wethContract = await this._getEtherTokenContractAsync(); - const txHash = await wethContract.withdraw(amountInWei, { + const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, { from: withdrawer, }); return txHash; diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 324c92062..fbb2c710f 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -90,7 +90,7 @@ export class ExchangeWrapper extends ContractWrapper { assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); const exchangeContract = await this._getExchangeContractAsync(); - let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.call(orderHash); + let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.callAsync(orderHash); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber unavailableTakerTokenAmount = new BigNumber(unavailableTakerTokenAmount); return unavailableTakerTokenAmount; @@ -104,7 +104,7 @@ export class ExchangeWrapper extends ContractWrapper { assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); const exchangeContract = await this._getExchangeContractAsync(); - let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHash); + let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits); return fillAmountInBaseUnits; @@ -119,7 +119,7 @@ export class ExchangeWrapper extends ContractWrapper { assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); const exchangeContract = await this._getExchangeContractAsync(); - let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHash); + let cancelledAmountInBaseUnits = await exchangeContract.cancelled.callAsync(orderHash); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits); return cancelledAmountInBaseUnits; @@ -156,7 +156,7 @@ export class ExchangeWrapper extends ContractWrapper { const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder); - const gas = await exchangeInstance.fillOrder.estimateGas( + const gas = await exchangeInstance.fillOrder.estimateGasAsync( orderAddresses, orderValues, fillTakerTokenAmount, @@ -168,7 +168,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const txHash: string = await exchangeInstance.fillOrder( + const txHash: string = await exchangeInstance.fillOrder.sendTransactionAsync( orderAddresses, orderValues, fillTakerTokenAmount, @@ -235,7 +235,7 @@ export class ExchangeWrapper extends ContractWrapper { ); const exchangeInstance = await this._getExchangeContractAsync(); - const gas = await exchangeInstance.fillOrdersUpTo.estimateGas( + const gas = await exchangeInstance.fillOrdersUpTo.estimateGasAsync( orderAddressesArray, orderValuesArray, fillTakerTokenAmount, @@ -247,7 +247,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const txHash = await exchangeInstance.fillOrdersUpTo( + const txHash = await exchangeInstance.fillOrdersUpTo.sendTransactionAsync( orderAddressesArray, orderValuesArray, fillTakerTokenAmount, @@ -316,7 +316,7 @@ export class ExchangeWrapper extends ContractWrapper { ); const exchangeInstance = await this._getExchangeContractAsync(); - const gas = await exchangeInstance.batchFillOrders.estimateGas( + const gas = await exchangeInstance.batchFillOrders.estimateGasAsync( orderAddressesArray, orderValuesArray, fillTakerTokenAmounts, @@ -328,7 +328,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const txHash = await exchangeInstance.batchFillOrders( + const txHash = await exchangeInstance.batchFillOrders.sendTransactionAsync( orderAddressesArray, orderValuesArray, fillTakerTokenAmounts, @@ -366,7 +366,7 @@ export class ExchangeWrapper extends ContractWrapper { const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder); - const gas = await exchangeInstance.fillOrKillOrder.estimateGas( + const gas = await exchangeInstance.fillOrKillOrder.estimateGasAsync( orderAddresses, orderValues, fillTakerTokenAmount, @@ -377,7 +377,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const txHash = await exchangeInstance.fillOrKillOrder( + const txHash = await exchangeInstance.fillOrKillOrder.sendTransactionAsync( orderAddresses, orderValues, fillTakerTokenAmount, @@ -434,7 +434,7 @@ export class ExchangeWrapper extends ContractWrapper { const [orderAddresses, orderValues, fillTakerTokenAmounts, vParams, rParams, sParams] = _.unzip(orderAddressesValuesAndTakerTokenFillAmounts); - const gas = await exchangeInstance.batchFillOrKillOrders.estimateGas( + const gas = await exchangeInstance.batchFillOrKillOrders.estimateGasAsync( orderAddresses, orderValues, fillTakerTokenAmounts, @@ -445,7 +445,7 @@ export class ExchangeWrapper extends ContractWrapper { from: takerAddress, }, ); - const txHash = await exchangeInstance.batchFillOrKillOrders( + const txHash = await exchangeInstance.batchFillOrKillOrders.sendTransactionAsync( orderAddresses, orderValues, fillTakerTokenAmounts, @@ -477,7 +477,7 @@ export class ExchangeWrapper extends ContractWrapper { await this.validateCancelOrderThrowIfInvalidAsync(order, cancelTakerTokenAmount); const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order); - const gas = await exchangeInstance.cancelOrder.estimateGas( + const gas = await exchangeInstance.cancelOrder.estimateGasAsync( orderAddresses, orderValues, cancelTakerTokenAmount, @@ -485,7 +485,7 @@ export class ExchangeWrapper extends ContractWrapper { from: order.maker, }, ); - const txHash = await exchangeInstance.cancelOrder( + const txHash = await exchangeInstance.cancelOrder.sendTransactionAsync( orderAddresses, orderValues, cancelTakerTokenAmount, @@ -535,7 +535,7 @@ export class ExchangeWrapper extends ContractWrapper { // We use _.unzip because _.unzip doesn't type check if values have different types :'( const [orderAddresses, orderValues, cancelTakerTokenAmounts] = _.unzip(orderAddressesValuesAndTakerTokenCancelAmounts); - const gas = await exchangeInstance.batchCancelOrders.estimateGas( + const gas = await exchangeInstance.batchCancelOrders.estimateGasAsync( orderAddresses, orderValues, cancelTakerTokenAmounts, @@ -543,7 +543,7 @@ export class ExchangeWrapper extends ContractWrapper { from: maker, }, ); - const txHash = await exchangeInstance.batchCancelOrders( + const txHash = await exchangeInstance.batchCancelOrders.sendTransactionAsync( orderAddresses, orderValues, cancelTakerTokenAmounts, @@ -677,7 +677,7 @@ export class ExchangeWrapper extends ContractWrapper { assert.isBigNumber('takerTokenAmount', takerTokenAmount); assert.isBigNumber('makerTokenAmount', makerTokenAmount); const exchangeInstance = await this._getExchangeContractAsync(); - const isRoundingError = await exchangeInstance.isRoundingError.call( + const isRoundingError = await exchangeInstance.isRoundingError.callAsync( fillTakerTokenAmount, takerTokenAmount, makerTokenAmount, ); return isRoundingError; @@ -694,7 +694,7 @@ export class ExchangeWrapper extends ContractWrapper { const exchangeInstance = await this._getExchangeContractAsync(); - const isValidSignature = await exchangeInstance.isValidSignature.call( + const isValidSignature = await exchangeInstance.isValidSignature.callAsync( signerAddressHex, dataHex, ecSignature.v, @@ -706,7 +706,7 @@ export class ExchangeWrapper extends ContractWrapper { private async _getOrderHashHexUsingContractCallAsync(order: Order|SignedOrder): Promise { const exchangeInstance = await this._getExchangeContractAsync(); const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order); - const orderHashHex = await exchangeInstance.getOrderHash.call(orderAddresses, orderValues); + const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues); return orderHashHex; } private _throwErrorLogsAsErrors(logs: ContractEvent[]): void { @@ -729,7 +729,7 @@ export class ExchangeWrapper extends ContractWrapper { } private async _getZRXTokenAddressAsync(): Promise { const exchangeInstance = await this._getExchangeContractAsync(); - const ZRXtokenAddress = await exchangeInstance.ZRX_TOKEN_CONTRACT.call(); + const ZRXtokenAddress = await exchangeInstance.ZRX_TOKEN_CONTRACT.callAsync(); return ZRXtokenAddress; } } diff --git a/src/contract_wrappers/token_registry_wrapper.ts b/src/contract_wrappers/token_registry_wrapper.ts index 57c9ca93d..79eb516fe 100644 --- a/src/contract_wrappers/token_registry_wrapper.ts +++ b/src/contract_wrappers/token_registry_wrapper.ts @@ -35,7 +35,7 @@ export class TokenRegistryWrapper extends ContractWrapper { */ public async getTokenAddressesAsync(): Promise { const tokenRegistryContract = await this._getTokenRegistryContractAsync(); - const addresses = await tokenRegistryContract.getTokenAddresses.call(); + const addresses = await tokenRegistryContract.getTokenAddresses.callAsync(); return addresses; } /** @@ -46,14 +46,14 @@ export class TokenRegistryWrapper extends ContractWrapper { assert.isETHAddressHex('address', address); const tokenRegistryContract = await this._getTokenRegistryContractAsync(); - const metadata = await tokenRegistryContract.getTokenMetaData.call(address); + const metadata = await tokenRegistryContract.getTokenMetaData.callAsync(address); const token = this._createTokenFromMetadata(metadata); return token; } public async getTokenAddressBySymbolIfExistsAsync(symbol: string): Promise { assert.isString('symbol', symbol); const tokenRegistryContract = await this._getTokenRegistryContractAsync(); - const addressIfExists = await tokenRegistryContract.getTokenAddressBySymbol.call(symbol); + const addressIfExists = await tokenRegistryContract.getTokenAddressBySymbol.callAsync(symbol); if (addressIfExists === constants.NULL_ADDRESS) { return undefined; } @@ -62,7 +62,7 @@ export class TokenRegistryWrapper extends ContractWrapper { public async getTokenAddressByNameIfExistsAsync(name: string): Promise { assert.isString('name', name); const tokenRegistryContract = await this._getTokenRegistryContractAsync(); - const addressIfExists = await tokenRegistryContract.getTokenAddressByName.call(name); + const addressIfExists = await tokenRegistryContract.getTokenAddressByName.callAsync(name); if (addressIfExists === constants.NULL_ADDRESS) { return undefined; } @@ -71,14 +71,14 @@ export class TokenRegistryWrapper extends ContractWrapper { public async getTokenBySymbolIfExistsAsync(symbol: string): Promise { assert.isString('symbol', symbol); const tokenRegistryContract = await this._getTokenRegistryContractAsync(); - const metadata = await tokenRegistryContract.getTokenBySymbol.call(symbol); + const metadata = await tokenRegistryContract.getTokenBySymbol.callAsync(symbol); const token = this._createTokenFromMetadata(metadata); return token; } public async getTokenByNameIfExistsAsync(name: string): Promise { assert.isString('name', name); const tokenRegistryContract = await this._getTokenRegistryContractAsync(); - const metadata = await tokenRegistryContract.getTokenByName.call(name); + const metadata = await tokenRegistryContract.getTokenByName.callAsync(name); const token = this._createTokenFromMetadata(metadata); return token; } diff --git a/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/src/contract_wrappers/token_transfer_proxy_wrapper.ts index 2b4b32961..2ed198be6 100644 --- a/src/contract_wrappers/token_transfer_proxy_wrapper.ts +++ b/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -15,7 +15,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper { */ public async isAuthorizedAsync(exchangeContractAddress: string): Promise { const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync(); - const isAuthorized = await tokenTransferProxyContractInstance.authorized.call(exchangeContractAddress); + const isAuthorized = await tokenTransferProxyContractInstance.authorized.callAsync(exchangeContractAddress); return isAuthorized; } /** @@ -24,7 +24,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper { */ public async getAuthorizedAddressesAsync(): Promise { const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync(); - const authorizedAddresses = await tokenTransferProxyContractInstance.getAuthorizedAddresses.call(); + const authorizedAddresses = await tokenTransferProxyContractInstance.getAuthorizedAddresses.callAsync(); return authorizedAddresses; } /** diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 944f0fb42..db1ce22b2 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -47,7 +47,7 @@ export class TokenWrapper extends ContractWrapper { assert.isETHAddressHex('tokenAddress', tokenAddress); const tokenContract = await this._getTokenContractAsync(tokenAddress); - let balance = await tokenContract.balanceOf.call(ownerAddress); + let balance = await tokenContract.balanceOf.callAsync(ownerAddress); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber balance = new BigNumber(balance); return balance; @@ -75,7 +75,7 @@ export class TokenWrapper extends ContractWrapper { // TODO: Debug issue in testrpc and submit a PR, then remove this hack const networkIdIfExists = await this._web3Wrapper.getNetworkIdIfExistsAsync(); const gas = networkIdIfExists === constants.TESTRPC_NETWORK_ID ? ALLOWANCE_TO_ZERO_GAS_AMOUNT : undefined; - const txHash = await tokenContract.approve(spenderAddress, amountInBaseUnits, { + const txHash = await tokenContract.approve.sendTransactionAsync(spenderAddress, amountInBaseUnits, { from: ownerAddress, gas, }); @@ -112,7 +112,7 @@ export class TokenWrapper extends ContractWrapper { assert.isETHAddressHex('tokenAddress', tokenAddress); const tokenContract = await this._getTokenContractAsync(tokenAddress); - let allowanceInBaseUnits = await tokenContract.allowance.call(ownerAddress, spenderAddress); + let allowanceInBaseUnits = await tokenContract.allowance.callAsync(ownerAddress, spenderAddress); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits); return allowanceInBaseUnits; @@ -187,7 +187,7 @@ export class TokenWrapper extends ContractWrapper { throw new Error(ZeroExError.InsufficientBalanceForTransfer); } - const txHash = await tokenContract.transfer(toAddress, amountInBaseUnits, { + const txHash = await tokenContract.transfer.sendTransactionAsync(toAddress, amountInBaseUnits, { from: fromAddress, }); return txHash; @@ -226,9 +226,12 @@ export class TokenWrapper extends ContractWrapper { throw new Error(ZeroExError.InsufficientBalanceForTransfer); } - const txHash = await tokenContract.transferFrom(fromAddress, toAddress, amountInBaseUnits, { - from: senderAddress, - }); + const txHash = await tokenContract.transferFrom.sendTransactionAsync( + fromAddress, toAddress, amountInBaseUnits, + { + from: senderAddress, + }, + ); return txHash; } /** diff --git a/src/types.ts b/src/types.ts index b65ffda73..e47f57e5e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -42,85 +42,90 @@ export type CreateContractEvent = (indexFilterValues: IndexedFilterValues, subscriptionOpts: SubscriptionOpts) => ContractEventObj; export interface ExchangeContract extends Web3.ContractInstance { isValidSignature: { - call: (signerAddressHex: string, dataHex: string, v: number, r: string, s: string, - txOpts?: TxOpts) => Promise; + callAsync: (signerAddressHex: string, dataHex: string, v: number, r: string, s: string, + txOpts?: TxOpts) => Promise; }; LogFill: CreateContractEvent; LogCancel: CreateContractEvent; LogError: CreateContractEvent; ZRX_TOKEN_CONTRACT: { - call: () => Promise; + callAsync: () => Promise; }; getUnavailableTakerTokenAmount: { - call: (orderHash: string) => Promise; + callAsync: (orderHash: string) => Promise; }; isRoundingError: { - call: (fillTakerAmount: BigNumber.BigNumber, takerTokenAmount: BigNumber.BigNumber, - makerTokenAmount: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; + callAsync: (fillTakerAmount: BigNumber.BigNumber, takerTokenAmount: BigNumber.BigNumber, + makerTokenAmount: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; }; fillOrder: { - (orderAddresses: OrderAddresses, orderValues: OrderValues, fillTakerTokenAmount: BigNumber.BigNumber, - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number, r: string, s: string, txOpts?: TxOpts): Promise; - estimateGas: (orderAddresses: OrderAddresses, orderValues: OrderValues, - fillTakerTokenAmount: BigNumber.BigNumber, - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number, r: string, s: string, txOpts?: TxOpts) => Promise; + sendTransactionAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, + fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number, r: string, s: string, txOpts?: TxOpts) => Promise; + estimateGasAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, + fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number, r: string, s: string, txOpts?: TxOpts) => Promise; }; batchFillOrders: { - (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmounts: BigNumber.BigNumber[], - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number[], r: string[], s: string[], txOpts?: TxOpts): Promise; - estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], - fillTakerTokenAmounts: BigNumber.BigNumber[], - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; + sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmounts: BigNumber.BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; + estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmounts: BigNumber.BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; }; fillOrdersUpTo: { - (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmount: BigNumber.BigNumber, - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number[], r: string[], s: string[], txOpts?: TxOpts): Promise; - estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], - fillTakerTokenAmount: BigNumber.BigNumber, - shouldThrowOnInsufficientBalanceOrAllowance: boolean, - v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; + sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; + estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmount: BigNumber.BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; }; cancelOrder: { - (orderAddresses: OrderAddresses, orderValues: OrderValues, cancelTakerTokenAmount: BigNumber.BigNumber, - txOpts?: TxOpts): Promise; - estimateGas: (orderAddresses: OrderAddresses, orderValues: OrderValues, - cancelTakerTokenAmount: BigNumber.BigNumber, - txOpts?: TxOpts) => Promise; + sendTransactionAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, + cancelTakerTokenAmount: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; + estimateGasAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, + cancelTakerTokenAmount: BigNumber.BigNumber, + txOpts?: TxOpts) => Promise; }; batchCancelOrders: { - (orderAddresses: OrderAddresses[], orderValues: OrderValues[], cancelTakerTokenAmounts: BigNumber.BigNumber[], - txOpts?: TxOpts): Promise; - estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], - cancelTakerTokenAmounts: BigNumber.BigNumber[], - txOpts?: TxOpts) => Promise; + sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + cancelTakerTokenAmounts: BigNumber.BigNumber[], txOpts?: TxOpts) => Promise; + estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + cancelTakerTokenAmounts: BigNumber.BigNumber[], + txOpts?: TxOpts) => Promise; }; fillOrKillOrder: { - (orderAddresses: OrderAddresses, orderValues: OrderValues, fillTakerTokenAmount: BigNumber.BigNumber, - v: number, r: string, s: string, txOpts?: TxOpts): Promise; - estimateGas: (orderAddresses: OrderAddresses, orderValues: OrderValues, - fillTakerTokenAmount: BigNumber.BigNumber, - v: number, r: string, s: string, txOpts?: TxOpts) => Promise; + sendTransactionAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, + fillTakerTokenAmount: BigNumber.BigNumber, + v: number, r: string, s: string, txOpts?: TxOpts) => Promise; + estimateGasAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, + fillTakerTokenAmount: BigNumber.BigNumber, + v: number, r: string, s: string, txOpts?: TxOpts) => Promise; }; batchFillOrKillOrders: { - (orderAddresses: OrderAddresses[], orderValues: OrderValues[], fillTakerTokenAmounts: BigNumber.BigNumber[], - v: number[], r: string[], s: string[], txOpts: TxOpts): Promise; - estimateGas: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], - fillTakerTokenAmounts: BigNumber.BigNumber[], - v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; + sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmounts: BigNumber.BigNumber[], + v: number[], r: string[], s: string[], txOpts: TxOpts) => Promise; + estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], + fillTakerTokenAmounts: BigNumber.BigNumber[], + v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise; }; filled: { - call: (orderHash: string) => Promise; + callAsync: (orderHash: string) => Promise; }; cancelled: { - call: (orderHash: string) => Promise; + callAsync: (orderHash: string) => Promise; }; getOrderHash: { - call: (orderAddresses: OrderAddresses, orderValues: OrderValues) => Promise; + callAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues) => Promise; }; } @@ -128,49 +133,61 @@ export interface TokenContract extends Web3.ContractInstance { Transfer: CreateContractEvent; Approval: CreateContractEvent; balanceOf: { - call: (address: string) => Promise; + callAsync: (address: string) => Promise; }; allowance: { - call: (ownerAddress: string, allowedAddress: string) => Promise; + callAsync: (ownerAddress: string, allowedAddress: string) => Promise; + }; + transfer: { + sendTransactionAsync: (toAddress: string, amountInBaseUnits: BigNumber.BigNumber, + txOpts?: TxOpts) => Promise; + }; + transferFrom: { + sendTransactionAsync: (fromAddress: string, toAddress: string, amountInBaseUnits: BigNumber.BigNumber, + txOpts?: TxOpts) => Promise; + }; + approve: { + sendTransactionAsync: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, + txOpts?: TxOpts) => Promise; }; - transfer: (toAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; - transferFrom: (fromAddress: string, toAddress: string, amountInBaseUnits: BigNumber.BigNumber, - txOpts?: TxOpts) => Promise; - approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts?: TxOpts) => Promise; } export interface TokenRegistryContract extends Web3.ContractInstance { getTokenMetaData: { - call: (address: string) => Promise; + callAsync: (address: string) => Promise; }; getTokenAddresses: { - call: () => Promise; + callAsync: () => Promise; }; getTokenAddressBySymbol: { - call: (symbol: string) => Promise; + callAsync: (symbol: string) => Promise; }; getTokenAddressByName: { - call: (name: string) => Promise; + callAsync: (name: string) => Promise; }; getTokenBySymbol: { - call: (symbol: string) => Promise; + callAsync: (symbol: string) => Promise; }; getTokenByName: { - call: (name: string) => Promise; + callAsync: (name: string) => Promise; }; } export interface EtherTokenContract extends Web3.ContractInstance { - deposit: (txOpts: TxOpts) => Promise; - withdraw: (amount: BigNumber.BigNumber, txOpts: TxOpts) => Promise; + deposit: { + sendTransactionAsync: (txOpts: TxOpts) => Promise; + }; + withdraw: { + sendTransactionAsync: (amount: BigNumber.BigNumber, txOpts: TxOpts) => Promise; + }; } export interface TokenTransferProxyContract extends Web3.ContractInstance { getAuthorizedAddresses: { - call: () => Promise; + callAsync: () => Promise; }; authorized: { - call: (address: string) => Promise; + callAsync: (address: string) => Promise; }; } -- cgit From 78c46d7cc98fdd1e383a22adcd66a916301e2242 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 13:45:32 +0200 Subject: Change the order of default overriding --- src/contract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contract.ts b/src/contract.ts index 9dfb04446..26da67b62 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -51,8 +51,8 @@ export class Contract implements Web3.ContractInstance { txData = args.pop(); } txData = { - ...txData, ...this.defaults, + ...txData, }; const callback = (err: Error, data: any) => { if (_.isNull(err)) { -- cgit From 92b101fac8c602e095b864fb72a241ec8c101f2b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 13:46:13 +0200 Subject: Remove unused code --- src/contract_wrappers/exchange_wrapper.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index fbb2c710f..d4daa34a2 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -42,14 +42,6 @@ import * as ExchangeArtifacts from '../artifacts/Exchange.json'; * events of the 0x Exchange smart contract. */ export class ExchangeWrapper extends ContractWrapper { - private _exchangeContractErrCodesToMsg = { - [ExchangeContractErrCodes.ERROR_FILL_EXPIRED]: ExchangeContractErrs.OrderFillExpired, - [ExchangeContractErrCodes.ERROR_CANCEL_EXPIRED]: ExchangeContractErrs.OrderFillExpired, - [ExchangeContractErrCodes.ERROR_FILL_NO_VALUE]: ExchangeContractErrs.OrderRemainingFillAmountZero, - [ExchangeContractErrCodes.ERROR_CANCEL_NO_VALUE]: ExchangeContractErrs.OrderRemainingFillAmountZero, - [ExchangeContractErrCodes.ERROR_FILL_TRUNCATION]: ExchangeContractErrs.OrderFillRoundingError, - [ExchangeContractErrCodes.ERROR_FILL_BALANCE_ALLOWANCE]: ExchangeContractErrs.FillBalanceAllowanceError, - }; private _exchangeContractIfExists?: ExchangeContract; private _exchangeLogEventEmitters: ContractEventEmitter[]; private _orderValidationUtils: OrderValidationUtils; @@ -709,14 +701,6 @@ export class ExchangeWrapper extends ContractWrapper { const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues); return orderHashHex; } - private _throwErrorLogsAsErrors(logs: ContractEvent[]): void { - const errEvent = _.find(logs, {event: 'LogError'}); - if (!_.isUndefined(errEvent)) { - const errCode = (errEvent.args as LogErrorContractEventArgs).errorId.toNumber(); - const errMessage = this._exchangeContractErrCodesToMsg[errCode]; - throw new Error(errMessage); - } - } private async _getExchangeContractAsync(): Promise { if (!_.isUndefined(this._exchangeContractIfExists)) { return this._exchangeContractIfExists; -- cgit From bc5fd316dfb7876f5e8913f7cb196b9a9e0e5ffc Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 13:47:17 +0200 Subject: Cast to Artifat type --- src/contract_wrappers/exchange_wrapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index d4daa34a2..2ce9b2922 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -706,7 +706,7 @@ export class ExchangeWrapper extends ContractWrapper { return this._exchangeContractIfExists; } const contractInstance = await this._instantiateContractIfExistsAsync( - (ExchangeArtifacts as any), + (ExchangeArtifacts as any as Artifact), ); this._exchangeContractIfExists = contractInstance as ExchangeContract; return this._exchangeContractIfExists; -- cgit From ec22097efb61d27aa73c979758bc0231cea7d61d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 13:49:47 +0200 Subject: Don't override function arguments --- src/web3_wrapper.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts index a0923bef9..7b9a28a7d 100644 --- a/src/web3_wrapper.ts +++ b/src/web3_wrapper.ts @@ -51,6 +51,7 @@ export class Web3Wrapper { } public async getContractInstanceFromArtifactAsync(artifact: Artifact, address?: string): Promise { + let contractAddress: string; if (_.isUndefined(address)) { const networkIdIfExists = await this.getNetworkIdIfExistsAsync(); if (_.isUndefined(networkIdIfExists)) { @@ -59,14 +60,16 @@ export class Web3Wrapper { if (_.isUndefined(artifact.networks[networkIdIfExists])) { throw new Error(ZeroExError.ContractNotDeployedOnNetwork); } - address = artifact.networks[networkIdIfExists].address.toLowerCase(); + contractAddress = artifact.networks[networkIdIfExists].address.toLowerCase(); + } else { + contractAddress = address; } - const doesContractExist = await this.doesContractExistAtAddressAsync(address); + const doesContractExist = await this.doesContractExistAtAddressAsync(contractAddress); if (!doesContractExist) { throw new Error(ZeroExError.ContractDoesNotExist); } const contractInstance = this.getContractInstance( - artifact.abi, address, + artifact.abi, contractAddress, ); return contractInstance; } -- cgit From ee00769be171531db725288f8d485964941af529 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 15:29:29 +0200 Subject: Use schema validation to distinguish txData argument --- package.json | 2 +- src/contract.ts | 9 ++++++++- yarn.lock | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2f4bf41ee..50f54e1c4 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "webpack": "^3.1.0" }, "dependencies": { - "0x-json-schemas": "^0.4.0", + "0x-json-schemas": "^0.5.0", "bignumber.js": "^4.0.2", "compare-versions": "^3.0.1", "es6-promisify": "^5.0.0", diff --git a/src/contract.ts b/src/contract.ts index 26da67b62..bd5afc16c 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -1,12 +1,14 @@ import * as Web3 from 'web3'; import * as _ from 'lodash'; import promisify = require('es6-promisify'); +import {SchemaValidator, schemas} from '0x-json-schemas'; export class Contract implements Web3.ContractInstance { public address: string; public abi: Web3.ContractAbi; private contract: Web3.ContractInstance; private defaults: Partial; + private validator: SchemaValidator; // This class instance is going to be populated with functions and events depending on the ABI // and we don't know their types in advance [name: string]: any; @@ -17,6 +19,7 @@ export class Contract implements Web3.ContractInstance { this.defaults = defaults; this.populateEvents(); this.populateFunctions(); + this.validator = new SchemaValidator(); } private populateFunctions(): void { const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === 'function'); @@ -47,7 +50,7 @@ export class Contract implements Web3.ContractInstance { const promise = new Promise((resolve, reject) => { const lastArg = args[args.length - 1]; let txData: Partial = {}; - if (_.isObject(lastArg) && !_.isArray(lastArg) && !lastArg.isBigNumber) { + if (this.isTxData(lastArg)) { txData = args.pop(); } txData = { @@ -69,4 +72,8 @@ export class Contract implements Web3.ContractInstance { }; return promisifiedWithDefaultParams; } + private isTxData(lastArg: any): boolean { + const isValid = this.validator.isValid(lastArg, schemas.txDataSchema); + return isValid; + } } diff --git a/yarn.lock b/yarn.lock index 30487b0af..949f0b5a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"0x-json-schemas@^0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/0x-json-schemas/-/0x-json-schemas-0.4.0.tgz#93cfa771c6418b3ce67f97595beff3e4b67bc28b" +"0x-json-schemas@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/0x-json-schemas/-/0x-json-schemas-0.5.0.tgz#36b1315480deb01dc0363ada949640e26f24a1d2" dependencies: jsonschema "^1.2.0" -- cgit From dff63f9b89a468ab09ac1be3c0c5e8ca157f8069 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 15:34:52 +0200 Subject: Use AbiType --- package.json | 2 +- src/contract.ts | 4 ++-- yarn.lock | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 50f54e1c4..c58c59834 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "types-ethereumjs-util": "^0.0.5", "typescript": "^2.4.1", "web3-provider-engine": "^13.0.1", - "web3-typescript-typings": "^0.4.1", + "web3-typescript-typings": "^0.5.0", "webpack": "^3.1.0" }, "dependencies": { diff --git a/src/contract.ts b/src/contract.ts index bd5afc16c..b9ab496b2 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -22,7 +22,7 @@ export class Contract implements Web3.ContractInstance { this.validator = new SchemaValidator(); } private populateFunctions(): void { - const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === 'function'); + const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === Web3.AbiType.Function); _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { if (functionAbi.constant) { const cbStyleCallFunction = this.contract[functionAbi.name].call; @@ -40,7 +40,7 @@ export class Contract implements Web3.ContractInstance { }); } private populateEvents(): void { - const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === 'event'); + const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === Web3.AbiType.Event); _.forEach(eventsAbi, (eventAbi: Web3.EventAbi) => { this[eventAbi.name] = this.contract[eventAbi.name]; }); diff --git a/yarn.lock b/yarn.lock index 949f0b5a0..49dca778f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5005,9 +5005,9 @@ web3-provider-engine@^8.4.0: xhr "^2.2.0" xtend "^4.0.1" -web3-typescript-typings@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.4.1.tgz#077f5c042c1d2625b4cabedad88b9e9427b38fb3" +web3-typescript-typings@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.5.0.tgz#a598ad5d4600c53d8e865c52e52b62f2ad04ec84" dependencies: bignumber.js "^4.0.2" -- cgit From b0547819fd97c9bace5e4eca3fe8666ec5e40f81 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 15:44:42 +0200 Subject: Define AbiType --- src/contract.ts | 5 +++-- src/types.ts | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/contract.ts b/src/contract.ts index b9ab496b2..1aacc65dc 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -2,6 +2,7 @@ import * as Web3 from 'web3'; import * as _ from 'lodash'; import promisify = require('es6-promisify'); import {SchemaValidator, schemas} from '0x-json-schemas'; +import {AbiType} from './types'; export class Contract implements Web3.ContractInstance { public address: string; @@ -22,7 +23,7 @@ export class Contract implements Web3.ContractInstance { this.validator = new SchemaValidator(); } private populateFunctions(): void { - const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === Web3.AbiType.Function); + const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function); _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { if (functionAbi.constant) { const cbStyleCallFunction = this.contract[functionAbi.name].call; @@ -40,7 +41,7 @@ export class Contract implements Web3.ContractInstance { }); } private populateEvents(): void { - const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === Web3.AbiType.Event); + const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event); _.forEach(eventsAbi, (eventAbi: Web3.EventAbi) => { this[eventAbi.name] = this.contract[eventAbi.name]; }); diff --git a/src/types.ts b/src/types.ts index e47f57e5e..ddf449c16 100644 --- a/src/types.ts +++ b/src/types.ts @@ -390,3 +390,10 @@ export interface ZeroExConfig { } export type TransactionReceipt = Web3.TransactionReceipt; + +export enum AbiType { + Function = 'function', + Constructor = 'constructor', + Event = 'event', + Fallback = 'fallback', +} -- cgit From f0572679557ebdc6956d079ea2b1f54fd52c2c67 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 16:45:40 +0200 Subject: Update json-schemas --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index c58c59834..7735acf76 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "webpack": "^3.1.0" }, "dependencies": { - "0x-json-schemas": "^0.5.0", + "0x-json-schemas": "^0.5.1", "bignumber.js": "^4.0.2", "compare-versions": "^3.0.1", "es6-promisify": "^5.0.0", diff --git a/yarn.lock b/yarn.lock index 49dca778f..dcbad943f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"0x-json-schemas@^0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/0x-json-schemas/-/0x-json-schemas-0.5.0.tgz#36b1315480deb01dc0363ada949640e26f24a1d2" +"0x-json-schemas@^0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/0x-json-schemas/-/0x-json-schemas-0.5.1.tgz#fce6c2962e44930884a838e01f5b605ddd217686" dependencies: jsonschema "^1.2.0" -- cgit From a7b2131db77b72379f0d57eaff694d5a925191cd Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 18:45:20 +0200 Subject: Decode logs args in awaitTransactionMinedAsync --- package.json | 1 + src/0x.ts | 43 ++++++++- src/contract_wrappers/ether_token_wrapper.ts | 4 +- src/contract_wrappers/exchange_wrapper.ts | 4 +- src/contract_wrappers/token_registry_wrapper.ts | 4 +- .../token_transfer_proxy_wrapper.ts | 4 +- src/contract_wrappers/token_wrapper.ts | 7 +- src/globals.d.ts | 15 +++ src/types.ts | 13 +++ test/exchange_wrapper_test.ts | 6 +- yarn.lock | 102 +++++++++++++++++++-- 11 files changed, 179 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 7735acf76..6983cf3d9 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ }, "dependencies": { "0x-json-schemas": "^0.5.1", + "abi-decoder": "^1.0.8", "bignumber.js": "^4.0.2", "compare-versions": "^3.0.1", "es6-promisify": "^5.0.0", diff --git a/src/0x.ts b/src/0x.ts index 209b2704d..d88683c3d 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -1,6 +1,7 @@ import * as _ from 'lodash'; import * as BigNumber from 'bignumber.js'; import * as Web3 from 'web3'; +import * as abiDecoder from 'abi-decoder'; import {SchemaValidator, schemas} from '0x-json-schemas'; import {bigNumberConfigs} from './bignumber_config'; import * as ethUtil from 'ethereumjs-util'; @@ -11,12 +12,24 @@ import {constants} from './utils/constants'; import {utils} from './utils/utils'; import {signatureUtils} from './utils/signature_utils'; import {assert} from './utils/assert'; +import {artifacts} from './artifacts'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper'; import {EtherTokenWrapper} from './contract_wrappers/ether_token_wrapper'; import {TokenWrapper} from './contract_wrappers/token_wrapper'; import {TokenTransferProxyWrapper} from './contract_wrappers/token_transfer_proxy_wrapper'; -import {ECSignature, ZeroExError, Order, SignedOrder, Web3Provider, ZeroExConfig, TransactionReceipt} from './types'; +import { + ECSignature, + ZeroExError, + Order, + SignedOrder, + Web3Provider, + ZeroExConfig, + TransactionReceipt, + DecodedLogArgs, + TransactionReceiptWithDecodedLogs, + LogWithDecodedArgs, +} from './types'; // Customize our BigNumber instances bigNumberConfigs.configure(); @@ -170,6 +183,7 @@ export class ZeroEx { // We re-assign the send method so that Web3@1.0 providers work with 0x.js (provider as any).sendAsync = (provider as any).send; } + this._registerArtifactsWithinABIDecoder(); const gasPrice = _.isUndefined(config) ? undefined : config.gasPrice; const defaults = { gasPrice, @@ -264,11 +278,34 @@ export class ZeroEx { const intervalId = setInterval(async () => { const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash); if (!_.isNull(transactionReceipt)) { - clearInterval(intervalId); - resolve(transactionReceipt); + clearInterval(intervalId); + const logsWithDecodedArgs = _.map(transactionReceipt.logs, (log: Web3.LogEntry) => { + const decodedLog = abiDecoder.decodeLogs([log])[0]; + const decodedArgs = decodedLog.events; + const args: DecodedLogArgs = {}; + _.forEach(decodedArgs, arg => { + args[arg.name] = arg.value; + }); + const logWithDecodedArgs: LogWithDecodedArgs = { + ...log, + args, + event: decodedLog.name, + }; + return logWithDecodedArgs; + }); + const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = { + ...transactionReceipt, + logs: logsWithDecodedArgs, + }; + resolve(transactionReceiptWithDecodedLogArgs); } }, pollingIntervalMs); }); return txReceiptPromise; } + private _registerArtifactsWithinABIDecoder(): void { + for (const artifact of _.values(artifacts)) { + abiDecoder.addABI(artifact.abi); + } + } } diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts index d31069b22..b86309f90 100644 --- a/src/contract_wrappers/ether_token_wrapper.ts +++ b/src/contract_wrappers/ether_token_wrapper.ts @@ -4,7 +4,7 @@ import {ContractWrapper} from './contract_wrapper'; import {TokenWrapper} from './token_wrapper'; import {EtherTokenContract, ZeroExError} from '../types'; import {assert} from '../utils/assert'; -import * as EtherTokenArtifacts from '../artifacts/EtherToken.json'; +import {artifacts} from '../artifacts'; /** * This class includes all the functionality related to interacting with a wrapped Ether ERC20 token contract. @@ -76,7 +76,7 @@ export class EtherTokenWrapper extends ContractWrapper { return this._etherTokenContractIfExists; } const contractInstance = await this._instantiateContractIfExistsAsync( - EtherTokenArtifacts as any as Artifact, + artifacts.EtherTokenArtifact, ); this._etherTokenContractIfExists = contractInstance as EtherTokenContract; return this._etherTokenContractIfExists; diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 2ce9b2922..115bd1110 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -35,7 +35,7 @@ import {ContractWrapper} from './contract_wrapper'; import {constants} from '../utils/constants'; import {TokenWrapper} from './token_wrapper'; import {decorators} from '../utils/decorators'; -import * as ExchangeArtifacts from '../artifacts/Exchange.json'; +import {artifacts} from '../artifacts'; /** * This class includes all the functionality related to calling methods and subscribing to @@ -706,7 +706,7 @@ export class ExchangeWrapper extends ContractWrapper { return this._exchangeContractIfExists; } const contractInstance = await this._instantiateContractIfExistsAsync( - (ExchangeArtifacts as any as Artifact), + artifacts.ExchangeArtifact, ); this._exchangeContractIfExists = contractInstance as ExchangeContract; return this._exchangeContractIfExists; diff --git a/src/contract_wrappers/token_registry_wrapper.ts b/src/contract_wrappers/token_registry_wrapper.ts index 79eb516fe..528a88e06 100644 --- a/src/contract_wrappers/token_registry_wrapper.ts +++ b/src/contract_wrappers/token_registry_wrapper.ts @@ -4,7 +4,7 @@ import {assert} from '../utils/assert'; import {Token, TokenRegistryContract, TokenMetadata} from '../types'; import {constants} from '../utils/constants'; import {ContractWrapper} from './contract_wrapper'; -import * as TokenRegistryArtifacts from '../artifacts/TokenRegistry.json'; +import {artifacts} from '../artifacts'; /** * This class includes all the functionality related to interacting with the 0x Token Registry smart contract. @@ -102,7 +102,7 @@ export class TokenRegistryWrapper extends ContractWrapper { return this._tokenRegistryContractIfExists; } const contractInstance = await this._instantiateContractIfExistsAsync( - TokenRegistryArtifacts as any as Artifact, + artifacts.TokenRegistryArtifact, ); this._tokenRegistryContractIfExists = contractInstance as TokenRegistryContract; return this._tokenRegistryContractIfExists; diff --git a/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/src/contract_wrappers/token_transfer_proxy_wrapper.ts index 2ed198be6..528d661d1 100644 --- a/src/contract_wrappers/token_transfer_proxy_wrapper.ts +++ b/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; import {ContractWrapper} from './contract_wrapper'; -import * as TokenTransferProxyArtifacts from '../artifacts/TokenTransferProxy.json'; +import {artifacts} from '../artifacts'; import {TokenTransferProxyContract} from '../types'; /** @@ -45,7 +45,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper { return this._tokenTransferProxyContractIfExists; } const contractInstance = await this._instantiateContractIfExistsAsync( - TokenTransferProxyArtifacts as any as Artifact, + artifacts.TokenTransferProxyArtifact, ); this._tokenTransferProxyContractIfExists = contractInstance as TokenTransferProxyContract; return this._tokenTransferProxyContractIfExists; diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index db1ce22b2..f1f967286 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -7,8 +7,7 @@ import {utils} from '../utils/utils'; import {eventUtils} from '../utils/event_utils'; import {constants} from '../utils/constants'; import {ContractWrapper} from './contract_wrapper'; -import * as TokenArtifacts from '../artifacts/Token.json'; -import * as TokenTransferProxyArtifacts from '../artifacts/TokenTransferProxy.json'; +import {artifacts} from '../artifacts'; import { TokenContract, ZeroExError, @@ -286,7 +285,7 @@ export class TokenWrapper extends ContractWrapper { return tokenContract; } const contractInstance = await this._instantiateContractIfExistsAsync( - TokenArtifacts as any as Artifact, tokenAddress, + artifacts.TokenArtifact, tokenAddress, ); tokenContract = contractInstance as TokenContract; this._tokenContractsByAddress[tokenAddress] = tokenContract; @@ -296,7 +295,7 @@ export class TokenWrapper extends ContractWrapper { const networkIdIfExists = await this._web3Wrapper.getNetworkIdIfExistsAsync(); const proxyNetworkConfigsIfExists = _.isUndefined(networkIdIfExists) ? undefined : - (TokenTransferProxyArtifacts as any).networks[networkIdIfExists]; + artifacts.TokenTransferProxyArtifact.networks[networkIdIfExists]; if (_.isUndefined(proxyNetworkConfigsIfExists)) { throw new Error(ZeroExError.ContractNotDeployedOnNetwork); } diff --git a/src/globals.d.ts b/src/globals.d.ts index 6f5f13b4e..39d0860eb 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -69,3 +69,18 @@ declare class HDWalletProvider { declare module 'truffle-hdwallet-provider' { export = HDWalletProvider; } + +// abi-decoder declarations +interface DecodedLogArg { + name: string; + value: string|BigNumber.BigNumber; +} +interface DecodedLog { + name: string; + events: DecodedLogArg[]; +} +declare module 'abi-decoder' { + import * as Web3 from 'web3'; + const addABI: (abi: Web3.AbiDefinition) => void; + const decodeLogs: (logs: Web3.LogEntry[]) => DecodedLog[]; +} diff --git a/src/types.ts b/src/types.ts index ddf449c16..9d3f77127 100644 --- a/src/types.ts +++ b/src/types.ts @@ -397,3 +397,16 @@ export enum AbiType { Event = 'event', Fallback = 'fallback', } + +export interface DecodedLogArgs { + [argName: string]: ContractEventArg; +} + +export interface LogWithDecodedArgs extends Web3.LogEntry { + args: DecodedLogArgs; + event: string; +} + +export interface TransactionReceiptWithDecodedLogs extends Web3.TransactionReceipt { + logs: LogWithDecodedArgs[]; +} diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 990a4dca6..f72e7f64f 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -169,8 +169,9 @@ describe('ExchangeWrapper', () => { .to.be.bignumber.equal(0); expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)) .to.be.bignumber.equal(fillableAmount); - await zeroEx.exchange.fillOrderAsync( + const txHash = await zeroEx.exchange.fillOrderAsync( signedOrder, fillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); + await zeroEx.awaitTransactionMinedAsync(txHash); expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)) .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount)); expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)) @@ -185,8 +186,9 @@ describe('ExchangeWrapper', () => { makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, ); const partialFillAmount = new BigNumber(3); - await zeroEx.exchange.fillOrderAsync( + const txHash = await zeroEx.exchange.fillOrderAsync( signedOrder, partialFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress); + await zeroEx.awaitTransactionMinedAsync(txHash); expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)) .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount)); expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)) diff --git a/yarn.lock b/yarn.lock index dcbad943f..d558a8243 100644 --- a/yarn.lock +++ b/yarn.lock @@ -66,6 +66,20 @@ abbrev@1: version "1.1.0" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" +abi-decoder@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/abi-decoder/-/abi-decoder-1.0.8.tgz#7794d864c4b3fd8bab600bdd445ceb01d333ea43" + dependencies: + babel-core "^6.23.1" + babel-loader "^6.3.2" + babel-plugin-add-module-exports "^0.2.1" + babel-plugin-transform-es2015-modules-amd "^6.22.0" + babel-preset-es2015 "^6.22.0" + chai "^3.5.0" + mocha "^3.2.0" + web3 "^0.18.4" + webpack "^2.2.1" + abstract-leveldown@2.4.1, abstract-leveldown@~2.4.0: version "2.4.1" resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.4.1.tgz#b3bfedb884eb693a12775f0c55e9f0a420ccee64" @@ -90,11 +104,15 @@ aes-js@^0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-0.2.4.tgz#94b881ab717286d015fa219e08fb66709dda5a3d" +ajv-keywords@^1.1.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" + ajv-keywords@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" -ajv@^4.9.1: +ajv@^4.7.0, ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: @@ -313,7 +331,7 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.0.14, babel-core@^6.24.1: +babel-core@^6.0.14, babel-core@^6.23.1, babel-core@^6.24.1: version "6.25.0" resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" dependencies: @@ -425,12 +443,25 @@ babel-helpers@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" +babel-loader@^6.3.2: + version "6.4.1" + resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-6.4.1.tgz#0b34112d5b0748a8dcdbf51acf6f9bd42d50b8ca" + dependencies: + find-cache-dir "^0.1.1" + loader-utils "^0.2.16" + mkdirp "^0.5.1" + object-assign "^4.0.1" + babel-messages@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" dependencies: babel-runtime "^6.22.0" +babel-plugin-add-module-exports@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.2.1.tgz#9ae9a1f4a8dc67f0cdec4f4aeda1e43a5ff65e25" + babel-plugin-check-es2015-constants@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" @@ -513,7 +544,7 @@ babel-plugin-transform-es2015-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-modules-amd@^6.24.1: +babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" dependencies: @@ -618,7 +649,7 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-preset-es2015@^6.24.0: +babel-preset-es2015@^6.22.0, babel-preset-es2015@^6.24.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" dependencies: @@ -1035,6 +1066,14 @@ chai-typescript-typings@^0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/chai-typescript-typings/-/chai-typescript-typings-0.0.0.tgz#52e076d72cf29129c94ab1dba6e33ce3828a0724" +chai@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247" + dependencies: + assertion-error "^1.0.1" + deep-eql "^0.1.3" + type-detect "^1.0.0" + chai@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/chai/-/chai-4.0.2.tgz#2f7327c4de6f385dd7787999e2ab02697a32b83b" @@ -1341,6 +1380,12 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" +deep-eql@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2" + dependencies: + type-detect "0.1.1" + deep-eql@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-2.0.2.tgz#b1bac06e56f0a76777686d50c9feb75c2ed7679a" @@ -2865,6 +2910,15 @@ loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" +loader-utils@^0.2.16: + version "0.2.17" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" + dependencies: + big.js "^3.1.3" + emojis-list "^2.0.0" + json5 "^0.5.0" + object-assign "^4.0.1" + loader-utils@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd" @@ -3179,7 +3233,7 @@ mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0: dependencies: minimist "0.0.8" -mocha@^3.4.1: +mocha@^3.2.0, mocha@^3.4.1: version "3.4.2" resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.4.2.tgz#d0ef4d332126dbf18d0d640c9b382dd48be97594" dependencies: @@ -4789,6 +4843,14 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" +type-detect@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" + +type-detect@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" + type-detect@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-3.0.0.tgz#46d0cc8553abb7b13a352b0d6dea2fd58f2d9b55" @@ -4841,7 +4903,7 @@ typescript@2.4.1, typescript@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.1.tgz#c3ccb16ddaa0b2314de031e7e6fee89e5ba346bc" -uglify-js@^2.6, uglify-js@^2.8.29: +uglify-js@^2.6, uglify-js@^2.8.27, uglify-js@^2.8.29: version "2.8.29" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" dependencies: @@ -5020,7 +5082,7 @@ web3@^0.16.0: utf8 "^2.1.1" xmlhttprequest "*" -web3@^0.18.2: +web3@^0.18.2, web3@^0.18.4: version "0.18.4" resolved "https://registry.yarnpkg.com/web3/-/web3-0.18.4.tgz#81ec1784145491f2eaa8955b31c06049e07c5e7d" dependencies: @@ -5047,6 +5109,32 @@ webpack-sources@^1.0.1: source-list-map "^2.0.0" source-map "~0.5.3" +webpack@^2.2.1: + version "2.7.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-2.7.0.tgz#b2a1226804373ffd3d03ea9c6bd525067034f6b1" + dependencies: + acorn "^5.0.0" + acorn-dynamic-import "^2.0.0" + ajv "^4.7.0" + ajv-keywords "^1.1.1" + async "^2.1.2" + enhanced-resolve "^3.3.0" + interpret "^1.0.0" + json-loader "^0.5.4" + json5 "^0.5.1" + loader-runner "^2.3.0" + loader-utils "^0.2.16" + memory-fs "~0.4.1" + mkdirp "~0.5.0" + node-libs-browser "^2.0.0" + source-map "^0.5.3" + supports-color "^3.1.0" + tapable "~0.2.5" + uglify-js "^2.8.27" + watchpack "^1.3.1" + webpack-sources "^1.0.1" + yargs "^6.0.0" + webpack@^3.0.0, webpack@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.1.0.tgz#ac0675e500db835f9ab2369d29ba096f51ad0731" -- cgit From 2f97ddb7279a95ffb93ae6bbdfa77618a7f41fe1 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 18:50:22 +0200 Subject: Fix the return types and export the required public types --- src/0x.ts | 9 +++++---- src/index.ts | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/0x.ts b/src/0x.ts index d88683c3d..0af164b1e 100644 --- a/src/0x.ts +++ b/src/0x.ts @@ -270,11 +270,12 @@ export class ZeroEx { * Waits for a transaction to be mined and returns the transaction receipt. * @param txHash Transaction hash * @param pollingIntervalMs How often (in ms) should we check if the transaction is mined. - * @return TransactionReceipt + * @return Transaction receipt with decoded log args. */ - public async awaitTransactionMinedAsync(txHash: string, - pollingIntervalMs: number = 1000): Promise { - const txReceiptPromise = new Promise((resolve: (receipt: TransactionReceipt) => void, reject) => { + public async awaitTransactionMinedAsync( + txHash: string, pollingIntervalMs: number = 1000): Promise { + const txReceiptPromise = new Promise( + (resolve: (receipt: TransactionReceiptWithDecodedLogs) => void, reject) => { const intervalId = setInterval(async () => { const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash); if (!_.isNull(transactionReceipt)) { diff --git a/src/index.ts b/src/index.ts index 44bd53547..00d4730da 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,5 +30,7 @@ export { ContractEventArgs, Web3Provider, ZeroExConfig, - TransactionReceipt, + TransactionReceiptWithDecodedLogs, + LogWithDecodedArgs, + DecodedLogArgs, } from './types'; -- cgit From 2fd5f2781b0d0966e04d4aef2f37851b922815ee Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 18:59:18 +0200 Subject: Add forgotten artifacts file --- src/artifacts.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/artifacts.ts diff --git a/src/artifacts.ts b/src/artifacts.ts new file mode 100644 index 000000000..0c4627337 --- /dev/null +++ b/src/artifacts.ts @@ -0,0 +1,13 @@ +import * as TokenArtifact from './artifacts/Token.json'; +import * as ExchangeArtifact from './artifacts/Exchange.json'; +import * as EtherTokenArtifact from './artifacts/EtherToken.json'; +import * as TokenRegistryArtifact from './artifacts/TokenRegistry.json'; +import * as TokenTransferProxyArtifact from './artifacts/TokenTransferProxy.json'; + +export const artifacts = { + TokenArtifact: TokenArtifact as any as Artifact, + ExchangeArtifact: ExchangeArtifact as any as Artifact, + EtherTokenArtifact: EtherTokenArtifact as any as Artifact, + TokenRegistryArtifact: TokenRegistryArtifact as any as Artifact, + TokenTransferProxyArtifact: TokenTransferProxyArtifact as any as Artifact, +}; -- cgit From e6e12e946e8ac4a56194e14744f3e107ae620d1b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 18:59:46 +0200 Subject: Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 934fc24d7..dc2f4a040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ v0.13.0 - _TBD, 2017_ * Made all the functions submitting transactions to the network to immediately return transaction hash (#151) * Added `zeroEx.awaitTransactionMinedAsync` (#151) + * Added `TransactionReceiptWithDecodedLogs`, `LogWithDecodedArgs`, `DecodedLogArgs` to public types (#151) v0.12.1 - _September 2, 2017_ * Added the support for web3@1.x.x provider (#142) -- cgit From df904f80e323376ff8dd6aabca445fa9f0be9c1b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 6 Sep 2017 00:18:07 +0200 Subject: Add test for logs decoding in awaitTransactionMinedAsync --- test/0x.js_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index 2b4e80ea3..c545b3fbe 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -6,6 +6,7 @@ import * as BigNumber from 'bignumber.js'; import * as Sinon from 'sinon'; import {ZeroEx, Order} from '../src'; import {constants} from './utils/constants'; +import {TokenUtils} from './utils/token_utils'; import {web3Factory} from './utils/web3_factory'; chaiSetup.configure(); @@ -204,4 +205,23 @@ describe('ZeroEx library', () => { expect(ecSignature).to.deep.equal(expectedECSignature); }); }); + describe('#awaitTransactionMinedAsync', () => { + it('return transaction receipt with decoded logs', async () => { + const availableAddresses = await zeroEx.getAvailableAddressesAsync(); + const coinbase = availableAddresses[0]; + const tokens = await zeroEx.tokenRegistry.getTokensAsync(); + const tokenUtils = new TokenUtils(tokens); + const zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address; + const proxyAddress = await zeroEx.proxy.getContractAddressAsync(); + const txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(zrxTokenAddress, coinbase); + const txReceiptWithDecodedLogs = await zeroEx.awaitTransactionMinedAsync(txHash); + const log = txReceiptWithDecodedLogs.logs[0]; + expect(log.event).to.be.equal('Approval'); + expect(log.args).to.be.deep.equal({ + _owner: coinbase, + _spender: proxyAddress, + _value: zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS.toString(), + }); + }); + }); }); -- cgit From 8ebc724379ad9047ad3f546985ed5a4c013ac7dd Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 6 Sep 2017 00:40:22 +0200 Subject: Add lifecycle methods --- test/0x.js_test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index c545b3fbe..d9c08d2c5 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -8,7 +8,9 @@ import {ZeroEx, Order} from '../src'; import {constants} from './utils/constants'; import {TokenUtils} from './utils/token_utils'; import {web3Factory} from './utils/web3_factory'; +import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; +const blockchainLifecycle = new BlockchainLifecycle(); chaiSetup.configure(); const expect = chai.expect; @@ -206,6 +208,12 @@ describe('ZeroEx library', () => { }); }); describe('#awaitTransactionMinedAsync', () => { + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); it('return transaction receipt with decoded logs', async () => { const availableAddresses = await zeroEx.getAvailableAddressesAsync(); const coinbase = availableAddresses[0]; -- cgit From 258b4fac31aee1bc0c26e42d62b10bd22c69c1b8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 6 Sep 2017 10:26:22 +0200 Subject: Fix a typo in test name --- test/0x.js_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index d9c08d2c5..c453b8dab 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -214,7 +214,7 @@ describe('ZeroEx library', () => { afterEach(async () => { await blockchainLifecycle.revertAsync(); }); - it('return transaction receipt with decoded logs', async () => { + it('returns transaction receipt with decoded logs', async () => { const availableAddresses = await zeroEx.getAvailableAddressesAsync(); const coinbase = availableAddresses[0]; const tokens = await zeroEx.tokenRegistry.getTokensAsync(); -- cgit