Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1790 from 0xProject/feature/3.0/contracts/exchang…
Browse files Browse the repository at this point in the history
…e/rich-revert-decoder

[3.0] Add LibExchangeRichErrorDecoder to exchange package
  • Loading branch information
dorothy-zbornak authored Apr 30, 2019
2 parents 02f6cb8 + 9384848 commit 39790f2
Show file tree
Hide file tree
Showing 34 changed files with 895 additions and 149 deletions.
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,10 @@ workflows:
- test-contracts-ganache:
requires:
- build-3.0
- test-contracts-geth:
requires:
- build-3.0
# Disabled until geth docker image is fixed.
# - test-contracts-geth:
# requires:
# - build-3.0
# Disabled for 3.0
# - test-pipeline:
# requires:
Expand Down
2 changes: 1 addition & 1 deletion contracts/asset-proxy/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"isOfflineMode": false,
"compilerSettings": {
"evmVersion": "constantinople",
Expand Down
2 changes: 1 addition & 1 deletion contracts/coordinator/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"compilerSettings": {
"evmVersion": "constantinople",
"optimizer": {
Expand Down
2 changes: 1 addition & 1 deletion contracts/erc1155/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "generated-artifacts",
"contractsDir": "contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"compilerSettings": {
"evmVersion": "constantinople",
"optimizer": { "enabled": true, "runs": 1000000 },
Expand Down
2 changes: 1 addition & 1 deletion contracts/erc20/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"isOfflineMode": false,
"compilerSettings": {
"evmVersion": "constantinople",
Expand Down
2 changes: 1 addition & 1 deletion contracts/erc721/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"isOfflineMode": false,
"compilerSettings": {
"evmVersion": "constantinople",
Expand Down
2 changes: 1 addition & 1 deletion contracts/exchange-forwarder/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"isOfflineMode": false,
"compilerSettings": {
"evmVersion": "constantinople",
Expand Down
12 changes: 12 additions & 0 deletions contracts/exchange-libs/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
{
"note": "Remove LibEIP712ExchangeDomainConstants and LibEIP712 contracts",
"pr": 1753
},
{
"note": "Add `LibExchangeRichErrorDecoder` contract.",
"pr": 1790
},
{
"note": "Break out types/interaces from `MExchangeRichErrors` into `MExchangeRichErrorTypes`.",
"pr": 1790
},
{
"note": "Reorder some revert error parameters for consistency",
"pr": 1790
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/exchange-libs/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"isOfflineMode": false,
"compilerSettings": {
"evmVersion": "constantinople",
Expand Down
3 changes: 2 additions & 1 deletion contracts/exchange/compiler.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"useDockerisedSolc": false,
"isOfflineMode": false,
"compilerSettings": {
"evmVersion": "constantinople",
Expand Down Expand Up @@ -41,6 +41,7 @@
"test/ReentrantERC20Token.sol",
"test/TestAssetProxyDispatcher.sol",
"test/TestExchangeInternals.sol",
"test/TestLibExchangeRichErrorDecoder.sol",
"test/TestRevertReceiver.sol",
"test/TestSignatureValidator.sol",
"test/TestStaticCallReceiver.sol"
Expand Down
9 changes: 6 additions & 3 deletions contracts/exchange/contracts/src/MixinExchangeCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ contract MixinExchangeCore is
// An order can only be filled if its status is FILLABLE.
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
rrevert(OrderStatusError(
OrderStatus(orderInfo.orderStatus),
orderInfo.orderHash
orderInfo.orderHash,
OrderStatus(orderInfo.orderStatus)
));
}

Expand Down Expand Up @@ -441,7 +441,10 @@ contract MixinExchangeCore is
// Ensure order is valid
// An order can only be cancelled if its status is FILLABLE.
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
rrevert(OrderStatusError(OrderStatus(orderInfo.orderStatus), orderInfo.orderHash));
rrevert(OrderStatusError(
orderInfo.orderHash,
OrderStatus(orderInfo.orderStatus)
));
}

// Validate sender is allowed to cancel this order
Expand Down
36 changes: 18 additions & 18 deletions contracts/exchange/contracts/src/MixinExchangeRichErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ contract MixinExchangeRichErrors is
{
// solhint-disable func-name-mixedcase
function SignatureError(
SignatureErrorCodes error,
bytes32 orderHash,
SignatureErrorCodes errorCode,
bytes32 hash,
address signer,
bytes memory signature
)
Expand All @@ -40,15 +40,15 @@ contract MixinExchangeRichErrors is
{
return abi.encodeWithSelector(
SIGNATURE_ERROR_SELECTOR,
error,
orderHash,
errorCode,
hash,
signer,
signature
);
}

function SignatureValidatorError(
bytes32 orderHash,
bytes32 hash,
address signer,
bytes memory signature,
bytes memory errorData
Expand All @@ -59,15 +59,15 @@ contract MixinExchangeRichErrors is
{
return abi.encodeWithSelector(
SIGNATURE_VALIDATOR_ERROR_SELECTOR,
orderHash,
hash,
signer,
signature,
errorData
);
}

function SignatureWalletError(
bytes32 orderHash,
bytes32 hash,
address signer,
bytes memory signature,
bytes memory errorData
Expand All @@ -78,7 +78,7 @@ contract MixinExchangeRichErrors is
{
return abi.encodeWithSelector(
SIGNATURE_WALLET_ERROR_SELECTOR,
orderHash,
hash,
signer,
signature,
errorData
Expand Down Expand Up @@ -124,17 +124,17 @@ contract MixinExchangeRichErrors is
}

function OrderStatusError(
LibOrder.OrderStatus orderStatus,
bytes32 orderHash
bytes32 orderHash,
LibOrder.OrderStatus orderStatus
)
internal
pure
returns (bytes memory)
{
return abi.encodeWithSelector(
ORDER_STATUS_ERROR_SELECTOR,
orderStatus,
orderHash
orderHash,
orderStatus
);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ contract MixinExchangeRichErrors is
}

function FillError(
FillErrorCodes error,
FillErrorCodes errorCode,
bytes32 orderHash
)
internal
Expand All @@ -178,7 +178,7 @@ contract MixinExchangeRichErrors is
{
return abi.encodeWithSelector(
FILL_ERROR_SELECTOR,
error,
errorCode,
orderHash
);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ contract MixinExchangeRichErrors is
}

function AssetProxyDispatchError(
AssetProxyDispatchErrorCodes error,
AssetProxyDispatchErrorCodes errorCode,
bytes32 orderHash,
bytes memory assetData
)
Expand All @@ -239,7 +239,7 @@ contract MixinExchangeRichErrors is
{
return abi.encodeWithSelector(
ASSET_PROXY_DISPATCH_ERROR_SELECTOR,
error,
errorCode,
orderHash,
assetData
);
Expand Down Expand Up @@ -278,7 +278,7 @@ contract MixinExchangeRichErrors is
}

function TransactionError(
TransactionErrorCodes error,
TransactionErrorCodes errorCode,
bytes32 transactionHash
)
internal
Expand All @@ -287,7 +287,7 @@ contract MixinExchangeRichErrors is
{
return abi.encodeWithSelector(
TRANSACTION_ERROR_SELECTOR,
error,
errorCode,
transactionHash
);
}
Expand Down
Loading

0 comments on commit 39790f2

Please sign in to comment.