Skip to content

Commit

Permalink
Merge branch 'development' of github.com:blockchain/blockchain-wallet…
Browse files Browse the repository at this point in the history
…-v4-frontend into development
  • Loading branch information
schnogz committed Dec 30, 2020
2 parents d874a21 + 5121c4c commit 92ca800
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ export const FETCH_SDD_LIMITS = '@EVENT.FETCH_SDD_LIMITS'
export const FETCH_SDD_LIMITS_FAILURE = '@EVENT.FETCH_SDD_LIMITS_FAILURE'
export const FETCH_SDD_LIMITS_LOADING = '@EVENT.FETCH_SDD_LIMITS_LOADING'
export const FETCH_SDD_LIMITS_SUCCESS = '@EVENT.FETCH_SDD_LIMITS_SUCCESS'

export const UPDATE_SDD_TRANSACTION_FINISHED =
'@EVENT.UPDATE_SDD_TRANSACTION_FINISHED'
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ const getPayloadObjectForStep = (payload: StepActionsPayload) => {
displayBack: payload.displayBack,
addBank: payload.addBank
}
case 'PREVIEW_SELL': {
return { step: payload.step, sellOrderType: payload.sellOrderType }
}
case 'CHECKOUT_CONFIRM':
case 'ORDER_SUMMARY':
case 'CANCEL_ORDER':
Expand Down Expand Up @@ -644,3 +647,6 @@ export const fetchSDDLimitsSuccess = (
sddLimits
}
})
export const updateSddTransactionFinished = () => ({
type: AT.UPDATE_SDD_TRANSACTION_FINISHED
})
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const INITIAL_STATE: SimpleBuyState = {
quote: Remote.NotAsked,
sddEligible: Remote.NotAsked,
sddVerified: Remote.NotAsked,
sddTransactionFinished: false,
sellOrder: undefined,
sellQuote: Remote.NotAsked,
step: 'CRYPTO_SELECTION',
Expand Down Expand Up @@ -331,6 +332,12 @@ export function simpleBuyReducer (
payment: Remote.Success(action.payload.payment)

This comment has been minimized.

Copy link
@Huper7777
}
}
case AT.UPDATE_SDD_TRANSACTION_FINISHED: {
return {
...state,
sddTransactionFinished: true
}
}
case AT.SET_STEP:
switch (action.payload.step) {
case 'ENTER_AMOUNT':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,6 @@ export const isUserSddVerified = (state: RootState) => {
}
export const getSddLimits = (state: RootState) =>
state.components.simpleBuy.sddLimits

export const getSddTransactionFinished = (state: RootState) =>
state.components.simpleBuy.sddTransactionFinished
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export type SimpleBuyState = {
quote: RemoteDataType<string, SBQuoteType>
sddEligible: RemoteDataType<string, SDDEligibleType>
sddLimits: RemoteDataType<string, undefined | SwapUserLimitsType>
sddTransactionFinished: boolean
sddVerified: RemoteDataType<string, SDDVerifiedType>
sellOrder: undefined | SwapOrderType
sellQuote: RemoteDataType<string, { quote: SwapQuoteType; rate: number }>
Expand Down Expand Up @@ -403,12 +404,15 @@ export type StepActionsPayload =
step: 'PAYMENT_METHODS'
}
| { order?: SBOrderType; step: '3DS_HANDLER' }
| {
sellOrderType?: 'ACCOUNT' | 'CUSTODIAL'
step: 'PREVIEW_SELL'
}
| {
step:
| 'ADD_CARD'
| 'CC_BILLING_ADDRESS'
| 'KYC_REQUIRED'
| 'PREVIEW_SELL'
| 'UPGRADE_TO_GOLD'
}

Expand Down Expand Up @@ -458,6 +462,9 @@ interface FetchSDDLimitsSuccess {
}
type: typeof AT.FETCH_SDD_LIMITS_SUCCESS
}
interface UpdateSddTransactionFinished {
type: typeof AT.UPDATE_SDD_TRANSACTION_FINISHED
}

