From eb00ff05a80bb2c4097807b5a3877bc26138f6cd Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Fri, 12 Apr 2019 17:09:09 -0400 Subject: [PATCH] Ran prettier/linter --- .../src/MixinAssetProxyDispatcher.sol | 11 +++++--- .../contracts/test/TestRevertReceiver.sol | 3 +- .../exchange/test/signature_validator.ts | 28 ++++++------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/contracts/exchange/contracts/src/MixinAssetProxyDispatcher.sol b/contracts/exchange/contracts/src/MixinAssetProxyDispatcher.sol index bd5d616d27..ce1eb119cc 100644 --- a/contracts/exchange/contracts/src/MixinAssetProxyDispatcher.sol +++ b/contracts/exchange/contracts/src/MixinAssetProxyDispatcher.sol @@ -179,13 +179,16 @@ contract MixinAssetProxyDispatcher is ) if iszero(didSucceed) { // Call reverted. - // Get the revert data. let revertDataSize := returndatasize() + // Construct a `bytes memory` type to hold the revert data + // at `cdStart`. + // The first 32 bytes are the length of the data. + mstore(cdStart, revertDataSize) + // Copy the revert data immediately after the length. + returndatacopy(add(cdStart, 32), 0, revertDataSize) // We need to move the free memory pointer because we // still have solidity logic that executes after this assembly. - mstore(64, add(cdStart, revertDataSize)) - // Copy the revert data. - returndatacopy(cdStart, 0, revertDataSize) + mstore(64, add(cdStart, add(revertDataSize, 32))) revertData := cdStart } } diff --git a/contracts/exchange/contracts/test/TestRevertReceiver.sol b/contracts/exchange/contracts/test/TestRevertReceiver.sol index 059a502f99..9a01048c5f 100644 --- a/contracts/exchange/contracts/test/TestRevertReceiver.sol +++ b/contracts/exchange/contracts/test/TestRevertReceiver.sol @@ -21,9 +21,10 @@ pragma solidity ^0.5.5; import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol"; +// solhint-disable no-unused-vars contract TestRevertReceiver { - string constant REVERT_REASON = "you shall not pass"; + string constant public REVERT_REASON = "you shall not pass"; /// @dev Reverts with `REVERT_REASON`. Intended to be used with `Validator` signature type. /// @param hash Message hash that is signed. diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts index 041cb92610..3c9d0677fb 100644 --- a/contracts/exchange/test/signature_validator.ts +++ b/contracts/exchange/test/signature_validator.ts @@ -90,13 +90,9 @@ describe('MixinSignatureValidator', () => { ); signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, artifacts); await web3Wrapper.awaitTransactionSuccessAsync( - await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync( - testValidator.address, - true, - { - from: signerAddress, - }, - ), + await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(testValidator.address, true, { + from: signerAddress, + }), constants.AWAIT_TRANSACTION_MINED_MS, ); await web3Wrapper.awaitTransactionSuccessAsync( @@ -144,6 +140,8 @@ describe('MixinSignatureValidator', () => { }); describe('isValidSignature', () => { + const REVERT_REASON = 'you shall not pass'; + beforeEach(async () => { signedOrder = await orderFactory.newSignedOrderAsync(); }); @@ -412,7 +410,7 @@ describe('MixinSignatureValidator', () => { orderHashHex, revertingWallet.address, signatureHex, - new StringRevertError('you shall not pass').encode(), + new StringRevertError(REVERT_REASON).encode(), ); const tx = signatureValidator.publicIsValidSignature.callAsync( orderHashHex, @@ -464,11 +462,7 @@ describe('MixinSignatureValidator', () => { signatureHex, constants.NULL_BYTES, ); - const tx = signatureValidator.publicIsValidSignature.callAsync( - orderHashHex, - signerAddress, - signatureHex, - ); + const tx = signatureValidator.publicIsValidSignature.callAsync(orderHashHex, signerAddress, signatureHex); return expect(tx).to.revertWith(expectedError); }); @@ -482,13 +476,9 @@ describe('MixinSignatureValidator', () => { orderHashHex, signedOrder.makerAddress, signatureHex, - new StringRevertError('you shall not pass').encode(), - ); - const tx = signatureValidator.publicIsValidSignature.callAsync( - orderHashHex, - signerAddress, - signatureHex, + new StringRevertError(REVERT_REASON).encode(), ); + const tx = signatureValidator.publicIsValidSignature.callAsync(orderHashHex, signerAddress, signatureHex); return expect(tx).to.revertWith(expectedError); });