Split tokens package into erc20 and erc721

This commit is contained in:
Amir Bandeali 2019-01-21 14:20:33 -08:00
parent 9fa8619590
commit 0758f231e2
104 changed files with 729 additions and 878 deletions

View File

@ -43,10 +43,12 @@ jobs:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-multisig
- run: yarn wsrun test:circleci @0x/contracts-utils
- run: yarn wsrun test:circleci @0x/contracts-libs
- run: yarn wsrun test:circleci @0x/contracts-tokens
- run: yarn wsrun test:circleci @0x/contracts-exchange-libs
- run: yarn wsrun test:circleci @0x/contracts-erc20
- run: yarn wsrun test:circleci @0x/contracts-erc721
- run: yarn wsrun test:circleci @0x/contracts-extensions
- run: yarn wsrun test:circleci @0x/contracts-protocol
- run: yarn wsrun test:circleci @0x/contracts-asset-proxy
- run: yarn wsrun test:circleci @0x/contracts-exchange
test-contracts-geth:
docker:
- image: circleci/node:9-browsers
@ -59,11 +61,13 @@ jobs:
# HACK(albrow): we need to sleep 10 seconds to ensure the devnet is
# initialized
- run: sleep 10 && TEST_PROVIDER=geth yarn wsrun test @0x/contracts-multisig
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-utils
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-exchange-libs
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-tokens
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-extensions
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-protocol
- run: yarn wsrun test:circleci @0x/contracts-utils
- run: yarn wsrun test:circleci @0x/contracts-exchange-libs
- run: yarn wsrun test:circleci @0x/contracts-erc20
- run: yarn wsrun test:circleci @0x/contracts-erc721
- run: yarn wsrun test:circleci @0x/contracts-extensions
- run: yarn wsrun test:circleci @0x/contracts-asset-proxy
- run: yarn wsrun test:circleci @0x/contracts-exchange
test-publish:
resource_class: medium+
docker:

6
.gitignore vendored
View File

@ -88,7 +88,8 @@ contracts/asset-proxy/generated-artifacts/
contracts/multisig/generated-artifacts/
contracts/utils/generated-artifacts/
contracts/exchange-libs/generated-artifacts/
contracts/tokens/generated-artifacts/
contracts/erc20/generated-artifacts/
contracts/erc721/generated-artifacts/
contracts/extensions/generated-artifacts/
packages/sol-tracing-utils/test/fixtures/artifacts/
packages/metacoin/artifacts/
@ -100,7 +101,8 @@ contracts/asset-proxy/generated-wrappers/
contracts/multisig/generated-wrappers/
contracts/utils/generated-wrappers/
contracts/exchange-libs/generated-wrappers/
contracts/tokens/generated-wrappers/
contracts/erc20/generated-wrappers/
contracts/erc721/generated-wrappers/
contracts/extensions/generated-wrappers/
packages/metacoin/src/contract_wrappers

View File

@ -10,8 +10,10 @@ lib
/contracts/utils/generated-artifacts
/contracts/exchange-libs/generated-wrappers
/contracts/exchange-libs/generated-artifacts
/contracts/tokens/generated-wrappers
/contracts/tokens/generated-artifacts
/contracts/erc20/generated-wrappers
/contracts/erc20/generated-artifacts
/contracts/erc721/generated-wrappers
/contracts/erc721/generated-artifacts
/contracts/extensions/generated-wrappers
/contracts/extensions/generated-artifacts
/packages/abi-gen-wrappers/src/generated-wrappers

View File

@ -69,9 +69,9 @@
},
"dependencies": {
"@0x/base-contract": "^3.0.13",
"@0x/contracts-interfaces": "^1.0.6",
"@0x/contracts-test-utils": "^2.0.1",
"@0x/contracts-tokens": "^1.0.6",
"@0x/contracts-erc20": "^1.0.6",
"@0x/contracts-erc721": "^1.0.6",
"@0x/contracts-utils": "^1.0.6",
"@0x/order-utils": "^3.1.2",
"@0x/types": "^1.5.2",

View File

@ -12,8 +12,7 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import { MixinAuthorizableContract } from '../generated-wrappers/mixin_authorizable';
import { artifacts } from '../src/artifacts';
import { artifacts, MixinAuthorizableContract } from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -1,4 +1,15 @@
import { artifacts as interfacesArtifacts, IAssetDataContract, IAssetProxyContract } from '@0x/contracts-interfaces';
import {
artifacts as erc20Artifacts,
DummyERC20TokenContract,
DummyERC20TokenTransferEventArgs,
DummyMultipleReturnERC20TokenContract,
DummyNoReturnERC20TokenContract,
} from '@0x/contracts-erc20';
import {
artifacts as erc721Artifacts,
DummyERC721ReceiverContract,
DummyERC721TokenContract,
} from '@0x/contracts-erc721';
import {
chaiSetup,
constants,
@ -9,15 +20,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import {
artifacts as tokensArtifacts,
DummyERC20TokenContract,
DummyERC20TokenTransferEventArgs,
DummyERC721ReceiverContract,
DummyERC721TokenContract,
DummyMultipleReturnERC20TokenContract,
DummyNoReturnERC20TokenContract,
} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason } from '@0x/types';
@ -26,24 +28,27 @@ import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
import { ERC20ProxyContract } from '../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../generated-wrappers/erc721_proxy';
import { MultiAssetProxyContract } from '../generated-wrappers/multi_asset_proxy';
import { artifacts } from '../src/artifacts';
import { ERC20Wrapper } from './utils/erc20_wrapper';
import { ERC721Wrapper } from './utils/erc721_wrapper';
import {
artifacts,
ERC20ProxyContract,
ERC20Wrapper,
ERC721ProxyContract,
ERC721Wrapper,
IAssetDataContract,
IAssetProxyContract,
MultiAssetProxyContract,
} from '../src';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const assetProxyInterface = new IAssetProxyContract(
interfacesArtifacts.IAssetProxy.compilerOutput.abi,
artifacts.IAssetProxy.compilerOutput.abi,
constants.NULL_ADDRESS,
provider,
);
const assetDataInterface = new IAssetDataContract(
interfacesArtifacts.IAssetData.compilerOutput.abi,
artifacts.IAssetData.compilerOutput.abi,
constants.NULL_ADDRESS,
provider,
);
@ -149,7 +154,7 @@ describe('Asset Transfer Proxies', () => {
constants.DUMMY_TOKEN_DECIMALS,
);
noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.DummyNoReturnERC20Token,
erc20Artifacts.DummyNoReturnERC20Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@ -158,7 +163,7 @@ describe('Asset Transfer Proxies', () => {
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
);
multipleReturnErc20Token = await DummyMultipleReturnERC20TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.DummyMultipleReturnERC20Token,
erc20Artifacts.DummyMultipleReturnERC20Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@ -199,7 +204,7 @@ describe('Asset Transfer Proxies', () => {
// Deploy and configure ERC721 tokens and receiver
[erc721TokenA, erc721TokenB] = await erc721Wrapper.deployDummyTokensAsync();
erc721Receiver = await DummyERC721ReceiverContract.deployFrom0xArtifactAsync(
tokensArtifacts.DummyERC721Receiver,
erc721Artifacts.DummyERC721Receiver,
provider,
txDefaults,
);
@ -563,7 +568,7 @@ describe('Asset Transfer Proxies', () => {
erc721Receiver.address,
amount,
);
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokensArtifacts });
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc721Artifacts });
const tx = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
to: erc721Proxy.address,
@ -755,7 +760,7 @@ describe('Asset Transfer Proxies', () => {
inputAmount,
);
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokensArtifacts });
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts });
const tx = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
to: multiAssetProxy.address,

View File

@ -1,5 +1,5 @@
import { artifacts as tokensArtifacts, DummyERC20TokenContract } from '@0x/contracts-erc20';
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts, DummyERC20TokenContract } from '@0x/contracts-tokens';
import { assetDataUtils } from '@0x/order-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';

View File

@ -1,5 +1,5 @@
import { artifacts as tokensArtifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts, DummyERC721TokenContract } from '@0x/contracts-tokens';
import { generatePseudoRandomSalt } from '@0x/order-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';

View File

@ -0,0 +1 @@
contracts/src/ZRXToken.sol

