-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): add tabs to show xpubs for all lockbox coin types
- Loading branch information
Showing
5 changed files
with
182 additions
and
72 deletions.
There are no files selected for viewing
42 changes: 40 additions & 2 deletions
42
packages/blockchain-wallet-v4-frontend/src/modals/Lockbox/ShowLockboxXPubs/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,50 @@ | ||
import React from 'react' | ||
import { actions } from 'data' | ||
import { connect } from 'react-redux' | ||
import { bindActionCreators, compose } from 'redux' | ||
|
||
import { getData } from './selectors' | ||
import modalEnhancer from 'providers/ModalEnhancer' | ||
import ShowLockboxXPubs from './template' | ||
|
||
class ShowLockboxXPubsContainer extends React.PureComponent { | ||
state = { | ||
activeTab: 'btc' | ||
} | ||
setActive = tab => { | ||
this.setState({ activeTab: tab }) | ||
} | ||
render () { | ||
return <ShowLockboxXPubs {...this.props} /> | ||
return this.props.data.cata({ | ||
Success: val => ( | ||
<ShowLockboxXPubs | ||
activeTab={this.state.activeTab} | ||
setActive={this.setActive} | ||
coins={val} | ||
{...this.props} | ||
/> | ||
), | ||
Failure: () => <div />, | ||
Loading: () => <div />, | ||
NotAsked: () => <div /> | ||
}) | ||
} | ||
} | ||
|
||
export default modalEnhancer('ShowLockboxXPubs')(ShowLockboxXPubsContainer) | ||
const mapStateToProps = (state, ownProps) => ({ | ||
data: getData(state, ownProps.deviceIndex) | ||
}) | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
modalActions: bindActionCreators(actions.modals, dispatch) | ||
}) | ||
|
||
const enhance = compose( | ||
modalEnhancer('ShowLockboxXPubs'), | ||
connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
) | ||
) | ||
|
||
export default enhance(ShowLockboxXPubsContainer) |
26 changes: 26 additions & 0 deletions
26
packages/blockchain-wallet-v4-frontend/src/modals/Lockbox/ShowLockboxXPubs/selectors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createDeepEqualSelector } from 'services/ReselectHelper' | ||
|
||
import { Remote } from 'blockchain-wallet-v4/src' | ||
import { selectors } from 'data' | ||
|
||
export const getData = (state, deviceIndex) => | ||
createDeepEqualSelector( | ||
[ | ||
selectors.core.kvStore.lockbox.getLockboxBtcDefaultAccount, | ||
selectors.core.kvStore.lockbox.getLockboxBchXpub, | ||
selectors.core.kvStore.lockbox.getEthContextForDevice, | ||
selectors.core.kvStore.lockbox.getXlmContextForDevice | ||
], | ||
(btcR, bchR, ethR, xlmR) => { | ||
const btc = btcR.getOrElse({}) | ||
const bch = bchR.getOrElse({}) | ||
const eth = ethR.getOrElse([]) | ||
const xlm = xlmR.getOrElse([]) | ||
return Remote.of({ | ||
btc: btc.xpub, | ||
bch, | ||
eth: eth[0], | ||
xlm: xlm[0] | ||
}) | ||
} | ||
)(state, deviceIndex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters