aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/types.ts117
1 files changed, 50 insertions, 67 deletions
diff --git a/src/types.ts b/src/types.ts
index 851627a09..db25c4f64 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,34 +1,21 @@
import * as _ from 'lodash';
import * as Web3 from 'web3';
-// Utility function to create a K:V from a list of strings
-// Adapted from: https://basarat.gitbooks.io/typescript/content/docs/types/literal-types.html
-export interface StringEnum {
- [key: string]: string;
-}
-function strEnum(values: string[]): StringEnum {
- return _.reduce(values, (result, key) => {
- result[key] = key;
- return result;
- }, Object.create(null));
-}
-
-export const ZeroExError = strEnum([
- 'CONTRACT_DOES_NOT_EXIST',
- 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
- 'UNHANDLED_ERROR',
- 'USER_HAS_NO_ASSOCIATED_ADDRESSES',
- 'INVALID_SIGNATURE',
- 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
- 'ZRX_NOT_IN_TOKEN_REGISTRY',
- 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
- 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
- 'INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT',
- 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL',
- 'INVALID_JUMP',
- 'OUT_OF_GAS',
-]);
-export type ZeroExError = keyof typeof ZeroExError;
+export enum ZeroExError {
+ CONTRACT_DOES_NOT_EXIST = 'CONTRACT_DOES_NOT_EXIST',
+ EXCHANGE_CONTRACT_DOES_NOT_EXIST = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
+ UNHANDLED_ERROR = 'UNHANDLED_ERROR',
+ USER_HAS_NO_ASSOCIATED_ADDRESSES = 'USER_HAS_NO_ASSOCIATED_ADDRESSES',
+ INVALID_SIGNATURE = 'INVALID_SIGNATURE',
+ CONTRACT_NOT_DEPLOYED_ON_NETWORK = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
+ ZRX_NOT_IN_TOKEN_REGISTRY = 'ZRX_NOT_IN_TOKEN_REGISTRY',
+ INSUFFICIENT_ALLOWANCE_FOR_TRANSFER = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
+ INSUFFICIENT_BALANCE_FOR_TRANSFER = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
+ INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT = 'INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT',
+ INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL = 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL',
+ INVALID_JUMP = 'INVALID_JUMP',
+ OUT_OF_GAS = 'OUT_OF_GAS',
+}
/**
* Elliptic Curve signature
@@ -175,11 +162,10 @@ export interface ProxyContract extends ContractInstance {
};
}
-export const SolidityTypes = strEnum([
- 'address',
- 'uint256',
-]);
-export type SolidityTypes = keyof typeof SolidityTypes;
+export enum SolidityTypes {
+ address = 'address',
+ uint256 = 'uint256',
+}
export enum ExchangeContractErrCodes {
ERROR_FILL_EXPIRED, // Order has already expired
@@ -190,29 +176,28 @@ export enum ExchangeContractErrCodes {
ERROR_CANCEL_NO_VALUE, // Order has already been fully filled or cancelled
}
-export const ExchangeContractErrs = strEnum([
- 'ORDER_FILL_EXPIRED',
- 'ORDER_CANCEL_EXPIRED',
- 'ORDER_CANCEL_AMOUNT_ZERO',
- 'ORDER_ALREADY_CANCELLED_OR_FILLED',
- 'ORDER_REMAINING_FILL_AMOUNT_ZERO',
- 'ORDER_FILL_ROUNDING_ERROR',
- 'FILL_BALANCE_ALLOWANCE_ERROR',
- 'INSUFFICIENT_TAKER_BALANCE',
- 'INSUFFICIENT_TAKER_ALLOWANCE',
- 'INSUFFICIENT_MAKER_BALANCE',
- 'INSUFFICIENT_MAKER_ALLOWANCE',
- 'INSUFFICIENT_TAKER_FEE_BALANCE',
- 'INSUFFICIENT_TAKER_FEE_ALLOWANCE',
- 'INSUFFICIENT_MAKER_FEE_BALANCE',
- 'INSUFFICIENT_MAKER_FEE_ALLOWANCE',
- 'TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER',
- 'MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED',
- 'INSUFFICIENT_REMAINING_FILL_AMOUNT',
- 'MULTIPLE_TAKER_TOKENS_IN_FILL_UP_TO_DISALLOWED',
- 'BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS',
-]);
-export type ExchangeContractErrs = keyof typeof ExchangeContractErrs;
+export enum ExchangeContractErrs {
+ ORDER_FILL_EXPIRED = 'ORDER_FILL_EXPIRED',
+ ORDER_CANCEL_EXPIRED = 'ORDER_CANCEL_EXPIRED',
+ ORDER_CANCEL_AMOUNT_ZERO = 'ORDER_CANCEL_AMOUNT_ZERO',
+ ORDER_ALREADY_CANCELLED_OR_FILLED = 'ORDER_ALREADY_CANCELLED_OR_FILLED',
+ ORDER_REMAINING_FILL_AMOUNT_ZERO = 'ORDER_REMAINING_FILL_AMOUNT_ZERO',
+ ORDER_FILL_ROUNDING_ERROR = 'ORDER_FILL_ROUNDING_ERROR',
+ FILL_BALANCE_ALLOWANCE_ERROR = 'FILL_BALANCE_ALLOWANCE_ERROR',
+ INSUFFICIENT_TAKER_BALANCE = 'INSUFFICIENT_TAKER_BALANCE',
+ INSUFFICIENT_TAKER_ALLOWANCE = 'INSUFFICIENT_TAKER_ALLOWANCE',
+ INSUFFICIENT_MAKER_BALANCE = 'INSUFFICIENT_MAKER_BALANCE',
+ INSUFFICIENT_MAKER_ALLOWANCE = 'INSUFFICIENT_MAKER_ALLOWANCE',
+ INSUFFICIENT_TAKER_FEE_BALANCE = 'INSUFFICIENT_TAKER_FEE_BALANCE',
+ INSUFFICIENT_TAKER_FEE_ALLOWANCE = 'INSUFFICIENT_TAKER_FEE_ALLOWANCE',
+ INSUFFICIENT_MAKER_FEE_BALANCE = 'INSUFFICIENT_MAKER_FEE_BALANCE',
+ INSUFFICIENT_MAKER_FEE_ALLOWANCE = 'INSUFFICIENT_MAKER_FEE_ALLOWANCE',
+ TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER = 'TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER',
+ MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED = 'MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED',
+ INSUFFICIENT_REMAINING_FILL_AMOUNT = 'INSUFFICIENT_REMAINING_FILL_AMOUNT',
+ MULTIPLE_TAKER_TOKENS_IN_FILL_UP_TO_DISALLOWED = 'MULTIPLE_TAKER_TOKENS_IN_FILL_UP_TO_DISALLOWED',
+ BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS = 'BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS',
+}
export interface ContractResponse {
logs: ContractEvent[];
@@ -312,18 +297,16 @@ export interface TokenAddressBySymbol {
[symbol: string]: string;
}
-export const ExchangeEvents = strEnum([
- 'LogFill',
- 'LogCancel',
- 'LogError',
-]);
-export type ExchangeEvents = keyof typeof ExchangeEvents;
+export enum ExchangeEvents {
+ LogFill = 'LogFill',
+ LogCancel = 'LogCancel',
+ LogError = 'LogError',
+}
-export const TokenEvents = strEnum([
- 'Transfer',
- 'Approval',
-]);
-export type TokenEvents = keyof typeof TokenEvents;
+export enum TokenEvents {
+ Transfer = 'Transfer',
+ Approval = 'Approval',
+}
export interface IndexedFilterValues {
[index: string]: ContractEventArg;