Merge branch 'v2-prototype' into feature/combinatorial-testing

* v2-prototype: (40 commits)
  Increase number of columns in relayer grid for small screens
  Make isValidSignature public
  Make batchFill methods return FIllResults struct
  Remove remove_tags script
  Small fixes
  Use semver package instead of getNextPatchVersion
  Use semver library instead of semverUtils
  small fixes
  Show all errors of a given kind at once rather then throwing after the first instance is encountered
  fix package.json
  Add more prepublish checks
  remove remove_tags script
  Create a shared Image component
  Adjust version in changelog
  Update RelayerGridTile render logic to incorportate colors and logos
  Add max width to top bar
  Set max-width for LargeLayout
  Finish last onboarding step
  Finish set allowance step
  Add onboarding assets
  ...
This commit is contained in:
Fabio Berger
2018-06-19 12:35:32 +02:00
73 changed files with 1966 additions and 416 deletions

View File

@@ -50,7 +50,35 @@ contract ERC20Proxy is
address token = readAddress(assetData, 0);
// Transfer tokens.
bool success = IERC20Token(token).transferFrom(from, to, amount);
// We do a raw call so we can check the success separate
// from the return data.
bool success = token.call(abi.encodeWithSelector(
IERC20Token(token).transferFrom.selector,
from,
to,
amount
));
require(
success,
TRANSFER_FAILED
);
// Check return data.
// If there is no return data, we assume the token incorrectly
// does not return a bool. In this case we expect it to revert
// on failure, which was handled above.
// If the token does return data, we require that it is a single
// value that evaluates to true.
assembly {
if returndatasize {
success := 0
if eq(returndatasize, 32) {
// First 64 bytes of memory are reserved scratch space
returndatacopy(0, 0, 32)
success := mload(0)
}
}
}
require(
success,
TRANSFER_FAILED

View File

@@ -82,7 +82,7 @@ contract MixinSignatureValidator is
address signer,
bytes memory signature
)
internal
public
view
returns (bool isValid)
{

View File

@@ -263,40 +263,50 @@ contract MixinWrapperFunctions is
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
/// NOTE: makerAssetFilledAmount and takerAssetFilledAmount may include amounts filled of different assets.
function batchFillOrders(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
public
returns (FillResults memory totalFillResults)
{
for (uint256 i = 0; i < orders.length; i++) {
fillOrder(
FillResults memory singleFillResults = fillOrder(
orders[i],
takerAssetFillAmounts[i],
signatures[i]
);
addFillResults(totalFillResults, singleFillResults);
}
return totalFillResults;
}
/// @dev Synchronously executes multiple calls of fillOrKill.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
/// NOTE: makerAssetFilledAmount and takerAssetFilledAmount may include amounts filled of different assets.
function batchFillOrKillOrders(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
public
returns (FillResults memory totalFillResults)
{
for (uint256 i = 0; i < orders.length; i++) {
fillOrKillOrder(
FillResults memory singleFillResults = fillOrKillOrder(
orders[i],
takerAssetFillAmounts[i],
signatures[i]
);
addFillResults(totalFillResults, singleFillResults);
}
return totalFillResults;
}
/// @dev Fills an order with specified parameters and ECDSA signature.
@@ -304,20 +314,25 @@ contract MixinWrapperFunctions is
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
/// NOTE: makerAssetFilledAmount and takerAssetFilledAmount may include amounts filled of different assets.
function batchFillOrdersNoThrow(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
public
returns (FillResults memory totalFillResults)
{
for (uint256 i = 0; i < orders.length; i++) {
fillOrderNoThrow(
FillResults memory singleFillResults = fillOrderNoThrow(
orders[i],
takerAssetFillAmounts[i],
signatures[i]
);
addFillResults(totalFillResults, singleFillResults);
}
return totalFillResults;
}
/// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.

View File

@@ -39,4 +39,18 @@ contract ISignatureValidator {
bool approval
)
external;
/// @dev Verifies that a signature is valid.
/// @param hash Message hash that is signed.
/// @param signer Address of signer.
/// @param signature Proof of signing.
/// @return Validity of order signature.
function isValidSignature(
bytes32 hash,
address signer,
bytes memory signature
)
public
view
returns (bool isValid);
}

View File

@@ -22,10 +22,7 @@ pragma experimental ABIEncoderV2;
import "../libs/LibOrder.sol";
import "../libs/LibFillResults.sol";
contract IWrapperFunctions is
LibOrder,
LibFillResults
{
contract IWrapperFunctions {
/// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.
/// @param order LibOrder.Order struct containing order specifications.
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
@@ -56,35 +53,41 @@ contract IWrapperFunctions is
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function batchFillOrders(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
public;
public
returns (LibFillResults.FillResults memory totalFillResults);
/// @dev Synchronously executes multiple calls of fillOrKill.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function batchFillOrKillOrders(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
public;
public
returns (LibFillResults.FillResults memory totalFillResults);
/// @dev Fills an order with specified parameters and ECDSA signature.
/// Returns false if the transaction would otherwise revert.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function batchFillOrdersNoThrow(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
public;
public
returns (LibFillResults.FillResults memory totalFillResults);
/// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.
/// @param orders Array of order specifications.

View File

@@ -35,18 +35,4 @@ contract MSignatureValidator is
PreSigned, // 0x07
Trezor // 0x08
}
/// @dev Verifies that a signature is valid.
/// @param hash Message hash that is signed.
/// @param signer Address of signer.
/// @param signature Proof of signing.
/// @return Validity of order signature.
function isValidSignature(
bytes32 hash,
address signer,
bytes memory signature
)
internal
view
returns (bool isValid);
}

View File

@@ -0,0 +1,21 @@
import { devConstants } from '@0xproject/dev-utils';
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0xproject/sol-cov';
import * as _ from 'lodash';
let revertTraceSubprovider: RevertTraceSubprovider;
export const revertTrace = {
getRevertTraceSubproviderSingleton(): RevertTraceSubprovider {
if (_.isUndefined(revertTraceSubprovider)) {
revertTraceSubprovider = revertTrace._getRevertTraceSubprovider();
}
return revertTraceSubprovider;
},
_getRevertTraceSubprovider(): RevertTraceSubprovider {
const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS;
const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter();
const isVerbose = true;
const subprovider = new RevertTraceSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose);
return subprovider;
},
};

View File

@@ -2,9 +2,11 @@ import { devConstants, env, EnvVars, web3Factory } from '@0xproject/dev-utils';
import { prependSubprovider } from '@0xproject/subproviders';
import { logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { coverage } from './coverage';
import { profiler } from './profiler';
import { revertTrace } from './revert_trace';
enum ProviderType {
Ganache = 'ganache',
@@ -48,10 +50,11 @@ const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs :
export const provider = web3Factory.getRpcProvider(providerConfigs);
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
const isProfilerEnabled = env.parseBoolean(EnvVars.SolidityProfiler);
if (isCoverageEnabled && isProfilerEnabled) {
throw new Error(
`Unfortunately for now you can't enable both coverage and profiler at the same time. They both use coverage.json file and there is no way to configure that.`,
);
const isRevertTraceEnabled = env.parseBoolean(EnvVars.SolidityRevertTrace);
const enabledSubproviderCount = _.filter([isCoverageEnabled, isProfilerEnabled, isRevertTraceEnabled], _.identity)
.length;
if (enabledSubproviderCount > 1) {
throw new Error(`Only one of coverage, profiler, or revert trace subproviders can be enabled at a time`);
}
if (isCoverageEnabled) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
@@ -71,5 +74,9 @@ if (isProfilerEnabled) {
profilerSubprovider.stop();
prependSubprovider(provider, profilerSubprovider);
}
if (isRevertTraceEnabled) {
const revertTraceSubprovider = revertTrace.getRevertTraceSubproviderSingleton();
prependSubprovider(provider, revertTraceSubprovider);
}
export const web3Wrapper = new Web3Wrapper(provider);