aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/asset-buyer/src/utils/order_provider_response_processor.ts2
-rw-r--r--packages/contract-wrappers/CHANGELOG.json9
-rw-r--r--packages/contract-wrappers/src/types.ts14
-rw-r--r--packages/contract-wrappers/test/exchange_wrapper_test.ts10
-rw-r--r--packages/contract-wrappers/test/forwarder_wrapper_test.ts8
-rw-r--r--packages/contract-wrappers/test/order_validator_wrapper_test.ts4
-rw-r--r--packages/instant/CHANGELOG.json9
-rw-r--r--packages/instant/src/redux/actions.ts93
-rw-r--r--packages/instant/src/redux/analytics_middleware.ts16
-rw-r--r--packages/instant/src/redux/reducer.ts46
-rw-r--r--packages/instant/src/style/theme.ts2
-rw-r--r--packages/instant/src/types.ts8
-rw-r--r--packages/instant/src/util/analytics.ts130
-rw-r--r--packages/pipeline/src/parsers/copper/index.ts6
-rw-r--r--packages/testnet-faucets/src/ts/handler.ts6
-rw-r--r--packages/tslint-config/package.json1
-rw-r--r--packages/tslint-config/rules/enumNamingRule.ts60
-rw-r--r--packages/tslint-config/test/enumNamingSpec.spec.ts88
-rw-r--r--packages/tslint-config/test/lintrunner.ts23
-rw-r--r--packages/tslint-config/tsconfig.json4
-rw-r--r--packages/tslint-config/tslint.json3
-rw-r--r--packages/website/ts/components/dialogs/ledger_config_dialog.tsx18
-rw-r--r--packages/website/ts/components/fill_order.tsx8
-rw-r--r--packages/website/ts/components/generate_order/asset_picker.tsx42
-rw-r--r--packages/website/ts/components/generate_order/generate_order_form.tsx20
-rw-r--r--packages/website/ts/components/generate_order/new_token_form.tsx2
-rw-r--r--packages/website/ts/components/inputs/allowance_state_toggle.tsx2
-rw-r--r--packages/website/ts/components/portal/portal.tsx4
-rw-r--r--packages/website/ts/components/token_balances.tsx22
-rw-r--r--packages/website/ts/components/ui/alert.tsx2
-rw-r--r--packages/website/ts/components/ui/lifecycle_raised_button.tsx24
-rw-r--r--packages/website/ts/types.ts36
-rw-r--r--packages/website/ts/utils/utils.ts10
33 files changed, 461 insertions, 271 deletions
diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
index 25e85b2cc..4244d196c 100644
--- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts
+++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
@@ -105,7 +105,7 @@ function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
// get corresponding on-chain state for the order
const { orderInfo, traderInfo } = ordersAndTradersInfo[index];
// if the order IS NOT fillable, do not add anything to the accumulations and continue iterating
- if (orderInfo.orderStatus !== OrderStatus.FILLABLE) {
+ if (orderInfo.orderStatus !== OrderStatus.Fillable) {
return accOrders;
}
// if the order IS fillable, add the order and calculate the remaining fillable amount
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index 3234ad31b..9a225726a 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "5.0.0",
+ "changes": [
+ {
+ "note": "Renamed OrderStatus enum members to PascalCase to conform with tslint enum-naming rule",
+ "pr": 1474
+ }
+ ]
+ },
+ {
"timestamp": 1547225310,
"version": "4.2.1",
"changes": [
diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts
index 945ca88cd..29cf8b2c4 100644
--- a/packages/contract-wrappers/src/types.ts
+++ b/packages/contract-wrappers/src/types.ts
@@ -177,13 +177,13 @@ export interface OrderInfo {
}
export enum OrderStatus {
- INVALID = 0,
- INVALID_MAKER_ASSET_AMOUNT,
- INVALID_TAKER_ASSET_AMOUNT,
- FILLABLE,
- EXPIRED,
- FULLY_FILLED,
- CANCELLED,
+ Invalid = 0,
+ InvalidMakerAssetAmount,
+ InvalidTakerAssetAmount,
+ Fillable,
+ Expired,
+ FullyFilled,
+ Cancelled,
}
export interface TraderInfo {
diff --git a/packages/contract-wrappers/test/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts
index 73ce6c743..a1d60dc6e 100644
--- a/packages/contract-wrappers/test/exchange_wrapper_test.ts
+++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts
@@ -109,7 +109,7 @@ describe('ExchangeWrapper', () => {
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder);
- expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
+ expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#fillOrKillOrderAsync', () => {
@@ -157,7 +157,7 @@ describe('ExchangeWrapper', () => {
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder);
- expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
+ expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#marketSellOrdersAsync', () => {
@@ -183,7 +183,7 @@ describe('ExchangeWrapper', () => {
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder);
- expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
+ expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#batchFillOrdersNoThrowAsync', () => {
@@ -197,9 +197,9 @@ describe('ExchangeWrapper', () => {
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
let orderInfo = await contractWrappers.exchange.getOrderInfoAsync(signedOrder);
- expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
+ expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
orderInfo = await contractWrappers.exchange.getOrderInfoAsync(anotherSignedOrder);
- expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
+ expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#batchFillOrKillOrdersAsync', () => {
diff --git a/packages/contract-wrappers/test/forwarder_wrapper_test.ts b/packages/contract-wrappers/test/forwarder_wrapper_test.ts
index ff4ff8b67..0d197eced 100644
--- a/packages/contract-wrappers/test/forwarder_wrapper_test.ts
+++ b/packages/contract-wrappers/test/forwarder_wrapper_test.ts
@@ -97,8 +97,8 @@ describe('ForwarderWrapper', () => {
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ordersInfo = await contractWrappers.exchange.getOrdersInfoAsync([signedOrder, anotherSignedOrder]);
- expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
- expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
+ expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FullyFilled);
+ expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
it('should throw when invalid transaction and shouldValidate is true', async () => {
const signedOrders = [signedOrder];
@@ -131,8 +131,8 @@ describe('ForwarderWrapper', () => {
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ordersInfo = await contractWrappers.exchange.getOrdersInfoAsync([signedOrder, anotherSignedOrder]);
- expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FULLY_FILLED);
- expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.FILLABLE);
+ expect(ordersInfo[0].orderStatus).to.be.equal(OrderStatus.FullyFilled);
+ expect(ordersInfo[1].orderStatus).to.be.equal(OrderStatus.Fillable);
expect(ordersInfo[1].orderTakerAssetFilledAmount).to.be.bignumber.equal(new BigNumber(4)); // only 95% of ETH is sold
});
it('should throw when invalid transaction and shouldValidate is true', async () => {
diff --git a/packages/contract-wrappers/test/order_validator_wrapper_test.ts b/packages/contract-wrappers/test/order_validator_wrapper_test.ts
index da3f99e72..c61c05d31 100644
--- a/packages/contract-wrappers/test/order_validator_wrapper_test.ts
+++ b/packages/contract-wrappers/test/order_validator_wrapper_test.ts
@@ -117,9 +117,9 @@ describe('OrderValidator', () => {
it('should return correct on-chain order info for input orders', async () => {
const firstOrderInfo = ordersInfo[0];
const secondOrderInfo = ordersInfo[1];
- expect(firstOrderInfo.orderStatus).to.be.equal(OrderStatus.FILLABLE);
+ expect(firstOrderInfo.orderStatus).to.be.equal(OrderStatus.Fillable);
expect(firstOrderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT);
- expect(secondOrderInfo.orderStatus).to.be.equal(OrderStatus.FILLABLE);
+ expect(secondOrderInfo.orderStatus).to.be.equal(OrderStatus.Fillable);
expect(secondOrderInfo.orderTakerAssetFilledAmount).to.bignumber.equal(constants.ZERO_AMOUNT);
});
it('should return correct on-chain trader info for input takers', async () => {
diff --git a/packages/instant/CHANGELOG.json b/packages/instant/CHANGELOG.json
index db187140f..537670584 100644
--- a/packages/instant/CHANGELOG.json
+++ b/packages/instant/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Renamed ActionTypes enum members to PascalCase to conform with tslint enum-naming rule",
+ "pr": 1474
+ }
+ ]
+ },
+ {
"timestamp": 1542821676,
"version": "1.0.1",
"changes": [
diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts
index 9d7a61fc7..ca0be543b 100644
--- a/packages/instant/src/redux/actions.ts
+++ b/packages/instant/src/redux/actions.ts
@@ -21,57 +21,56 @@ function createAction<T extends string, P>(type: T, data?: P): PlainAction<T> |
}
export enum ActionTypes {
- SET_ACCOUNT_STATE_LOADING = 'SET_ACCOUNT_STATE_LOADING',
- SET_ACCOUNT_STATE_LOCKED = 'SET_ACCOUNT_STATE_LOCKED',
- SET_ACCOUNT_STATE_READY = 'SET_ACCOUNT_STATE_READY',
- UPDATE_ACCOUNT_ETH_BALANCE = 'UPDATE_ACCOUNT_ETH_BALANCE',
- UPDATE_ETH_USD_PRICE = 'UPDATE_ETH_USD_PRICE',
- UPDATE_SELECTED_ASSET_UNIT_AMOUNT = 'UPDATE_SELECTED_ASSET_UNIT_AMOUNT',
- SET_BUY_ORDER_STATE_NONE = 'SET_BUY_ORDER_STATE_NONE',
- SET_BUY_ORDER_STATE_VALIDATING = 'SET_BUY_ORDER_STATE_VALIDATING',
- SET_BUY_ORDER_STATE_PROCESSING = 'SET_BUY_ORDER_STATE_PROCESSING',
- SET_BUY_ORDER_STATE_FAILURE = 'SET_BUY_ORDER_STATE_FAILURE',
- SET_BUY_ORDER_STATE_SUCCESS = 'SET_BUY_ORDER_STATE_SUCCESS',
- UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE',
- UPDATE_SELECTED_ASSET = 'UPDATE_SELECTED_ASSET',
- SET_AVAILABLE_ASSETS = 'SET_AVAILABLE_ASSETS',
- SET_QUOTE_REQUEST_STATE_PENDING = 'SET_QUOTE_REQUEST_STATE_PENDING',
- SET_QUOTE_REQUEST_STATE_FAILURE = 'SET_QUOTE_REQUEST_STATE_FAILURE',
- SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE',
- HIDE_ERROR = 'HIDE_ERROR',
- CLEAR_ERROR = 'CLEAR_ERROR',
- RESET_AMOUNT = 'RESET_AMOUNT',
- OPEN_STANDARD_SLIDING_PANEL = 'OPEN_STANDARD_SLIDING_PANEL',
- CLOSE_STANDARD_SLIDING_PANEL = 'CLOSE_STANDARD_SLIDING_PANEL',
- UPDATE_BASE_CURRENCY = 'UPDATE_BASE_CURRENCY',
+ SetAccountStateLoading = 'SET_ACCOUNT_STATE_LOADING',
+ SetAccountStateLocked = 'SET_ACCOUNT_STATE_LOCKED',
+ SetAccountStateReady = 'SET_ACCOUNT_STATE_READY',
+ UpdateAccountEthBalance = 'UPDATE_ACCOUNT_ETH_BALANCE',
+ UpdateEthUsdPrice = 'UPDATE_ETH_USD_PRICE',
+ UpdateSelectedAssetUnitAmount = 'UPDATE_SELECTED_ASSET_UNIT_AMOUNT',
+ SetBuyOrderStateNone = 'SET_BUY_ORDER_STATE_NONE',
+ SetBuyOrderStateValidating = 'SET_BUY_ORDER_STATE_VALIDATING',
+ SetBuyOrderStateProcessing = 'SET_BUY_ORDER_STATE_PROCESSING',
+ SetBuyOrderStateFailure = 'SET_BUY_ORDER_STATE_FAILURE',
+ SetBuyOrderStateSuccess = 'SET_BUY_ORDER_STATE_SUCCESS',
+ UpdateLatestBuyQuote = 'UPDATE_LATEST_BUY_QUOTE',
+ UpdateSelectedAsset = 'UPDATE_SELECTED_ASSET',
+ SetAvailableAssets = 'SET_AVAILABLE_ASSETS',
+ SetQuoteRequestStatePending = 'SET_QUOTE_REQUEST_STATE_PENDING',
+ SetQuoteRequestStateFailure = 'SET_QUOTE_REQUEST_STATE_FAILURE',
+ SetErrorMessage = 'SET_ERROR_MESSAGE',
+ HideError = 'HIDE_ERROR',
+ ClearError = 'CLEAR_ERROR',
+ ResetAmount = 'RESET_AMOUNT',
+ OpenStandardSlidingPanel = 'OPEN_STANDARD_SLIDING_PANEL',
+ CloseStandardSlidingPanel = 'CLOSE_STANDARD_SLIDING_PANEL',
+ UpdateBaseCurrency = 'UPDATE_BASE_CURRENCY',
}
export const actions = {
- setAccountStateLoading: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOADING),
- setAccountStateLocked: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOCKED),
- setAccountStateReady: (address: string) => createAction(ActionTypes.SET_ACCOUNT_STATE_READY, address),
+ setAccountStateLoading: () => createAction(ActionTypes.SetAccountStateLoading),
+ setAccountStateLocked: () => createAction(ActionTypes.SetAccountStateLocked),
+ setAccountStateReady: (address: string) => createAction(ActionTypes.SetAccountStateReady, address),
updateAccountEthBalance: (addressAndBalance: AddressAndEthBalanceInWei) =>
- createAction(ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE, addressAndBalance),
- updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UPDATE_ETH_USD_PRICE, price),
- updateSelectedAssetAmount: (amount?: BigNumber) =>
- createAction(ActionTypes.UPDATE_SELECTED_ASSET_UNIT_AMOUNT, amount),
- setBuyOrderStateNone: () => createAction(ActionTypes.SET_BUY_ORDER_STATE_NONE),
- setBuyOrderStateValidating: () => createAction(ActionTypes.SET_BUY_ORDER_STATE_VALIDATING),
+ createAction(ActionTypes.UpdateAccountEthBalance, addressAndBalance),
+ updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UpdateEthUsdPrice, price),
+ updateSelectedAssetAmount: (amount?: BigNumber) => createAction(ActionTypes.UpdateSelectedAssetUnitAmount, amount),
+ setBuyOrderStateNone: () => createAction(ActionTypes.SetBuyOrderStateNone),
+ setBuyOrderStateValidating: () => createAction(ActionTypes.SetBuyOrderStateValidating),
setBuyOrderStateProcessing: (txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- createAction(ActionTypes.SET_BUY_ORDER_STATE_PROCESSING, { txHash, startTimeUnix, expectedEndTimeUnix }),
- setBuyOrderStateFailure: (txHash: string) => createAction(ActionTypes.SET_BUY_ORDER_STATE_FAILURE, txHash),
- setBuyOrderStateSuccess: (txHash: string) => createAction(ActionTypes.SET_BUY_ORDER_STATE_SUCCESS, txHash),
- updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote),
- updateSelectedAsset: (asset: Asset) => createAction(ActionTypes.UPDATE_SELECTED_ASSET, asset),
- setAvailableAssets: (availableAssets: Asset[]) => createAction(ActionTypes.SET_AVAILABLE_ASSETS, availableAssets),
- setQuoteRequestStatePending: () => createAction(ActionTypes.SET_QUOTE_REQUEST_STATE_PENDING),
- setQuoteRequestStateFailure: () => createAction(ActionTypes.SET_QUOTE_REQUEST_STATE_FAILURE),
- setErrorMessage: (errorMessage: string) => createAction(ActionTypes.SET_ERROR_MESSAGE, errorMessage),
- hideError: () => createAction(ActionTypes.HIDE_ERROR),
- clearError: () => createAction(ActionTypes.CLEAR_ERROR),
- resetAmount: () => createAction(ActionTypes.RESET_AMOUNT),
+ createAction(ActionTypes.SetBuyOrderStateProcessing, { txHash, startTimeUnix, expectedEndTimeUnix }),
+ setBuyOrderStateFailure: (txHash: string) => createAction(ActionTypes.SetBuyOrderStateFailure, txHash),
+ setBuyOrderStateSuccess: (txHash: string) => createAction(ActionTypes.SetBuyOrderStateSuccess, txHash),
+ updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UpdateLatestBuyQuote, buyQuote),
+ updateSelectedAsset: (asset: Asset) => createAction(ActionTypes.UpdateSelectedAsset, asset),
+ setAvailableAssets: (availableAssets: Asset[]) => createAction(ActionTypes.SetAvailableAssets, availableAssets),
+ setQuoteRequestStatePending: () => createAction(ActionTypes.SetQuoteRequestStatePending),
+ setQuoteRequestStateFailure: () => createAction(ActionTypes.SetQuoteRequestStateFailure),
+ setErrorMessage: (errorMessage: string) => createAction(ActionTypes.SetErrorMessage, errorMessage),
+ hideError: () => createAction(ActionTypes.HideError),
+ clearError: () => createAction(ActionTypes.ClearError),
+ resetAmount: () => createAction(ActionTypes.ResetAmount),
openStandardSlidingPanel: (content: StandardSlidingPanelContent) =>
- createAction(ActionTypes.OPEN_STANDARD_SLIDING_PANEL, content),
- closeStandardSlidingPanel: () => createAction(ActionTypes.CLOSE_STANDARD_SLIDING_PANEL),
- updateBaseCurrency: (baseCurrency: BaseCurrency) => createAction(ActionTypes.UPDATE_BASE_CURRENCY, baseCurrency),
+ createAction(ActionTypes.OpenStandardSlidingPanel, content),
+ closeStandardSlidingPanel: () => createAction(ActionTypes.CloseStandardSlidingPanel),
+ updateBaseCurrency: (baseCurrency: BaseCurrency) => createAction(ActionTypes.UpdateBaseCurrency, baseCurrency),
};
diff --git a/packages/instant/src/redux/analytics_middleware.ts b/packages/instant/src/redux/analytics_middleware.ts
index a86a16b1a..4b4d30213 100644
--- a/packages/instant/src/redux/analytics_middleware.ts
+++ b/packages/instant/src/redux/analytics_middleware.ts
@@ -21,7 +21,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
const curAccount = curState.providerState.account;
switch (nextAction.type) {
- case ActionTypes.SET_ACCOUNT_STATE_READY:
+ case ActionTypes.SetAccountStateReady:
if (curAccount.state === AccountState.Ready) {
const didJustTurnReady = prevAccount.state !== AccountState.Ready;
const didJustUpdateAddress =
@@ -38,13 +38,13 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
}
}
break;
- case ActionTypes.SET_ACCOUNT_STATE_LOCKED:
+ case ActionTypes.SetAccountStateLocked:
if (prevAccount.state !== AccountState.Locked && curAccount.state === AccountState.Locked) {
// if we are moving from account not locked to account locked, track `Account - Locked`
analytics.trackAccountLocked();
}
break;
- case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE:
+ case ActionTypes.UpdateAccountEthBalance:
if (
curAccount.state === AccountState.Ready &&
curAccount.ethBalanceInWei &&
@@ -58,7 +58,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
analytics.addEventProperties({ ethBalanceInUnitAmount });
}
break;
- case ActionTypes.UPDATE_SELECTED_ASSET:
+ case ActionTypes.UpdateSelectedAsset:
const selectedAsset = curState.selectedAsset;
if (selectedAsset) {
const assetName = selectedAsset.metaData.name;
@@ -79,7 +79,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
analytics.addEventProperties(selectedAssetEventProperties);
}
break;
- case ActionTypes.SET_AVAILABLE_ASSETS:
+ case ActionTypes.SetAvailableAssets:
const availableAssets = curState.availableAssets;
if (availableAssets) {
analytics.addEventProperties({
@@ -87,19 +87,19 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
});
}
break;
- case ActionTypes.OPEN_STANDARD_SLIDING_PANEL:
+ case ActionTypes.OpenStandardSlidingPanel:
const openSlidingContent = curState.standardSlidingPanelSettings.content;
if (openSlidingContent === StandardSlidingPanelContent.InstallWallet) {
analytics.trackInstallWalletModalOpened();
}
break;
- case ActionTypes.CLOSE_STANDARD_SLIDING_PANEL:
+ case ActionTypes.CloseStandardSlidingPanel:
const closeSlidingContent = curState.standardSlidingPanelSettings.content;
if (closeSlidingContent === StandardSlidingPanelContent.InstallWallet) {
analytics.trackInstallWalletModalClosed();
}
break;
- case ActionTypes.UPDATE_BASE_CURRENCY:
+ case ActionTypes.UpdateBaseCurrency:
analytics.trackBaseCurrencyChanged(curState.baseCurrency);
analytics.addEventProperties({ baseCurrency: curState.baseCurrency });
}
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 8c13c9c72..0d8bb4b05 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -72,11 +72,11 @@ export const DEFAULT_STATE: DefaultState = {
export const createReducer = (initialState: State) => {
const reducer = (state: State = initialState, action: Action): State => {
switch (action.type) {
- case ActionTypes.SET_ACCOUNT_STATE_LOADING:
+ case ActionTypes.SetAccountStateLoading:
return reduceStateWithAccount(state, LOADING_ACCOUNT);
- case ActionTypes.SET_ACCOUNT_STATE_LOCKED:
+ case ActionTypes.SetAccountStateLocked:
return reduceStateWithAccount(state, LOCKED_ACCOUNT);
- case ActionTypes.SET_ACCOUNT_STATE_READY: {
+ case ActionTypes.SetAccountStateReady: {
const address = action.data;
let newAccount: AccountReady = {
state: AccountState.Ready,
@@ -91,7 +91,7 @@ export const createReducer = (initialState: State) => {
}
return reduceStateWithAccount(state, newAccount);
}
- case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE: {
+ case ActionTypes.UpdateAccountEthBalance: {
const { address, ethBalanceInWei } = action.data;
const currentAccount = state.providerState.account;
if (currentAccount.state !== AccountState.Ready || currentAccount.address !== address) {
@@ -104,17 +104,17 @@ export const createReducer = (initialState: State) => {
return reduceStateWithAccount(state, newAccount);
}
}
- case ActionTypes.UPDATE_ETH_USD_PRICE:
+ case ActionTypes.UpdateEthUsdPrice:
return {
...state,
ethUsdPrice: action.data,
};
- case ActionTypes.UPDATE_SELECTED_ASSET_UNIT_AMOUNT:
+ case ActionTypes.UpdateSelectedAssetUnitAmount:
return {
...state,
selectedAssetUnitAmount: action.data,
};
- case ActionTypes.UPDATE_LATEST_BUY_QUOTE:
+ case ActionTypes.UpdateLatestBuyQuote:
const newBuyQuoteIfExists = action.data;
const shouldUpdate =
_.isUndefined(newBuyQuoteIfExists) || doesBuyQuoteMatchState(newBuyQuoteIfExists, state);
@@ -127,29 +127,29 @@ export const createReducer = (initialState: State) => {
} else {
return state;
}
- case ActionTypes.SET_QUOTE_REQUEST_STATE_PENDING:
+ case ActionTypes.SetQuoteRequestStatePending:
return {
...state,
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.Pending,
};
- case ActionTypes.SET_QUOTE_REQUEST_STATE_FAILURE:
+ case ActionTypes.SetQuoteRequestStateFailure:
return {
...state,
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.Failure,
};
- case ActionTypes.SET_BUY_ORDER_STATE_NONE:
+ case ActionTypes.SetBuyOrderStateNone:
return {
...state,
buyOrderState: { processState: OrderProcessState.None },
};
- case ActionTypes.SET_BUY_ORDER_STATE_VALIDATING:
+ case ActionTypes.SetBuyOrderStateValidating:
return {
...state,
buyOrderState: { processState: OrderProcessState.Validating },
};
- case ActionTypes.SET_BUY_ORDER_STATE_PROCESSING:
+ case ActionTypes.SetBuyOrderStateProcessing:
const processingData = action.data;
const { startTimeUnix, expectedEndTimeUnix } = processingData;
return {
@@ -163,7 +163,7 @@ export const createReducer = (initialState: State) => {
},
},
};
- case ActionTypes.SET_BUY_ORDER_STATE_FAILURE:
+ case ActionTypes.SetBuyOrderStateFailure:
const failureTxHash = action.data;
if ('txHash' in state.buyOrderState) {
if (state.buyOrderState.txHash === failureTxHash) {
@@ -179,7 +179,7 @@ export const createReducer = (initialState: State) => {
}
}
return state;
- case ActionTypes.SET_BUY_ORDER_STATE_SUCCESS:
+ case ActionTypes.SetBuyOrderStateSuccess:
const successTxHash = action.data;
if ('txHash' in state.buyOrderState) {
if (state.buyOrderState.txHash === successTxHash) {
@@ -195,29 +195,29 @@ export const createReducer = (initialState: State) => {
}
}
return state;
- case ActionTypes.SET_ERROR_MESSAGE:
+ case ActionTypes.SetErrorMessage:
return {
...state,
latestErrorMessage: action.data,
latestErrorDisplayStatus: DisplayStatus.Present,
};
- case ActionTypes.HIDE_ERROR:
+ case ActionTypes.HideError:
return {
...state,
latestErrorDisplayStatus: DisplayStatus.Hidden,
};
- case ActionTypes.CLEAR_ERROR:
+ case ActionTypes.ClearError:
return {
...state,
latestErrorMessage: undefined,
latestErrorDisplayStatus: DisplayStatus.Hidden,
};
- case ActionTypes.UPDATE_SELECTED_ASSET:
+ case ActionTypes.UpdateSelectedAsset:
return {
...state,
selectedAsset: action.data,
};
- case ActionTypes.RESET_AMOUNT:
+ case ActionTypes.ResetAmount:
return {
...state,
latestBuyQuote: undefined,
@@ -225,12 +225,12 @@ export const createReducer = (initialState: State) => {
buyOrderState: { processState: OrderProcessState.None },
selectedAssetUnitAmount: undefined,
};
- case ActionTypes.SET_AVAILABLE_ASSETS:
+ case ActionTypes.SetAvailableAssets:
return {
...state,
availableAssets: action.data,
};
- case ActionTypes.OPEN_STANDARD_SLIDING_PANEL:
+ case ActionTypes.OpenStandardSlidingPanel:
return {
...state,
standardSlidingPanelSettings: {
@@ -238,7 +238,7 @@ export const createReducer = (initialState: State) => {
animationState: 'slidIn',
},
};
- case ActionTypes.CLOSE_STANDARD_SLIDING_PANEL:
+ case ActionTypes.CloseStandardSlidingPanel:
return {
...state,
standardSlidingPanelSettings: {
@@ -246,7 +246,7 @@ export const createReducer = (initialState: State) => {
animationState: 'slidOut',
},
};
- case ActionTypes.UPDATE_BASE_CURRENCY:
+ case ActionTypes.UpdateBaseCurrency:
return {
...state,
baseCurrency: action.data,
diff --git a/packages/instant/src/style/theme.ts b/packages/instant/src/style/theme.ts
index fd3f03c3f..49f3c81e6 100644
--- a/packages/instant/src/style/theme.ts
+++ b/packages/instant/src/style/theme.ts
@@ -11,7 +11,7 @@ const {
} = styledComponents;
export type Theme = { [key in ColorOption]: string };
-
+// tslint:disable:enum-naming
export enum ColorOption {
primaryColor = 'primaryColor',
black = 'black',
diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts
index f07a407da..606294c93 100644
--- a/packages/instant/src/types.ts
+++ b/packages/instant/src/types.ts
@@ -27,8 +27,8 @@ export enum QuoteFetchOrigin {
}
export enum BaseCurrency {
- USD = 'USD',
- ETH = 'ETH',
+ USD = 'USD', // tslint:disable-line:enum-naming
+ ETH = 'ETH', // tslint:disable-line:enum-naming
}
export interface SimulatedProgress {
@@ -95,7 +95,7 @@ export enum Network {
export enum ZeroExInstantError {
AssetMetaDataNotAvailable = 'ASSET_META_DATA_NOT_AVAILABLE',
- InsufficientETH = 'INSUFFICIENT_ETH',
+ InsufficientETH = 'INSUFFICIENT_ETH', // tslint:disable-line:enum-naming
CouldNotSubmitTransaction = 'COULD_NOT_SUBMIT_TRANSACTION',
}
@@ -168,7 +168,7 @@ export enum WalletSuggestion {
export enum OperatingSystem {
Android = 'ANDROID',
- iOS = 'IOS',
+ iOS = 'IOS', // tslint:disable-line:enum-naming
Mac = 'MAC',
Windows = 'WINDOWS',
WindowsPhone = 'WINDOWS_PHONE',
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index 4faeaaf5a..fa8a72a2c 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -31,38 +31,38 @@ export const evaluateIfEnabled = (fnCall: () => void) => {
};
enum EventNames {
- INSTANT_OPENED = 'Instant - Opened',
- INSTANT_CLOSED = 'Instant - Closed',
- ACCOUNT_LOCKED = 'Account - Locked',
- ACCOUNT_READY = 'Account - Ready',
- ACCOUNT_UNLOCK_REQUESTED = 'Account - Unlock Requested',
- ACCOUNT_UNLOCK_DENIED = 'Account - Unlock Denied',
- ACCOUNT_ADDRESS_CHANGED = 'Account - Address Changed',
- BASE_CURRENCY_CHANGED = 'Base Currency - Changed',
- PAYMENT_METHOD_DROPDOWN_OPENED = 'Payment Method - Dropdown Opened',
- PAYMENT_METHOD_OPENED_ETHERSCAN = 'Payment Method - Opened Etherscan',
- PAYMENT_METHOD_COPIED_ADDRESS = 'Payment Method - Copied Address',
- BUY_NOT_ENOUGH_ETH = 'Buy - Not Enough Eth',
- BUY_STARTED = 'Buy - Started',
- BUY_SIGNATURE_DENIED = 'Buy - Signature Denied',
- BUY_SIMULATION_FAILED = 'Buy - Simulation Failed',
- BUY_UNKNOWN_ERROR = 'Buy - Unknown Error',
- BUY_TX_SUBMITTED = 'Buy - Tx Submitted',
- BUY_TX_SUCCEEDED = 'Buy - Tx Succeeded',
- BUY_TX_FAILED = 'Buy - Tx Failed',
- USD_PRICE_FETCH_FAILED = 'USD Price - Fetch Failed',
- INSTALL_WALLET_CLICKED = 'Install Wallet - Clicked',
- INSTALL_WALLET_MODAL_OPENED = 'Install Wallet - Modal - Opened',
- INSTALL_WALLET_MODAL_CLICKED_EXPLANATION = 'Install Wallet - Modal - Clicked Explanation',
- INSTALL_WALLET_MODAL_CLICKED_GET = 'Install Wallet - Modal - Clicked Get',
- INSTALL_WALLET_MODAL_CLOSED = 'Install Wallet - Modal - Closed',
- TOKEN_SELECTOR_OPENED = 'Token Selector - Opened',
- TOKEN_SELECTOR_CLOSED = 'Token Selector - Closed',
- TOKEN_SELECTOR_CHOSE = 'Token Selector - Chose',
- TOKEN_SELECTOR_SEARCHED = 'Token Selector - Searched',
- TRANSACTION_VIEWED = 'Transaction - Viewed',
- QUOTE_FETCHED = 'Quote - Fetched',
- QUOTE_ERROR = 'Quote - Error',
+ InstantOpened = 'Instant - Opened',
+ InstantClosed = 'Instant - Closed',
+ AccountLocked = 'Account - Locked',
+ AccountReady = 'Account - Ready',
+ AccountUnlockRequested = 'Account - Unlock Requested',
+ AccountUnlockDenied = 'Account - Unlock Denied',
+ AccountAddressChanged = 'Account - Address Changed',
+ BaseCurrencyChanged = 'Base Currency - Changed',
+ PaymentMethodDropdownOpened = 'Payment Method - Dropdown Opened',
+ PaymentMethodOpenedEtherscan = 'Payment Method - Opened Etherscan',
+ PaymentMethodCopiedAddress = 'Payment Method - Copied Address',
+ BuyNotEnoughEth = 'Buy - Not Enough Eth',
+ BuyStarted = 'Buy - Started',
+ BuySignatureDenied = 'Buy - Signature Denied',
+ BuySimulationFailed = 'Buy - Simulation Failed',
+ BuyUnknownError = 'Buy - Unknown Error',
+ BuyTxSubmitted = 'Buy - Tx Submitted',
+ BuyTxSucceeded = 'Buy - Tx Succeeded',
+ BuyTxFailed = 'Buy - Tx Failed',
+ UsdPriceFetchFailed = 'USD Price - Fetch Failed',
+ InstallWalletClicked = 'Install Wallet - Clicked',
+ InstallWalletModalOpened = 'Install Wallet - Modal - Opened',
+ InstallWalletModalClickedExplanation = 'Install Wallet - Modal - Clicked Explanation',
+ InstallWalletModalClickedGet = 'Install Wallet - Modal - Clicked Get',
+ InstallWalletModalClosed = 'Install Wallet - Modal - Closed',
+ TokenSelectorOpened = 'Token Selector - Opened',
+ TokenSelectorClosed = 'Token Selector - Closed',
+ TokenSelectorChose = 'Token Selector - Chose',
+ TokenSelectorSearched = 'Token Selector - Searched',
+ TransactionViewed = 'Transaction - Viewed',
+ QuoteFetched = 'Quote - Fetched',
+ QuoteError = 'Quote - Error',
}
const track = (eventName: EventNames, eventProperties: EventProperties = {}): void => {
@@ -125,7 +125,7 @@ export interface AnalyticsEventOptions {
baseCurrency?: string;
}
export enum TokenSelectorClosedVia {
- ClickedX = 'Clicked X',
+ ClickedX = 'Clicked X', // tslint:disable-line:enum-naming
TokenChose = 'Token Chose',
}
export const analytics = {
@@ -169,80 +169,80 @@ export const analytics = {
};
return eventOptions;
},
- trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED),
- trackInstantClosed: trackingEventFnWithoutPayload(EventNames.INSTANT_CLOSED),
- trackAccountLocked: trackingEventFnWithoutPayload(EventNames.ACCOUNT_LOCKED),
- trackAccountReady: (address: string) => trackingEventFnWithPayload(EventNames.ACCOUNT_READY)({ address }),
- trackAccountUnlockRequested: trackingEventFnWithoutPayload(EventNames.ACCOUNT_UNLOCK_REQUESTED),
- trackAccountUnlockDenied: trackingEventFnWithoutPayload(EventNames.ACCOUNT_UNLOCK_DENIED),
+ trackInstantOpened: trackingEventFnWithoutPayload(EventNames.InstantOpened),
+ trackInstantClosed: trackingEventFnWithoutPayload(EventNames.InstantClosed),
+ trackAccountLocked: trackingEventFnWithoutPayload(EventNames.AccountLocked),
+ trackAccountReady: (address: string) => trackingEventFnWithPayload(EventNames.AccountReady)({ address }),
+ trackAccountUnlockRequested: trackingEventFnWithoutPayload(EventNames.AccountUnlockRequested),
+ trackAccountUnlockDenied: trackingEventFnWithoutPayload(EventNames.AccountUnlockDenied),
trackAccountAddressChanged: (address: string) =>
- trackingEventFnWithPayload(EventNames.ACCOUNT_ADDRESS_CHANGED)({ address }),
+ trackingEventFnWithPayload(EventNames.AccountAddressChanged)({ address }),
trackBaseCurrencyChanged: (currencyChangedTo: BaseCurrency) =>
- trackingEventFnWithPayload(EventNames.BASE_CURRENCY_CHANGED)({ currencyChangedTo }),
- trackPaymentMethodDropdownOpened: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_DROPDOWN_OPENED),
- trackPaymentMethodOpenedEtherscan: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_OPENED_ETHERSCAN),
- trackPaymentMethodCopiedAddress: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_COPIED_ADDRESS),
+ trackingEventFnWithPayload(EventNames.BaseCurrencyChanged)({ currencyChangedTo }),
+ trackPaymentMethodDropdownOpened: trackingEventFnWithoutPayload(EventNames.PaymentMethodDropdownOpened),
+ trackPaymentMethodOpenedEtherscan: trackingEventFnWithoutPayload(EventNames.PaymentMethodOpenedEtherscan),
+ trackPaymentMethodCopiedAddress: trackingEventFnWithoutPayload(EventNames.PaymentMethodCopiedAddress),
trackBuyNotEnoughEth: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_NOT_ENOUGH_ETH)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuyNotEnoughEth)(buyQuoteEventProperties(buyQuote)),
trackBuyStarted: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_STARTED)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuyStarted)(buyQuoteEventProperties(buyQuote)),
trackBuySignatureDenied: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_SIGNATURE_DENIED)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuySignatureDenied)(buyQuoteEventProperties(buyQuote)),
trackBuySimulationFailed: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_SIMULATION_FAILED)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuySimulationFailed)(buyQuoteEventProperties(buyQuote)),
trackBuyUnknownError: (buyQuote: BuyQuote, errorMessage: string) =>
- trackingEventFnWithPayload(EventNames.BUY_UNKNOWN_ERROR)({
+ trackingEventFnWithPayload(EventNames.BuyUnknownError)({
...buyQuoteEventProperties(buyQuote),
errorMessage,
}),
trackBuyTxSubmitted: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_SUBMITTED)({
+ trackingEventFnWithPayload(EventNames.BuyTxSubmitted)({
...buyQuoteEventProperties(buyQuote),
txHash,
expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix,
}),
trackBuyTxSucceeded: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_SUCCEEDED)({
+ trackingEventFnWithPayload(EventNames.BuyTxSucceeded)({
...buyQuoteEventProperties(buyQuote),
txHash,
expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix,
actualTxTimeMs: new Date().getTime() - startTimeUnix,
}),
trackBuyTxFailed: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_FAILED)({
+ trackingEventFnWithPayload(EventNames.BuyTxFailed)({
...buyQuoteEventProperties(buyQuote),
txHash,
expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix,
actualTxTimeMs: new Date().getTime() - startTimeUnix,
}),
trackInstallWalletClicked: (walletSuggestion: WalletSuggestion) =>
- trackingEventFnWithPayload(EventNames.INSTALL_WALLET_CLICKED)({ walletSuggestion }),
+ trackingEventFnWithPayload(EventNames.InstallWalletClicked)({ walletSuggestion }),
trackInstallWalletModalClickedExplanation: trackingEventFnWithoutPayload(
- EventNames.INSTALL_WALLET_MODAL_CLICKED_EXPLANATION,
+ EventNames.InstallWalletModalClickedExplanation,
),
- trackInstallWalletModalClickedGet: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_CLICKED_GET),
- trackInstallWalletModalOpened: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_OPENED),
- trackInstallWalletModalClosed: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_CLOSED),
- trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TOKEN_SELECTOR_OPENED),
+ trackInstallWalletModalClickedGet: trackingEventFnWithoutPayload(EventNames.InstallWalletModalClickedGet),
+ trackInstallWalletModalOpened: trackingEventFnWithoutPayload(EventNames.InstallWalletModalOpened),
+ trackInstallWalletModalClosed: trackingEventFnWithoutPayload(EventNames.InstallWalletModalClosed),
+ trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TokenSelectorOpened),
trackTokenSelectorClosed: (closedVia: TokenSelectorClosedVia) =>
- trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CLOSED)({ closedVia }),
+ trackingEventFnWithPayload(EventNames.TokenSelectorClosed)({ closedVia }),
trackTokenSelectorChose: (payload: { assetName: string; assetData: string }) =>
- trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CHOSE)(payload),
+ trackingEventFnWithPayload(EventNames.TokenSelectorChose)(payload),
trackTokenSelectorSearched: (searchText: string) =>
- trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_SEARCHED)({ searchText }),
+ trackingEventFnWithPayload(EventNames.TokenSelectorSearched)({ searchText }),
trackTransactionViewed: (orderProcesState: OrderProcessState) =>
- trackingEventFnWithPayload(EventNames.TRANSACTION_VIEWED)({ orderState: orderProcesState }),
+ trackingEventFnWithPayload(EventNames.TransactionViewed)({ orderState: orderProcesState }),
trackQuoteFetched: (buyQuote: BuyQuote, fetchOrigin: QuoteFetchOrigin) =>
- trackingEventFnWithPayload(EventNames.QUOTE_FETCHED)({
+ trackingEventFnWithPayload(EventNames.QuoteFetched)({
...buyQuoteEventProperties(buyQuote),
fetchOrigin,
}),
trackQuoteError: (errorMessage: string, assetBuyAmount: BigNumber, fetchOrigin: QuoteFetchOrigin) => {
- trackingEventFnWithPayload(EventNames.QUOTE_ERROR)({
+ trackingEventFnWithPayload(EventNames.QuoteError)({
errorMessage,
assetBuyAmount: assetBuyAmount.toString(),
fetchOrigin,
});
},
- trackUsdPriceFailed: trackingEventFnWithoutPayload(EventNames.USD_PRICE_FETCH_FAILED),
+ trackUsdPriceFailed: trackingEventFnWithoutPayload(EventNames.UsdPriceFetchFailed),
};
diff --git a/packages/pipeline/src/parsers/copper/index.ts b/packages/pipeline/src/parsers/copper/index.ts
index 6c0c5abd5..07da66d10 100644
--- a/packages/pipeline/src/parsers/copper/index.ts
+++ b/packages/pipeline/src/parsers/copper/index.ts
@@ -44,8 +44,8 @@ export interface CopperActivityParentResponse {
// custom activity types
export enum CopperActivityTypeCategory {
- user = 'user',
- system = 'system',
+ User = 'user',
+ System = 'system',
}
export interface CopperActivityTypeResponse {
id: number;
@@ -90,7 +90,7 @@ export enum CopperCustomFieldType {
Date = 'Date',
Checkbox = 'Checkbox',
Float = 'Float',
- URL = 'URL',
+ URL = 'URL', // tslint:disable-line:enum-naming
Percentage = 'Percentage',
Currency = 'Currency',
Connect = 'Connect',
diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts
index 2dfa3c3af..8f642d4b0 100644
--- a/packages/testnet-faucets/src/ts/handler.ts
+++ b/packages/testnet-faucets/src/ts/handler.ts
@@ -36,9 +36,9 @@ interface ItemByNetworkId<T> {
}
enum RequestedAssetType {
- ETH = 'ETH',
- WETH = 'WETH',
- ZRX = 'ZRX',
+ ETH = 'ETH', // tslint:disable-line:enum-naming
+ WETH = 'WETH', // tslint:disable-line:enum-naming
+ ZRX = 'ZRX', // tslint:disable-line:enum-naming
}
const FIVE_DAYS_IN_MS = 4.32e8; // TODO: make this configurable
diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json
index 77c28f32c..cf39bde3e 100644
--- a/packages/tslint-config/package.json
+++ b/packages/tslint-config/package.json
@@ -9,6 +9,7 @@
"scripts": {
"build": "tsc -b",
"build:ci": "yarn build",
+ "test": "mocha ./lib/test/*.spec.js",
"clean": "shx rm -rf lib",
"lint": "tslint --format stylish --project ."
},
diff --git a/packages/tslint-config/rules/enumNamingRule.ts b/packages/tslint-config/rules/enumNamingRule.ts
new file mode 100644
index 000000000..56499618f
--- /dev/null
+++ b/packages/tslint-config/rules/enumNamingRule.ts
@@ -0,0 +1,60 @@
+import * as Lint from 'tslint';
+import * as ts from 'typescript';
+
+export class Rule extends Lint.Rules.AbstractRule {
+ public static FAILURE_STRING = `Enum member names should be PascalCase`;
+
+ public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
+ return this.applyWithFunction(sourceFile, walk);
+ }
+}
+
+function walk(ctx: Lint.WalkContext<void>): void {
+ // Recursively walk the AST starting with root node, `ctx.sourceFile`.
+ // Call the function `cb` (defined below) for each child.
+ return ts.forEachChild(ctx.sourceFile, cb);
+
+ function cb(node: ts.Node): void {
+ if (node.kind === ts.SyntaxKind.EnumMember) {
+ const keyNode = node.getFirstToken(ctx.sourceFile);
+ if (keyNode !== undefined) {
+ const keyText = keyNode.getText(ctx.sourceFile);
+ if (!isPascalCase(keyText)) {
+ return ctx.addFailureAtNode(node, Rule.FAILURE_STRING, getFix(keyText, node));
+ }
+ }
+ }
+ // Continue recursion into the AST by calling function `cb` for every child of the current node.
+ return ts.forEachChild(node, cb);
+ }
+
+ function getFix(text: string, node: ts.Node): Lint.Replacement {
+ let fix = toPascalCase(text);
+ // check for `member = value`
+ if (node.getChildCount(ctx.sourceFile) === 3) {
+ const value = node.getLastToken(ctx.sourceFile);
+ if (value !== undefined) {
+ fix += ` = ${value.getText(ctx.sourceFile)}`;
+ }
+ }
+ return new Lint.Replacement(node.getStart(ctx.sourceFile), node.getWidth(ctx.sourceFile), fix);
+ }
+}
+
+// Modified from: https://github.com/jonschlinkert/pascalcase/
+function toPascalCase(str: string): string {
+ let result = str.replace(/([a-z0-9\W])([A-Z])/g, '$1 $2');
+ if (result.length === 1) {
+ return result.toUpperCase();
+ }
+ result = result.replace(/^[\W_\.]+|[\W_\.]+$/g, '').toLowerCase();
+ result = result.charAt(0).toUpperCase() + result.slice(1);
+ return result.replace(/[\W_\.]+(\w|$)/g, (_, ch) => {
+ return ch.toUpperCase();
+ });
+}
+function isPascalCase(s: string): boolean {
+ const regex = /^([A-Z0-9]+[a-z0-9]+)+$/g;
+ const key = s.split('=')[0].trim();
+ return regex.test(key);
+}
diff --git a/packages/tslint-config/test/enumNamingSpec.spec.ts b/packages/tslint-config/test/enumNamingSpec.spec.ts
new file mode 100644
index 000000000..d5b864eba
--- /dev/null
+++ b/packages/tslint-config/test/enumNamingSpec.spec.ts
@@ -0,0 +1,88 @@
+import * as assert from 'assert';
+
+import { Rule } from '../rules/enumNamingRule';
+
+import { getFixedResult, helper } from './lintrunner';
+const rule = 'enum-naming';
+
+describe('enumNamingRule', () => {
+ it(`should not fail PascalCase`, () => {
+ const src = `enum test { MemberOne, MemberTwo }`;
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 0);
+ });
+ it(`should not fail PascalCase keys with uncased values`, () => {
+ const src = `enum test { MemberOne = 'member_one', MemberTwo = 'member two' }`;
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 0);
+ });
+ it(`should not fail PascalCase keys with numbers`, () => {
+ const src = `enum test { Member1 = 'member_one', MemberTwo = 'member two' }`;
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 0);
+ });
+ it(`should fail with camelCase`, () => {
+ const src = `enum test { memberOne, memberTwo }`;
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 2);
+ });
+ it(`should fail with snake case`, () => {
+ const src = `enum test { member_one, member_two }`;
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 2);
+ });
+ it(`should fail with all caps`, () => {
+ const src = `enum test { MEMBERONE, MEMBER_TWO }`;
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 2);
+ });
+ it(`should fail with mixed case`, () => {
+ const src = `enum test { member_one, MemberTwo }`;
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 1);
+ });
+
+ it(`should fail with the right position`, () => {
+ const src = `enum test { MemberOne, member_two }`;
+ const startPosition = src.indexOf('member_two');
+ const endPosition = startPosition + 'member_two'.length;
+ const failure = helper(src, rule).failures[0];
+
+ assert.equal(failure.getStartPosition().getPosition(), startPosition);
+ assert.equal(failure.getEndPosition().getPosition(), endPosition);
+ assert.equal(failure.getFailure(), Rule.FAILURE_STRING);
+ });
+
+ it(`should fail with the right message`, () => {
+ const src = `enum test { memberOne, memberTwo }`;
+ const failure = helper(src, rule).failures[0];
+
+ assert.equal(failure.getFailure(), Rule.FAILURE_STRING);
+ });
+});
+describe('enumNaming fixer', () => {
+ it('should fix keys', () => {
+ const src = `enum test { MemberOne, memberTwo, member_three, MEMBER_FOUR, MEMBERFIVE }`;
+ const expected = `enum test { MemberOne, MemberTwo, MemberThree, MemberFour, Memberfive }`;
+ const actual = getFixedResult(src, rule);
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 4); // tslint:disable-line:custom-no-magic-numbers
+ assert.equal(actual, expected);
+ });
+ it('should not fix values', () => {
+ const src = `enum test { MemberOne = 'MemberOne', memberTwo = 'memberTwo', member_three = 'member_three', MEMBER_FOUR = 'MEMBER_FOUR' }`;
+ const expected = `enum test { MemberOne = 'MemberOne', MemberTwo = 'memberTwo', MemberThree = 'member_three', MemberFour = 'MEMBER_FOUR' }`;
+ const actual = getFixedResult(src, rule);
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 3); // tslint:disable-line:custom-no-magic-numbers
+ assert.equal(actual, expected);
+ });
+ it('should preserve values with equals sign', () => {
+ const src = `enum Operators { assign = '=', EQUALS = '==', Triple_Equals = '===' }`;
+ const expected = `enum Operators { Assign = '=', Equals = '==', TripleEquals = '===' }`;
+ const actual = getFixedResult(src, rule);
+ const result = helper(src, rule);
+ assert.equal(result.errorCount, 3); // tslint:disable-line:custom-no-magic-numbers
+ assert.equal(actual, expected);
+ });
+});
diff --git a/packages/tslint-config/test/lintrunner.ts b/packages/tslint-config/test/lintrunner.ts
new file mode 100644
index 000000000..fcd1b6844
--- /dev/null
+++ b/packages/tslint-config/test/lintrunner.ts
@@ -0,0 +1,23 @@
+import * as path from 'path';
+import { Configuration, Linter, Replacement } from 'tslint';
+
+export const helper = (src: string, rule: string) => {
+ const linter = new Linter({ fix: false });
+ linter.lint(
+ '',
+ src,
+ Configuration.parseConfigFile({
+ rules: {
+ [rule]: true,
+ },
+ rulesDirectory: path.join(__dirname, '../rules'),
+ }),
+ );
+ return linter.getResult();
+};
+
+export const getFixedResult = (src: string, rule: string) => {
+ const result = helper(src, rule);
+ const fixes = [].concat.apply(result.failures.map(x => x.getFix()));
+ return Replacement.applyFixes(src, fixes);
+};
diff --git a/packages/tslint-config/tsconfig.json b/packages/tslint-config/tsconfig.json
index 44845cf1f..b9a4dd03e 100644
--- a/packages/tslint-config/tsconfig.json
+++ b/packages/tslint-config/tsconfig.json
@@ -2,7 +2,7 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
- "rootDir": "rules"
+ "rootDir": "."
},
- "include": ["./rules/**/*"]
+ "include": ["./rules/**/*", "test/**/*"]
}
diff --git a/packages/tslint-config/tslint.json b/packages/tslint-config/tslint.json
index e8de6221e..a5fa6962c 100644
--- a/packages/tslint-config/tslint.json
+++ b/packages/tslint-config/tslint.json
@@ -25,6 +25,7 @@
"curly": true,
"custom-no-magic-numbers": [true, 0, 1, 2, 3, -1],
"encoding": true,
+ "enum-naming": true,
"eofline": true,
"import-spacing": true,
"indent": [true, "spaces", 4],
@@ -125,5 +126,5 @@
"check-preblock"
]
},
- "rulesDirectory": "lib"
+ "rulesDirectory": "lib/rules"
}
diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
index e15a2dd94..527353aa0 100644
--- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
+++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
@@ -20,8 +20,8 @@ import { utils } from 'ts/utils/utils';
const VALID_ETHEREUM_DERIVATION_PATH_PREFIX = `44'/60'`;
enum LedgerSteps {
- CONNECT,
- SELECT_ADDRESS,
+ Connect,
+ SelectAddress,
}
interface LedgerConfigDialogProps {
@@ -52,7 +52,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
const derivationPathIfExists = props.blockchain.getLedgerDerivationPathIfExists();
this.state = {
connectionErrMsg: '',
- stepIndex: LedgerSteps.CONNECT,
+ stepIndex: LedgerSteps.Connect,
userAddresses: [],
addressBalances: [],
derivationPath: _.isUndefined(derivationPathIfExists)
@@ -67,7 +67,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
<FlatButton key="ledgerConnectCancel" label="Cancel" onClick={this._onClose.bind(this)} />,
];
const dialogTitle =
- this.state.stepIndex === LedgerSteps.CONNECT ? 'Connect to your Ledger' : 'Select desired address';
+ this.state.stepIndex === LedgerSteps.Connect ? 'Connect to your Ledger' : 'Select desired address';
return (
<Dialog
title={dialogTitle}
@@ -79,8 +79,8 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
bodyStyle={{ paddingBottom: 0 }}
>
<div style={{ color: colors.grey700, paddingTop: 1 }}>
- {this.state.stepIndex === LedgerSteps.CONNECT && this._renderConnectStep()}
- {this.state.stepIndex === LedgerSteps.SELECT_ADDRESS && this._renderSelectAddressStep()}
+ {this.state.stepIndex === LedgerSteps.Connect && this._renderConnectStep()}
+ {this.state.stepIndex === LedgerSteps.SelectAddress && this._renderSelectAddressStep()}
</div>
</Dialog>
);
@@ -195,7 +195,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
private _onClose(): void {
this.setState({
connectionErrMsg: '',
- stepIndex: LedgerSteps.CONNECT,
+ stepIndex: LedgerSteps.Connect,
});
const isOpen = false;
this.props.toggleDialogFn(isOpen);
@@ -210,7 +210,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
this.props.blockchain.fetchTokenInformationAsync();
this.props.dispatcher.updateUserWeiBalance(selectAddressBalance);
this.setState({
- stepIndex: LedgerSteps.CONNECT,
+ stepIndex: LedgerSteps.Connect,
});
const isOpen = false;
this.props.toggleDialogFn(isOpen);
@@ -284,7 +284,7 @@ export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps,
const didSucceed = await this._fetchAddressesAndBalancesAsync();
if (didSucceed) {
this.setState({
- stepIndex: LedgerSteps.SELECT_ADDRESS,
+ stepIndex: LedgerSteps.SelectAddress,
connectionErrMsg: '',
});
}
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index 2fa2b94a0..7fee8c4df 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -182,7 +182,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
</div>
)}
{!_.isEmpty(this.state.orderJSONErrMsg) && (
- <Alert type={AlertTypes.ERROR} message={this.state.orderJSONErrMsg} />
+ <Alert type={AlertTypes.Error} message={this.state.orderJSONErrMsg} />
)}
</div>
);
@@ -298,7 +298,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
onClick={this._onCancelOrderClickFireAndForgetAsync.bind(this)}
/>
{this.state.didCancelOrderSucceed && (
- <Alert type={AlertTypes.SUCCESS} message={this._renderCancelSuccessMsg()} />
+ <Alert type={AlertTypes.Success} message={this._renderCancelSuccessMsg()} />
)}
</div>
) : (
@@ -310,10 +310,10 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
onClick={this._onFillOrderClick.bind(this)}
/>
{!_.isEmpty(this.state.globalErrMsg) && (
- <Alert type={AlertTypes.ERROR} message={this.state.globalErrMsg} />
+ <Alert type={AlertTypes.Error} message={this.state.globalErrMsg} />
)}
{this.state.didFillOrderSucceed && (
- <Alert type={AlertTypes.SUCCESS} message={this._renderFillSuccessMsg()} />
+ <Alert type={AlertTypes.Success} message={this._renderFillSuccessMsg()} />
)}
</div>
)}
diff --git a/packages/website/ts/components/generate_order/asset_picker.tsx b/packages/website/ts/components/generate_order/asset_picker.tsx
index e6ecd2ec8..d3f11f962 100644
--- a/packages/website/ts/components/generate_order/asset_picker.tsx
+++ b/packages/website/ts/components/generate_order/asset_picker.tsx
@@ -18,9 +18,9 @@ import { utils } from 'ts/utils/utils';
const TOKEN_ICON_DIMENSION = 100;
const TILE_DIMENSION = 146;
enum AssetViews {
- ASSET_PICKER = 'ASSET_PICKER',
- NEW_TOKEN_FORM = 'NEW_TOKEN_FORM',
- CONFIRM_TRACK_TOKEN = 'CONFIRM_TRACK_TOKEN',
+ AssetPicker = 'ASSET_PICKER',
+ NewTokenForm = 'NEW_TOKEN_FORM',
+ ConfirmTrackToken = 'CONFIRM_TRACK_TOKEN',
}
interface AssetPickerProps {
@@ -44,29 +44,29 @@ interface AssetPickerState {
export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerState> {
public static defaultProps: Partial<AssetPickerProps> = {
- tokenVisibility: TokenVisibility.ALL,
+ tokenVisibility: TokenVisibility.All,
};
private readonly _dialogConfigsByAssetView: { [assetView: string]: DialogConfigs };
constructor(props: AssetPickerProps) {
super(props);
this.state = {
- assetView: AssetViews.ASSET_PICKER,
+ assetView: AssetViews.AssetPicker,
hoveredAddress: undefined,
chosenTrackTokenAddress: undefined,
isAddingTokenToTracked: false,
};
this._dialogConfigsByAssetView = {
- [AssetViews.ASSET_PICKER]: {
+ [AssetViews.AssetPicker]: {
title: 'Select token',
isModal: false,
actions: [],
},
- [AssetViews.NEW_TOKEN_FORM]: {
+ [AssetViews.NewTokenForm]: {
title: 'Add an ERC20 token',
isModal: false,
actions: [],
},
- [AssetViews.CONFIRM_TRACK_TOKEN]: {
+ [AssetViews.ConfirmTrackToken]: {
title: 'Tracking confirmation',
isModal: true,
actions: [
@@ -95,15 +95,15 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
autoScrollBodyContent={true}
onRequestClose={this._onCloseDialog.bind(this)}
>
- {this.state.assetView === AssetViews.ASSET_PICKER && this._renderAssetPicker()}
- {this.state.assetView === AssetViews.NEW_TOKEN_FORM && (
+ {this.state.assetView === AssetViews.AssetPicker && this._renderAssetPicker()}
+ {this.state.assetView === AssetViews.NewTokenForm && (
<NewTokenForm
blockchain={this.props.blockchain}
onNewTokenSubmitted={this._onNewTokenSubmitted.bind(this)}
tokenByAddress={this.props.tokenByAddress}
/>
)}
- {this.state.assetView === AssetViews.CONFIRM_TRACK_TOKEN && this._renderConfirmTrackToken()}
+ {this.state.assetView === AssetViews.ConfirmTrackToken && this._renderConfirmTrackToken()}
</Dialog>
);
}
@@ -138,19 +138,19 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
const allTokens = _.values(this.props.tokenByAddress);
// filter tokens based on visibility specified in props, do not show ZRX or ETHER as tracked or untracked
const filteredTokens =
- this.props.tokenVisibility === TokenVisibility.ALL
+ this.props.tokenVisibility === TokenVisibility.All
? allTokens
: _.filter(allTokens, token => {
return (
token.symbol !== constants.ZRX_TOKEN_SYMBOL &&
token.symbol !== constants.ETHER_TOKEN_SYMBOL &&
- ((this.props.tokenVisibility === TokenVisibility.TRACKED && utils.isTokenTracked(token)) ||
- (this.props.tokenVisibility === TokenVisibility.UNTRACKED &&
+ ((this.props.tokenVisibility === TokenVisibility.Tracked && utils.isTokenTracked(token)) ||
+ (this.props.tokenVisibility === TokenVisibility.Untracked &&
!utils.isTokenTracked(token)))
);
});
// if we are showing tracked tokens, sort by date added, otherwise sort by symbol
- const sortKey = this.props.tokenVisibility === TokenVisibility.TRACKED ? 'trackedTimestamp' : 'symbol';
+ const sortKey = this.props.tokenVisibility === TokenVisibility.Tracked ? 'trackedTimestamp' : 'symbol';
const sortedTokens = filteredTokens.sort(firstBy(sortKey));
if (_.isEmpty(sortedTokens)) {
return <div className="mx-auto p4 h2">No tokens to remove.</div>;
@@ -188,7 +188,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
cursor: 'pointer',
opacity: isHovered ? 0.6 : 1,
};
- if (this.props.tokenVisibility !== TokenVisibility.TRACKED) {
+ if (this.props.tokenVisibility !== TokenVisibility.Tracked) {
gridTiles.push(
<div
key={otherTokenKey}
@@ -222,7 +222,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
}
private _onCloseDialog(): void {
this.setState({
- assetView: AssetViews.ASSET_PICKER,
+ assetView: AssetViews.AssetPicker,
});
this.props.onTokenChosen(this.props.currentTokenAddress);
}
@@ -232,21 +232,21 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
this.props.onTokenChosen(tokenAddress);
} else {
this.setState({
- assetView: AssetViews.CONFIRM_TRACK_TOKEN,
+ assetView: AssetViews.ConfirmTrackToken,
chosenTrackTokenAddress: tokenAddress,
});
}
}
private _onCustomAssetChosen(): void {
this.setState({
- assetView: AssetViews.NEW_TOKEN_FORM,
+ assetView: AssetViews.NewTokenForm,
});
}
private _onNewTokenSubmitted(newToken: Token): void {
trackedTokenStorage.addTrackedTokenToUser(this.props.userAddress, this.props.networkId, newToken);
this.props.dispatcher.addTokenToTokenByAddress(newToken);
this.setState({
- assetView: AssetViews.ASSET_PICKER,
+ assetView: AssetViews.AssetPicker,
});
this.props.onTokenChosen(newToken.address);
}
@@ -254,7 +254,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt
const resetState: AssetPickerState = {
...this.state,
isAddingTokenToTracked: false,
- assetView: AssetViews.ASSET_PICKER,
+ assetView: AssetViews.AssetPicker,
chosenTrackTokenAddress: undefined,
};
if (!didUserAcceptTracking) {
diff --git a/packages/website/ts/components/generate_order/generate_order_form.tsx b/packages/website/ts/components/generate_order/generate_order_form.tsx
index 8afbee977..0f70aa18f 100644
--- a/packages/website/ts/components/generate_order/generate_order_form.tsx
+++ b/packages/website/ts/components/generate_order/generate_order_form.tsx
@@ -36,9 +36,9 @@ import { errorReporter } from 'ts/utils/error_reporter';
import { utils } from 'ts/utils/utils';
enum SigningState {
- UNSIGNED,
- SIGNING,
- SIGNED,
+ Unsigned,
+ Signing,
+ Signed,
}
interface GenerateOrderFormProps {
@@ -76,7 +76,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
this.state = {
globalErrMsg: '',
shouldShowIncompleteErrs: false,
- signingState: SigningState.UNSIGNED,
+ signingState: SigningState.Unsigned,
};
}
public componentDidMount(): void {
@@ -207,7 +207,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
/>
</div>
{this.state.globalErrMsg !== '' && (
- <Alert type={AlertTypes.ERROR} message={this.state.globalErrMsg} />
+ <Alert type={AlertTypes.Error} message={this.state.globalErrMsg} />
)}
</div>
</div>
@@ -215,7 +215,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
title="Order JSON"
titleStyle={{ fontWeight: 100 }}
modal={false}
- open={this.state.signingState === SigningState.SIGNED}
+ open={this.state.signingState === SigningState.Signed}
onRequestClose={this._onCloseOrderJSONDialog.bind(this)}
>
<OrderJSON
@@ -247,7 +247,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
// orderHash will not collide with the previously generated orderHash.
this.props.dispatcher.updateOrderSalt(generatePseudoRandomSalt());
this.setState({
- signingState: SigningState.UNSIGNED,
+ signingState: SigningState.Unsigned,
});
}
private async _onSignClickedAsync(): Promise<boolean> {
@@ -305,13 +305,13 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
}
private async _signTransactionAsync(): Promise<PortalOrder | undefined> {
this.setState({
- signingState: SigningState.SIGNING,
+ signingState: SigningState.Signing,
});
const exchangeAddress = this.props.blockchain.getExchangeContractAddressIfExists();
if (_.isUndefined(exchangeAddress)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
this.setState({
- signingState: SigningState.UNSIGNED,
+ signingState: SigningState.Unsigned,
});
return undefined;
}
@@ -371,7 +371,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
}
}
this.setState({
- signingState: globalErrMsg === '' ? SigningState.SIGNED : SigningState.UNSIGNED,
+ signingState: globalErrMsg === '' ? SigningState.Signed : SigningState.Unsigned,
globalErrMsg,
});
return order;
diff --git a/packages/website/ts/components/generate_order/new_token_form.tsx b/packages/website/ts/components/generate_order/new_token_form.tsx
index b8cd88b18..ce684d177 100644
--- a/packages/website/ts/components/generate_order/new_token_form.tsx
+++ b/packages/website/ts/components/generate_order/new_token_form.tsx
@@ -93,7 +93,7 @@ export class NewTokenForm extends React.Component<NewTokenFormProps, NewTokenFor
onClickAsyncFn={this._onAddNewTokenClickAsync.bind(this)}
/>
</div>
- {this.state.globalErrMsg !== '' && <Alert type={AlertTypes.ERROR} message={this.state.globalErrMsg} />}
+ {this.state.globalErrMsg !== '' && <Alert type={AlertTypes.Error} message={this.state.globalErrMsg} />}
</div>
);
}
diff --git a/packages/website/ts/components/inputs/allowance_state_toggle.tsx b/packages/website/ts/components/inputs/allowance_state_toggle.tsx
index 5396295d2..3a78d32f3 100644
--- a/packages/website/ts/components/inputs/allowance_state_toggle.tsx
+++ b/packages/website/ts/components/inputs/allowance_state_toggle.tsx
@@ -150,7 +150,7 @@ export class AllowanceStateToggle extends React.Component<AllowanceStateTogglePr
}
logUtils.log(`Unexpected error encountered: ${err}`);
logUtils.log(err.stack);
- this.props.onErrorOccurred(BalanceErrs.allowanceSettingFailed);
+ this.props.onErrorOccurred(BalanceErrs.AllowanceSettingFailed);
errorReporter.report(err);
}
}
diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx
index 6d7c90573..59cf2db71 100644
--- a/packages/website/ts/components/portal/portal.tsx
+++ b/packages/website/ts/components/portal/portal.tsx
@@ -229,8 +229,8 @@ export class Portal extends React.Component<PortalProps, PortalState> {
const isAssetPickerDialogOpen = this.state.tokenManagementState !== TokenManagementState.None;
const tokenVisibility =
this.state.tokenManagementState === TokenManagementState.Add
- ? TokenVisibility.UNTRACKED
- : TokenVisibility.TRACKED;
+ ? TokenVisibility.Untracked
+ : TokenVisibility.Tracked;
return (
<Container>
<MetaTags title={DOCUMENT_TITLE} description={DOCUMENT_DESCRIPTION} />
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx
index 2ed0229c8..e8f2a6461 100644
--- a/packages/website/ts/components/token_balances.tsx
+++ b/packages/website/ts/components/token_balances.tsx
@@ -303,7 +303,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
currentTokenAddress={''}
onTokenChosen={this._onAssetTokenPicked.bind(this)}
tokenByAddress={this.props.tokenByAddress}
- tokenVisibility={this.state.isAddingToken ? TokenVisibility.UNTRACKED : TokenVisibility.TRACKED}
+ tokenVisibility={this.state.isAddingToken ? TokenVisibility.Untracked : TokenVisibility.Tracked}
/>
</div>
);
@@ -439,7 +439,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
}
private _onSendFailed(): void {
this.setState({
- errorType: BalanceErrs.sendFailed,
+ errorType: BalanceErrs.SendFailed,
});
}
private _renderAmount(amount: BigNumber, decimals: number): React.ReactNode {
@@ -460,7 +460,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
}
private _renderErrorDialogBody(): React.ReactNode {
switch (this.state.errorType) {
- case BalanceErrs.incorrectNetworkForFaucet:
+ case BalanceErrs.IncorrectNetworkForFaucet:
return (
<div>
Our faucet can only send test Ether to addresses on testnets. Please make sure you are connected
@@ -468,7 +468,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
</div>
);
- case BalanceErrs.faucetRequestFailed:
+ case BalanceErrs.FaucetRequestFailed:
return (
<div>
An unexpected error occurred while trying to request test Ether from our faucet. Please refresh
@@ -476,13 +476,13 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
</div>
);
- case BalanceErrs.faucetQueueIsFull:
+ case BalanceErrs.FaucetQueueIsFull:
return <div>Our test Ether faucet queue is full. Please try requesting test Ether again later.</div>;
- case BalanceErrs.mintingFailed:
+ case BalanceErrs.MintingFailed:
return <div>Minting your test tokens failed unexpectedly. Please refresh the page and try again.</div>;
- case BalanceErrs.allowanceSettingFailed:
+ case BalanceErrs.AllowanceSettingFailed:
return (
<div>
An unexpected error occurred while trying to set your test token allowance. Please refresh the
@@ -521,7 +521,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
logUtils.log(`Unexpected error encountered: ${err}`);
logUtils.log(err.stack);
this.setState({
- errorType: BalanceErrs.mintingFailed,
+ errorType: BalanceErrs.MintingFailed,
});
errorReporter.report(err);
return false;
@@ -537,7 +537,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
// from, we must show user an error message
if (!utils.isTestNetwork(this.props.blockchain.networkId)) {
this.setState({
- errorType: BalanceErrs.incorrectNetworkForFaucet,
+ errorType: BalanceErrs.IncorrectNetworkForFaucet,
});
return false;
}
@@ -553,8 +553,8 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
logUtils.log(`Unexpected status code: ${response.status} -> ${responseBody}`);
const errorType =
response.status === constants.UNAVAILABLE_STATUS
- ? BalanceErrs.faucetQueueIsFull
- : BalanceErrs.faucetRequestFailed;
+ ? BalanceErrs.FaucetQueueIsFull
+ : BalanceErrs.FaucetRequestFailed;
this.setState({
errorType,
});
diff --git a/packages/website/ts/components/ui/alert.tsx b/packages/website/ts/components/ui/alert.tsx
index 32e0f1be8..c7a5b9030 100644
--- a/packages/website/ts/components/ui/alert.tsx
+++ b/packages/website/ts/components/ui/alert.tsx
@@ -8,7 +8,7 @@ interface AlertProps {
}
export const Alert = (props: AlertProps) => {
- const isAlert = props.type === AlertTypes.ERROR;
+ const isAlert = props.type === AlertTypes.Error;
const errMsgStyles = {
background: isAlert ? colors.red200 : colors.lightestGreen,
color: colors.white,
diff --git a/packages/website/ts/components/ui/lifecycle_raised_button.tsx b/packages/website/ts/components/ui/lifecycle_raised_button.tsx
index a8daf4102..f004dd47f 100644
--- a/packages/website/ts/components/ui/lifecycle_raised_button.tsx
+++ b/packages/website/ts/components/ui/lifecycle_raised_button.tsx
@@ -6,9 +6,9 @@ import * as React from 'react';
const COMPLETE_STATE_SHOW_LENGTH_MS = 2000;
enum ButtonState {
- READY,
- LOADING,
- COMPLETE,
+ Ready,
+ Loading,
+ Complete,
}
interface LifeCycleRaisedButtonProps {
@@ -38,7 +38,7 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton
constructor(props: LifeCycleRaisedButtonProps) {
super(props);
this.state = {
- buttonState: ButtonState.READY,
+ buttonState: ButtonState.Ready,
};
}
public componentWillUnmount(): void {
@@ -52,13 +52,13 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton
let label;
switch (this.state.buttonState) {
- case ButtonState.READY:
+ case ButtonState.Ready:
label = this.props.labelReady;
break;
- case ButtonState.LOADING:
+ case ButtonState.Loading:
label = this.props.labelLoading;
break;
- case ButtonState.COMPLETE:
+ case ButtonState.Complete:
label = this.props.labelComplete;
break;
default:
@@ -72,13 +72,13 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton
backgroundColor={this.props.backgroundColor}
labelColor={this.props.labelColor}
onClick={this.onClickAsync.bind(this)}
- disabled={this.props.isDisabled || this.state.buttonState !== ButtonState.READY}
+ disabled={this.props.isDisabled || this.state.buttonState !== ButtonState.Ready}
/>
);
}
public async onClickAsync(): Promise<void> {
this.setState({
- buttonState: ButtonState.LOADING,
+ buttonState: ButtonState.Loading,
});
const didSucceed = await this.props.onClickAsyncFn();
if (this._didUnmount) {
@@ -86,16 +86,16 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton
}
if (didSucceed) {
this.setState({
- buttonState: ButtonState.COMPLETE,
+ buttonState: ButtonState.Complete,
});
this._buttonTimeoutId = window.setTimeout(() => {
this.setState({
- buttonState: ButtonState.READY,
+ buttonState: ButtonState.Ready,
});
}, COMPLETE_STATE_SHOW_LENGTH_MS);
} else {
this.setState({
- buttonState: ButtonState.READY,
+ buttonState: ButtonState.Ready,
});
}
}
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index 50114e2d6..9492da5a5 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -83,12 +83,12 @@ export interface Fill {
}
export enum BalanceErrs {
- incorrectNetworkForFaucet,
- faucetRequestFailed,
- faucetQueueIsFull,
- mintingFailed,
- sendFailed,
- allowanceSettingFailed,
+ IncorrectNetworkForFaucet,
+ FaucetRequestFailed,
+ FaucetQueueIsFull,
+ MintingFailed,
+ SendFailed,
+ AllowanceSettingFailed,
}
export enum ActionTypes {
@@ -209,8 +209,8 @@ export enum ScreenWidths {
}
export enum AlertTypes {
- ERROR,
- SUCCESS,
+ Error,
+ Success,
}
export enum BlockchainErrs {
@@ -228,11 +228,11 @@ export enum BlockchainCallErrs {
}
export enum Environments {
- DEVELOPMENT = 'DEVELOPMENT',
- DOGFOOD = 'DOGFOOD',
- STAGING = 'STAGING',
- PRODUCTION = 'PRODUCTION',
- UNKNOWN = 'UNKNOWN',
+ Development = 'DEVELOPMENT',
+ Dogfood = 'DOGFOOD',
+ Staging = 'STAGING',
+ Production = 'PRODUCTION',
+ Unknown = 'UNKNOWN',
}
export type ContractInstance = any; // TODO: add type definition for Contract
@@ -323,9 +323,9 @@ export interface DialogConfigs {
}
export enum TokenVisibility {
- ALL = 'ALL',
- UNTRACKED = 'UNTRACKED',
- TRACKED = 'TRACKED',
+ All = 'ALL',
+ Untracked = 'UNTRACKED',
+ Tracked = 'TRACKED',
}
export interface VersionToFilePath {
@@ -350,7 +350,7 @@ export enum WebsitePaths {
Docs = '/docs',
ZeroExJs = '/docs/0x.js',
Home = '/',
- FAQ = '/faq',
+ FAQ = '/faq', // tslint:disable-line:enum-naming
About = '/about',
AboutMission = '/about/mission',
AboutTeam = '/about/team',
@@ -629,7 +629,7 @@ export enum BrowserType {
export enum OperatingSystemType {
Android = 'Android',
- iOS = 'iOS',
+ iOS = 'iOS', // tslint:disable-line:enum-naming
Mac = 'Mac',
Windows = 'Windows',
WindowsPhone = 'WindowsPhone',
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 8cc0061de..890f1553a 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -342,18 +342,18 @@ export const utils = {
},
getEnvironment(): Environments {
if (utils.isDogfood()) {
- return Environments.DOGFOOD;
+ return Environments.Dogfood;
}
if (utils.isDevelopment()) {
- return Environments.DEVELOPMENT;
+ return Environments.Development;
}
if (utils.isStaging()) {
- return Environments.STAGING;
+ return Environments.Staging;
}
if (utils.isProduction()) {
- return Environments.PRODUCTION;
+ return Environments.Production;
}
- return Environments.UNKNOWN;
+ return Environments.Unknown;
},
getEthToken(tokenByAddress: TokenByAddress): Token {
return utils.getTokenBySymbol(constants.ETHER_TOKEN_SYMBOL, tokenByAddress);