aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/asset_proxy
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-06-02 05:17:13 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-06-08 06:38:48 +0800
commite4e36760952287a84f8991df8589c183036383db (patch)
tree83c5ba694848232f6d3b01a72dc8c3d94cb9d071 /packages/contracts/test/asset_proxy
parent3ed13150e106c19563c8e9b06621be3d44d66b6c (diff)
downloaddexon-sol-tools-e4e36760952287a84f8991df8589c183036383db.tar
dexon-sol-tools-e4e36760952287a84f8991df8589c183036383db.tar.gz
dexon-sol-tools-e4e36760952287a84f8991df8589c183036383db.tar.bz2
dexon-sol-tools-e4e36760952287a84f8991df8589c183036383db.tar.lz
dexon-sol-tools-e4e36760952287a84f8991df8589c183036383db.tar.xz
dexon-sol-tools-e4e36760952287a84f8991df8589c183036383db.tar.zst
dexon-sol-tools-e4e36760952287a84f8991df8589c183036383db.zip
Fixed up after rebasing. Contracts build and tests pass
Diffstat (limited to 'packages/contracts/test/asset_proxy')
-rw-r--r--packages/contracts/test/asset_proxy/decoder.ts9
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts33
2 files changed, 14 insertions, 28 deletions
diff --git a/packages/contracts/test/asset_proxy/decoder.ts b/packages/contracts/test/asset_proxy/decoder.ts
index e395c04c1..6336f69ae 100644
--- a/packages/contracts/test/asset_proxy/decoder.ts
+++ b/packages/contracts/test/asset_proxy/decoder.ts
@@ -1,9 +1,10 @@
-import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+import { generatePseudoRandomSalt } from '@0xproject/order-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import BN = require('bn.js');
import * as chai from 'chai';
+import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
@@ -57,7 +58,7 @@ describe('TestAssetDataDecoders', () => {
});
it('should correctly decode ERC721 asset data', async () => {
- const tokenId = ZeroEx.generatePseudoRandomSalt();
+ const tokenId = generatePseudoRandomSalt();
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(testAddress, tokenId);
const expectedDecodedAssetData = assetProxyUtils.decodeERC721AssetData(encodedAssetData);
let decodedAssetProxyId: number;
@@ -77,9 +78,9 @@ describe('TestAssetDataDecoders', () => {
});
it('should correctly decode ERC721 asset data with receiver data', async () => {
- const tokenId = ZeroEx.generatePseudoRandomSalt();
+ const tokenId = generatePseudoRandomSalt();
const receiverData =
- ethUtil.bufferToHex(assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt())) + 'FFFF';
+ ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt())) + 'FFFF';
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(testAddress, tokenId, receiverData);
const expectedDecodedAssetData = assetProxyUtils.decodeERC721AssetData(encodedAssetData);
let decodedAssetProxyId: number;
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index e8c598935..6dc652383 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -1,8 +1,10 @@
-import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils } from '@0xproject/order-utils';
+import { generatePseudoRandomSalt } from '@0xproject/order-utils';
+import { AssetProxyId } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
+import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
@@ -82,20 +84,11 @@ describe('Asset Transfer Proxies', () => {
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
-
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
- from: owner,
- });
-
erc721Receiver = await DummyERC721ReceiverContract.deployFrom0xArtifactAsync(
artifacts.DummyERC721Receiver,
provider,
txDefaults,
);
-
- zeroEx = new ZeroEx(provider, {
- networkId: constants.TESTRPC_NETWORK_ID,
- });
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -298,10 +291,8 @@ describe('Asset Transfer Proxies', () => {
);
// Parse transaction logs
- const tx = await zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === erc721Receiver.address);
- const logDecoder = new LogDecoder(constants.TESTRPC_NETWORK_ID);
- tx.logs = _.map(tx.logs, log => logDecoder.decodeLogOrThrow(log));
+ const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address);
+ const tx = await logDecoder.getTxWithDecodedLogsAsync(txHash);
// Verify that no log was emitted by erc721 receiver
expect(tx.logs.length).to.be.equal(0);
// Verify transfer was successful
@@ -311,9 +302,7 @@ describe('Asset Transfer Proxies', () => {
it('should call onERC721Received when transferring to a smart contract with receiver data', async () => {
// Construct ERC721 asset data
- const receiverData = ethUtil.bufferToHex(
- assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt()),
- );
+ const receiverData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(
erc721Token.address,
erc721MakerTokenId,
@@ -333,10 +322,8 @@ describe('Asset Transfer Proxies', () => {
{ from: exchangeAddress },
);
// Parse transaction logs
- const tx = await zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === erc721Receiver.address);
- const logDecoder = new LogDecoder(constants.TESTRPC_NETWORK_ID);
- tx.logs = _.map(tx.logs, log => logDecoder.decodeLogOrThrow(log));
+ const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address);
+ const tx = await logDecoder.getTxWithDecodedLogsAsync(txHash);
// Validate log emitted by erc721 receiver
expect(tx.logs.length).to.be.equal(1);
const tokenReceivedLog = tx.logs[0] as LogWithDecodedArgs<TokenReceivedContractEventArgs>;
@@ -350,9 +337,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if there is receiver data but contract does not have onERC721Received', async () => {
// Construct ERC721 asset data
- const receiverData = ethUtil.bufferToHex(
- assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt()),
- );
+ const receiverData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(
erc721Token.address,
erc721MakerTokenId,