Skip to content

Commit

Permalink
fix(BSV): Populate from with selected account
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Dec 31, 2018
1 parent 5dccabe commit 2bc2590
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as AT from './actionTypes'

export const initialized = () => ({ type: AT.SEND_BSV_INITIALIZED })
export const initialized = index => ({
type: AT.SEND_BSV_INITIALIZED,
payload: { index }
})
export const destroyed = () => ({ type: AT.SEND_BSV_DESTROYED })
export const sendBsvPaymentUpdated = payment => ({
type: AT.SEND_BSV_PAYMENT_UPDATED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export const logLocation = 'components/sendBsv/sagas'
export const bsvDefaultFee = 4

export default ({ coreSagas }) => {
const initialized = function*() {
const initialized = function*(action) {
try {
const { payload } = action
const { index } = payload
yield put(A.sendBsvPaymentUpdated(Remote.Loading))
let payment = coreSagas.payment.bsv.create({
network: settings.NETWORK_BSV
Expand All @@ -34,7 +36,7 @@ export default ({ coreSagas }) => {
const defaultIndexR = yield select(
selectors.core.kvStore.bsv.getDefaultAccountIndex
)
const defaultIndex = defaultIndexR.getOrElse(0)
const defaultIndex = index || defaultIndexR.getOrElse(0)
const defaultAccountR = accountsR.map(nth(defaultIndex))
payment = yield payment.from(defaultIndex, ADDRESS_TYPES.ACCOUNT)
payment = yield payment.fee(bsvDefaultFee)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SecondStep from './SecondStep'

class SendBsvContainer extends React.PureComponent {
componentDidMount () {
this.props.actions.initialized()
this.props.actions.initialized(this.props.index)
}

componentWillUnmount () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class BsvWalletsContainer extends React.Component {
return !Remote.Loading.is(nextProps.data)
}

onSendBsv = () => {
this.props.modalActions.showModal(model.components.sendBsv.MODAL)
onSendBsv = index => {
this.props.modalActions.showModal(model.components.sendBsv.MODAL, { index })
}

onSwapBsv = account => {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ const Success = props => {
flexBasis: '20%'
}}
>
<ClickableText weight={400} size='13px' onClick={onSendBsv}>
<ClickableText
weight={400}
size='13px'
onClick={() => onSendBsv(i)}
>
<FormattedMessage
id='scenes.settings.addresses.bsv.wallets.send'
defaultMessage='Send'
Expand Down

0 comments on commit 2bc2590

Please sign in to comment.