diff options
Diffstat (limited to 'packages/instant')
21 files changed, 203 insertions, 214 deletions
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/README.md b/packages/instant/README.md index 32abf76e0..8832e562d 100644 --- a/packages/instant/README.md +++ b/packages/instant/README.md @@ -17,9 +17,12 @@ The package is available as a UMD module named `zeroExInstant` at https://instan <body> <div id="zeroExInstantContainer"></div> <script> - zeroExInstant.render({ - // Initialization options - }, '#zeroExInstantContainer'); + zeroExInstant.render( + { + // Initialization options + }, + '#zeroExInstantContainer', + ); </script> </body> ``` diff --git a/packages/instant/package.json b/packages/instant/package.json index 0888fc6a6..0012b5b9a 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -1,6 +1,6 @@ { "name": "@0x/instant", - "version": "1.0.5", + "version": "1.0.6", "engines": { "node": ">=6.12" }, @@ -41,18 +41,18 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md", "dependencies": { - "@0x/assert": "^1.0.21", - "@0x/asset-buyer": "^3.0.5", - "@0x/json-schemas": "^2.1.5", - "@0x/order-utils": "^3.1.0", - "@0x/subproviders": "^2.1.9", - "@0x/types": "^1.5.0", - "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.1.1", - "@0x/web3-wrapper": "^3.2.2", + "@0x/assert": "^1.0.22", + "@0x/asset-buyer": "^4.0.0", + "@0x/json-schemas": "^2.1.6", + "@0x/order-utils": "^3.1.1", + "@0x/subproviders": "^2.1.10", + "@0x/types": "^1.5.1", + "@0x/typescript-typings": "^3.0.7", + "@0x/utils": "^3.0.0", + "@0x/web3-wrapper": "^3.2.3", "bowser": "^1.9.4", "copy-to-clipboard": "^3.0.8", - "ethereum-types": "^1.1.4", + "ethereum-types": "^1.1.5", "lodash": "^4.17.5", "polished": "^2.2.0", "react": "^16.5.2", @@ -65,7 +65,7 @@ "ts-optchain": "^0.1.1" }, "devDependencies": { - "@0x/tslint-config": "^2.0.0", + "@0x/tslint-config": "^2.0.1", "@static/discharge": "https://github.com/0xProject/discharge.git", "@types/enzyme": "^3.1.14", "@types/enzyme-adapter-react-16": "^1.0.3", diff --git a/packages/instant/src/components/animations/full_rotation.tsx b/packages/instant/src/components/animations/full_rotation.tsx index 9adb565f9..1dff1b1fc 100644 --- a/packages/instant/src/components/animations/full_rotation.tsx +++ b/packages/instant/src/components/animations/full_rotation.tsx @@ -14,10 +14,7 @@ to { } `; -export const FullRotation = - styled.div < - FullRotationProps > - ` +export const FullRotation = styled.div<FullRotationProps>` animation: ${rotatingKeyframes} 2s linear infinite; height: ${props => props.height}; width: ${props => props.width}; diff --git a/packages/instant/src/components/animations/position_animation.tsx b/packages/instant/src/components/animations/position_animation.tsx index 8b3b294b7..4f8f25679 100644 --- a/packages/instant/src/components/animations/position_animation.tsx +++ b/packages/instant/src/components/animations/position_animation.tsx @@ -95,10 +95,7 @@ const animationForSize = ( return animationSettingsForSize && mediaFn`${generatePositionAnimationCss(animationSettingsForSize)}`; }; -export const PositionAnimation = - styled.div < - PositionAnimationProps > - ` +export const PositionAnimation = styled.div<PositionAnimationProps>` && { ${props => props.zIndex && stylesForMedia<number>('z-index', props.zIndex)} ${props => defaultAnimation(props.positionSettings)} diff --git a/packages/instant/src/components/css_reset.tsx b/packages/instant/src/components/css_reset.tsx index 0bef85389..d1b20f4c9 100644 --- a/packages/instant/src/components/css_reset.tsx +++ b/packages/instant/src/components/css_reset.tsx @@ -4,9 +4,9 @@ import { createGlobalStyle } from '../style/theme'; export interface CSSResetProps {} /* -* Derived from -* https://github.com/jtrost/Complete-CSS-Reset -*/ + * Derived from + * https://github.com/jtrost/Complete-CSS-Reset + */ export const CSSReset = createGlobalStyle` .${INJECTED_DIV_CLASS} { a, abbr, area, article, aside, audio, b, bdo, blockquote, body, button, diff --git a/packages/instant/src/components/timed_progress_bar.tsx b/packages/instant/src/components/timed_progress_bar.tsx index b1644b871..287269af7 100644 --- a/packages/instant/src/components/timed_progress_bar.tsx +++ b/packages/instant/src/components/timed_progress_bar.tsx @@ -68,10 +68,7 @@ interface ProgressProps { animationSettings?: WidthAnimationSettings; } -export const Progress = - styled.div < - ProgressProps > - ` +export const Progress = styled.div<ProgressProps>` && { background-color: ${props => props.theme[ColorOption.primaryColor]}; border-radius: 6px; diff --git a/packages/instant/src/components/ui/circle.tsx b/packages/instant/src/components/ui/circle.tsx index 4f9f56f12..e4f2c5260 100644 --- a/packages/instant/src/components/ui/circle.tsx +++ b/packages/instant/src/components/ui/circle.tsx @@ -8,16 +8,15 @@ export interface CircleProps { } export const Circle = withTheme( - styled.div < - CircleProps > - ` - && { - width: ${props => props.diameter}px; - height: ${props => props.diameter}px; - background-color: ${props => (props.rawColor ? props.rawColor : props.theme[props.color || ColorOption.white])}; - border-radius: 50%; - } -`, + styled.div<CircleProps>` + && { + width: ${props => props.diameter}px; + height: ${props => props.diameter}px; + background-color: ${props => + props.rawColor ? props.rawColor : props.theme[props.color || ColorOption.white]}; + border-radius: 50%; + } + `, ); Circle.displayName = 'Circle'; diff --git a/packages/instant/src/components/ui/container.tsx b/packages/instant/src/components/ui/container.tsx index 58d7d5871..59b733f3e 100644 --- a/packages/instant/src/components/ui/container.tsx +++ b/packages/instant/src/components/ui/container.tsx @@ -51,10 +51,7 @@ const getBackgroundColor = (theme: any, backgroundColor?: ColorOption, rawBackgr return 'none'; }; -export const Container = - styled.div < - ContainerProps > - ` +export const Container = styled.div<ContainerProps>` && { box-sizing: border-box; ${props => cssRuleIfExists(props, 'flex-grow')} diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx index 274c46b9e..145e654f1 100644 --- a/packages/instant/src/components/ui/flex.tsx +++ b/packages/instant/src/components/ui/flex.tsx @@ -14,10 +14,7 @@ export interface FlexProps { flexGrow?: number | string; } -export const Flex = - styled.div < - FlexProps > - ` +export const Flex = styled.div<FlexProps>` && { display: ${props => (props.inline ? 'inline-flex' : 'flex')}; flex-direction: ${props => props.direction}; diff --git a/packages/instant/src/components/ui/input.tsx b/packages/instant/src/components/ui/input.tsx index 53c43ea0b..024e81b15 100644 --- a/packages/instant/src/components/ui/input.tsx +++ b/packages/instant/src/components/ui/input.tsx @@ -14,10 +14,7 @@ export interface InputProps extends React.HTMLAttributes<HTMLInputElement> { onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void; } -export const Input = - styled.input < - InputProps > - ` +export const Input = styled.input<InputProps>` && { all: initial; font-size: ${props => props.fontSize}; @@ -32,10 +29,11 @@ export const Input = color: ${props => props.theme[props.fontColor || 'white']} !important; opacity: 0.5 !important; } - &::-webkit-outer-spin-button, &::-webkit-inner-spin-button { + &::-webkit-outer-spin-button, + &::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; - } + } } `; diff --git a/packages/instant/src/components/ui/overlay.tsx b/packages/instant/src/components/ui/overlay.tsx index 0b5eaf299..0b1be6a65 100644 --- a/packages/instant/src/components/ui/overlay.tsx +++ b/packages/instant/src/components/ui/overlay.tsx @@ -12,10 +12,7 @@ export interface OverlayProps { showMaxWidth?: ScreenWidths; } -export const Overlay = - styled.div < - OverlayProps > - ` +export const Overlay = styled.div<OverlayProps>` && { position: fixed; top: 0; diff --git a/packages/instant/src/components/ui/text.tsx b/packages/instant/src/components/ui/text.tsx index 282477758..ca120f3bd 100644 --- a/packages/instant/src/components/ui/text.tsx +++ b/packages/instant/src/components/ui/text.tsx @@ -31,10 +31,7 @@ export const Text: React.StatelessComponent<TextProps> = ({ href, onClick, ...re }; const opacityOnHoverAmount = 0.5; -export const StyledText = - styled.div < - TextProps > - ` +export const StyledText = styled.div<TextProps>` && { font-family: 'Inter UI', sans-serif; font-style: ${props => props.fontStyle}; diff --git a/packages/instant/src/containers/latest_error.tsx b/packages/instant/src/containers/latest_error.tsx index 6da4558ef..57a2dbdc2 100644 --- a/packages/instant/src/containers/latest_error.tsx +++ b/packages/instant/src/containers/latest_error.tsx @@ -62,4 +62,7 @@ const mapDispatchToProps = (dispatch: Dispatch<Action>, _ownProps: LatestErrorPr }, }); -export const LatestError = connect(mapStateToProps, mapDispatchToProps)(LatestErrorComponent); +export const LatestError = connect( + mapStateToProps, + mapDispatchToProps, +)(LatestErrorComponent); 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/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts index b009a327f..709561dbc 100644 --- a/packages/instant/src/util/asset.ts +++ b/packages/instant/src/util/asset.ts @@ -104,9 +104,8 @@ export const assetUtils = { return assetDataGroupIfExists[Network.Mainnet]; }, getERC20AssetsFromAssets: (assets: Asset[]): ERC20Asset[] => { - const erc20sOrUndefined = _.map( - assets, - asset => (asset.metaData.assetProxyId === AssetProxyId.ERC20 ? (asset as ERC20Asset) : undefined), + const erc20sOrUndefined = _.map(assets, asset => + asset.metaData.assetProxyId === AssetProxyId.ERC20 ? (asset as ERC20Asset) : undefined, ); return _.compact(erc20sOrUndefined); }, |