View File

@ -22,23 +22,13 @@
"DummyERC20Token",
"DummyMultipleReturnERC20Token",
"DummyNoReturnERC20Token",
"DummyERC721Receiver",
"InvalidERC721Receiver",
"DummyERC721Token",
"ReentrantERC20Token",
"ERC20Token",
"IERC20Token",
"MintableERC20Token",
"UnlimitedAllowanceERC20Token",
"ERC721Token",
"IERC721Receiver",
"IERC721Token",
"MintableERC721Token",
"IEtherToken",
"WETH9",
"ERC20Token_v1",
"Token_v1",
"UnlimitedAllowanceToken_v1",
"ZRXToken"
]
}

View File

@ -18,7 +18,7 @@
pragma solidity ^0.4.24;
import "./IERC20Token.sol";
import "./interfaces/IERC20Token.sol";
contract ERC20Token is

View File

@ -0,0 +1,150 @@
/*
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.11;
contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
contract ERC20Token is Token {
function transfer(address _to, uint _value) returns (bool) {
//Default assumes totalSupply can't be over max (2^256 - 1).
if (balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint _value) returns (bool) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant returns (uint) {
return balances[_owner];
}
function approve(address _spender, uint _value) returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint) {
return allowed[_owner][_spender];
}
mapping (address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
uint public totalSupply;
}
contract UnlimitedAllowanceToken is ERC20Token {
uint constant MAX_UINT = 2**256 - 1;
/// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance.
/// @param _from Address to transfer from.
/// @param _to Address to transfer to.
/// @param _value Amount to transfer.
/// @return Success of transfer.
function transferFrom(address _from, address _to, uint _value)
public
returns (bool)
{
uint allowance = allowed[_from][msg.sender];
if (balances[_from] >= _value
&& allowance >= _value
&& balances[_to] + _value >= balances[_to]
) {
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT) {
allowed[_from][msg.sender] -= _value;
}
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}
}
contract ZRXToken is
UnlimitedAllowanceToken
{
// solhint-disable const-name-snakecase
uint8 constant public decimals = 18;
uint256 public totalSupply = 10**27; // 1 billion tokens, 18 decimal places
string constant public name = "0x Protocol Token";
string constant public symbol = "ZRX";
// solhint-enableconst-name-snakecase
function ZRXToken()
public
{
balances[msg.sender] = totalSupply;
}
}

View File

@ -18,7 +18,7 @@
pragma solidity ^0.4.24;
import "../ERC20Token/IERC20Token.sol";
import "./IERC20Token.sol";
contract IEtherToken is

View File

@ -19,7 +19,7 @@
pragma solidity 0.4.24;
import "@0x/contracts-utils/contracts/src/Ownable.sol";
import "../../ERC20Token/MintableERC20Token.sol";
import "../src/MintableERC20Token.sol";
contract DummyERC20Token is

View File

@ -20,7 +20,7 @@ pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "../../ERC20Token/ERC20Token.sol";
import "../src/ERC20Token.sol";
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";

View File

@ -1,5 +1,5 @@
{
"name": "@0x/contracts-tokens",
"name": "@0x/contracts-erc20",
"version": "1.0.6",
"engines": {
"node": ">=6.12"
@ -32,7 +32,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|DummyERC721Receiver|InvalidERC721Receiver|DummyERC721Token|ReentrantERC20Token|ERC20Token|IERC20Token|MintableERC20Token|UnlimitedAllowanceERC20Token|ERC721Token|IERC721Receiver|IERC721Token|MintableERC721Token|IEtherToken|WETH9|ERC20Token_v1|Token_v1|UnlimitedAllowanceToken_v1|ZRXToken).json"
"abis": "generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ReentrantERC20Token|ERC20Token|IERC20Token|MintableERC20Token|UnlimitedAllowanceERC20Token|IEtherToken|WETH9|ZRXToken).json"
},
"repository": {
"type": "git",

View File

@ -1,24 +1,14 @@
import { ContractArtifact } from 'ethereum-types';
import * as DummyERC20Token from '../../generated-artifacts/DummyERC20Token.json';
import * as DummyERC721Receiver from '../../generated-artifacts/DummyERC721Receiver.json';
import * as DummyERC721Token from '../../generated-artifacts/DummyERC721Token.json';
import * as DummyMultipleReturnERC20Token from '../../generated-artifacts/DummyMultipleReturnERC20Token.json';
import * as DummyNoReturnERC20Token from '../../generated-artifacts/DummyNoReturnERC20Token.json';
import * as ERC20Token from '../../generated-artifacts/ERC20Token.json';
import * as ERC20Token_v1 from '../../generated-artifacts/ERC20Token_v1.json';
import * as ERC721Token from '../../generated-artifacts/ERC721Token.json';
import * as IERC20Token from '../../generated-artifacts/IERC20Token.json';
import * as IERC721Receiver from '../../generated-artifacts/IERC721Receiver.json';
import * as IERC721Token from '../../generated-artifacts/IERC721Token.json';
import * as IEtherToken from '../../generated-artifacts/IEtherToken.json';
import * as InvalidERC721Receiver from '../../generated-artifacts/InvalidERC721Receiver.json';
import * as MintableERC20Token from '../../generated-artifacts/MintableERC20Token.json';
import * as MintableERC721Token from '../../generated-artifacts/MintableERC721Token.json';
import * as ReentrantERC20Token from '../../generated-artifacts/ReentrantERC20Token.json';
import * as Token_v1 from '../../generated-artifacts/Token_v1.json';
import * as UnlimitedAllowanceERC20Token from '../../generated-artifacts/UnlimitedAllowanceERC20Token.json';
import * as UnlimitedAllowanceToken_v1 from '../../generated-artifacts/UnlimitedAllowanceToken_v1.json';
import * as WETH9 from '../../generated-artifacts/WETH9.json';
import * as ZRXToken from '../../generated-artifacts/ZRXToken.json';
@ -27,23 +17,13 @@ export const artifacts = {
DummyERC20Token: DummyERC20Token as ContractArtifact,
DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact,
DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact,
DummyERC721Receiver: DummyERC721Receiver as ContractArtifact,
InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact,
DummyERC721Token: DummyERC721Token as ContractArtifact,
ReentrantERC20Token: ReentrantERC20Token as ContractArtifact,
ERC20Token: ERC20Token as ContractArtifact,
IERC20Token: IERC20Token as ContractArtifact,
MintableERC20Token: MintableERC20Token as ContractArtifact,
UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact,
ERC721Token: ERC721Token as ContractArtifact,
IERC721Receiver: IERC721Receiver as ContractArtifact,
IERC721Token: IERC721Token as ContractArtifact,
MintableERC721Token: MintableERC721Token as ContractArtifact,
IEtherToken: IEtherToken as ContractArtifact,
WETH9: WETH9 as ContractArtifact,
ERC20Token_v1: ERC20Token_v1 as ContractArtifact,
Token_v1: Token_v1 as ContractArtifact,
UnlimitedAllowanceToken_v1: UnlimitedAllowanceToken_v1 as ContractArtifact,
// Note(albrow): "as any" hack still required here because ZRXToken does not
// conform to the v2 artifact type.
ZRXToken: (ZRXToken as any) as ContractArtifact,

View File

@ -1,21 +1,11 @@
export * from '../../generated-wrappers/zrx_token';
export * from '../../generated-wrappers/weth9';
export * from '../../generated-wrappers/unlimitedallowancetoken_v1';
export * from '../../generated-wrappers/unlimited_allowance_erc20_token';
export * from '../../generated-wrappers/token_v1';
export * from '../../generated-wrappers/reentrant_erc20_token';
export * from '../../generated-wrappers/mintable_erc721_token';
export * from '../../generated-wrappers/mintable_erc20_token';
export * from '../../generated-wrappers/invalid_erc721_receiver';
export * from '../../generated-wrappers/i_ether_token';
export * from '../../generated-wrappers/i_erc721_token';
export * from '../../generated-wrappers/i_erc721_receiver';
export * from '../../generated-wrappers/i_erc20_token';
export * from '../../generated-wrappers/erc721_token';
export * from '../../generated-wrappers/erc20token_v1';
export * from '../../generated-wrappers/erc20_token';
export * from '../../generated-wrappers/dummy_no_return_erc20_token';
export * from '../../generated-wrappers/dummy_multiple_return_erc20_token';
export * from '../../generated-wrappers/dummy_erc721_token';
export * from '../../generated-wrappers/dummy_erc721_receiver';
export * from '../../generated-wrappers/dummy_erc20_token';

View File

@ -10,23 +10,13 @@
"./generated-artifacts/DummyERC20Token.json",
"./generated-artifacts/DummyMultipleReturnERC20Token.json",
"./generated-artifacts/DummyNoReturnERC20Token.json",
"./generated-artifacts/DummyERC721Receiver.json",
"./generated-artifacts/InvalidERC721Receiver.json",
"./generated-artifacts/DummyERC721Token.json",
"./generated-artifacts/ReentrantERC20Token.json",
"./generated-artifacts/ERC20Token.json",
"./generated-artifacts/IERC20Token.json",
"./generated-artifacts/MintableERC20Token.json",
"./generated-artifacts/UnlimitedAllowanceERC20Token.json",
"./generated-artifacts/ERC721Token.json",
"./generated-artifacts/IERC721Receiver.json",
"./generated-artifacts/IERC721Token.json",
"./generated-artifacts/MintableERC721Token.json",
"./generated-artifacts/IEtherToken.json",
"./generated-artifacts/WETH9.json",
"./generated-artifacts/ERC20Token_v1.json",
"./generated-artifacts/Token_v1.json",
"./generated-artifacts/UnlimitedAllowanceToken_v1.json",
"./generated-artifacts/ZRXToken.json"
],
"exclude": ["./deploy/solc/solc_bin"]

View File

@ -0,0 +1,56 @@
[
{
"version": "2.0.0",
"changes": [
{
"note": "Upgrade the bignumber.js to v8.0.2",
"pr": 1517
}
]
},
{
"timestamp": 1547747677,
"version": "1.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1547561734,
"version": "1.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1547225310,
"version": "1.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1547040760,
"version": "1.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1544741676,
"version": "1.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
}
]

View File

@ -0,0 +1,26 @@
<!--
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
Edit the package's CHANGELOG.json file only.
-->
CHANGELOG
## v1.0.6 - _January 17, 2019_
* Dependencies updated
## v1.0.5 - _January 15, 2019_
* Dependencies updated
## v1.0.4 - _January 11, 2019_
* Dependencies updated
## v1.0.3 - _January 9, 2019_
* Dependencies updated
## v1.0.2 - _December 13, 2018_
* Dependencies updated

View File

@ -0,0 +1,16 @@
[
{
"name": "ZRXToken",
"version": "1.0.0",
"changes": [
{
"note": "protocol v1 deploy",
"networks": {
"1": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"3": "0xff67881f8d12f372d91baae9752eb3631ff0ed00",
"42": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa"
}
}
]
}
]

View File

@ -0,0 +1,74 @@
## Token contracts
Token smart contracts that are used in the 0x protocol. Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [CHANGELOG](./CHANGELOG.json) of this package.
## Usage
Token contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories:
- [tokens](./contracts/tokens)
- This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md).
- [test](./contracts/test)
- This directory contains mocks and other contracts that are used solely for testing contracts within the other directories.
## Bug bounty
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty).
## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
PKG=@0x/contracts-tokens yarn build
```
Or continuously rebuild on change:
```bash
PKG=@0x/contracts-tokens yarn watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```
#### Testing options
Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md).

View File

@ -0,0 +1,30 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"compilerSettings": {
"optimizer": {
"enabled": true,
"runs": 1000000
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
}
},
"contracts": [
"DummyERC721Receiver",
"InvalidERC721Receiver",
"DummyERC721Token",
"ERC721Token",
"IERC721Receiver",
"IERC721Token",
"MintableERC721Token"
]
}

View File

@ -18,8 +18,8 @@
pragma solidity ^0.4.24;
import "./IERC721Token.sol";
import "./IERC721Receiver.sol";
import "./interfaces/IERC721Token.sol";
import "./interfaces/IERC721Receiver.sol";
import "@0x/contracts-utils/contracts/src/SafeMath.sol";

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../ERC721Token/IERC721Receiver.sol";
import "../src/interfaces/IERC721Receiver.sol";
contract DummyERC721Receiver is

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../ERC721Token/MintableERC721Token.sol";
import "../src/MintableERC721Token.sol";
import "@0x/contracts-utils/contracts/src/Ownable.sol";

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../ERC721Token/IERC721Receiver.sol";
import "../src/interfaces/IERC721Receiver.sol";
contract InvalidERC721Receiver is

View File

@ -0,0 +1,89 @@
{
"name": "@0x/contracts-erc721",
"version": "1.0.6",
"engines": {
"node": ">=6.12"
},
"description": "Token contracts used by 0x protocol",
"main": "lib/src/index.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build:ci": "yarn build",
"pre_build": "run-s compile generate_contract_wrappers",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile": "sol-compiler",
"watch": "sol-compiler -w",
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
"profiler:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test",
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "generated-artifacts/@(DummyERC721Receiver|InvalidERC721Receiver|DummyERC721Token|ERC721Token|IERC721Receiver|IERC721Token|MintableERC721Token).json"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^1.0.22",
"@0x/contracts-test-utils": "^2.0.1",
"@0x/dev-utils": "^1.0.24",
"@0x/sol-compiler": "^2.0.2",
"@0x/subproviders": "^2.1.11",
"@0x/tslint-config": "^2.0.2",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"@types/node": "*",
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereumjs-abi": "0.6.5",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"solhint": "^1.4.1",
"tslint": "5.11.0",
"typescript": "3.0.1",
"yargs": "^10.0.3"
},
"dependencies": {
"@0x/base-contract": "^3.0.13",
"@0x/contracts-exchange-libs": "^1.0.6",
"@0x/contracts-utils": "^1.0.6",
"@0x/order-utils": "^3.1.2",
"@0x/types": "^1.5.2",
"@0x/typescript-typings": "^3.0.8",
"@0x/utils": "^3.0.1",
"@0x/web3-wrapper": "^3.2.4",
"@types/js-combinatorics": "^0.5.29",
"bn.js": "^4.11.8",
"ethereum-types": "^1.1.6",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.5"
},
"publishConfig": {
"access": "public"
}
}

View File

@ -0,0 +1,20 @@
import { ContractArtifact } from 'ethereum-types';
import * as DummyERC721Receiver from '../../generated-artifacts/DummyERC721Receiver.json';
import * as DummyERC721Token from '../../generated-artifacts/DummyERC721Token.json';
import * as ERC721Token from '../../generated-artifacts/ERC721Token.json';
import * as IERC721Receiver from '../../generated-artifacts/IERC721Receiver.json';
import * as IERC721Token from '../../generated-artifacts/IERC721Token.json';
import * as InvalidERC721Receiver from '../../generated-artifacts/InvalidERC721Receiver.json';
import * as MintableERC721Token from '../../generated-artifacts/MintableERC721Token.json';
// tslint:disable:no-unnecessary-type-assertion
export const artifacts = {
DummyERC721Receiver: DummyERC721Receiver as ContractArtifact,
InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact,
DummyERC721Token: DummyERC721Token as ContractArtifact,
ERC721Token: ERC721Token as ContractArtifact,
IERC721Receiver: IERC721Receiver as ContractArtifact,
IERC721Token: IERC721Token as ContractArtifact,
MintableERC721Token: MintableERC721Token as ContractArtifact,
};

View File

@ -0,0 +1,2 @@
export * from './wrappers';
export * from './artifacts';

View File

@ -0,0 +1,7 @@
export * from '../../generated-wrappers/mintable_erc721_token';
export * from '../../generated-wrappers/invalid_erc721_receiver';
export * from '../../generated-wrappers/i_erc721_token';
export * from '../../generated-wrappers/i_erc721_receiver';
export * from '../../generated-wrappers/erc721_token';
export * from '../../generated-wrappers/dummy_erc721_token';
export * from '../../generated-wrappers/dummy_erc721_receiver';

View File

@ -0,0 +1,17 @@
import { env, EnvVars } from '@0x/dev-utils';
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
before('start web3 provider', () => {
provider.start();
});
after('generate coverage report', async () => {
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
await coverageSubprovider.writeCoverageAsync();
}
if (env.parseBoolean(EnvVars.SolidityProfiler)) {
const profilerSubprovider = profiler.getProfilerSubproviderSingleton();
await profilerSubprovider.writeProfilerOutputAsync();
}
provider.stop();
});

View File

@ -0,0 +1,19 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": ".",
"resolveJsonModule": true
},
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"./generated-artifacts/DummyERC721Receiver.json",
"./generated-artifacts/InvalidERC721Receiver.json",
"./generated-artifacts/DummyERC721Token.json",
"./generated-artifacts/ERC721Token.json",
"./generated-artifacts/IERC721Receiver.json",
"./generated-artifacts/IERC721Token.json",
"./generated-artifacts/MintableERC721Token.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}

View File

@ -0,0 +1,6 @@
{
"extends": ["@0x/tslint-config"],
"rules": {
"custom-no-magic-numbers": false
}
}

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "@0x/contracts-tokens/contracts/ERC20Token/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
// solhint-disable no-unused-vars

View File

@ -73,7 +73,8 @@
"@0x/contracts-exchange-libs": "^1.0.6",
"@0x/contracts-multisig": "^1.0.6",
"@0x/contracts-test-utils": "^2.0.1",
"@0x/contracts-tokens": "^1.0.6",
"@0x/contracts-erc20": "^1.0.6",
"@0x/contracts-erc721": "^1.0.6",
"@0x/contracts-utils": "^1.0.6",
"@0x/order-utils": "^3.1.2",
"@0x/types": "^1.5.2",

View File

@ -1,9 +1,19 @@
import {
artifacts as proxyArtifacts,
ERC20ProxyContract,
ERC20Wrapper,
ERC721ProxyContract,
ERC721Wrapper,
MultiAssetProxyContract,
} from '@0x/contracts-asset-proxy';
import {
artifacts as erc20Artifacts,
DummyERC20TokenContract,
DummyERC20TokenTransferEventArgs,
DummyNoReturnERC20TokenContract,
ReentrantERC20TokenContract,
} from '@0x/contracts-erc20';
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import {
chaiSetup,
constants,
@ -17,14 +27,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import {
artifacts as tokensArtifacts,
DummyERC20TokenContract,
DummyERC20TokenTransferEventArgs,
DummyERC721TokenContract,
DummyNoReturnERC20TokenContract,
ReentrantERC20TokenContract,
} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
@ -35,13 +37,13 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import { ExchangeCancelEventArgs, ExchangeContract } from '../generated-wrappers/exchange';
import { TestStaticCallReceiverContract } from '../generated-wrappers/test_static_call_receiver';
import { artifacts } from '../src/artifacts';
import { ERC20Wrapper } from './utils/erc20_wrapper';
import { ERC721Wrapper } from './utils/erc721_wrapper';
import { ExchangeWrapper } from './utils/exchange_wrapper';
import {
artifacts,
ExchangeCancelEventArgs,
ExchangeContract,
ExchangeWrapper,
TestStaticCallReceiverContract,
} from '../src';
chaiSetup.configure();
const expect = chai.expect;
@ -118,7 +120,7 @@ describe('Exchange core', () => {
txDefaults,
);
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.ReentrantERC20Token,
erc20Artifacts.ReentrantERC20Token,
provider,
txDefaults,
exchange.address,
@ -343,7 +345,7 @@ describe('Exchange core', () => {
describe('Testing exchange of ERC20 tokens with no return values', () => {
before(async () => {
noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.DummyNoReturnERC20Token,
erc20Artifacts.DummyNoReturnERC20Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,

View File

@ -1,4 +1,11 @@
import { artifacts as proxyArtifacts, ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
import {
artifacts as proxyArtifacts,
ERC20ProxyContract,
ERC20Wrapper,
ERC721ProxyContract,
ERC721Wrapper,
} from '@0x/contracts-asset-proxy';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
import {
chaiSetup,
constants,
@ -8,7 +15,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { DummyERC20TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { AssetProxyId, RevertReason } from '@0x/types';
@ -18,13 +24,10 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
import {
artifacts,
TestAssetProxyDispatcherAssetProxyRegisteredEventArgs,
TestAssetProxyDispatcherContract,
} from '../generated-wrappers/test_asset_proxy_dispatcher';
import { artifacts } from '../src/artifacts';
import { ERC20Wrapper } from './utils/erc20_wrapper';
import { ERC721Wrapper } from './utils/erc721_wrapper';
} from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -16,10 +16,7 @@ import {
import { BlockchainLifecycle } from '@0x/dev-utils';
import * as _ from 'lodash';
import {
FillOrderCombinatorialUtils,
fillOrderCombinatorialUtilsFactoryAsync,
} from './utils/fill_order_combinatorial_utils';
import { FillOrderCombinatorialUtils, fillOrderCombinatorialUtilsFactoryAsync } from '../src';
chaiSetup.configure();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);

View File

@ -16,8 +16,7 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import { TestExchangeInternalsContract } from '../generated-wrappers/test_exchange_internals';
import { artifacts } from '../src/artifacts';
import { artifacts, TestExchangeInternalsContract } from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -1,4 +1,6 @@
import { ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
import { ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { artifacts as erc20Artifacts, DummyERC20TokenContract, ReentrantERC20TokenContract } from '@0x/contracts-erc20';
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import {
chaiSetup,
constants,
@ -10,12 +12,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import {
artifacts as tokensArtifacts,
DummyERC20TokenContract,
DummyERC721TokenContract,
ReentrantERC20TokenContract,
} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason } from '@0x/types';
@ -24,14 +20,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
import { ExchangeContract } from '../generated-wrappers/exchange';
import { TestExchangeInternalsContract } from '../generated-wrappers/test_exchange_internals';
import { artifacts } from '../src/artifacts';
import { ERC20Wrapper } from './utils/erc20_wrapper';
import { ERC721Wrapper } from './utils/erc721_wrapper';
import { ExchangeWrapper } from './utils/exchange_wrapper';
import { MatchOrderTester } from './utils/match_order_tester';
import { artifacts, ExchangeContract, ExchangeWrapper, MatchOrderTester, TestExchangeInternalsContract } from '../src';
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
@ -142,7 +131,7 @@ describe('matchOrders', () => {
);
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.ReentrantERC20Token,
erc20Artifacts.ReentrantERC20Token,
provider,
txDefaults,
exchange.address,

View File

@ -1,3 +1,4 @@
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import {
addressUtils,
chaiSetup,
@ -9,7 +10,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils';
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
@ -78,7 +78,7 @@ describe('MixinSignatureValidator', () => {
provider,
txDefaults,
);
signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokensArtifacts });
signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts });
await web3Wrapper.awaitTransactionSuccessAsync(
await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(testValidator.address, true, {
from: signerAddress,

View File

@ -1,4 +1,5 @@
import { ERC20ProxyContract } from '@0x/contracts-asset-proxy';
import { ERC20ProxyContract, ERC20Wrapper } from '@0x/contracts-asset-proxy';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
import {
chaiSetup,
constants,
@ -12,7 +13,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { DummyERC20TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0x/types';
@ -20,11 +20,7 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import { ExchangeContract } from '../generated-wrappers/exchange';
import { artifacts, ExchangeWrapperContract, WhitelistContract } from '../src/';
import { ERC20Wrapper } from './utils/erc20_wrapper';
import { ExchangeWrapper } from './utils/exchange_wrapper';
import { artifacts, ExchangeContract, ExchangeWrapper, ExchangeWrapperContract, WhitelistContract } from '../src/';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -4,8 +4,7 @@ import { AssetProxyId } from '@0x/types';
import { BigNumber, errorUtils } from '@0x/utils';
import * as _ from 'lodash';
import { ERC20Wrapper } from './erc20_wrapper';
import { ERC721Wrapper } from './erc721_wrapper';
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
interface ProxyIdToAssetWrappers {
[proxyId: string]: AbstractAssetWrapper;
@ -28,11 +27,13 @@ export class AssetWrapper {
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) {
case AssetProxyId.ERC20: {
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
const balance = await erc20Wrapper.getBalanceAsync(userAddress, assetData);
return balance;
}
case AssetProxyId.ERC721: {
// tslint:disable-next-line:no-unnecessary-type-assertion
const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
const assetProxyData = assetDataUtils.decodeERC721AssetData(assetData);
const isOwner = await assetWrapper.isOwnerAsync(
@ -51,6 +52,7 @@ export class AssetWrapper {
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) {
case AssetProxyId.ERC20: {
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
await erc20Wrapper.setBalanceAsync(userAddress, assetData, desiredBalance);
return;
@ -59,6 +61,7 @@ export class AssetWrapper {
if (!desiredBalance.eq(0) && !desiredBalance.eq(1)) {
throw new Error(`Balance for ERC721 token can only be set to 0 or 1. Got: ${desiredBalance}`);
}
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
const assetProxyData = assetDataUtils.decodeERC721AssetData(assetData);
const doesTokenExist = erc721Wrapper.doesTokenExistAsync(
@ -109,11 +112,13 @@ export class AssetWrapper {
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) {
case AssetProxyId.ERC20: {
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
const allowance = await erc20Wrapper.getProxyAllowanceAsync(userAddress, assetData);
return allowance;
}
case AssetProxyId.ERC721: {
// tslint:disable-next-line:no-unnecessary-type-assertion
const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
const erc721ProxyData = assetDataUtils.decodeERC721AssetData(assetData);
const isProxyApprovedForAll = await assetWrapper.isProxyApprovedForAllAsync(
@ -143,6 +148,7 @@ export class AssetWrapper {
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) {
case AssetProxyId.ERC20: {
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
await erc20Wrapper.setAllowanceAsync(userAddress, assetData, desiredAllowance);
return;
@ -157,6 +163,7 @@ export class AssetWrapper {
`Allowance for ERC721 token can only be set to 0, 1 or 2^256-1. Got: ${desiredAllowance}`,
);
}
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
const assetProxyData = assetDataUtils.decodeERC721AssetData(assetData);

View File

@ -1,177 +0,0 @@
import { artifacts as proxyArtifacts, ERC20ProxyContract } from '@0x/contracts-asset-proxy';
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts, DummyERC20TokenContract } from '@0x/contracts-tokens';
import { assetDataUtils } from '@0x/order-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
export class ERC20Wrapper {
private readonly _tokenOwnerAddresses: string[];
private readonly _contractOwnerAddress: string;
private readonly _web3Wrapper: Web3Wrapper;
private readonly _provider: Provider;
private readonly _dummyTokenContracts: DummyERC20TokenContract[];
private _proxyContract?: ERC20ProxyContract;
private _proxyIdIfExists?: string;
/**
* Instanitates an ERC20Wrapper
* @param provider Web3 provider to use for all JSON RPC requests
* @param tokenOwnerAddresses Addresses that we want to endow as owners for dummy ERC20 tokens
* @param contractOwnerAddress Desired owner of the contract
* Instance of ERC20Wrapper
*/
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._dummyTokenContracts = [];
this._web3Wrapper = new Web3Wrapper(provider);
this._provider = provider;
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
}
public async deployDummyTokensAsync(
numberToDeploy: number,
decimals: BigNumber,
): Promise<DummyERC20TokenContract[]> {
for (let i = 0; i < numberToDeploy; i++) {
this._dummyTokenContracts.push(
await DummyERC20TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.DummyERC20Token,
this._provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL,
decimals,
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
),
);
}
return this._dummyTokenContracts;
}
public async deployProxyAsync(): Promise<ERC20ProxyContract> {
this._proxyContract = await ERC20ProxyContract.deployFrom0xArtifactAsync(
proxyArtifacts.ERC20Proxy,
this._provider,
txDefaults,
);
this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync();
return this._proxyContract;
}
public getProxyId(): string {
this._validateProxyContractExistsOrThrow();
return this._proxyIdIfExists as string;
}
public async setBalancesAndAllowancesAsync(): Promise<void> {
this._validateDummyTokenContractsExistOrThrow();
this._validateProxyContractExistsOrThrow();
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
await this._web3Wrapper.awaitTransactionSuccessAsync(
await dummyTokenContract.setBalance.sendTransactionAsync(
tokenOwnerAddress,
constants.INITIAL_ERC20_BALANCE,
{ from: this._contractOwnerAddress },
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
await this._web3Wrapper.awaitTransactionSuccessAsync(
await dummyTokenContract.approve.sendTransactionAsync(
(this._proxyContract as ERC20ProxyContract).address,
constants.INITIAL_ERC20_ALLOWANCE,
{ from: tokenOwnerAddress },
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
}
}
public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
const tokenContract = this._getTokenContractFromAssetData(assetData);
const balance = new BigNumber(await tokenContract.balanceOf.callAsync(userAddress));
return balance;
}
public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(assetData);
await this._web3Wrapper.awaitTransactionSuccessAsync(
await tokenContract.setBalance.sendTransactionAsync(userAddress, amount, {
from: this._contractOwnerAddress,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
const tokenContract = this._getTokenContractFromAssetData(assetData);
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
const allowance = new BigNumber(await tokenContract.allowance.callAsync(userAddress, proxyAddress));
return allowance;
}
public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(assetData);
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
await this._web3Wrapper.awaitTransactionSuccessAsync(
await tokenContract.approve.sendTransactionAsync(proxyAddress, amount, {
from: userAddress,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
public async getBalancesAsync(): Promise<ERC20BalancesByOwner> {
this._validateDummyTokenContractsExistOrThrow();
const balancesByOwner: ERC20BalancesByOwner = {};
const balances: BigNumber[] = [];
const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = [];
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
balances.push(await dummyTokenContract.balanceOf.callAsync(tokenOwnerAddress));
balanceInfo.push({
tokenOwnerAddress,
tokenAddress: dummyTokenContract.address,
});
}
}
_.forEach(balances, (balance, balanceIndex) => {
const tokenAddress = balanceInfo[balanceIndex].tokenAddress;
const tokenOwnerAddress = balanceInfo[balanceIndex].tokenOwnerAddress;
if (_.isUndefined(balancesByOwner[tokenOwnerAddress])) {
balancesByOwner[tokenOwnerAddress] = {};
}
const wrappedBalance = new BigNumber(balance);
balancesByOwner[tokenOwnerAddress][tokenAddress] = wrappedBalance;
});
return balancesByOwner;
}
public addDummyTokenContract(dummy: DummyERC20TokenContract): void {
if (!_.isUndefined(this._dummyTokenContracts)) {
this._dummyTokenContracts.push(dummy);
}
}
public addTokenOwnerAddress(address: string): void {
this._tokenOwnerAddresses.push(address);
}
public getTokenOwnerAddresses(): string[] {
return this._tokenOwnerAddresses;
}
public getTokenAddresses(): string[] {
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
private _getTokenContractFromAssetData(assetData: string): DummyERC20TokenContract {
const erc20ProxyData = assetDataUtils.decodeERC20AssetData(assetData);
const tokenAddress = erc20ProxyData.tokenAddress;
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
if (_.isUndefined(tokenContractIfExists)) {
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
}
return tokenContractIfExists;
}
private _validateDummyTokenContractsExistOrThrow(): void {
if (_.isUndefined(this._dummyTokenContracts)) {
throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
}
}
private _validateProxyContractExistsOrThrow(): void {
if (_.isUndefined(this._proxyContract)) {
throw new Error('ERC20 proxy contract not yet deployed, please call "deployProxyAsync"');
}
}
}

View File

@ -1,234 +0,0 @@
import { artifacts as proxyArtifacts, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts, DummyERC721TokenContract } from '@0x/contracts-tokens';
import { generatePseudoRandomSalt } from '@0x/order-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
export class ERC721Wrapper {
private readonly _tokenOwnerAddresses: string[];
private readonly _contractOwnerAddress: string;
private readonly _web3Wrapper: Web3Wrapper;
private readonly _provider: Provider;
private readonly _dummyTokenContracts: DummyERC721TokenContract[];
private _proxyContract?: ERC721ProxyContract;
private _proxyIdIfExists?: string;
private _initialTokenIdsByOwner: ERC721TokenIdsByOwner = {};
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._web3Wrapper = new Web3Wrapper(provider);
this._provider = provider;
this._dummyTokenContracts = [];
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
}
public async deployDummyTokensAsync(): Promise<DummyERC721TokenContract[]> {
// tslint:disable-next-line:no-unused-variable
for (const i of _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY)) {
this._dummyTokenContracts.push(
await DummyERC721TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.DummyERC721Token,
this._provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL,
),
);
}
return this._dummyTokenContracts;
}
public async deployProxyAsync(): Promise<ERC721ProxyContract> {
this._proxyContract = await ERC721ProxyContract.deployFrom0xArtifactAsync(
proxyArtifacts.ERC721Proxy,
this._provider,
txDefaults,
);
this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync();
return this._proxyContract;
}
public getProxyId(): string {
this._validateProxyContractExistsOrThrow();
return this._proxyIdIfExists as string;
}
public async setBalancesAndAllowancesAsync(): Promise<void> {
this._validateDummyTokenContractsExistOrThrow();
this._validateProxyContractExistsOrThrow();
this._initialTokenIdsByOwner = {};
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
// tslint:disable-next-line:no-unused-variable
for (const i of _.times(constants.NUM_ERC721_TOKENS_TO_MINT)) {
const tokenId = generatePseudoRandomSalt();
await this.mintAsync(dummyTokenContract.address, tokenId, tokenOwnerAddress);
if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress])) {
this._initialTokenIdsByOwner[tokenOwnerAddress] = {
[dummyTokenContract.address]: [],
};
}
if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address])) {
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] = [];
}
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId);
await this.approveProxyAsync(dummyTokenContract.address, tokenId);
}
}
}
}
public async doesTokenExistAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const owner = await tokenContract.ownerOf.callAsync(tokenId);
const doesExist = owner !== constants.NULL_ADDRESS;
return doesExist;
}
public async approveProxyAsync(tokenAddress: string, tokenId: BigNumber): Promise<void> {
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
await this.approveAsync(proxyAddress, tokenAddress, tokenId);
}
public async approveProxyForAllAsync(tokenAddress: string, tokenId: BigNumber, isApproved: boolean): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
await this._web3Wrapper.awaitTransactionSuccessAsync(
await tokenContract.setApprovalForAll.sendTransactionAsync(proxyAddress, isApproved, {
from: tokenOwner,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
await this._web3Wrapper.awaitTransactionSuccessAsync(
await tokenContract.approve.sendTransactionAsync(to, tokenId, {
from: tokenOwner,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
public async transferFromAsync(
tokenAddress: string,
tokenId: BigNumber,
currentOwner: string,
userAddress: string,
): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
await this._web3Wrapper.awaitTransactionSuccessAsync(
await tokenContract.transferFrom.sendTransactionAsync(currentOwner, userAddress, tokenId, {
from: currentOwner,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
await this._web3Wrapper.awaitTransactionSuccessAsync(
await tokenContract.mint.sendTransactionAsync(userAddress, tokenId, {
from: this._contractOwnerAddress,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
await this._web3Wrapper.awaitTransactionSuccessAsync(
await tokenContract.burn.sendTransactionAsync(owner, tokenId, {
from: this._contractOwnerAddress,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
}
public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise<string> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const owner = await tokenContract.ownerOf.callAsync(tokenId);
return owner;
}
public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const tokenOwner = await tokenContract.ownerOf.callAsync(tokenId);
const isOwner = tokenOwner === userAddress;
return isOwner;
}
public async isProxyApprovedForAllAsync(userAddress: string, tokenAddress: string): Promise<boolean> {
this._validateProxyContractExistsOrThrow();
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const operator = (this._proxyContract as ERC721ProxyContract).address;
const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator);
return didApproveAll;
}
public async isProxyApprovedAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
this._validateProxyContractExistsOrThrow();
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const approvedAddress = await tokenContract.getApproved.callAsync(tokenId);
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
const isProxyAnApprovedOperator = approvedAddress === proxyAddress;
return isProxyAnApprovedOperator;
}
public async getBalancesAsync(): Promise<ERC721TokenIdsByOwner> {
this._validateDummyTokenContractsExistOrThrow();
this._validateBalancesAndAllowancesSetOrThrow();
const tokenIdsByOwner: ERC721TokenIdsByOwner = {};
const tokenOwnerAddresses: string[] = [];
const tokenInfo: Array<{ tokenId: BigNumber; tokenAddress: string }> = [];
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
const initialTokenOwnerIds = this._initialTokenIdsByOwner[tokenOwnerAddress][
dummyTokenContract.address
];
for (const tokenId of initialTokenOwnerIds) {
tokenOwnerAddresses.push(await dummyTokenContract.ownerOf.callAsync(tokenId));
tokenInfo.push({
tokenId,
tokenAddress: dummyTokenContract.address,
});
}
}
}
_.forEach(tokenOwnerAddresses, (tokenOwnerAddress, ownerIndex) => {
const tokenAddress = tokenInfo[ownerIndex].tokenAddress;
const tokenId = tokenInfo[ownerIndex].tokenId;
if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress])) {
tokenIdsByOwner[tokenOwnerAddress] = {
[tokenAddress]: [],
};
}
if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress][tokenAddress])) {
tokenIdsByOwner[tokenOwnerAddress][tokenAddress] = [];
}
tokenIdsByOwner[tokenOwnerAddress][tokenAddress].push(tokenId);
});
return tokenIdsByOwner;
}
public getTokenOwnerAddresses(): string[] {
return this._tokenOwnerAddresses;
}
public getTokenAddresses(): string[] {
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
private _getTokenContractFromAssetData(tokenAddress: string): DummyERC721TokenContract {
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
if (_.isUndefined(tokenContractIfExists)) {
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
}
return tokenContractIfExists;
}
private _validateDummyTokenContractsExistOrThrow(): void {
if (_.isUndefined(this._dummyTokenContracts)) {
throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyTokensAsync"');
}
}
private _validateProxyContractExistsOrThrow(): void {
if (_.isUndefined(this._proxyContract)) {
throw new Error('ERC721 proxy contract not yet deployed, please call "deployProxyAsync"');
}
}
private _validateBalancesAndAllowancesSetOrThrow(): void {
if (_.keys(this._initialTokenIdsByOwner).length === 0) {
throw new Error(
'Dummy ERC721 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
);
}
}
}

View File

@ -1,3 +1,5 @@
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
import {
FillResults,
formatters,
@ -6,15 +8,13 @@ import {
orderUtils,
SignedTransaction,
} from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { SignedOrder } from '@0x/types';
import { AbiEncoder, BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { MethodAbi, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { artifacts } from '../../src/artifacts';
import { artifacts, ExchangeContract } from '../../src';
import { AbiDecodedFillOrderData } from './types';
@ -25,7 +25,7 @@ export class ExchangeWrapper {
constructor(exchangeContract: ExchangeContract, provider: Provider) {
this._exchange = exchangeContract;
this._web3Wrapper = new Web3Wrapper(provider);
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts });
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...erc20Artifacts, ...erc721Artifacts });
}
public async fillOrderAsync(
signedOrder: SignedOrder,

View File

@ -1,4 +1,5 @@
import { artifacts as libsArtifacts, TestLibsContract } from '@0x/contracts-libs';
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { artifacts as libsArtifacts, TestLibsContract } from '@0x/contracts-exchange-libs';
import {
AllowanceAmountScenario,
AssetDataScenario,
@ -32,12 +33,9 @@ import { LogWithDecodedArgs, Provider, TxData } from 'ethereum-types';
import * as _ from 'lodash';
import 'make-promises-safe';
import { ExchangeContract, ExchangeFillEventArgs } from '../../generated-wrappers/exchange';
import { artifacts } from '../../src/artifacts';
import { artifacts, ExchangeContract, ExchangeFillEventArgs } from '../../src';
import { AssetWrapper } from './asset_wrapper';
import { ERC20Wrapper } from './erc20_wrapper';
import { ERC721Wrapper } from './erc721_wrapper';
import { ExchangeWrapper } from './exchange_wrapper';
import { OrderFactoryFromScenario } from './order_factory_from_scenario';
import { SimpleAssetBalanceAndProxyAllowanceFetcher } from './simple_asset_balance_and_proxy_allowance_fetcher';

View File

@ -1,3 +1,3 @@
export * from './exchange_wrapper';
export * from './erc20_wrapper';
export * from './erc721_wrapper';
export * from './fill_order_combinatorial_utils';
export * from './match_order_tester';

View File

@ -1,3 +1,4 @@
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import {
chaiSetup,
ERC20BalancesByOwner,
@ -15,8 +16,6 @@ import * as _ from 'lodash';
import { TransactionReceiptWithDecodedLogs } from '../../../../node_modules/ethereum-types';
import { ERC20Wrapper } from './erc20_wrapper';
import { ERC721Wrapper } from './erc721_wrapper';
import { ExchangeWrapper } from './exchange_wrapper';
chaiSetup.configure();

View File

@ -1,3 +1,4 @@
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import {
AssetDataScenario,
constants,
@ -8,7 +9,6 @@ import {
OrderScenario,
TakerScenario,
} from '@0x/contracts-test-utils';
import { DummyERC721TokenContract } from '@0x/contracts-tokens';
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
import { Order } from '@0x/types';
import { BigNumber, errorUtils } from '@0x/utils';

View File

@ -1,4 +1,6 @@
import { ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
import { ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { artifacts as erc20Artifacts, DummyERC20TokenContract, ReentrantERC20TokenContract } from '@0x/contracts-erc20';
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import {
chaiSetup,
constants,
@ -12,12 +14,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import {
artifacts as tokensArtifacts,
DummyERC20TokenContract,
DummyERC721TokenContract,
ReentrantERC20TokenContract,
} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
@ -26,12 +22,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
import { ExchangeContract } from '../generated-wrappers/exchange';
import { artifacts } from '../src/artifacts';
import { ERC20Wrapper } from './utils/erc20_wrapper';
import { ERC721Wrapper } from './utils/erc721_wrapper';
import { ExchangeWrapper } from './utils/exchange_wrapper';
import { artifacts, ExchangeContract, ExchangeWrapper } from '../src';
chaiSetup.configure();
const expect = chai.expect;
@ -116,7 +107,7 @@ describe('Exchange wrappers', () => {
);
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
tokensArtifacts.ReentrantERC20Token,
erc20Artifacts.ReentrantERC20Token,
provider,
txDefaults,
exchange.address,

View File

@ -21,7 +21,7 @@ pragma experimental ABIEncoderV2;
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "@0x/contracts-tokens/contracts/ERC20Token/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/SafeMath.sol";

View File

@ -20,8 +20,8 @@ pragma solidity ^0.4.24;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/Ownable.sol";
import "@0x/contracts-tokens/contracts/ERC20Token/IERC20Token.sol";
import "@0x/contracts-tokens/contracts/ERC721Token/IERC721Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
import "./libs/LibConstants.sol";
import "./mixins/MAssets.sol";

View File

@ -20,8 +20,8 @@ pragma solidity ^0.4.24;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
import "@0x/contracts-tokens/contracts/EtherToken/IEtherToken.sol";
import "@0x/contracts-tokens/contracts/ERC20Token/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
contract LibConstants {

View File

@ -20,8 +20,8 @@ pragma solidity ^0.4.24;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/Ownable.sol";
import "@0x/contracts-tokens/contracts/ERC20Token/IERC20Token.sol";
import "@0x/contracts-tokens/contracts/ERC721Token/IERC721Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
import "./mixins/MAssets.sol";
import "./libs/LibConstants.sol";

View File

@ -21,8 +21,8 @@ pragma experimental ABIEncoderV2;
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "@0x/contracts-tokens/contracts/ERC20Token/IERC20Token.sol";
import "@0x/contracts-tokens/contracts/ERC721Token/IERC721Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
import "@0x/contracts-utils/contracts/src/LibBytes.sol";

View File

@ -74,7 +74,8 @@
"@0x/contracts-asset-proxy": "^2.2.3",
"@0x/contracts-exchange-libs": "^1.0.6",
"@0x/contracts-exchange": "^2.2.3",
"@0x/contracts-tokens": "^1.0.6",
"@0x/contracts-erc20": "^1.0.6",
"@0x/contracts-erc721": "^1.0.6",
"@0x/contracts-utils": "^1.0.6",
"@0x/order-utils": "^3.1.2",
"@0x/types": "^1.5.2",

View File

@ -1,2 +1,3 @@
export * from './artifacts';
export * from './wrappers';
export * from '../test/utils';

View File

@ -7,13 +7,9 @@ import * as chai from 'chai';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import {
artifacts as exchangeArtifacts,
ERC20Wrapper,
ERC721Wrapper,
ExchangeContract,
ExchangeWrapper,
} from '@0x/contracts-exchange';
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@ -27,11 +23,8 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { DummyERC20TokenContract } from '@0x/contracts-tokens';
import { BalanceThresholdFilterContract } from '../../generated-wrappers/balance_threshold_filter';
import { artifacts } from '../../src/artifacts';
import { BalanceThresholdWrapper } from '../utils/balance_threshold_wrapper';
import { artifacts, BalanceThresholdFilterContract, BalanceThresholdWrapper } from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -1,11 +1,8 @@
import { DutchAuctionWrapper } from '@0x/contract-wrappers';
import {
artifacts as exchangeArtifacts,
ERC20Wrapper,
ERC721Wrapper,
ExchangeContract,
ExchangeWrapper,
} from '@0x/contracts-exchange';
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { artifacts as erc20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20';
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@ -18,12 +15,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import {
artifacts as tokensArtifacts,
DummyERC20TokenContract,
DummyERC721TokenContract,
WETH9Contract,
} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
@ -32,9 +23,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
import { artifacts } from '../../src/artifacts';
import { DutchAuctionTestWrapper } from '../utils/dutch_auction_test_wrapper';
import { artifacts, DutchAuctionContract, DutchAuctionTestWrapper } from '../src';
chaiSetup.configure();
const expect = chai.expect;
@ -93,7 +82,7 @@ describe(ContractName.DutchAuction, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
wethContract = await WETH9Contract.deployFrom0xArtifactAsync(tokensArtifacts.WETH9, provider, txDefaults);
wethContract = await WETH9Contract.deployFrom0xArtifactAsync(erc20Artifacts.WETH9, provider, txDefaults);
erc20Wrapper.addDummyTokenContract(wethContract as any);
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);

View File

@ -1,10 +1,7 @@
import {
artifacts as exchangeArtifacts,
ERC20Wrapper,
ERC721Wrapper,
ExchangeContract,
ExchangeWrapper,
} from '@0x/contracts-exchange';
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { artifacts as erc20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20';
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@ -18,12 +15,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import {
artifacts as tokenArtifacts,
DummyERC20TokenContract,
DummyERC721TokenContract,
WETH9Contract,
} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
@ -32,10 +23,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import { ForwarderContract } from '../../generated-wrappers/forwarder';
import { artifacts } from '../../src/artifacts';
import { ForwarderWrapper } from '../utils/forwarder_wrapper';
import { artifacts, ForwarderContract, ForwarderWrapper } from '../src';
chaiSetup.configure();
const expect = chai.expect;
@ -100,7 +88,7 @@ describe(ContractName.Forwarder, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
wethContract = await WETH9Contract.deployFrom0xArtifactAsync(tokenArtifacts.WETH9, provider, txDefaults);
wethContract = await WETH9Contract.deployFrom0xArtifactAsync(erc20Artifacts.WETH9, provider, txDefaults);
weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider);
erc20Wrapper.addDummyTokenContract(weth);

View File

@ -1,7 +1,13 @@
import { artifacts as proxyArtifacts, ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
import {
artifacts as proxyArtifacts,
ERC20ProxyContract,
ERC20Wrapper,
ERC721ProxyContract,
} from '@0x/contracts-asset-proxy';
import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20';
import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
import {
artifacts as exchangeArtifacts,
ERC20Wrapper,
ExchangeContract,
ExchangeFillEventArgs,
ExchangeWrapper,
@ -19,7 +25,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { artifacts as tokenArtifacts, DummyERC20TokenContract, DummyERC721TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason } from '@0x/types';
@ -29,8 +34,7 @@ import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
import { OrderMatcherContract } from '../../generated-wrappers/order_matcher';
import { artifacts } from '../../src/artifacts';
import { artifacts, OrderMatcherContract } from '../src';
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
@ -450,7 +454,7 @@ describe('OrderMatcher', () => {
signedOrderLeft.signature,
signedOrderRight.signature,
);
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokenArtifacts, ...exchangeArtifacts });
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts, ...exchangeArtifacts });
const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
data,
@ -488,7 +492,7 @@ describe('OrderMatcher', () => {
signedOrderLeft.signature,
signedOrderRight.signature,
);
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokenArtifacts, ...exchangeArtifacts });
const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts, ...exchangeArtifacts });
const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
data,
@ -725,7 +729,7 @@ describe('OrderMatcher', () => {
});
it('should allow owner to withdraw ERC721 tokens', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
tokenArtifacts.DummyERC721Token,
erc721Artifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@ -770,7 +774,7 @@ describe('OrderMatcher', () => {
});
it('should be able to approve an ERC721 token by passing in allowance = 1', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
tokenArtifacts.DummyERC721Token,
erc721Artifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@ -787,7 +791,7 @@ describe('OrderMatcher', () => {
});
it('should be able to approve an ERC721 token by passing in allowance > 1', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
tokenArtifacts.DummyERC721Token,
erc721Artifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,

View File

@ -1,11 +1,7 @@
import { ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
import {
artifacts as exchangeArtifacts,
ERC20Wrapper,
ERC721Wrapper,
ExchangeContract,
ExchangeWrapper,
} from '@0x/contracts-exchange';
import { ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@ -15,7 +11,6 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { DummyERC20TokenContract, DummyERC721TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { SignedOrder } from '@0x/types';
@ -23,8 +18,7 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import { OrderValidatorContract } from '../../generated-wrappers/order_validator';
import { artifacts } from '../../src/artifacts/index';
import { artifacts, OrderValidatorContract } from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -1,3 +1,5 @@
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange';
import {
FillResults,
@ -7,7 +9,6 @@ import {
orderUtils,
TransactionFactory,
} from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
@ -35,7 +36,8 @@ export class BalanceThresholdWrapper {
this._web3Wrapper = new Web3Wrapper(provider);
this._logDecoder = new LogDecoder(this._web3Wrapper, {
...artifacts,
...tokensArtifacts,
...erc20Artifacts,
...erc721Artifacts,
...exchangeArtifacts,
});
}

View File

@ -1,6 +1,7 @@
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
import { artifacts as exchangeArtifacts } from '@0x/contracts-exchange';
import { LogDecoder } from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { DutchAuctionDetails, SignedOrder } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
@ -19,7 +20,8 @@ export class DutchAuctionTestWrapper {
this._web3Wrapper = new Web3Wrapper(provider);
this._logDecoder = new LogDecoder(this._web3Wrapper, {
...artifacts,
...tokensArtifacts,
...erc20Artifacts,
...erc721Artifacts,
...exchangeArtifacts,
});
}

View File

@ -1,6 +1,7 @@
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
import { artifacts as exchangeArtifacts } from '@0x/contracts-exchange';
import { constants, formatters, LogDecoder, MarketSellOrders } from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
@ -62,7 +63,8 @@ export class ForwarderWrapper {
this._web3Wrapper = new Web3Wrapper(provider);
this._logDecoder = new LogDecoder(this._web3Wrapper, {
...artifacts,
...tokensArtifacts,
...erc20Artifacts,
...erc721Artifacts,
...exchangeArtifacts,
});
}

View File

@ -0,0 +1,3 @@
export * from './balance_threshold_wrapper';
export * from './dutch_auction_test_wrapper';
export * from './forwarder_wrapper';

View File

@ -71,7 +71,7 @@
"dependencies": {
"@0x/base-contract": "^3.0.13",
"@0x/contracts-asset-proxy": "^2.2.3",
"@0x/contracts-tokens": "^1.0.6",
"@0x/contracts-erc20": "^1.0.6",
"@0x/order-utils": "^3.1.2",
"@0x/types": "^1.5.2",
"@0x/typescript-typings": "^3.0.8",

View File

@ -1,2 +1,3 @@
export * from './artifacts';
export * from './wrappers';
export * from '../test/utils';

View File

@ -1,2 +1,5 @@
export * from '../../generated-wrappers/asset_proxy_owner';
export * from '../../generated-wrappers/multi_sig_wallet';
export * from '../../generated-wrappers/multi_sig_wallet_with_time_lock';
export * from '../../generated-wrappers/test_asset_proxy_owner';
export * from '../../generated-wrappers/test_reject_ether';

View File

@ -19,16 +19,15 @@ import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import {
artifacts,
AssetProxyOwnerAssetProxyRegistrationEventArgs,
AssetProxyOwnerContract,
AssetProxyOwnerExecutionEventArgs,
AssetProxyOwnerExecutionFailureEventArgs,
AssetProxyOwnerSubmissionEventArgs,
} from '../generated-wrappers/asset_proxy_owner';
import { TestAssetProxyOwnerContract } from '../generated-wrappers/test_asset_proxy_owner';
import { artifacts } from '../src/artifacts';
import { AssetProxyOwnerWrapper } from './utils/asset_proxy_owner_wrapper';
AssetProxyOwnerWrapper,
TestAssetProxyOwnerContract,
} from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -16,17 +16,16 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
import {
artifacts,
MultiSigWalletWithTimeLockConfirmationEventArgs,
MultiSigWalletWithTimeLockConfirmationTimeSetEventArgs,
MultiSigWalletWithTimeLockContract,
MultiSigWalletWithTimeLockExecutionEventArgs,
MultiSigWalletWithTimeLockExecutionFailureEventArgs,
MultiSigWalletWithTimeLockSubmissionEventArgs,
} from '../generated-wrappers/multi_sig_wallet_with_time_lock';
import { TestRejectEtherContract } from '../generated-wrappers/test_reject_ether';
import { artifacts } from '../src/artifacts';
import { MultiSigWrapper } from './utils/multi_sig_wrapper';
MultiSigWrapper,
TestRejectEtherContract,
} from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -1,6 +1,6 @@
import { artifacts as proxyArtifacts } from '@0x/contracts-asset-proxy';
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
import { LogDecoder } from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
@ -16,7 +16,7 @@ export class AssetProxyOwnerWrapper {
constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) {
this._assetProxyOwner = assetproxyOwnerContract;
this._web3Wrapper = new Web3Wrapper(provider);
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts, ...proxyArtifacts });
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...erc20Artifacts, ...proxyArtifacts });
}
public async submitTransactionAsync(
destination: string,

View File

@ -0,0 +1,2 @@
export * from './asset_proxy_owner_wrapper';
export * from './multi_sig_wrapper';

View File

@ -1,44 +0,0 @@
pragma solidity ^0.4.11;
import { Token_v1 as Token } from "./Token_v1.sol";
contract ERC20Token_v1 is Token {
function transfer(address _to, uint _value) returns (bool) {
//Default assumes totalSupply can't be over max (2^256 - 1).
if (balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint _value) returns (bool) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant returns (uint) {
return balances[_owner];
}
function approve(address _spender, uint _value) returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint) {
return allowed[_owner][_spender];
}
mapping (address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
uint public totalSupply;
}

View File

@ -1,39 +0,0 @@
pragma solidity ^0.4.11;
contract Token_v1 {
/// @return total amount of tokens
function totalSupply() constant returns (uint supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint remaining) {}
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}

View File

@ -1,52 +0,0 @@
/*
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.11;
import { ERC20Token_v1 as ERC20Token } from "./ERC20Token_v1.sol";
contract UnlimitedAllowanceToken_v1 is ERC20Token {
uint constant MAX_UINT = 2**256 - 1;
/// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance.
/// @param _from Address to transfer from.
/// @param _to Address to transfer to.
/// @param _value Amount to transfer.
/// @return Success of transfer.
function transferFrom(address _from, address _to, uint _value)
public
returns (bool)
{
uint allowance = allowed[_from][msg.sender];
if (balances[_from] >= _value
&& allowance >= _value
&& balances[_to] + _value >= balances[_to]
) {
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT) {
allowed[_from][msg.sender] -= _value;
}
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}
}

Some files were not shown because too many files have changed in this diff Show More