Skip to content

Commit

Permalink
fix(merge conflict)
Browse files Browse the repository at this point in the history
  • Loading branch information
sixtedemaupeou committed May 30, 2018
2 parents 25c182e + 0aa2f22 commit ef75ede
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@
"scenes.recover.firststep.explain": "Recover funds from your lost wallet",
"scenes.recover.firststep.warning": "You should always pair or login if you have access to your Wallet ID and password. Recovering your funds will create a new Wallet ID.",
"scenes.recover.firststep.mnemonic": "Your backup phrase",
"scenes.recover.firststep.mnemonic_explain": "Enter your 12 word phrase, with spaces between each, to recover your funds & transactions.",
"scenes.recover.firststep.mnemonic_explain": "Enter your 12 word phrase, lowercase, with spaces between each, to recover your funds & transactions.",
"scenes.recover.firststep.back": "Go Back",
"scenes.recover.firststep.continue": "Continue",
"scenes.recover.secondstep.funds": "Recover Funds",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const TradeItem = props => {
const { conversion, handleClick, handleFinish, handleTradeCancel, trade, status, cancelTradeId } = props
const receiveAmount = trade.isBuy ? trade.receiveAmount : Exchange.displayFiatToFiat({ value: trade.receiveAmount })
const exchangeAmount = trade.isBuy ? Exchange.displayFiatToFiat({ value: trade.sendAmount / conversion.buy }) : trade.sendAmount / conversion.sell
const canCancel = trade.state === 'awaiting_transfer_in'
const canCancel = trade.isBuy && trade.state === 'awaiting_transfer_in'

return (
<TableRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SelectBox.propTypes = {
elements: PropTypes.arrayOf(PropTypes.shape({
group: PropTypes.string.isRequired,
items: PropTypes.arrayOf(PropTypes.shape({
text: PropTypes.oneOfType([PropTypes.string.isRequired, PropTypes.object.isRequired]),
text: PropTypes.oneOfType([PropTypes.string.isRequired, PropTypes.number.isRequired, PropTypes.object.isRequired]),
value: PropTypes.oneOfType([PropTypes.string.isRequired, PropTypes.number.isRequired, PropTypes.object.isRequired])
})).isRequired
})).isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default ({ coreSagas }) => {
if (path(['description', 'length'], payment.value())) {
yield put(actions.core.kvStore.bch.setTxNotesBch(payment.value().txId, payment.value().description))
}
yield put(actions.core.data.bch.fetchTransactions('', true))
yield put(actions.router.push('/bch/transactions'))
yield put(actions.alerts.displaySuccess('Your bitcoin cash transaction is now pending.'))
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export default ({ coreSagas }) => {
payment = yield payment.sign(password)
payment = yield payment.publish()
yield put(A.sendBtcPaymentUpdated(Remote.of(payment.value())))
yield put(actions.core.data.bitcoin.fetchTransactions('', true))
if (path(['description', 'length'], payment.value())) {
yield put(actions.core.wallet.setTransactionNote(payment.value().txId, payment.value().description))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,39 +141,65 @@ export default ({ coreSagas }) => {

switch (field) {
case 'leftVal':
const leftLimitsError = service.getLimitsError(payload, limits.data, values.currency)
if (leftLimitsError) {
yield put(A.setCoinifyCheckoutError(leftLimitsError))
return
if (type === 'buy') {
const leftLimitsError = service.getLimitsError(payload, limits.data, values.currency, type)
if (leftLimitsError) {
yield put(A.setCoinifyCheckoutError(leftLimitsError))
return
} else {
yield put(A.clearCoinifyCheckoutError())
}
}

const leftResult = yield call(coreSagas.data.coinify.fetchQuote,
{ quote: { amount: payload * 100, baseCurrency: values.currency, quoteCurrency: 'BTC', type } })
const amount = Math.abs(leftResult.quoteAmount)

if (type === 'sell') {
const payment = yield select(sendBtcSelectors.getPayment)
const effectiveBalance = prop('effectiveBalance', payment.getOrElse(undefined))
if (service.isOverEffectiveMax(amount, effectiveBalance)) {
yield put(A.setCoinifyCheckoutError('over_effective_max'))
let btcAmt = (amount / 1e8)
const leftLimitsError = service.getLimitsError(btcAmt, limits.data, values.currency, type)
if (leftLimitsError) {
yield put(A.setCoinifyCheckoutError(leftLimitsError))
} else {
yield put(A.clearCoinifyCheckoutError())
const payment = yield select(sendBtcSelectors.getPayment)
const effectiveBalance = prop('effectiveBalance', payment.getOrElse(undefined))
if (service.isOverEffectiveMax(amount, effectiveBalance)) yield put(A.setCoinifyCheckoutError('over_effective_max'))
else yield put(A.clearCoinifyCheckoutError())
}
}

yield put(actions.form.initialize(form, merge(values, { 'rightVal': amount / 1e8 })))
yield put(A.coinifyCheckoutBusyOff())
break
case 'rightVal':
if (type === 'sell') {
const rightLimitsError = service.getLimitsError(payload, limits.data, values.currency, type)
if (rightLimitsError) {
yield put(A.setCoinifyCheckoutError(rightLimitsError))
return
} else {
yield put(A.clearCoinifyCheckoutError())
}
}

const rightResult = yield call(coreSagas.data.coinify.fetchQuote,
{ quote: { amount: Math.round((payload * 1e8) * -1), baseCurrency: 'BTC', quoteCurrency: values.currency, type } })
const fiatAmount = Math.abs(rightResult.quoteAmount)

const rightLimitsError = service.getLimitsError(fiatAmount, limits.data, values.currency)
let rightLimitsError
if (type === 'sell') rightLimitsError = service.getLimitsError(payload, limits.data, values.currency, type)
if (type === 'buy') rightLimitsError = service.getLimitsError(fiatAmount, limits.data, values.currency, type)

if (rightLimitsError) {
yield put(A.setCoinifyCheckoutError(rightLimitsError))
yield put(actions.form.initialize(form, merge(values, { 'leftVal': fiatAmount })))
return
} else {
const payment = yield select(sendBtcSelectors.getPayment)
const effectiveBalance = prop('effectiveBalance', payment.getOrElse(undefined))
if (service.isOverEffectiveMax(payload * 1e8, effectiveBalance)) yield put(A.setCoinifyCheckoutError('over_effective_max'))
else yield put(A.clearCoinifyCheckoutError())
}

yield put(actions.form.initialize(form, merge(values, { 'leftVal': fiatAmount })))
yield put(A.coinifyCheckoutBusyOff())
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export const MaximumAmountMessage = () => (
)

export const InsufficientFundsMessage = () => (
<FormattedMessage id='modals.sendbch.insufficientfundsnessage' defaultMessage="Insufficients funds" />
<FormattedMessage id='modals.sendbch.insufficientfundsnessage' defaultMessage='Insufficient funds' />
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Wrapper = styled.div`
`

export const InvalidAmountMessage = () => (
<FormattedMessage id='modals.sendbtc.amountnotzeromessage' defaultMessage="Invalid amount" />
<FormattedMessage id='modals.sendbtc.amountnotzeromessage' defaultMessage='Invalid amount' />
)

export const MaximumAmountMessage = () => (
Expand Down Expand Up @@ -50,7 +50,7 @@ export const MinimumFeeMessage = () => (
)

export const InsufficientFundsMessage = () => (
<FormattedMessage id='modals.sendbtc.insufficientfundsnessage' defaultMessage="Insufficients funds" />
<FormattedMessage id='modals.sendbtc.insufficientfundsnessage' defaultMessage='Insufficient funds' />
)

export const AddressMatchesPriv = () => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export const MaximumAmountMessage = () => (
)

export const InsufficientFundsMessage = () => (
<FormattedMessage id='modals.sendeth.insufficientfundsnessage' defaultMessage="Insufficients funds" />
<FormattedMessage id='modals.sendeth.insufficientfundsnessage' defaultMessage='Insufficient funds' />
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ const LimitsNotice = styled.div`
`

const KYCNotification = (props) => {
const { kyc, onTrigger, symbol, limits } = props
const { kyc, onTrigger, symbol, limits, type } = props

const state = path(['state'], kyc)
const header = kycHeaderHelper(state)
const body = kycNotificationBodyHelper(state)

let effBal = limits.effectiveMax / 1e8
let sellMax = Math.min(effBal, limits.max)

return (
<Wrapper>
{
state === 'pending' || state === 'reviewing'
(state === 'pending' || state === 'reviewing')
? <LimitsNotice>
<Text size='12px' weight={300}>
<FormattedMessage id='kyc.limitsnotice' defaultMessage='While your identity gets verified, you can buy and sell up to {symbol}{limit} using your credit/debit card.' values={{ symbol: symbol, limit: limits.max }} />
{
type === 'sell'
? <FormattedMessage id='kyc.sell.limitsnotice' defaultMessage='While your identity gets verified, you can sell up to {limit} BTC.' values={{ limit: sellMax }} />
: <FormattedMessage id='kyc.buy.limitsnotice' defaultMessage='While your identity gets verified, you can buy up to {symbol}{limit} using your credit/debit card.' values={{ symbol: symbol, limit: limits.max }} />
}
</Text>
</LimitsNotice>
: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class QuoteInput extends Component {
setMin={setMin}
checkoutError={checkoutError}
increaseLimit={increaseLimit}
type={type}
/>
},
Failure: (msg) => <div>Failure: {msg.error}</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,34 @@ const LimitsHelper = styled.div`
}
`

const getLimitsError = (errorType, limits, symbol, setMin) => {
const getLimitsError = (errorType, limits, curr, setMin) => {
switch (errorType) {
case 'below_min': return `Your limit of ${symbol}${limits.max} is below the minimum allowed amount.`
case 'over_max': return `Enter an amount under your ${symbol}${limits.max.toLocaleString()} limit`
case 'under_min': return <FormattedMessage id='buy.quote_input.under_min' defaultMessage='Enter an amount above the {setMin} minimum' values={{ setMin: <a onClick={() => setMin(limits.min)}>{symbol}{limits.min.toLocaleString()}</a> }} />
case 'below_min': return `Your limit of ${curr}${limits.max} is below the minimum allowed amount.`
case 'over_max': return `Enter an amount under your ${curr}${limits.max} limit`
case 'under_min': return <FormattedMessage id='buy.quote_input.under_min' defaultMessage='Enter an amount above the {setMin} minimum' values={{ setMin: <a onClick={() => setMin(limits.min)}>{curr}{limits.min}</a> }} />
case 'over_effective_max': return `Enter an amount less than your balance minus the priority fee (${limits.effectiveMax / 1e8} BTC)`
}
}

const FiatConvertor = (props) => {
const { val, disabled, setMax, setMin, limits, checkoutError, defaultCurrency, symbol, increaseLimit, type } = props
const { val, disabled, setMax, setMin, limits, checkoutError, defaultCurrency, symbol, increaseLimit, form } = props
const currency = 'BTC'
const level = val.level || { name: 1 }
const kyc = val.kycs.length && head(val.kycs)
const { canTrade, cannotTradeReason, profile } = val
const { canTradeAfter } = profile
const isSell = form === 'coinifyCheckoutSell'
const curr = isSell ? 'BTC' : symbol

const reasonExplanation = cannotTradeReason && getReasonExplanation(cannotTradeReason, canTradeAfter)

const getSellLimits = () => {
let effBal = limits.effectiveMax / 1e8
let max = Math.min(effBal, limits.max)

return <FormattedMessage id='sell.quote_input.remaining_sell_limit' defaultMessage='Your remaining sell limit is {max}' values={{ max: <a onClick={() => setMax(max)}>{max} BTC</a> }} />
}

const renderErrorsAndLimits = () => {
if (!canTrade) {
return (
Expand All @@ -105,14 +114,17 @@ const FiatConvertor = (props) => {
} else if (checkoutError) {
return (
<Error size='13px' weight={300} color='error'>
{ getLimitsError(checkoutError, limits, symbol, setMin) }
{ getLimitsError(checkoutError, limits, curr, setMin) }
</Error>
)
} else {
return (
<LimitsHelper>
<FormattedMessage id='buysell.quote_input.remaining_buy_limit' defaultMessage='Your remaining {type} limit is' values={{ type }} />
<a onClick={() => setMax(limits.max)}>{symbol}{limits.max}</a>
{
form === 'coinifyCheckoutBuy'
? <FormattedMessage id='buy.quote_input.remaining_buy_limit' defaultMessage='Your remaining buy limit is {max}' values={{ max: <a onClick={() => setMax(limits.max)}>{curr}{limits.max}</a> }} />
: getSellLimits()
}
{
level.name < 2 && kyc.state !== 'reviewing'
? <a onClick={() => increaseLimit()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class SellContainer extends React.Component {
fetchSellQuote={(quote) => fetchQuote({ quote, nextAddress: value.nextAddress })}
currency={currency}
checkoutBusy={checkoutBusy}
setMax={(amt) => formActions.change('coinifyCheckoutSell', 'leftVal', amt)}
setMin={(amt) => formActions.change('coinifyCheckoutSell', 'leftVal', amt)}
setMax={(btcAmt) => formActions.change('coinifyCheckoutSell', 'rightVal', btcAmt)}
setMin={(btcAmt) => formActions.change('coinifyCheckoutSell', 'rightVal', btcAmt)}
paymentMedium={paymentMedium}
initiateSell={this.startSell}
step={step}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Sell = props => {
<div>
{
value.kycs.length
? <KYCNotification kyc={kyc} limits={limits.sell} symbol={symbol} onTrigger={(kyc) => handleKycAction(kyc)} />
? <KYCNotification kyc={kyc} limits={limits.sell} symbol={symbol} onTrigger={(kyc) => handleKycAction(kyc)} type='sell' />
: null
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const renderDisplay = item => (
const renderHeader = item => (
<HeaderWrapper>
{prop('text', item) === 'Bitcoin' && <Icon name='bitcoin-in-circle' size='14px' weight={300} />}
{prop('text', item) === 'Bitcoin cash' && <Icon name='bitcoin-cash' size='14px' weight={300} />}
{prop('text', item) === 'Bitcoin Cash' && <Icon name='bitcoin-cash' size='14px' weight={300} />}
{prop('text', item) === 'Ether' && <Icon name='ethereum-filled' size='14px' weight={300} />}
<Separator align='right'>
<Text size='14px' weight={300} uppercase>{item.text}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const generateGroup = (bchAccounts, btcAccounts, ethAccounts, hasOneAccou
if (hasOneAccount) {
const accounts = [
btcAccounts.map(formatDefault('Bitcoin')),
bchAccounts.map(formatDefault('Bitcoin cash')),
bchAccounts.map(formatDefault('Bitcoin Cash')),
ethAccounts.map(formatDefault('Ether'))
]

Expand All @@ -21,7 +21,7 @@ export const generateGroup = (bchAccounts, btcAccounts, ethAccounts, hasOneAccou
}
return [
{ group: 'Bitcoin', items: btcAccounts.map(format) },
{ group: 'Bitcoin cash', items: bchAccounts.map(format) },
{ group: 'Bitcoin Cash', items: bchAccounts.map(format) },
{ group: 'Ether', items: ethAccounts.map(format) }
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ const Success = props => {
</Text>
</TableCell>
<TableCell>
<Text size='13px' weight={300} uppercase>
{orderId}
<Text size='13px' weight={300}>
SFT-{orderId}
</Text>
</TableCell>
</TableRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const FirstStep = (props) => {
<FormattedMessage id='scenes.recover.firststep.mnemonic' defaultMessage='Your backup phrase' />
</MnemonicLabel>
<Text size='12px' weight={300}>
<FormattedMessage id='scenes.recover.firststep.mnemonic_explain' defaultMessage='Enter your 12 word phrase, with spaces between each, to recover your funds & transactions.' />
<FormattedMessage id='scenes.recover.firststep.mnemonic_explain' defaultMessage='Enter your 12 word phrase, lowercase, with spaces between each, to recover your funds & transactions.' />
</Text>
<Field name='mnemonic' autoFocus validate={[required, validMnemonic]} component={TextBox} />
</FormItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Success = (props) => {
</ImportedAddressesSettingHeader>
<AddressesSettingDescription>
<WarningWrapper>
<Icon name='alert-filled' size='22px' className={'warning-icon'} color='brand-yellow'/>
<Icon name='alert-filled' size='22px' className={'warning-icon'} color='brand-yellow' />
<FormattedMessage id='scenes.settings.addresses.imported_bch_addrs_desc' defaultMessage='Imported funds are not protected by your backup phrase. To ensure these funds are secured, please transfer them directly into your wallet.' />
</WarningWrapper>
</AddressesSettingDescription>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,35 @@ import { FormattedMessage } from 'react-intl'
export const getLimits = (limits, curr, effectiveBalance) => {
const getMin = (limits, curr) => Math.min(limits.bank.minimumInAmounts[curr], limits.card.minimumInAmounts[curr])
const getMax = (limits, curr) => Math.max(limits.bank.inRemaining[curr], limits.card.inRemaining[curr])
const getSellMin = (limits, curr) => limits.blockchain.minimumInAmounts[curr]
const getSellMax = (limits, curr) => limits.blockchain.inRemaining[curr]
return {
buy: {
min: getMin(limits, curr),
max: getMax(limits, curr)
},
sell: {
min: getMin(limits, curr),
max: getMax(limits, curr),
min: getSellMin(limits, 'BTC'),
max: getSellMax(limits, 'BTC'),
effectiveMax: effectiveBalance
}
}
}

export const getLimitsError = (amt, userLimits, curr) => {
export const getLimitsError = (amt, userLimits, curr, type) => {
const limits = getLimits(userLimits, curr)
if (limits.buy.max < limits.buy.min) return 'max_below_min'
if (amt > limits.buy.max) return 'over_max'
if (amt < limits.buy.min) return 'under_min'

if (type === 'buy') {
if (limits.buy.max < limits.buy.min) return 'max_below_min'
if (amt > limits.buy.max) return 'over_max'
if (amt < limits.buy.min) return 'under_min'
}
if (type === 'sell') {
if (limits.sell.max < limits.sell.min) return 'max_below_min'
if (amt > limits.sell.max) return 'over_max'
if (amt < limits.sell.min) return 'under_min'
}

return false
}

Expand Down

0 comments on commit ef75ede

Please sign in to comment.