diff options
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/package.json | 5 | ||||
-rw-r--r-- | packages/contracts/test/ether_token.ts | 2 | ||||
-rw-r--r-- | packages/contracts/test/exchange/core.ts | 12 | ||||
-rw-r--r-- | packages/contracts/test/exchange/helpers.ts | 12 | ||||
-rw-r--r-- | packages/contracts/test/exchange/wrapper.ts | 16 | ||||
-rw-r--r-- | packages/contracts/test/multi_sig_with_time_lock.ts | 4 | ||||
-rw-r--r-- | packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts | 6 | ||||
-rw-r--r-- | packages/contracts/test/token_registry.ts | 2 | ||||
-rw-r--r-- | packages/contracts/test/token_transfer_proxy/auth.ts | 2 | ||||
-rw-r--r-- | packages/contracts/test/token_transfer_proxy/transfer_from.ts | 4 | ||||
-rw-r--r-- | packages/contracts/test/tutorials/arbitrage.ts | 38 | ||||
-rw-r--r-- | packages/contracts/test/unlimited_allowance_token.ts | 2 | ||||
-rw-r--r-- | packages/contracts/test/zrx_token.ts | 2 |
13 files changed, 56 insertions, 51 deletions
diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 7efcd58a0..9e082a6de 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -19,7 +19,7 @@ "compile": "node ../sol-compiler/lib/src/cli.js", "clean": "shx rm -rf ./lib", "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", - "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'", + "lint": "tslint --project .", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", @@ -60,6 +60,7 @@ }, "dependencies": { "0x.js": "^0.37.2", + "@0xproject/base-contract": "^0.3.1", "@0xproject/sol-compiler": "^0.4.3", "@0xproject/types": "^0.6.3", "@0xproject/typescript-typings": "^0.3.1", @@ -68,7 +69,7 @@ "bn.js": "^4.11.8", "ethereumjs-abi": "^0.6.4", "ethereumjs-util": "^5.1.1", - "ethers-contracts": "^2.2.1", + "ethers": "^3.0.15", "lodash": "^4.17.4", "web3": "^0.20.0" } diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts index a3ede5df0..a25e4ebba 100644 --- a/packages/contracts/test/ether_token.ts +++ b/packages/contracts/test/ether_token.ts @@ -26,7 +26,7 @@ describe('EtherToken', () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); account = accounts[0]; - const etherToken = await WETH9Contract.deploy0xArtifactAsync(artifacts.EtherToken, provider, defaults); + const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, defaults); etherTokenAddress = etherToken.address; zeroEx = new ZeroEx(provider, { gasPrice, diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index a94e6cf51..1a404c410 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -57,7 +57,7 @@ describe('Exchange', () => { maker = accounts[0]; [tokenOwner, taker, feeRecipient] = accounts; [rep, dgd, zrx] = await Promise.all([ - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -66,7 +66,7 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -75,7 +75,7 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -85,12 +85,12 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), ]); - tokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, ); - exchange = await ExchangeContract.deploy0xArtifactAsync( + exchange = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, defaults, @@ -713,7 +713,7 @@ describe('Exchange', () => { it('should throw if getBalance or getAllowance attempts to change state and \ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => { - const maliciousToken = await MaliciousTokenContract.deploy0xArtifactAsync( + const maliciousToken = await MaliciousTokenContract.deployFrom0xArtifactAsync( artifacts.MaliciousToken, provider, defaults, diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts index 888d5ab2e..8835412de 100644 --- a/packages/contracts/test/exchange/helpers.ts +++ b/packages/contracts/test/exchange/helpers.ts @@ -40,18 +40,18 @@ describe('Exchange', () => { before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); [maker, feeRecipient] = accounts; - const tokenRegistry = await TokenRegistryContract.deploy0xArtifactAsync( + const tokenRegistry = await TokenRegistryContract.deployFrom0xArtifactAsync( artifacts.TokenRegistry, provider, defaults, ); - const tokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + const tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, ); const [rep, dgd, zrx] = await Promise.all([ - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -60,7 +60,7 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -69,7 +69,7 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -79,7 +79,7 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), ]); - const exchange = await ExchangeContract.deploy0xArtifactAsync( + const exchange = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, defaults, diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index 6e55edabb..1c80189ab 100644 --- a/packages/contracts/test/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -56,7 +56,7 @@ describe('Exchange', () => { tokenOwner = accounts[0]; [maker, taker, feeRecipient] = accounts; [rep, dgd, zrx] = await Promise.all([ - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -65,7 +65,7 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -74,7 +74,7 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), - DummyTokenContract.deploy0xArtifactAsync( + DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -84,13 +84,17 @@ describe('Exchange', () => { constants.DUMMY_TOKEN_TOTAL_SUPPLY, ), ]); - tokenRegistry = await TokenRegistryContract.deploy0xArtifactAsync(artifacts.TokenRegistry, provider, defaults); - tokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + tokenRegistry = await TokenRegistryContract.deployFrom0xArtifactAsync( + artifacts.TokenRegistry, + provider, + defaults, + ); + tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, ); - exchange = await ExchangeContract.deploy0xArtifactAsync( + exchange = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, defaults, diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts index d3d478868..361d87ff7 100644 --- a/packages/contracts/test/multi_sig_with_time_lock.ts +++ b/packages/contracts/test/multi_sig_with_time_lock.ts @@ -47,7 +47,7 @@ describe('MultiSigWalletWithTimeLock', () => { describe('changeTimeLock', () => { describe('initially non-time-locked', async () => { before('deploy a wallet', async () => { - multiSig = await MultiSigWalletWithTimeLockContract.deploy0xArtifactAsync( + multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( artifacts.MultiSigWalletWithTimeLock, provider, defaults, @@ -142,7 +142,7 @@ describe('MultiSigWalletWithTimeLock', () => { }); describe('initially time-locked', async () => { before('deploy a wallet', async () => { - multiSig = await MultiSigWalletWithTimeLockContract.deploy0xArtifactAsync( + multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( artifacts.MultiSigWalletWithTimeLock, provider, defaults, diff --git a/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts index e8f970d64..ba23889b3 100644 --- a/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts +++ b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts @@ -46,7 +46,7 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => { owners = [accounts[0], accounts[1]]; [authorizedAddress, unauthorizedAddress] = accounts; const initialOwner = accounts[0]; - tokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, @@ -54,7 +54,7 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => { await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(authorizedAddress, { from: initialOwner, }); - multiSig = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract.deploy0xArtifactAsync( + multiSig = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract.deployFrom0xArtifactAsync( artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress, provider, defaults, @@ -109,7 +109,7 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => { }); it('should throw if tx destination is not the tokenTransferProxy', async () => { - const invalidTokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + const invalidTokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts index fbd7f130d..363631385 100644 --- a/packages/contracts/test/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -29,7 +29,7 @@ describe('TokenRegistry', () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); owner = accounts[0]; notOwner = accounts[1]; - tokenReg = await TokenRegistryContract.deploy0xArtifactAsync(artifacts.TokenRegistry, provider, defaults); + tokenReg = await TokenRegistryContract.deployFrom0xArtifactAsync(artifacts.TokenRegistry, provider, defaults); tokenRegWrapper = new TokenRegWrapper(tokenReg); }); beforeEach(async () => { diff --git a/packages/contracts/test/token_transfer_proxy/auth.ts b/packages/contracts/test/token_transfer_proxy/auth.ts index 78ef78beb..6baadab61 100644 --- a/packages/contracts/test/token_transfer_proxy/auth.ts +++ b/packages/contracts/test/token_transfer_proxy/auth.ts @@ -24,7 +24,7 @@ describe('TokenTransferProxy', () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); owner = address = accounts[0]; notOwner = accounts[1]; - tokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, diff --git a/packages/contracts/test/token_transfer_proxy/transfer_from.ts b/packages/contracts/test/token_transfer_proxy/transfer_from.ts index 79189415f..92573caf7 100644 --- a/packages/contracts/test/token_transfer_proxy/transfer_from.ts +++ b/packages/contracts/test/token_transfer_proxy/transfer_from.ts @@ -32,12 +32,12 @@ describe('TokenTransferProxy', () => { before(async () => { accounts = await web3Wrapper.getAvailableAddressesAsync(); owner = notAuthorized = accounts[0]; - tokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, ); - rep = await DummyTokenContract.deploy0xArtifactAsync( + rep = await DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, diff --git a/packages/contracts/test/tutorials/arbitrage.ts b/packages/contracts/test/tutorials/arbitrage.ts index f28120883..43dbd2989 100644 --- a/packages/contracts/test/tutorials/arbitrage.ts +++ b/packages/contracts/test/tutorials/arbitrage.ts @@ -40,8 +40,8 @@ describe('Arbitrage', () => { const INITIAL_BALANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18); const INITIAL_ALLOWANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18); - let weth: Web3.ContractInstance; - let zrx: Web3.ContractInstance; + let weth: DummyTokenContract; + let zrx: DummyTokenContract; let arbitrage: ArbitrageContract; let etherDelta: EtherDeltaContract; @@ -58,7 +58,7 @@ describe('Arbitrage', () => { before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); [coinbase, maker, edMaker, edFrontRunner] = accounts; - weth = await DummyTokenContract.deploy0xArtifactAsync( + weth = await DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -67,7 +67,7 @@ describe('Arbitrage', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ); - zrx = await DummyTokenContract.deploy0xArtifactAsync( + zrx = await DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, @@ -76,7 +76,7 @@ describe('Arbitrage', () => { constants.DUMMY_TOKEN_DECIMALS, constants.DUMMY_TOKEN_TOTAL_SUPPLY, ); - const accountLevels = await AccountLevelsContract.deploy0xArtifactAsync( + const accountLevels = await AccountLevelsContract.deployFrom0xArtifactAsync( artifacts.AccountLevels, provider, defaults, @@ -85,7 +85,7 @@ describe('Arbitrage', () => { const edMakerFee = new BigNumber(0); const edTakerFee = new BigNumber(0); const edFeeRebate = new BigNumber(0); - etherDelta = await EtherDeltaContract.deploy0xArtifactAsync( + etherDelta = await EtherDeltaContract.deployFrom0xArtifactAsync( artifacts.EtherDelta, provider, defaults, @@ -96,12 +96,12 @@ describe('Arbitrage', () => { edTakerFee, edFeeRebate, ); - const tokenTransferProxy = await TokenTransferProxyContract.deploy0xArtifactAsync( + const tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, defaults, ); - const exchange = await ExchangeContract.deploy0xArtifactAsync( + const exchange = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, defaults, @@ -129,7 +129,7 @@ describe('Arbitrage', () => { takerFee: new BigNumber(0), }; orderFactory = new OrderFactory(zeroEx, defaultOrderParams); - arbitrage = await ArbitrageContract.deploy0xArtifactAsync( + arbitrage = await ArbitrageContract.deployFrom0xArtifactAsync( artifacts.Arbitrage, provider, defaults, @@ -142,26 +142,26 @@ describe('Arbitrage', () => { await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase }); // Give some tokens to arbitrage contract - await weth.setBalance(arbitrage.address, takerTokenAmount, { from: coinbase }); + await weth.setBalance.sendTransactionAsync(arbitrage.address, takerTokenAmount, { from: coinbase }); // Fund the maker on exchange side - await zrx.setBalance(maker, makerTokenAmount, { from: coinbase }); + await zrx.setBalance.sendTransactionAsync(maker, makerTokenAmount, { from: coinbase }); // Set the allowance for the maker on Exchange side - await zrx.approve(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: maker }); + await zrx.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: maker }); amountGive = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18); // Fund the maker on EtherDelta side - await weth.setBalance(edMaker, amountGive, { from: coinbase }); + await weth.setBalance.sendTransactionAsync(edMaker, amountGive, { from: coinbase }); // Set the allowance for the maker on EtherDelta side - await weth.approve(etherDelta.address, INITIAL_ALLOWANCE, { from: edMaker }); + await weth.approve.sendTransactionAsync(etherDelta.address, INITIAL_ALLOWANCE, { from: edMaker }); // Deposit maker funds into EtherDelta await etherDelta.depositToken.sendTransactionAsync(weth.address, amountGive, { from: edMaker }); amountGet = makerTokenAmount; // Fund the front runner on EtherDelta side - await zrx.setBalance(edFrontRunner, amountGet, { from: coinbase }); + await zrx.setBalance.sendTransactionAsync(edFrontRunner, amountGet, { from: coinbase }); // Set the allowance for the front-runner on EtherDelta side - await zrx.approve(etherDelta.address, INITIAL_ALLOWANCE, { from: edFrontRunner }); + await zrx.approve.sendTransactionAsync(etherDelta.address, INITIAL_ALLOWANCE, { from: edFrontRunner }); // Deposit front runner funds into EtherDelta await etherDelta.depositToken.sendTransactionAsync(zrx.address, amountGet, { from: edFrontRunner }); }); @@ -228,11 +228,11 @@ describe('Arbitrage', () => { from: coinbase, }); const res = await zeroEx.awaitTransactionMinedAsync(txHash); - const postBalance = await weth.balanceOf(arbitrage.address); + const postBalance = await weth.balanceOf.callAsync(arbitrage.address); expect(postBalance).to.be.bignumber.equal(amountGive); }); it('should fail and revert if front-runned', async () => { - const preBalance = await weth.balanceOf(arbitrage.address); + const preBalance = await weth.balanceOf.callAsync(arbitrage.address); // Front-running transaction await etherDelta.trade.sendTransactionAsync( tokenGet, @@ -252,7 +252,7 @@ describe('Arbitrage', () => { await expect( arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, { from: coinbase }), ).to.be.rejectedWith(constants.REVERT); - const postBalance = await weth.balanceOf(arbitrage.address); + const postBalance = await weth.balanceOf.callAsync(arbitrage.address); expect(preBalance).to.be.bignumber.equal(postBalance); }); }); diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts index a541c495f..546958cfd 100644 --- a/packages/contracts/test/unlimited_allowance_token.ts +++ b/packages/contracts/test/unlimited_allowance_token.ts @@ -33,7 +33,7 @@ describe('UnlimitedAllowanceToken', () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); owner = accounts[0]; spender = accounts[1]; - token = await DummyTokenContract.deploy0xArtifactAsync( + token = await DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, defaults, diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts index 0ad3d86b7..dcba5ab1a 100644 --- a/packages/contracts/test/zrx_token.ts +++ b/packages/contracts/test/zrx_token.ts @@ -34,7 +34,7 @@ describe('ZRXToken', () => { zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID, }); - zrx = await ZRXTokenContract.deploy0xArtifactAsync(artifacts.ZRX, provider, defaults); + zrx = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, defaults); zrxAddress = zrx.address; MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; }); |