Skip to content

Commit

Permalink
feat(Pit link): handle xlm depo addrs from PIT
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Sep 9, 2019
1 parent b7ac284 commit cba546e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -88,13 +88,20 @@ export default ({ api, coreSagas }) => {
break
case 'to':
const value = pathOr({}, ['value', 'value'], payload)
payment = yield payment.to(value)
const splitValue = value.split(':')
const address = splitValue[0]
payment = yield payment.to(address)
// Do not block payment update when to is changed w/ destinationAccount check
yield put(A.paymentUpdatedSuccess(payment.value()))
// check if destination exists
yield put(A.sendXlmCheckDestinationAccountExists(value))
yield put(A.sendXlmCheckDestinationAccountExists(address))
// check if destination is an exchange
yield put(A.sendXlmCheckIfDestinationIsExchange(value))
yield put(A.sendXlmCheckIfDestinationIsExchange(address))
// PIT address split on : is [address, memo]
if (splitValue.length > 1) {
const memo = splitValue[1]
yield put(actions.form.change(FORM, 'memo', memo))
}
return
case 'amount':
const xlmAmount = prop('coin', payload)
Expand Down
6 changes: 5 additions & 1 deletion packages/blockchain-wallet-v4/src/utils/xlm.js
Expand Up @@ -26,7 +26,11 @@ export const overflowsFullBalance = (amount, effectiveBalance, reserve) =>
export const overflowsEffectiveBalance = (amount, effectiveBalance) =>
new BigNumber(effectiveBalance).isLessThan(amount)

export const isValidAddress = StellarSdk.StrKey.isValidEd25519PublicKey
export const isValidAddress = value => {
// PIT address split on : is [address, memo]
const address = value.split(':')[0]
return StellarSdk.StrKey.isValidEd25519PublicKey(address)
}

export const calculateTransactionAmount = (amount, fee) =>
new BigNumber.sum(amount, fee).toString()
Expand Down

0 comments on commit cba546e

Please sign in to comment.