Use an enum for contract name
This commit is contained in:
parent
6f13d107c4
commit
9d62e5fb6f
@ -5,6 +5,7 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
|
||||
import { constants } from '../util/constants';
|
||||
import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
@ -24,7 +25,7 @@ describe('EtherToken', () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
account = accounts[0];
|
||||
|
||||
const etherToken = await deployer.deployAsync('WETH9');
|
||||
const etherToken = await deployer.deployAsync(ContractName.EtherToken);
|
||||
etherTokenAddress = etherToken.address;
|
||||
zeroEx = new ZeroEx(web3.currentProvider, {
|
||||
gasPrice,
|
||||
|
@ -19,7 +19,7 @@ import { crypto } from '../../util/crypto';
|
||||
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
||||
import { Order } from '../../util/order';
|
||||
import { OrderFactory } from '../../util/order_factory';
|
||||
import { BalancesByOwner, ExchangeContractErrs } from '../../util/types';
|
||||
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
|
||||
@ -58,12 +58,12 @@ describe('Exchange', () => {
|
||||
taker = accounts[1] || accounts[accounts.length - 1];
|
||||
feeRecipient = accounts[2] || accounts[accounts.length - 1];
|
||||
[rep, dgd, zrx] = await Promise.all([
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
]);
|
||||
tokenTransferProxy = await deployer.deployAsync('TokenTransferProxy');
|
||||
exchange = await deployer.deployAsync('Exchange', [zrx.address, tokenTransferProxy.address]);
|
||||
tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
exchange = await deployer.deployAsync(ContractName.Exchange, [zrx.address, tokenTransferProxy.address]);
|
||||
await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] });
|
||||
zeroEx = new ZeroEx(web3.currentProvider, {
|
||||
exchangeContractAddress: exchange.address,
|
||||
@ -669,7 +669,7 @@ describe('Exchange', () => {
|
||||
|
||||
it('should throw if getBalance or getAllowance attempts to change state and \
|
||||
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||
const maliciousToken = await deployer.deployAsync('MaliciousToken');
|
||||
const maliciousToken = await deployer.deployAsync(ContractName.MaliciousToken);
|
||||
await maliciousToken.approve(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: taker });
|
||||
|
||||
order = await orderFactory.newSignedOrderAsync({
|
||||
|
@ -9,6 +9,7 @@ import { constants } from '../../util/constants';
|
||||
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
||||
import { Order } from '../../util/order';
|
||||
import { OrderFactory } from '../../util/order_factory';
|
||||
import { ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
|
||||
@ -31,14 +32,14 @@ describe('Exchange', () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
maker = accounts[0];
|
||||
feeRecipient = accounts[1] || accounts[accounts.length - 1];
|
||||
const tokenRegistry = await deployer.deployAsync('TokenRegistry');
|
||||
const tokenTransferProxy = await deployer.deployAsync('TokenTransferProxy');
|
||||
const tokenRegistry = await deployer.deployAsync(ContractName.TokenRegistry);
|
||||
const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
const [rep, dgd, zrx] = await Promise.all([
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
]);
|
||||
const exchange = await deployer.deployAsync('Exchange', [zrx.address, tokenTransferProxy.address]);
|
||||
const exchange = await deployer.deployAsync(ContractName.Exchange, [zrx.address, tokenTransferProxy.address]);
|
||||
await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] });
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
|
||||
|
@ -11,7 +11,7 @@ import { constants } from '../../util/constants';
|
||||
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
||||
import { Order } from '../../util/order';
|
||||
import { OrderFactory } from '../../util/order_factory';
|
||||
import { BalancesByOwner } from '../../util/types';
|
||||
import { BalancesByOwner, ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
|
||||
@ -49,13 +49,13 @@ describe('Exchange', () => {
|
||||
taker = accounts[1] || accounts[accounts.length - 1];
|
||||
feeRecipient = accounts[2] || accounts[accounts.length - 1];
|
||||
[rep, dgd, zrx] = await Promise.all([
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync('DummyToken'),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
deployer.deployAsync(ContractName.DummyToken),
|
||||
]);
|
||||
tokenRegistry = await deployer.deployAsync('TokenRegistry');
|
||||
tokenTransferProxy = await deployer.deployAsync('TokenTransferProxy');
|
||||
exchange = await deployer.deployAsync('Exchange', [zrx.address, tokenTransferProxy.address]);
|
||||
tokenRegistry = await deployer.deployAsync(ContractName.TokenRegistry);
|
||||
tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
exchange = await deployer.deployAsync(ContractName.Exchange, [zrx.address, tokenTransferProxy.address]);
|
||||
await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] });
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
exWrapper = new ExchangeWrapper(exchange, zeroEx);
|
||||
|
@ -9,7 +9,7 @@ import * as multiSigWalletJSON from '../../build/contracts/MultiSigWalletWithTim
|
||||
import { artifacts } from '../util/artifacts';
|
||||
import { constants } from '../util/constants';
|
||||
import { MultiSigWrapper } from '../util/multi_sig_wrapper';
|
||||
import { SubmissionContractEventArgs } from '../util/types';
|
||||
import { ContractName, SubmissionContractEventArgs } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
@ -52,7 +52,11 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
describe('changeTimeLock', () => {
|
||||
describe('initially non-time-locked', async () => {
|
||||
before('deploy a walet', async () => {
|
||||
multiSig = await deployer.deployAsync('MultiSigWalletWithTimeLock', [owners, SIGNATURES_REQUIRED, 0]);
|
||||
multiSig = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
|
||||
owners,
|
||||
SIGNATURES_REQUIRED,
|
||||
0,
|
||||
]);
|
||||
multiSigWrapper = new MultiSigWrapper(multiSig);
|
||||
|
||||
const secondsTimeLocked = await multiSig.secondsTimeLocked();
|
||||
@ -140,7 +144,7 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
});
|
||||
describe('initially time-locked', async () => {
|
||||
before('deploy a walet', async () => {
|
||||
multiSig = await deployer.deployAsync('MultiSigWalletWithTimeLock', [
|
||||
multiSig = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
|
||||
owners,
|
||||
SIGNATURES_REQUIRED,
|
||||
SECONDS_TIME_LOCKED,
|
||||
|
@ -9,7 +9,7 @@ import { artifacts } from '../util/artifacts';
|
||||
import { constants } from '../util/constants';
|
||||
import { crypto } from '../util/crypto';
|
||||
import { MultiSigWrapper } from '../util/multi_sig_wrapper';
|
||||
import { SubmissionContractEventArgs, TransactionDataParams } from '../util/types';
|
||||
import { ContractName, SubmissionContractEventArgs, TransactionDataParams } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
@ -52,11 +52,11 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
|
||||
.slice(0, 20)
|
||||
.toString('hex')}`;
|
||||
const initialOwner = accounts[0];
|
||||
tokenTransferProxy = await deployer.deployAsync('TokenTransferProxy');
|
||||
tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
await tokenTransferProxy.addAuthorizedAddress(authorizedAddress, {
|
||||
from: initialOwner,
|
||||
});
|
||||
multiSig = await deployer.deployAsync('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', [
|
||||
multiSig = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress, [
|
||||
owners,
|
||||
requiredApprovals,
|
||||
SECONDS_TIME_LOCKED,
|
||||
@ -106,7 +106,7 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
|
||||
});
|
||||
|
||||
it('should throw if tx destination is not the tokenTransferProxy', async () => {
|
||||
const invalidTokenTransferProxy = await deployer.deployAsync('TokenTransferProxy');
|
||||
const invalidTokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
const invalidDestination = invalidTokenTransferProxy.address;
|
||||
const dataParams: TransactionDataParams = {
|
||||
name: 'removeAuthorizedAddress',
|
||||
|
@ -8,6 +8,7 @@ import * as Web3 from 'web3';
|
||||
|
||||
import { constants } from '../util/constants';
|
||||
import { TokenRegWrapper } from '../util/token_registry_wrapper';
|
||||
import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
@ -27,7 +28,7 @@ describe('TokenRegistry', () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
notOwner = accounts[1];
|
||||
tokenReg = await deployer.deployAsync('TokenRegistry');
|
||||
tokenReg = await deployer.deployAsync(ContractName.TokenRegistry);
|
||||
tokenRegWrapper = new TokenRegWrapper(tokenReg);
|
||||
});
|
||||
beforeEach(async () => {
|
||||
|
@ -4,6 +4,7 @@ import * as chai from 'chai';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { constants } from '../../util/constants';
|
||||
import { ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
|
||||
@ -22,7 +23,7 @@ describe('TokenTransferProxy', () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = address = accounts[0];
|
||||
notOwner = accounts[1];
|
||||
tokenTransferProxy = await deployer.deployAsync('TokenTransferProxy');
|
||||
tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
|
@ -5,6 +5,7 @@ import * as Web3 from 'web3';
|
||||
|
||||
import { Balances } from '../../util/balances';
|
||||
import { constants } from '../../util/constants';
|
||||
import { ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
|
||||
@ -28,8 +29,8 @@ describe('TokenTransferProxy', () => {
|
||||
before(async () => {
|
||||
accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = notAuthorized = accounts[0];
|
||||
tokenTransferProxy = await deployer.deployAsync('TokenTransferProxy');
|
||||
rep = await deployer.deployAsync('DummyToken');
|
||||
tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
rep = await deployer.deployAsync(ContractName.DummyToken);
|
||||
|
||||
dmyBalances = new Balances([rep], [accounts[0], accounts[1]]);
|
||||
await Promise.all([
|
||||
|
@ -6,6 +6,7 @@ import * as chai from 'chai';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { constants } from '../util/constants';
|
||||
import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
@ -32,7 +33,7 @@ describe('UnlimitedAllowanceToken', () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
spender = accounts[1];
|
||||
token = await deployer.deployAsync('DummyToken');
|
||||
token = await deployer.deployAsync(ContractName.DummyToken);
|
||||
await token.mint(MAX_MINT_VALUE, { from: owner });
|
||||
tokenAddress = token.address;
|
||||
});
|
||||
|
@ -6,6 +6,7 @@ import * as chai from 'chai';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { constants } from '../util/constants';
|
||||
import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
@ -32,7 +33,7 @@ describe('UnlimitedAllowanceTokenV2', () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
spender = accounts[1];
|
||||
token = await deployer.deployAsync('DummyToken_v2');
|
||||
token = await deployer.deployAsync(ContractName.DummyToken_v2);
|
||||
await token.mint(MAX_MINT_VALUE, { from: owner });
|
||||
tokenAddress = token.address;
|
||||
});
|
||||
|
@ -6,6 +6,7 @@ import * as chai from 'chai';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { constants } from '../util/constants';
|
||||
import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
@ -33,7 +34,7 @@ describe('ZRXToken', () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
});
|
||||
zrx = await deployer.deployAsync('ZRXToken');
|
||||
zrx = await deployer.deployAsync(ContractName.ZRXToken);
|
||||
zrxAddress = zrx.address;
|
||||
MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
||||
});
|
||||
|
@ -119,20 +119,21 @@ export enum ExchangeContractErrs {
|
||||
ERROR_INSUFFICIENT_BALANCE_OR_ALLOWANCE,
|
||||
}
|
||||
|
||||
export type ArtifactContractName =
|
||||
| 'TokenTransferProxy'
|
||||
| 'TokenRegistry'
|
||||
| 'MultiSigWalletWithTimeLock'
|
||||
| 'Exchange'
|
||||
| 'ZRXToken'
|
||||
| 'DummyToken'
|
||||
| 'DummyToken_v2'
|
||||
| 'WETH9'
|
||||
| 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress'
|
||||
| 'MaliciousToken';
|
||||
export enum ContractName {
|
||||
TokenTransferProxy = 'TokenTransferProxy',
|
||||
TokenRegistry = 'TokenRegistry',
|
||||
MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock',
|
||||
Exchange = 'Exchange',
|
||||
ZRXToken = 'ZRXToken',
|
||||
DummyToken = 'DummyToken',
|
||||
DummyToken_v2 = 'DummyToken_v2',
|
||||
EtherToken = 'WETH9',
|
||||
MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress = 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
|
||||
MaliciousToken = 'MaliciousToken',
|
||||
}
|
||||
|
||||
export interface Artifact {
|
||||
contract_name: ArtifactContractName;
|
||||
contract_name: ContractName;
|
||||
networks: {
|
||||
[networkId: number]: {
|
||||
abi: Web3.ContractAbi;
|
||||
|
Loading…
x
Reference in New Issue
Block a user