diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-04-12 03:23:20 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:17 +0800 |
commit | 32a7442845f8b8db37f9a67648e5d3beac36490c (patch) | |
tree | 6a94d5efcd8940281a425584b254bc7e4ba5867b /packages/contracts/test | |
parent | a0dfdefd165ce8b8eb0e76707391f5efb8485040 (diff) | |
download | dexon-0x-contracts-32a7442845f8b8db37f9a67648e5d3beac36490c.tar dexon-0x-contracts-32a7442845f8b8db37f9a67648e5d3beac36490c.tar.gz dexon-0x-contracts-32a7442845f8b8db37f9a67648e5d3beac36490c.tar.bz2 dexon-0x-contracts-32a7442845f8b8db37f9a67648e5d3beac36490c.tar.lz dexon-0x-contracts-32a7442845f8b8db37f9a67648e5d3beac36490c.tar.xz dexon-0x-contracts-32a7442845f8b8db37f9a67648e5d3beac36490c.tar.zst dexon-0x-contracts-32a7442845f8b8db37f9a67648e5d3beac36490c.zip |
Minor style improvements to asset proxy utils
Diffstat (limited to 'packages/contracts/test')
-rw-r--r-- | packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts | 12 | ||||
-rw-r--r-- | packages/contracts/test/asset_proxy_dispatcher/proxies.ts | 34 | ||||
-rw-r--r-- | packages/contracts/test/exchange/core.ts | 48 | ||||
-rw-r--r-- | packages/contracts/test/exchange/helpers.ts | 10 | ||||
-rw-r--r-- | packages/contracts/test/exchange/wrapper.ts | 20 |
5 files changed, 62 insertions, 62 deletions
diff --git a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts index 7ee2f98f0..624f2666f 100644 --- a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts +++ b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts @@ -13,9 +13,9 @@ import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c import { ERC20Proxy_v1Contract } from '../../src/contract_wrappers/generated/erc20proxy_v1'; import { TokenTransferProxyContract } from '../../src/contract_wrappers/generated/token_transfer_proxy'; import { - encodeERC20ProxyMetadata, - encodeERC20ProxyMetadata_V1, - encodeERC721ProxyMetadata, + encodeERC20ProxyData, + encodeERC20V1ProxyData, + encodeERC721ProxyData, } from '../../src/utils/asset_proxy_utils'; import { Balances } from '../../src/utils/balances'; import { constants } from '../../src/utils/constants'; @@ -268,7 +268,7 @@ describe('AssetProxyDispatcher', () => { ); // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC20ProxyMetadata(zrx.address); + const encodedProxyMetadata = encodeERC20ProxyData(zrx.address); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); @@ -293,7 +293,7 @@ describe('AssetProxyDispatcher', () => { it('should throw if delegating to unregistered proxy', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC20ProxyMetadata(zrx.address); + const encodedProxyMetadata = encodeERC20ProxyData(zrx.address); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); @@ -319,7 +319,7 @@ describe('AssetProxyDispatcher', () => { ); // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC20ProxyMetadata(zrx.address); + const encodedProxyMetadata = encodeERC20ProxyData(zrx.address); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); diff --git a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts index a8c5a2abc..91346cb6f 100644 --- a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts +++ b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts @@ -13,9 +13,9 @@ import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c import { ERC20Proxy_v1Contract } from '../../src/contract_wrappers/generated/erc20proxy_v1'; import { TokenTransferProxyContract } from '../../src/contract_wrappers/generated/token_transfer_proxy'; import { - encodeERC20ProxyMetadata, - encodeERC20ProxyMetadata_V1, - encodeERC721ProxyMetadata, + encodeERC20ProxyData, + encodeERC20V1ProxyData, + encodeERC721ProxyData, } from '../../src/utils/asset_proxy_utils'; import { Balances } from '../../src/utils/balances'; import { constants } from '../../src/utils/constants'; @@ -144,7 +144,7 @@ describe('Asset Transfer Proxies', () => { }); it('should successfully decode metadata encoded by typescript helpers', async () => { - const metadata = encodeERC20ProxyMetadata_V1(zrx.address); + const metadata = encodeERC20V1ProxyData(zrx.address); const address = await erc20TransferProxyV1.decodeMetadata.callAsync(metadata); expect(address).to.be.equal(zrx.address); }); @@ -158,14 +158,14 @@ describe('Asset Transfer Proxies', () => { it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => { const testAddress = '0x0000000000000000056000000000000000000010'; - const metadata = encodeERC20ProxyMetadata_V1(testAddress); + const metadata = encodeERC20V1ProxyData(testAddress); const address = await erc20TransferProxyV1.decodeMetadata.callAsync(metadata); expect(address).to.be.equal(testAddress); }); it('should successfully transfer tokens', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC20ProxyMetadata_V1(zrx.address); + const encodedProxyMetadata = encodeERC20V1ProxyData(zrx.address); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); @@ -190,7 +190,7 @@ describe('Asset Transfer Proxies', () => { it('should throw if requesting address is not authorized', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC20ProxyMetadata_V1(zrx.address); + const encodedProxyMetadata = encodeERC20V1ProxyData(zrx.address); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); @@ -215,7 +215,7 @@ describe('Asset Transfer Proxies', () => { }); it('should successfully decode metadata encoded by typescript helpers', async () => { - const metadata = encodeERC20ProxyMetadata(zrx.address); + const metadata = encodeERC20ProxyData(zrx.address); const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata); expect(address).to.be.equal(zrx.address); }); @@ -229,14 +229,14 @@ describe('Asset Transfer Proxies', () => { it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => { const testAddress = '0x0000000000000000056000000000000000000010'; - const metadata = encodeERC20ProxyMetadata(testAddress); + const metadata = encodeERC20ProxyData(testAddress); const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata); expect(address).to.be.equal(testAddress); }); it('should successfully transfer tokens', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC20ProxyMetadata(zrx.address); + const encodedProxyMetadata = encodeERC20ProxyData(zrx.address); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); @@ -261,7 +261,7 @@ describe('Asset Transfer Proxies', () => { it('should throw if requesting address is not authorized', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC20ProxyMetadata(zrx.address); + const encodedProxyMetadata = encodeERC20ProxyData(zrx.address); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); @@ -291,7 +291,7 @@ describe('Asset Transfer Proxies', () => { }); it('should successfully decode metadata encoded by typescript helpers', async () => { - const metadata = encodeERC721ProxyMetadata(ck.address, makerTokenId); + const metadata = encodeERC721ProxyData(ck.address, makerTokenId); const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata); expect(address).to.be.equal(ck.address); expect(tokenId).to.be.bignumber.equal(makerTokenId); @@ -311,7 +311,7 @@ describe('Asset Transfer Proxies', () => { it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => { const testAddress = '0x0000000000000000056000000000000000000010'; - const metadata = encodeERC721ProxyMetadata(testAddress, makerTokenId); + const metadata = encodeERC721ProxyData(testAddress, makerTokenId); const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata); expect(address).to.be.equal(testAddress); expect(tokenId).to.be.bignumber.equal(makerTokenId); @@ -319,7 +319,7 @@ describe('Asset Transfer Proxies', () => { it('should successfully transfer tokens', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC721ProxyMetadata(ck.address, makerTokenId); + const encodedProxyMetadata = encodeERC721ProxyData(ck.address, makerTokenId); // Verify pre-condition const ownerMakerToken = await ck.ownerOf.callAsync(makerTokenId); @@ -343,7 +343,7 @@ describe('Asset Transfer Proxies', () => { it('should throw if transferring 0 amount of a token', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC721ProxyMetadata(ck.address, makerTokenId); + const encodedProxyMetadata = encodeERC721ProxyData(ck.address, makerTokenId); // Verify pre-condition const ownerMakerToken = await ck.ownerOf.callAsync(makerTokenId); @@ -365,7 +365,7 @@ describe('Asset Transfer Proxies', () => { it('should throw if transferring >1 amount of a token', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC721ProxyMetadata(ck.address, makerTokenId); + const encodedProxyMetadata = encodeERC721ProxyData(ck.address, makerTokenId); // Verify pre-condition const ownerMakerToken = await ck.ownerOf.callAsync(makerTokenId); @@ -387,7 +387,7 @@ describe('Asset Transfer Proxies', () => { it('should throw if requesting address is not authorized', async () => { // Construct metadata for ERC20 proxy - const encodedProxyMetadata = encodeERC721ProxyMetadata(zrx.address, makerTokenId); + const encodedProxyMetadata = encodeERC721ProxyData(zrx.address, makerTokenId); // Perform a transfer from makerAddress to takerAddress const balances = await dmyBalances.getAsync(); diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 2f357be57..a1f858c78 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -21,9 +21,9 @@ import { } from '../../src/contract_wrappers/generated/exchange'; import { TokenTransferProxyContract } from '../../src/contract_wrappers/generated/token_transfer_proxy'; import { - encodeERC20ProxyMetadata, - encodeERC20ProxyMetadata_V1, - encodeERC721ProxyMetadata, + encodeERC20ProxyData, + encodeERC20V1ProxyData, + encodeERC721ProxyData, } from '../../src/utils/asset_proxy_utils'; import { Balances } from '../../src/utils/balances'; import { constants } from '../../src/utils/constants'; @@ -132,7 +132,7 @@ describe('Exchange', () => { const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [ zrx.address, - encodeERC20ProxyMetadata(zrx.address), + encodeERC20ProxyData(zrx.address), assetProxyDispatcher.address, ]); exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider); @@ -183,8 +183,8 @@ describe('Exchange', () => { takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18), makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), - makerAssetData: encodeERC20ProxyMetadata(rep.address), - takerAssetData: encodeERC20ProxyMetadata(dgd.address), + makerAssetData: encodeERC20ProxyData(rep.address), + takerAssetData: encodeERC20ProxyData(dgd.address), }; const privateKey = constants.TESTRPC_PRIVATE_KEYS[0]; orderFactory = new OrderFactory(privateKey, defaultOrderParams); @@ -966,8 +966,8 @@ describe('Exchange', () => { takerTokenAddress: ck.address, makerTokenAmount: new BigNumber(1), takerTokenAmount: new BigNumber(1), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), }); // Verify pre-conditions @@ -996,8 +996,8 @@ describe('Exchange', () => { takerTokenAddress: ck.address, makerTokenAmount: new BigNumber(1), takerTokenAmount: new BigNumber(1), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), }); // Verify pre-conditions @@ -1026,8 +1026,8 @@ describe('Exchange', () => { takerTokenAddress: ck.address, makerTokenAmount: new BigNumber(1), takerTokenAmount: new BigNumber(1), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), }); // Verify pre-conditions @@ -1052,8 +1052,8 @@ describe('Exchange', () => { takerTokenAddress: ck.address, makerTokenAmount: new BigNumber(1), takerTokenAmount: new BigNumber(1), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), }); // Verify pre-conditions @@ -1078,8 +1078,8 @@ describe('Exchange', () => { takerTokenAddress: ck.address, makerTokenAmount: new BigNumber(2), takerTokenAmount: new BigNumber(1), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), }); // Verify pre-conditions @@ -1104,8 +1104,8 @@ describe('Exchange', () => { takerTokenAddress: ck.address, makerTokenAmount: new BigNumber(1), takerTokenAmount: new BigNumber(500), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), }); // Verify pre-conditions @@ -1130,8 +1130,8 @@ describe('Exchange', () => { takerTokenAddress: ck.address, makerTokenAmount: new BigNumber(1), takerTokenAmount: new BigNumber(0), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), }); // Verify pre-conditions @@ -1155,8 +1155,8 @@ describe('Exchange', () => { takerTokenAddress: dgd.address, makerTokenAmount: new BigNumber(1), takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18), - makerAssetData: encodeERC721ProxyMetadata(ck.address, makerTokenId), - takerAssetData: encodeERC20ProxyMetadata(dgd.address), + makerAssetData: encodeERC721ProxyData(ck.address, makerTokenId), + takerAssetData: encodeERC20ProxyData(dgd.address), }); // Verify pre-conditions @@ -1199,8 +1199,8 @@ describe('Exchange', () => { makerTokenAddress: dgd.address, takerTokenAmount: new BigNumber(1), makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18), - takerAssetData: encodeERC721ProxyMetadata(ck.address, takerTokenId), - makerAssetData: encodeERC20ProxyMetadata(dgd.address), + takerAssetData: encodeERC721ProxyData(ck.address, takerTokenId), + makerAssetData: encodeERC20ProxyData(dgd.address), }); // Verify pre-conditions diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts index 6990ac88b..48ece0a7a 100644 --- a/packages/contracts/test/exchange/helpers.ts +++ b/packages/contracts/test/exchange/helpers.ts @@ -7,9 +7,9 @@ import ethUtil = require('ethereumjs-util'); import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange'; import { - encodeERC20ProxyMetadata, - encodeERC20ProxyMetadata_V1, - encodeERC721ProxyMetadata, + encodeERC20ProxyData, + encodeERC20V1ProxyData, + encodeERC721ProxyData, } from '../../src/utils/asset_proxy_utils'; import { constants } from '../../src/utils/constants'; import { ExchangeWrapper } from '../../src/utils/exchange_wrapper'; @@ -88,8 +88,8 @@ describe('Exchange', () => { takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18), makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), - makerAssetData: encodeERC20ProxyMetadata(rep.address), - takerAssetData: encodeERC20ProxyMetadata(dgd.address), + makerAssetData: encodeERC20ProxyData(rep.address), + takerAssetData: encodeERC20ProxyData(dgd.address), }; const privateKey = constants.TESTRPC_PRIVATE_KEYS[0]; orderFactory = new OrderFactory(privateKey, defaultOrderParams); diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index 8c55dfe19..aef21429f 100644 --- a/packages/contracts/test/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -16,9 +16,9 @@ import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange import { TokenRegistryContract } from '../../src/contract_wrappers/generated/token_registry'; import { TokenTransferProxyContract } from '../../src/contract_wrappers/generated/token_transfer_proxy'; import { - encodeERC20ProxyMetadata, - encodeERC20ProxyMetadata_V1, - encodeERC721ProxyMetadata, + encodeERC20ProxyData, + encodeERC20V1ProxyData, + encodeERC721ProxyData, } from '../../src/utils/asset_proxy_utils'; import { Balances } from '../../src/utils/balances'; import { constants } from '../../src/utils/constants'; @@ -100,7 +100,7 @@ describe('Exchange', () => { ); const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [ zrx.address, - encodeERC20ProxyMetadata(zrx.address), + encodeERC20ProxyData(zrx.address), assetProxyDispatcher.address, ]); exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider); @@ -139,8 +139,8 @@ describe('Exchange', () => { takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18), makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), - makerAssetData: encodeERC20ProxyMetadata(rep.address), - takerAssetData: encodeERC20ProxyMetadata(dgd.address), + makerAssetData: encodeERC20ProxyData(rep.address), + takerAssetData: encodeERC20ProxyData(dgd.address), }; const privateKey = constants.TESTRPC_PRIVATE_KEYS[0]; @@ -341,7 +341,7 @@ describe('Exchange', () => { makerTokenAddress: zrx.address, makerTokenAmount: makerZRXBalance, makerFee: new BigNumber(1), - makerAssetData: encodeERC20ProxyMetadata(zrx.address), + makerAssetData: encodeERC20ProxyData(zrx.address), }); await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress); const newBalances = await dmyBalances.getAsync(); @@ -354,7 +354,7 @@ describe('Exchange', () => { makerTokenAddress: zrx.address, makerTokenAmount: new BigNumber(makerZRXAllowance), makerFee: new BigNumber(1), - makerAssetData: encodeERC20ProxyMetadata(zrx.address), + makerAssetData: encodeERC20ProxyData(zrx.address), }); await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress); const newBalances = await dmyBalances.getAsync(); @@ -367,7 +367,7 @@ describe('Exchange', () => { takerTokenAddress: zrx.address, takerTokenAmount: takerZRXBalance, takerFee: new BigNumber(1), - takerAssetData: encodeERC20ProxyMetadata(zrx.address), + takerAssetData: encodeERC20ProxyData(zrx.address), }); await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress); const newBalances = await dmyBalances.getAsync(); @@ -380,7 +380,7 @@ describe('Exchange', () => { takerTokenAddress: zrx.address, takerTokenAmount: new BigNumber(takerZRXAllowance), takerFee: new BigNumber(1), - takerAssetData: encodeERC20ProxyMetadata(zrx.address), + takerAssetData: encodeERC20ProxyData(zrx.address), }); await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress); const newBalances = await dmyBalances.getAsync(); |