From 9b82e2df58cfd7f4dc9954fa93167450919f457f Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Thu, 24 May 2018 12:29:45 -0700 Subject: Foundation for TestLibAssetProxyDecoder --- packages/contracts/compiler.json | 1 + packages/contracts/package.json | 2 +- .../TestLibAssetProxyDecoder.sol | 50 +++++++++++++++ packages/contracts/src/utils/artifacts.ts | 2 + packages/contracts/src/utils/types.ts | 1 + packages/contracts/test/asset_proxy/decoder.ts | 72 ++++++++++++++++++++++ packages/contracts/test/libraries/lib_mem.ts | 2 +- 7 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 packages/contracts/src/contracts/current/test/TestLibAssetProxyDecoder/TestLibAssetProxyDecoder.sol create mode 100644 packages/contracts/test/asset_proxy/decoder.ts (limited to 'packages/contracts') diff --git a/packages/contracts/compiler.json b/packages/contracts/compiler.json index a11f2a2c0..639849cd7 100644 --- a/packages/contracts/compiler.json +++ b/packages/contracts/compiler.json @@ -29,6 +29,7 @@ "MixinAuthorizable", "MultiSigWallet", "MultiSigWalletWithTimeLock", + "TestLibAssetProxyDecoder", "TestAssetProxyDispatcher", "TestLibBytes", "TestLibMem", diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 009fe87ec..43c33e7d3 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -30,7 +30,7 @@ "test:circleci": "yarn test" }, "config": { - "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyDispatcher|TestLibBytes|TestLibMem|TestLibs|TestSignatureValidator|TokenRegistry|Whitelist|WETH9|ZRXToken).json" + "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyDispatcher|TestLibAssetProxyDecoder|TestLibBytes|TestLibMem|TestLibs|TestSignatureValidator|TokenRegistry|Whitelist|WETH9|ZRXToken).json" }, "repository": { "type": "git", diff --git a/packages/contracts/src/contracts/current/test/TestLibAssetProxyDecoder/TestLibAssetProxyDecoder.sol b/packages/contracts/src/contracts/current/test/TestLibAssetProxyDecoder/TestLibAssetProxyDecoder.sol new file mode 100644 index 000000000..ac7cd63ab --- /dev/null +++ b/packages/contracts/src/contracts/current/test/TestLibAssetProxyDecoder/TestLibAssetProxyDecoder.sol @@ -0,0 +1,50 @@ +/* + + Copyright 2018 ZeroEx Intl. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +pragma solidity ^0.4.24; +pragma experimental ABIEncoderV2; + +import "../../utils/LibAssetProxyDecoder/LibAssetProxyDecoder.sol"; + +contract TestLibAssetProxyDecoder is + LibAssetProxyDecoder +{ + + /// @dev Decodes ERC721 Asset Proxy data + function publicDecodeERC20Data(bytes memory proxyData) + public + pure + returns (uint8, address) + { + return decodeERC20Data(proxyData); + } + + /// @dev Decodes ERC721 Asset Proxy data + function publicDecodeERC721Data(bytes memory proxyData) + internal + pure + returns ( + uint8, + address, + uint256, + bytes memory + ) + { + return decodeERC721Data(proxyData); + } +} diff --git a/packages/contracts/src/utils/artifacts.ts b/packages/contracts/src/utils/artifacts.ts index 1b47f1d41..44de43a95 100644 --- a/packages/contracts/src/utils/artifacts.ts +++ b/packages/contracts/src/utils/artifacts.ts @@ -10,6 +10,7 @@ import * as MixinAuthorizable from '../artifacts/MixinAuthorizable.json'; import * as MultiSigWallet from '../artifacts/MultiSigWallet.json'; import * as MultiSigWalletWithTimeLock from '../artifacts/MultiSigWalletWithTimeLock.json'; import * as TestAssetProxyDispatcher from '../artifacts/TestAssetProxyDispatcher.json'; +import * as TestLibAssetProxyDecoder from '../artifacts/TestLibAssetProxyDecoder.json'; import * as TestLibBytes from '../artifacts/TestLibBytes.json'; import * as TestLibMem from '../artifacts/TestLibMem.json'; import * as TestLibs from '../artifacts/TestLibs.json'; @@ -31,6 +32,7 @@ export const artifacts = { MultiSigWallet: (MultiSigWallet as any) as ContractArtifact, MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact, TestAssetProxyDispatcher: (TestAssetProxyDispatcher as any) as ContractArtifact, + TestLibAssetProxyDecoder: (TestLibAssetProxyDecoder as any) as ContractArtifact, TestLibBytes: (TestLibBytes as any) as ContractArtifact, TestLibMem: (TestLibMem as any) as ContractArtifact, TestLibs: (TestLibs as any) as ContractArtifact, diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts index cc6f00b95..70abb2643 100644 --- a/packages/contracts/src/utils/types.ts +++ b/packages/contracts/src/utils/types.ts @@ -90,6 +90,7 @@ export enum ContractName { AccountLevels = 'AccountLevels', EtherDelta = 'EtherDelta', Arbitrage = 'Arbitrage', + TestLibAssetProxyDecoder = 'TestLibAssetProxyDecoder', TestAssetProxyDispatcher = 'TestAssetProxyDispatcher', TestLibMem = 'TestLibMem', TestLibs = 'TestLibs', diff --git a/packages/contracts/test/asset_proxy/decoder.ts b/packages/contracts/test/asset_proxy/decoder.ts new file mode 100644 index 000000000..74e7547d3 --- /dev/null +++ b/packages/contracts/test/asset_proxy/decoder.ts @@ -0,0 +1,72 @@ +import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js'; +import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import BN = require('bn.js'); +import * as chai from 'chai'; +import ethUtil = require('ethereumjs-util'); +import * as Web3 from 'web3'; + +import { TestLibAssetProxyDecoderContract } from '../../src/contract_wrappers/generated/test_lib_asset_proxy_decoder'; +import { artifacts } from '../../src/utils/artifacts'; +import { chaiSetup } from '../../src/utils/chai_setup'; +import { constants } from '../../src/utils/constants'; +import { AssetProxyId } from '../../src/utils/types'; +import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; + +chaiSetup.configure(); +const expect = chai.expect; +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); + +describe.only('AssetProxyDecoder', () => { + let owner: string; + let testAssetProxyDecoder: TestLibAssetProxyDecoderContract; + + before(async () => { + // Setup accounts & addresses + const accounts = await web3Wrapper.getAvailableAddressesAsync(); + owner = accounts[0]; + // Deploy TestLibMem + testAssetProxyDecoder = await TestLibAssetProxyDecoderContract.deployFrom0xArtifactAsync( + artifacts.TestLibAssetProxyDecoder, + provider, + txDefaults, + ); + }); + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); + + describe('LibAssetProxyDecoder', () => { + /*it('should )', async () => { + await testAssetProxyDecoder.test1.sendTransactionAsync(); + }); + + it('should )', async () => { + await testLibMem.test2.sendTransactionAsync(); + }); + + it('should )', async () => { + await testLibMem.test3.sendTransactionAsync(); + }); + + it('should )', async () => { + await testLibMem.test4.sendTransactionAsync(); + }); + + it('should )', async () => { + await testLibMem.test5.sendTransactionAsync(); + }); + + it('should )', async () => { + await testLibMem.test6.sendTransactionAsync(); + }); + + it('should )', async () => { + return expect(testLibMem.test7.sendTransactionAsync()).to.be.rejectedWith(constants.REVERT); + });*/ + }); +}); diff --git a/packages/contracts/test/libraries/lib_mem.ts b/packages/contracts/test/libraries/lib_mem.ts index c861484f3..6ce4ab9b6 100644 --- a/packages/contracts/test/libraries/lib_mem.ts +++ b/packages/contracts/test/libraries/lib_mem.ts @@ -18,7 +18,7 @@ chaiSetup.configure(); const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); -describe.only('LibMem', () => { +describe('LibMem', () => { let owner: string; let testLibMem: TestLibMemContract; -- cgit v1.2.3