aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol10
-rw-r--r--packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol5
-rw-r--r--packages/contracts/src/utils/assertions.ts12
-rw-r--r--packages/contracts/src/utils/constants.ts13
-rw-r--r--packages/contracts/src/utils/types.ts44
5 files changed, 63 insertions, 21 deletions
diff --git a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
index d35815474..8b52858b1 100644
--- a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
+++ b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol
@@ -23,13 +23,13 @@ import "../../protocol/Exchange/interfaces/IExchange.sol";
import "../../protocol/Exchange/libs/LibOrder.sol";
import "../../utils/Ownable/Ownable.sol";
-contract Whitelist is
+contract Whitelist is
Ownable
{
// Revert reasons
- string constant MAKER_NOT_WHITELISTED = "Maker address not whitelisted.";
- string constant TAKER_NOT_WHITELISTED = "Taker address not whitelisted.";
- string constant INVALID_SENDER = "Sender must equal transaction origin.";
+ string constant MAKER_NOT_WHITELISTED = "MAKER_NOT_WHITELISTED"; // Maker address not whitelisted.
+ string constant TAKER_NOT_WHITELISTED = "TAKER_NOT_WHITELISTED"; // Taker address not whitelisted.
+ string constant INVALID_SENDER = "INVALID_SENDER"; // Sender must equal transaction origin.
// Mapping of address => whitelist status.
mapping (address => bool) public isWhitelisted;
@@ -77,7 +77,7 @@ contract Whitelist is
public
{
address takerAddress = msg.sender;
-
+
// This contract must be the entry point for the transaction.
require(
takerAddress == tx.origin,
diff --git a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol
index f0bcdafef..b6961a6ec 100644
--- a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol
+++ b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol
@@ -23,8 +23,8 @@ import "./IERC20Token.sol";
contract ERC20Token is IERC20Token {
- string constant INSUFFICIENT_BALANCE = "Insufficient balance to complete transfer.";
- string constant INSUFFICIENT_ALLOWANCE = "Insufficient allowance to complete transfer.";
+ string constant INSUFFICIENT_BALANCE = "ERC20_INSUFFICIENT_BALANCE";
+ string constant INSUFFICIENT_ALLOWANCE = "ERC20_INSUFFICIENT_ALLOWANCE";
string constant OVERFLOW = "Transfer would result in an overflow.";
mapping (address => uint256) balances;
@@ -97,4 +97,3 @@ contract ERC20Token is IERC20Token {
return allowed[_owner][_spender];
}
}
-
diff --git a/packages/contracts/src/utils/assertions.ts b/packages/contracts/src/utils/assertions.ts
index 615e648f3..29489e648 100644
--- a/packages/contracts/src/utils/assertions.ts
+++ b/packages/contracts/src/utils/assertions.ts
@@ -52,6 +52,18 @@ export function expectRevertOrAlwaysFailingTransactionAsync<T>(p: Promise<T>): P
}
/**
+ * Rejects if the given Promise does not reject with the given revert reason or "always
+ * failing transaction" error.
+ * @param p the Promise which is expected to reject
+ * @param reason a specific revert reason
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
+export function expectRevertReasonOrAlwaysFailingTransactionAsync<T>(p: Promise<T>, reason: string): PromiseLike<void> {
+ return _expectEitherErrorAsync(p, 'always failing transaction', reason);
+}
+
+/**
* Rejects if the given Promise does not reject with a "revert" or "Contract
* call failed" error.
* @param p the Promise which is expected to reject
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts
index 6999146c7..1e7b731dc 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/src/utils/constants.ts
@@ -19,21 +19,8 @@ const TESTRPC_PRIVATE_KEYS_STRINGS = [
export const constants = {
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
- LIB_BYTES_GREATER_THAN_ZERO_LENGTH_REQUIRED: 'GREATER_THAN_ZERO_LENGTH_REQUIRED',
- LIB_BYTES_GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED',
- LIB_BYTES_GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED',
- LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED',
- LIB_BYTES_GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED',
- LIB_BYTES_GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED',
- ERC20_INSUFFICIENT_BALANCE: 'Insufficient balance to complete transfer.',
- ERC20_INSUFFICIENT_ALLOWANCE: 'Insufficient allowance to complete transfer.',
ERC20_PROXY_ID: 1,
ERC721_PROXY_ID: 2,
- EXCHANGE_LENGTH_GREATER_THAN_0_REQUIRED: 'LENGTH_GREATER_THAN_0_REQUIRED',
- EXCHANGE_SIGNATURE_UNSUPPORTED: 'SIGNATURE_UNSUPPORTED',
- EXCHANGE_SIGNATURE_ILLEGAL: 'SIGNATURE_ILLEGAL',
- EXCHANGE_LENGTH_0_REQUIRED: 'LENGTH_0_REQUIRED',
- EXCHANGE_LENGTH_65_REQUIRED: 'LENGTH_65_REQUIRED',
TESTRPC_NETWORK_ID: 50,
// Note(albrow): In practice V8 and most other engines limit the minimum
// interval for setInterval to 10ms. We still set it to 0 here in order to
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index b792bb90a..e996ad96a 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -227,3 +227,47 @@ export interface FillScenario {
makerStateScenario: TraderStateScenario;
takerStateScenario: TraderStateScenario;
}
+
+export enum RevertReasons {
+ OrderUnfillable = 'ORDER_UNFILLABLE',
+ InvalidMaker = 'INVALID_MAKER',
+ InvalidTaker = 'INVALID_TAKER',
+ InvalidSender = 'INVALID_SENDER',
+ InvalidOrderSignature = 'INVALID_ORDER_SIGNATURE',
+ InvalidTakerAmount = 'INVALID_TAKER_AMOUNT',
+ RoundingError = 'ROUNDING_ERROR',
+ InvalidSignature = 'INVALID_SIGNATURE',
+ SignatureIllegal = 'SIGNATURE_ILLEGAL',
+ SignatureUnsupported = 'SIGNATURE_UNSUPPORTED',
+ InvalidNewOrderEpoch = 'INVALID_NEW_ORDER_EPOCH',
+ CompleteFillFailed = 'COMPLETE_FILL_FAILED',
+ NegativeSpreadRequired = 'NEGATIVE_SPREAD_REQUIRED',
+ ReentrancyIllegal = 'REENTRANCY_ILLEGAL',
+ InvalidTxHash = 'INVALID_TX_HASH',
+ InvalidTxSignature = 'INVALID_TX_SIGNATURE',
+ FailedExecution = 'FAILED_EXECUTION',
+ AssetProxyMismatch = 'ASSET_PROXY_MISMATCH',
+ AssetProxyIdMismatch = 'ASSET_PROXY_ID_MISMATCH',
+ LengthGreaterThan0Required = 'LENGTH_GREATER_THAN_0_REQUIRED',
+ Length0Required = 'LENGTH_0_REQUIRED',
+ Length65Required = 'LENGTH_65_REQUIRED',
+ InvalidAmount = 'INVALID_AMOUNT',
+ TransferFailed = 'TRANSFER_FAILED',
+ SenderNotAuthorized = 'SENDER_NOT_AUTHORIZED',
+ TargetNotAuthorized = 'TARGET_NOT_AUTHORIZED',
+ TargetAlreadyAuthorized = 'TARGET_ALREADY_AUTHORIZED',
+ IndexOutOfBounds = 'INDEX_OUT_OF_BOUNDS',
+ AuthorizedAddressMismatch = 'AUTHORIZED_ADDRESS_MISMATCH',
+ OnlyContractOwner = 'ONLY_CONTRACT_OWNER',
+ MakerNotWhitelisted = 'MAKER_NOT_WHITELISTED',
+ TakerNotWhitelisted = 'TAKER_NOT_WHITELISTED',
+ AssetProxyDoesNotExist = 'ASSET_PROXY_DOES_NOT_EXIST',
+ LibBytesGreaterThanZeroLengthRequired = 'GREATER_THAN_ZERO_LENGTH_REQUIRED',
+ LibBytesGreaterOrEqualTo4LengthRequired = 'GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED',
+ LibBytesGreaterOrEqualTo20LengthRequired = 'GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED',
+ LibBytesGreaterOrEqualTo32LengthRequired = 'GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED',
+ LibBytesGreaterOrEqualToNestedBytesLengthRequired = 'GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED',
+ LibBytesGreaterOrEqualToSourceBytesLengthRequired = 'GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED',
+ Erc20InsufficientBalance = 'ERC20_INSUFFICIENT_BALANCE',
+ Erc20InsufficientAllowance = 'ERC20_INSUFFICIENT_ALLOWANCE',
+}