export type SimpleBuyActionTypes =
| ActivateSBCardFailure
Expand Down Expand Up @@ -512,3 +519,4 @@ export type SimpleBuyActionTypes =
| UpdatePaymentFailureAction
| UpdatePaymentLoadingAction
| UpdatePaymentSuccessAction
| UpdateSddTransactionFinished
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,27 @@ export default ({
) as InitSwapFormValuesType

if (initSwapFormValues?.BASE && initSwapFormValues?.COUNTER) {
yield put(A.setStep({ step: 'ENTER_AMOUNT' }))
yield put(
A.setStep({
step: 'ENTER_AMOUNT',
options: {
coin: payload.account.coin,
account: payload.account.type,
side: payload.side
}
})
)
} else {
yield put(A.setStep({ step: 'INIT_SWAP' }))
yield put(
A.setStep({
step: 'INIT_SWAP',
options: {
coin: payload.account.coin,
account: payload.account.type,
side: payload.side
}
})
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,32 @@ interface SwitchFixActionType {
}

export type SwapStepPayload =
// added these optional payloads for data science tracking
| {
options?: never
options?: {
account?: 'ACCOUNT' | 'CUSTODIAL',
coin?: CoinType,
side?: 'BASE' | 'COUNTER'
}
step: 'ENTER_AMOUNT'
}
| {
options?: never
options?: {
account?: 'ACCOUNT' | 'CUSTODIAL',
coin?: CoinType,
side?: 'BASE' | 'COUNTER'
}
step: 'INIT_SWAP'
}
| { options?: never; step: 'PREVIEW_SWAP' }
| {
options?: {
baseAccountType?: 'ACCOUNT' | 'CUSTODIAL',
baseCoin?: CoinType,
counterAccountType?: 'ACCOUNT' | 'CUSTODIAL',
counterCoin?: CoinType
}
step: 'PREVIEW_SWAP'
}
| {
options: {
order: SwapOrderType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { equals, includes, path, prop } from 'ramda'

import { StepActionsPayload } from 'data/types'
import { StepActionsPayload, SwapStepPayload } from 'data/types'

const PAYLOAD = ['payload']
const NAME = ['payload', 'name']
Expand All @@ -26,6 +26,7 @@ const WhitelistActionTypesEnum = {
'@EVENT.KYC.UPDATE_EMAIL': '@EVENT.KYC.UPDATE_EMAIL',
'@EVENT.BORROW.SET_STEP': '@EVENT.BORROW.SET_STEP',
'@EVENT.SET_SB_STEP': '@EVENT.SET_SB_STEP',
'@EVENT.SET_SWAP_STEP': '@EVENT.SET_SWAP_STEP',
CLOSE_MODAL: 'CLOSE_MODAL',
SHOW_MODAL: 'SHOW_MODAL'
}
Expand Down Expand Up @@ -73,12 +74,82 @@ const sanitizeEvent = (
fiatCurrency: sbAction.fiatCurrency,
pair: sbAction.pair ? sbAction.pair.pair : '',
side: sbAction.orderType,
sellOrderType: sbAction.swapAccount?.type,
step: sbAction.step
})
]
case 'PREVIEW_SELL':
return [
nextCategory,
formatEvent({
step: sbAction.step,
sellOrderType: sbAction.sellOrderType
})
]
case 'SELL_ORDER_SUMMARY':
return [
nextCategory,
formatEvent({
step: sbAction.step,
sellOrderType: sbAction.sellOrder.kind.direction
})
]
default:
return [nextCategory, formatEvent(sbAction.step)]
}
case '@EVENT.SET_SWAP_STEP':
const swapAction = nextAction as SwapStepPayload
switch (swapAction.step) {
case 'COIN_SELECTION':
return [
nextCategory,
formatEvent({
side: swapAction.options.side
})
]
case 'INIT_SWAP':
return [
nextCategory,
formatEvent({
step: swapAction.step,
side: swapAction.options?.side,
coin: swapAction.options?.coin,
accountType: swapAction.options?.account
})
]
case 'ENTER_AMOUNT':
return [
nextCategory,
formatEvent({
step: swapAction.step,
side: swapAction.options?.side,
coin: swapAction.options?.coin,
accountType: swapAction.options?.account
})
]
case 'PREVIEW_SWAP':
return [
nextCategory,
formatEvent({
step: swapAction.step,
baseCoin: swapAction.options?.baseCoin,
baseAccountType: swapAction.options?.baseAccountType,
counterCoin: swapAction.options?.counterCoin,
counterAccountType: swapAction.options?.counterAccountType
})
]
case 'SUCCESSFUL_SWAP':
return [
nextCategory,
formatEvent({
step: swapAction.step,
orderType: swapAction.options.order.kind.direction,
orderPair: swapAction.options.order.pair
})
]
default:
return [nextCategory, formatEvent(swapAction.step)]
}
default:
return [nextCategory, formatEvent(nextAction), formatEvent(nextName)]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export type Props = OwnProps & SuccessStateType
const CryptoSelector: React.FC<InjectedFormProps<{}, Props> &
Props> = props => {
const [orderType, setOrderType] = useState(props.orderType)
const showWelcome = props.isFirstLogin
const showWelcome = props.isFirstLogin && !props.sddTransactionFinished

const handleBuy = (pair: SBPairType) => {
const currentTier = props.userData?.tiers?.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class CryptoSelection extends PureComponent<Props> {
const mapStateToProps = (state: RootState) => ({
data: getData(state),
fiatCurrency: selectors.components.simpleBuy.getFiatCurrency(state) || 'USD',
isFirstLogin: selectors.auth.getFirstLogin(state)
isFirstLogin: selectors.auth.getFirstLogin(state),
sddTransactionFinished: selectors.components.simpleBuy.getSddTransactionFinished(
state
)
})

export const mapDispatchToProps = (dispatch: Dispatch) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class Checkout extends PureComponent<Props> {
// TODO: sell
// need to do kyc check
if (formValues?.orderType === 'SELL') {
return this.props.simpleBuyActions.setStep({ step: 'PREVIEW_SELL' })
return this.props.simpleBuyActions.setStep({
step: 'PREVIEW_SELL',
sellOrderType: this.props.swapAccount?.type
})
}

if (isSddFlow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,12 @@ const Success: React.FC<Props> = props => {
size='16px'
height='48px'
nature='primary'
onClick={() =>
onClick={() => {
props.simpleBuyActions.setStep({
step: 'UPGRADE_TO_GOLD'
})
}
props.simpleBuyActions.updateSddTransactionFinished()
}}
style={{ marginBottom: '32px' }}
>
<FormattedMessage id='buttons.ok' defaultMessage='OK' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,15 @@ const Checkout: React.FC<InjectedFormProps<{}, Props> & Props> = props => {

const handleSubmit = e => {
e.preventDefault()
props.swapActions.setStep({ step: 'PREVIEW_SWAP' })
props.swapActions.setStep({
step: 'PREVIEW_SWAP',
options: {
baseCoin: BASE.coin,
baseAccountType: BASE.type,
counterCoin: COUNTER.coin,
counterAccountType: COUNTER.type
}
})
}
const userMax = Number(payment ? payment.effectiveBalance : BASE.balance)
const balanceBelowMinimum = userMax < Number(min)
Expand Down

0 comments on commit 92ca800

Please sign in to comment.