Skip to content

Commit

Permalink
feat: fixed conflicst
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-bc committed Jul 15, 2020
2 parents 92d19c0 + 96f8041 commit e484387
Show file tree
Hide file tree
Showing 72 changed files with 802 additions and 565 deletions.
@@ -1,6 +1,7 @@
import {
AccountTypes,
CoinType,
RatesType,
RemoteDataType,
SupportedCoinsType,
SupportedCoinType
Expand All @@ -9,7 +10,6 @@ import { connect, ConnectedProps } from 'react-redux'
import { Field } from 'redux-form'
import { getData } from './selectors'
import { Icon, Text } from 'blockchain-info-components'
import { RatesType } from 'data/types'
import { RootState } from 'data/rootReducer'
import CoinDisplay from 'components/Display/CoinDisplay'
import FiatDisplay from 'components/Display/FiatDisplay'
Expand Down
@@ -1,12 +1,10 @@
import { actions, selectors } from 'data'
import { isEmpty } from 'ramda'
import { put, select } from 'redux-saga/effects'
import { Remote } from 'blockchain-wallet-v4/src'

export default () => {
const initialized = function * () {
try {
const logsR = yield select(selectors.core.data.misc.getLogs)
const btcTransactions = yield select(
selectors.core.data.btc.getTransactions
)
Expand All @@ -19,9 +17,6 @@ export default () => {
const xlmTransactions = yield select(
selectors.core.data.xlm.getTransactions
)
if (!Remote.Success.is(logsR)) {
yield put(actions.core.data.misc.fetchLogs())
}
if (isEmpty(btcTransactions)) {
yield put(actions.core.data.btc.fetchTransactions('', true))
}
Expand Down
Expand Up @@ -3,7 +3,7 @@ import * as S from './selectors'
import { actions, selectors } from 'data'
import { all, call, put, select } from 'redux-saga/effects'
import { APIType } from 'blockchain-wallet-v4/src/network/api'
import { BorrowFormValuesType, RatesType, RepayLoanFormType } from './types'
import { BorrowFormValuesType, RepayLoanFormType } from './types'
import {
convertBaseToStandard,
convertStandardToBase
Expand All @@ -22,7 +22,8 @@ import {
LoanFinancialsType,
LoanType,
PaymentType,
PaymentValue
PaymentValue,
RatesType
} from 'core/types'
import BigNumber from 'bignumber.js'
import EthUtil from 'ethereumjs-util'
Expand Down
@@ -1,5 +1,4 @@
import { RatesType } from './types'
import { RemoteDataType } from 'core/types'
import { RatesType, RemoteDataType } from 'core/types'
import { RootState } from '../../rootReducer'
import { selectors } from 'data'

Expand All @@ -23,7 +22,7 @@ export const getBorrowHistory = (state: RootState) =>

export const getRates = (
state: RootState
): RemoteDataType<string | Error, RatesType> => {
): RemoteDataType<string, RatesType> => {
const coinType = getCoinType(state)

return selectors.core.data.misc.getRatesSelector(coinType, state)
Expand Down
Expand Up @@ -2,7 +2,6 @@ import * as AT from './actionTypes'
import {
AccountTypes,
CoinType,
FiatType,
LoanTransactionsType,
LoanType,
NabuApiErrorType,
Expand Down Expand Up @@ -35,17 +34,6 @@ export enum BorrowSteps {
'REPAY_LOAN'
}

// TODO: move to ticker
export type RatesType = {
[key in FiatType]: {
'15m': number
buy: number
last: number
sell: number
symbol: '$'
}
}

export type RepayLoanFormType = {
amount?: string
'repay-method': 'principal' | 'collateral'
Expand Down
Expand Up @@ -7,15 +7,14 @@ import { actions, model, selectors } from 'data'
import { APIType } from 'core/network/api'
import { convertStandardToBase } from '../exchange/services'
import { errorHandler } from 'blockchain-wallet-v4/src/utils'
import { PaymentType, PaymentValue } from 'core/types'
import { PaymentType, PaymentValue, RatesType } from 'core/types'
import { Remote } from 'blockchain-wallet-v4/src'

import * as A from './actions'
import * as AT from './actionTypes'
import * as S from './selectors'
import { DEFAULT_INTEREST_BALANCES } from './model'
import { InterestDepositFormType } from './types'
import { RatesType } from '../borrow/types'
import exchangeSagaUtils from '../exchange/sagas.utils'
import profileSagas from '../../modules/profile/sagas'
import utils from './sagas.utils'
Expand Down
Expand Up @@ -7,13 +7,13 @@ import {
FiatType,
PaymentType,
PaymentValue,
RatesType,
RemoteDataType
} from 'core/types'
import { convertBaseToStandard } from '../exchange/services'
import { Exchange } from 'blockchain-wallet-v4/src'
import { INVALID_COIN_TYPE } from 'blockchain-wallet-v4/src/model'
import { promptForSecondPassword } from 'services/SagaService'
import { RatesType } from '../borrow/types'
import { selectors } from 'data'

export default ({ coreSagas, networks }: { coreSagas: any; networks: any }) => {
Expand Down
@@ -1,9 +1,7 @@
import { FiatType, RemoteDataType } from 'core/types'
import { FiatType, RatesType, RemoteDataType } from 'core/types'
import { RootState } from 'data/rootReducer'
import { selectors } from 'data'

import { RatesType } from '../borrow/types'

export const getInterestAccountBalance = (state: RootState) =>
state.components.interest.accountBalance

Expand Down Expand Up @@ -43,7 +41,7 @@ export const getPayment = (state: RootState) =>

export const getRates = (
state: RootState
): RemoteDataType<string | Error, RatesType> => {
): RemoteDataType<string, RatesType> => {
const coinType = getCoinType(state)

return selectors.core.data.misc.getRatesSelector(coinType, state)
Expand Down
Expand Up @@ -106,10 +106,11 @@ export function simpleBuyReducer (
...state,
card: Remote.Success(action.payload.card)
}
// cards fetch fails so often in staging that this is a temp fix
case AT.FETCH_SB_CARDS_FAILURE: {
return {
...state,
cards: Remote.Failure(action.payload.error)
cards: Remote.Success([])
}
}
case AT.FETCH_SB_CARDS_LOADING:
Expand Down
Expand Up @@ -14,6 +14,7 @@ import {
take
} from 'redux-saga/effects'
import { compose, equals, lift, prop, sortBy, tail } from 'ramda'
import { ExtractSuccess } from 'core/types'
import { KYC_STATES, USER_ACTIVATION_STATES } from './model'
import { promptForSecondPassword } from 'services/SagaService'
import { Remote } from 'blockchain-wallet-v4/src'
Expand Down Expand Up @@ -264,7 +265,7 @@ export default ({ api, coreSagas, networks }) => {
if (!userId || !lifetimeToken) return call(generateAuthCredentials)
return authCredentials
})
.getOrElse({})
.getOrElse({} as ExtractSuccess<typeof authCredentialsR>)

yield call(setSession, userId, lifetimeToken, email, guid)
}
Expand Down
Expand Up @@ -23,6 +23,7 @@ import { KYC_STATES, TIERS_STATES, USER_ACTIVATION_STATES } from './model'
import { RemoteDataType } from 'core/types'
import { RootState } from 'data/rootReducer'
import { selectors } from 'data'
import { UserDataType } from './types'

export const getUserData = (state: RootState) => state.profile.userData
export const getUserCampaigns = (state: RootState) =>
Expand All @@ -34,7 +35,9 @@ export const getWalletAddresses = compose(
getUserData
)
export const getUserActivationState = compose(lift(prop('state')), getUserData)
export const getUserKYCState = compose(lift(prop('kycState')), getUserData)
export const getUserKYCState = compose(lift(prop('kycState')), getUserData) as (
state: RootState
) => RemoteDataType<string, UserDataType['kycState']>
export const getTags = compose(lift(path(['tags'])), getUserData)
export const getSunRiverTag = compose(
lift(path(['tags', 'SUNRIVER'])),
Expand Down Expand Up @@ -177,8 +180,8 @@ export const isExchangeAccountLinked = (
// suggest to the linking saga that a relink should be attempted
export const isExchangeRelinkRequired = (
state
): RemoteDataType<string, boolean> =>
lift(user => {
): RemoteDataType<string, boolean | number> =>
lift((user: UserDataType) => {
return (
not(isNil(prop('settings', user))) && length(getRemainingCoins(state))
)
Expand Down
@@ -1,11 +1,12 @@
import { actions } from 'data'
import { bindActionCreators, compose, Dispatch } from 'redux'
import { BorrowMinMaxType, RatesType } from 'data/types'
import { BorrowMinMaxType } from 'data/types'
import {
CoinType,
LoanType,
OfferType,
PaymentValue,
RatesType,
RemoteDataType,
SupportedCoinsType
} from 'core/types'
Expand Down
@@ -1,6 +1,5 @@
import { LoanType, OfferType, SupportedCoinsType } from 'core/types'
import { LoanType, OfferType, RatesType, SupportedCoinsType } from 'core/types'
import { model } from 'data'
import { RatesType } from 'data/types'
import { Text } from 'blockchain-info-components'
import React from 'react'
import styled from 'styled-components'
Expand Down
Expand Up @@ -2,14 +2,7 @@ import { actions } from 'data'
import { bindActionCreators, Dispatch } from 'redux'
import { connect, ConnectedProps } from 'react-redux'
import { getData } from './selectors'
import {
LoanTransactionsType,
LoanType,
OfferType,
RemoteDataType,
SupportedCoinsType
} from 'core/types'
import { RatesType } from 'data/types'
import { LoanType, OfferType } from 'core/types'
import { RootState } from 'data/rootReducer'
import Loading from './template.loading'
import React, { PureComponent } from 'react'
Expand All @@ -33,7 +26,7 @@ class BorrowDetails extends PureComponent<Props> {
}
}

const mapStateToProps = (state: RootState): LinkStatePropsType => ({
const mapStateToProps = (state: RootState) => ({
data: getData(state)
})

Expand All @@ -48,14 +41,8 @@ type OwnProps = {
loan: LoanType
offer: OfferType
}
export type SuccessStateType = {
loanTransactions: Array<LoanTransactionsType>
rates: RatesType
supportedCoins: SupportedCoinsType
}
type LinkStatePropsType = {
data: RemoteDataType<string | Error, SuccessStateType>
}
export type SuccessStateType = ReturnType<typeof getData>['data']

export type Props = OwnProps & ConnectedProps<typeof connector>

export default connector(BorrowDetails)
@@ -1,3 +1,4 @@
import { ExtractSuccess, SupportedCoinsType } from 'core/types'
import { lift } from 'ramda'
import { RootState } from 'data/rootReducer'
import { selectors } from 'data'
Expand All @@ -9,7 +10,11 @@ export const getData = (state: RootState) => {
const ratesR = selectors.components.borrow.getRates(state)
const supportedCoinsR = selectors.core.walletOptions.getSupportedCoins(state)

const transform = (loanTransactions, rates, supportedCoins) => ({
const transform = (
loanTransactions: ExtractSuccess<typeof loanTransactionsR>,
rates: ExtractSuccess<typeof ratesR>,
supportedCoins: SupportedCoinsType
) => ({
loanTransactions,
rates,
supportedCoins
Expand Down
@@ -1,11 +1,11 @@
import { BorrowFormValuesType, RatesType } from 'data/types'
import { BorrowFormValuesType } from 'data/types'
import {
coinToString,
fiatToString,
formatFiat
} from 'blockchain-wallet-v4/src/exchange/currency'
import { FormattedMessage } from 'react-intl'
import { OfferType } from 'core/types'
import { OfferType, RatesType } from 'core/types'
import { TableRow, Title, Value } from 'components/Borrow'
import { Text, TooltipHost, TooltipIcon } from 'blockchain-info-components'
import React from 'react'
Expand Down
@@ -1,10 +1,11 @@
import { actions } from 'data'
import { bindActionCreators, compose, Dispatch } from 'redux'
import { BorrowMinMaxType, RatesType } from 'data/types'
import { BorrowMinMaxType } from 'data/types'
import {
CoinType,
OfferType,
PaymentValue,
RatesType,
RemoteDataType,
SupportedCoinsType
} from 'core/types'
Expand Down
Expand Up @@ -2,8 +2,7 @@ import { actions } from 'data'
import { bindActionCreators, compose, Dispatch } from 'redux'
import { connect } from 'react-redux'
import { getData } from './selectors'
import { OfferType, PaymentValue, RemoteDataType } from 'core/types'
import { RatesType } from 'data/types'
import { OfferType, PaymentValue, RatesType, RemoteDataType } from 'core/types'
import { RootState } from 'data/rootReducer'
import DataError from 'components/DataError'
import Loading from './template.loading'
Expand Down
@@ -1,13 +1,14 @@
import { actions } from 'data'
import { bindActionCreators, Dispatch } from 'redux'
import { BorrowMinMaxType, RatesType } from 'data/types'
import { BorrowMinMaxType } from 'data/types'
import { connect, ConnectedProps } from 'react-redux'
import { getData } from './selectors'
import {
LoanTransactionsType,
LoanType,
OfferType,
PaymentValue,
RatesType,
RemoteDataType,
SupportedCoinsType
} from 'core/types'
Expand Down
Expand Up @@ -7,6 +7,12 @@ import modalEnhancer from 'providers/ModalEnhancer'
import React from 'react'
import TransferEth from './template'

const DEFAULTS = {
txFee: '0',
ethBalance: '0',
ethAddr: ''
}

class TransferEthContainer extends React.PureComponent<Props> {
componentDidMount () {
this.props.transferEthActions.initialized({
Expand All @@ -17,15 +23,15 @@ class TransferEthContainer extends React.PureComponent<Props> {

componentDidUpdate () {
if (Remote.Success.is(this.props.data)) {
const { txFee, ethBalance } = this.props.data.getOrElse({})
const { txFee, ethBalance } = this.props.data.getOrElse(DEFAULTS)
if (parseFloat(txFee) > parseFloat(ethBalance)) {
this.props.modalActions.closeAllModals()
}
}
}

handleSubmit = () => {
const { ethAddr, ethBalance } = this.props.data.getOrElse({})
const { ethAddr, ethBalance } = this.props.data.getOrElse(DEFAULTS)
this.props.transferEthActions.confirmTransferEth({
to: ethAddr,
effectiveBalance: ethBalance
Expand Down
Expand Up @@ -12,8 +12,8 @@ export const getData = state => {

const transform = (ethAddr, payment) => ({
ethAddr,
ethBalance: propOr('0', 'effectiveBalance', payment),
txFee: propOr('0', 'fee', payment)
ethBalance: propOr('0', 'effectiveBalance', payment) as string,
txFee: propOr('0', 'fee', payment) as string
})

return lift(transform)(defaultAccountR, paymentR)
Expand Down

0 comments on commit e484387

Please sign in to comment.