diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-05-25 03:29:45 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-06-08 06:36:18 +0800 |
commit | 9b82e2df58cfd7f4dc9954fa93167450919f457f (patch) | |
tree | 8b84f49b930ef7053dd34ad10894fc7f57c0e033 /packages/contracts | |
parent | 3d65341080177bdd436e7628a76e65774b947a38 (diff) | |
download | dexon-sol-tools-9b82e2df58cfd7f4dc9954fa93167450919f457f.tar dexon-sol-tools-9b82e2df58cfd7f4dc9954fa93167450919f457f.tar.gz dexon-sol-tools-9b82e2df58cfd7f4dc9954fa93167450919f457f.tar.bz2 dexon-sol-tools-9b82e2df58cfd7f4dc9954fa93167450919f457f.tar.lz dexon-sol-tools-9b82e2df58cfd7f4dc9954fa93167450919f457f.tar.xz dexon-sol-tools-9b82e2df58cfd7f4dc9954fa93167450919f457f.tar.zst dexon-sol-tools-9b82e2df58cfd7f4dc9954fa93167450919f457f.zip |
Foundation for TestLibAssetProxyDecoder
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/compiler.json | 1 | ||||
-rw-r--r-- | packages/contracts/package.json | 2 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/test/TestLibAssetProxyDecoder/TestLibAssetProxyDecoder.sol | 50 | ||||
-rw-r--r-- | packages/contracts/src/utils/artifacts.ts | 2 | ||||
-rw-r--r-- | packages/contracts/src/utils/types.ts | 1 | ||||
-rw-r--r-- | packages/contracts/test/asset_proxy/decoder.ts | 72 | ||||
-rw-r--r-- | packages/contracts/test/libraries/lib_mem.ts | 2 |
7 files changed, 128 insertions, 2 deletions
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; |