Introduce publicFacingContracts config in all package.jsons, refactor all imports from src in contracts packages
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
"compile:truffle": "truffle compile"
|
||||
},
|
||||
"config": {
|
||||
"publicInterfaceContracts": "IWallet,LibEIP712ExchangeDomain,LibExchangeRichErrors,LibMath,LibMathRichErrors,LibOrder,LibZeroExTransaction",
|
||||
"abis": "./test/generated-artifacts/@(IWallet|LibEIP712ExchangeDomain|LibExchangeRichErrors|LibFillResults|LibMath|LibMathRichErrors|LibOrder|LibZeroExTransaction|TestLibEIP712ExchangeDomain|TestLibFillResults|TestLibMath|TestLibOrder|TestLibZeroExTransaction).json",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||
},
|
||||
|
@@ -8,28 +8,16 @@ import { ContractArtifact } from 'ethereum-types';
|
||||
import * as IWallet from '../generated-artifacts/IWallet.json';
|
||||
import * as LibEIP712ExchangeDomain from '../generated-artifacts/LibEIP712ExchangeDomain.json';
|
||||
import * as LibExchangeRichErrors from '../generated-artifacts/LibExchangeRichErrors.json';
|
||||
import * as LibFillResults from '../generated-artifacts/LibFillResults.json';
|
||||
import * as LibMath from '../generated-artifacts/LibMath.json';
|
||||
import * as LibMathRichErrors from '../generated-artifacts/LibMathRichErrors.json';
|
||||
import * as LibOrder from '../generated-artifacts/LibOrder.json';
|
||||
import * as LibZeroExTransaction from '../generated-artifacts/LibZeroExTransaction.json';
|
||||
import * as TestLibEIP712ExchangeDomain from '../generated-artifacts/TestLibEIP712ExchangeDomain.json';
|
||||
import * as TestLibFillResults from '../generated-artifacts/TestLibFillResults.json';
|
||||
import * as TestLibMath from '../generated-artifacts/TestLibMath.json';
|
||||
import * as TestLibOrder from '../generated-artifacts/TestLibOrder.json';
|
||||
import * as TestLibZeroExTransaction from '../generated-artifacts/TestLibZeroExTransaction.json';
|
||||
export const artifacts = {
|
||||
IWallet: IWallet as ContractArtifact,
|
||||
LibEIP712ExchangeDomain: LibEIP712ExchangeDomain as ContractArtifact,
|
||||
LibExchangeRichErrors: LibExchangeRichErrors as ContractArtifact,
|
||||
LibFillResults: LibFillResults as ContractArtifact,
|
||||
LibMath: LibMath as ContractArtifact,
|
||||
LibMathRichErrors: LibMathRichErrors as ContractArtifact,
|
||||
LibOrder: LibOrder as ContractArtifact,
|
||||
LibZeroExTransaction: LibZeroExTransaction as ContractArtifact,
|
||||
TestLibEIP712ExchangeDomain: TestLibEIP712ExchangeDomain as ContractArtifact,
|
||||
TestLibFillResults: TestLibFillResults as ContractArtifact,
|
||||
TestLibMath: TestLibMath as ContractArtifact,
|
||||
TestLibOrder: TestLibOrder as ContractArtifact,
|
||||
TestLibZeroExTransaction: TestLibZeroExTransaction as ContractArtifact,
|
||||
};
|
||||
|
@@ -6,13 +6,7 @@
|
||||
export * from '../generated-wrappers/i_wallet';
|
||||
export * from '../generated-wrappers/lib_e_i_p712_exchange_domain';
|
||||
export * from '../generated-wrappers/lib_exchange_rich_errors';
|
||||
export * from '../generated-wrappers/lib_fill_results';
|
||||
export * from '../generated-wrappers/lib_math';
|
||||
export * from '../generated-wrappers/lib_math_rich_errors';
|
||||
export * from '../generated-wrappers/lib_order';
|
||||
export * from '../generated-wrappers/lib_zero_ex_transaction';
|
||||
export * from '../generated-wrappers/test_lib_e_i_p712_exchange_domain';
|
||||
export * from '../generated-wrappers/test_lib_fill_results';
|
||||
export * from '../generated-wrappers/test_lib_math';
|
||||
export * from '../generated-wrappers/test_lib_order';
|
||||
export * from '../generated-wrappers/test_lib_zero_ex_transaction';
|
||||
|
@@ -2,7 +2,9 @@ import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts
|
||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
||||
import { artifacts, TestLibEIP712ExchangeDomainContract } from '../src';
|
||||
import { TestLibEIP712ExchangeDomainContract } from './wrappers';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
|
||||
blockchainTests('LibEIP712ExchangeDomain', env => {
|
||||
describe('constructor', () => {
|
||||
|
@@ -13,7 +13,10 @@ import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, ReferenceFunctions, TestLibFillResultsContract } from '../src';
|
||||
import { addFillResults, calculateFillResults, getPartialAmountFloor } from '../src/reference_functions';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { TestLibFillResultsContract } from './wrappers';
|
||||
|
||||
blockchainTests('LibFillResults', env => {
|
||||
interface PartialMatchedFillResults {
|
||||
@@ -92,7 +95,7 @@ blockchainTests('LibFillResults', env => {
|
||||
// in any mathematical operation in either the reference TypeScript
|
||||
// implementation or the Solidity implementation of
|
||||
// calculateFillResults.
|
||||
return ReferenceFunctions.calculateFillResults(
|
||||
return calculateFillResults(
|
||||
makeOrder(otherAmount, orderTakerAssetAmount, otherAmount, otherAmount),
|
||||
takerAssetFilledAmount,
|
||||
takerAssetFilledAmount, // Using this so that the gas price is distinct from protocolFeeMultiplier
|
||||
@@ -139,7 +142,7 @@ blockchainTests('LibFillResults', env => {
|
||||
takerFee: ONE_ETHER.times(0.0025),
|
||||
});
|
||||
const takerAssetFilledAmount = ONE_ETHER.dividedToIntegerBy(3);
|
||||
const expected = ReferenceFunctions.calculateFillResults(
|
||||
const expected = calculateFillResults(
|
||||
order,
|
||||
takerAssetFilledAmount,
|
||||
DEFAULT_PROTOCOL_FEE_MULTIPLIER,
|
||||
@@ -184,7 +187,7 @@ blockchainTests('LibFillResults', env => {
|
||||
makerFee: MAX_UINT256_ROOT.times(11),
|
||||
});
|
||||
const takerAssetFilledAmount = MAX_UINT256_ROOT.dividedToIntegerBy(10);
|
||||
const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor(
|
||||
const makerAssetFilledAmount = getPartialAmountFloor(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount,
|
||||
@@ -272,7 +275,7 @@ blockchainTests('LibFillResults', env => {
|
||||
makerFee: new BigNumber(100),
|
||||
});
|
||||
const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3);
|
||||
const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor(
|
||||
const makerAssetFilledAmount = getPartialAmountFloor(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount,
|
||||
@@ -299,7 +302,7 @@ blockchainTests('LibFillResults', env => {
|
||||
takerFee: new BigNumber(100),
|
||||
});
|
||||
const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3);
|
||||
const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor(
|
||||
const makerAssetFilledAmount = getPartialAmountFloor(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount,
|
||||
@@ -349,7 +352,7 @@ blockchainTests('LibFillResults', env => {
|
||||
makerFee: new BigNumber(100),
|
||||
});
|
||||
const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3);
|
||||
const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor(
|
||||
const makerAssetFilledAmount = getPartialAmountFloor(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount,
|
||||
@@ -392,7 +395,7 @@ blockchainTests('LibFillResults', env => {
|
||||
|
||||
it('matches the output of the reference function', async () => {
|
||||
const [a, b] = DEFAULT_FILL_RESULTS;
|
||||
const expected = ReferenceFunctions.addFillResults(a, b);
|
||||
const expected = addFillResults(a, b);
|
||||
const actual = await libsContract.addFillResults.callAsync(a, b);
|
||||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
@@ -9,7 +9,17 @@ import {
|
||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
|
||||
import { artifacts, ReferenceFunctions, TestLibMathContract } from '../src';
|
||||
import {
|
||||
getPartialAmountCeil,
|
||||
getPartialAmountFloor,
|
||||
isRoundingErrorCeil,
|
||||
isRoundingErrorFloor,
|
||||
safeGetPartialAmountCeil,
|
||||
safeGetPartialAmountFloor,
|
||||
} from '../src/reference_functions';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { TestLibMathContract } from './wrappers';
|
||||
|
||||
blockchainTests('LibMath', env => {
|
||||
const { ONE_ETHER, MAX_UINT256, MAX_UINT256_ROOT, ZERO_AMOUNT } = constants;
|
||||
@@ -42,7 +52,7 @@ blockchainTests('LibMath', env => {
|
||||
describe.optional('combinatorial tests', () => {
|
||||
testCombinatoriallyWithReferenceFunc(
|
||||
'getPartialAmountFloor',
|
||||
createAsyncReferenceFunction(ReferenceFunctions.getPartialAmountFloor),
|
||||
createAsyncReferenceFunction(getPartialAmountFloor),
|
||||
createContractTestFunction('getPartialAmountFloor'),
|
||||
[uint256Values, uint256Values, uint256Values],
|
||||
);
|
||||
@@ -53,7 +63,7 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = ONE_ETHER;
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expected = ReferenceFunctions.getPartialAmountFloor(numerator, denominator, target);
|
||||
const expected = getPartialAmountFloor(numerator, denominator, target);
|
||||
const actual = await libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.bignumber.eq(expected);
|
||||
});
|
||||
@@ -101,7 +111,7 @@ blockchainTests('LibMath', env => {
|
||||
describe.optional('combinatorial tests', () => {
|
||||
testCombinatoriallyWithReferenceFunc(
|
||||
'getPartialAmountCeil',
|
||||
createAsyncReferenceFunction(ReferenceFunctions.getPartialAmountCeil),
|
||||
createAsyncReferenceFunction(getPartialAmountCeil),
|
||||
createContractTestFunction('getPartialAmountCeil'),
|
||||
[uint256Values, uint256Values, uint256Values],
|
||||
);
|
||||
@@ -112,7 +122,7 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = ONE_ETHER;
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expected = ReferenceFunctions.getPartialAmountCeil(numerator, denominator, target);
|
||||
const expected = getPartialAmountCeil(numerator, denominator, target);
|
||||
const actual = await libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.bignumber.eq(expected);
|
||||
});
|
||||
@@ -161,7 +171,7 @@ blockchainTests('LibMath', env => {
|
||||
describe.optional('combinatorial tests', () => {
|
||||
testCombinatoriallyWithReferenceFunc(
|
||||
'safeGetPartialAmountFloor',
|
||||
createAsyncReferenceFunction(ReferenceFunctions.safeGetPartialAmountFloor),
|
||||
createAsyncReferenceFunction(safeGetPartialAmountFloor),
|
||||
createContractTestFunction('safeGetPartialAmountFloor'),
|
||||
[uint256Values, uint256Values, uint256Values],
|
||||
);
|
||||
@@ -172,7 +182,7 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = ONE_ETHER;
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expected = ReferenceFunctions.safeGetPartialAmountFloor(numerator, denominator, target);
|
||||
const expected = safeGetPartialAmountFloor(numerator, denominator, target);
|
||||
const actual = await libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.bignumber.eq(expected);
|
||||
});
|
||||
@@ -226,7 +236,7 @@ blockchainTests('LibMath', env => {
|
||||
describe.optional('combinatorial tests', () => {
|
||||
testCombinatoriallyWithReferenceFunc(
|
||||
'safeGetPartialAmountCeil',
|
||||
createAsyncReferenceFunction(ReferenceFunctions.safeGetPartialAmountCeil),
|
||||
createAsyncReferenceFunction(safeGetPartialAmountCeil),
|
||||
createContractTestFunction('safeGetPartialAmountCeil'),
|
||||
[uint256Values, uint256Values, uint256Values],
|
||||
);
|
||||
@@ -237,7 +247,7 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = ONE_ETHER;
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expected = ReferenceFunctions.safeGetPartialAmountCeil(numerator, denominator, target);
|
||||
const expected = safeGetPartialAmountCeil(numerator, denominator, target);
|
||||
const actual = await libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.bignumber.eq(expected);
|
||||
});
|
||||
@@ -291,7 +301,7 @@ blockchainTests('LibMath', env => {
|
||||
describe.optional('combinatorial tests', () => {
|
||||
testCombinatoriallyWithReferenceFunc(
|
||||
'isRoundingErrorFloor',
|
||||
createAsyncReferenceFunction(ReferenceFunctions.isRoundingErrorFloor),
|
||||
createAsyncReferenceFunction(isRoundingErrorFloor),
|
||||
createContractTestFunction('isRoundingErrorFloor'),
|
||||
[uint256Values, uint256Values, uint256Values],
|
||||
);
|
||||
@@ -321,7 +331,7 @@ blockchainTests('LibMath', env => {
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const expected = ReferenceFunctions.isRoundingErrorFloor(numerator, denominator, target);
|
||||
const expected = isRoundingErrorFloor(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(expected);
|
||||
@@ -357,7 +367,7 @@ blockchainTests('LibMath', env => {
|
||||
describe.optional('combinatorial tests', () => {
|
||||
testCombinatoriallyWithReferenceFunc(
|
||||
'isRoundingErrorCeil',
|
||||
createAsyncReferenceFunction(ReferenceFunctions.isRoundingErrorCeil),
|
||||
createAsyncReferenceFunction(isRoundingErrorCeil),
|
||||
createContractTestFunction('isRoundingErrorCeil'),
|
||||
[uint256Values, uint256Values, uint256Values],
|
||||
);
|
||||
@@ -387,7 +397,7 @@ blockchainTests('LibMath', env => {
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const expected = ReferenceFunctions.isRoundingErrorCeil(numerator, denominator, target);
|
||||
const expected = isRoundingErrorCeil(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(expected);
|
||||
|
@@ -5,7 +5,9 @@ import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, TestLibOrderContract } from '../src';
|
||||
import { TestLibOrderContract } from './wrappers';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
|
||||
blockchainTests('LibOrder', env => {
|
||||
let libOrderContract: TestLibOrderContract;
|
||||
|
@@ -5,7 +5,9 @@ import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, TestLibZeroExTransactionContract } from '../src';
|
||||
import { TestLibZeroExTransactionContract } from './wrappers';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
|
||||
blockchainTests('LibZeroExTransaction', env => {
|
||||
let libZeroExTransactionContract: TestLibZeroExTransactionContract;
|
||||
|
@@ -6,16 +6,10 @@
|
||||
"generated-artifacts/IWallet.json",
|
||||
"generated-artifacts/LibEIP712ExchangeDomain.json",
|
||||
"generated-artifacts/LibExchangeRichErrors.json",
|
||||
"generated-artifacts/LibFillResults.json",
|
||||
"generated-artifacts/LibMath.json",
|
||||
"generated-artifacts/LibMathRichErrors.json",
|
||||
"generated-artifacts/LibOrder.json",
|
||||
"generated-artifacts/LibZeroExTransaction.json",
|
||||
"generated-artifacts/TestLibEIP712ExchangeDomain.json",
|
||||
"generated-artifacts/TestLibFillResults.json",
|
||||
"generated-artifacts/TestLibMath.json",
|
||||
"generated-artifacts/TestLibOrder.json",
|
||||
"generated-artifacts/TestLibZeroExTransaction.json",
|
||||
"test/generated-artifacts/IWallet.json",
|
||||
"test/generated-artifacts/LibEIP712ExchangeDomain.json",
|
||||
"test/generated-artifacts/LibExchangeRichErrors.json",
|
||||
|
Reference in New Issue
Block a user