Meriadec Pillet
7 years ago
committed by
GitHub
17 changed files with 192 additions and 86 deletions
@ -1,32 +1,38 @@ |
|||
### requirements |
|||
# Ledger Wallet Desktop |
|||
|
|||
#### Linux |
|||
## Requirements |
|||
|
|||
``` |
|||
libicns |
|||
graphicsmagick |
|||
``` |
|||
* nodejs v8.x (https://nodejs.org/en/) |
|||
* yarn latest (https://yarnpkg.com/fr/docs/install) |
|||
|
|||
install dependencies |
|||
## Installation |
|||
|
|||
``` |
|||
yarn |
|||
``` |
|||
|
|||
launch development version |
|||
## Development |
|||
|
|||
``` |
|||
yarn start |
|||
``` |
|||
|
|||
build, but not package for distribution |
|||
## Build |
|||
|
|||
> Not package for distribution |
|||
|
|||
``` |
|||
yarn dist:dir |
|||
``` |
|||
|
|||
build and package everything |
|||
> Package everything |
|||
|
|||
``` |
|||
yarn dist |
|||
``` |
|||
|
|||
## Release |
|||
|
|||
``` |
|||
yarn release |
|||
``` |
|||
|
@ -1,29 +1,29 @@ |
|||
// @flow
|
|||
|
|||
// eslint-disable import/prefer-default-export
|
|||
/* eslint-disable import/prefer-default-export */ |
|||
|
|||
import type { Device, Devices } from 'types/common' |
|||
|
|||
export type deviceChooseType = (Device | null) => { type: string, payload: Device | null } |
|||
export const deviceChoose: deviceChooseType = payload => ({ |
|||
type: 'DEVICE_CHOOSE', |
|||
export type SetCurrentDevice = (Device | null) => { type: string, payload: Device | null } |
|||
export const setCurrentDevice: SetCurrentDevice = payload => ({ |
|||
type: 'SET_CURRENT_DEVICE', |
|||
payload, |
|||
}) |
|||
|
|||
type devicesAddType = Device => { type: string, payload: Device } |
|||
export const deviceAdd: devicesAddType = payload => ({ |
|||
type: 'DEVICE_ADD', |
|||
type AddDevice = Device => { type: string, payload: Device } |
|||
export const addDevice: AddDevice = payload => ({ |
|||
type: 'ADD_DEVICE', |
|||
payload, |
|||
}) |
|||
|
|||
type devicesRemoveType = Device => { type: string, payload: Device } |
|||
export const deviceRemove: devicesRemoveType = payload => ({ |
|||
type: 'DEVICE_REMOVE', |
|||
type RemoveDevice = Device => { type: string, payload: Device } |
|||
export const removeDevice: RemoveDevice = payload => ({ |
|||
type: 'REMOVE_DEVICE', |
|||
payload, |
|||
}) |
|||
|
|||
type devicesUpdateType = Devices => { type: string, payload: Devices } |
|||
export const devicesUpdate: devicesUpdateType = payload => ({ |
|||
type: 'DEVICES_UPDATE', |
|||
type UpdateDevices = Devices => { type: string, payload: Devices } |
|||
export const updateDevices: UpdateDevices = payload => ({ |
|||
type: 'UPDATE_DEVICES', |
|||
payload, |
|||
}) |
|||
|
@ -0,0 +1,9 @@ |
|||
// @flow
|
|||
|
|||
/* eslint-disable import/prefer-default-export */ |
|||
|
|||
export type SetCurrentWalletType = (Object | null) => { type: string, payload: Object | null } |
|||
export const setCurrentWallet: SetCurrentWalletType = payload => ({ |
|||
type: 'SET_CURRENT_WALLET', |
|||
payload, |
|||
}) |
@ -1,15 +1,73 @@ |
|||
// @flow
|
|||
|
|||
import React, { PureComponent } from 'react' |
|||
import { connect } from 'react-redux' |
|||
|
|||
import type { MapStateToProps } from 'react-redux' |
|||
import type { Device } from 'types/common' |
|||
|
|||
import { getCurrentDevice } from 'reducers/devices' |
|||
|
|||
import { sendEvent } from 'renderer/events' |
|||
|
|||
import Box from 'components/base/Box' |
|||
|
|||
type Props = {} |
|||
const mapStateToProps: MapStateToProps<*, *, *> = state => ({ |
|||
currentDevice: getCurrentDevice(state), |
|||
currentWallet: state.wallets.currentWallet, |
|||
}) |
|||
|
|||
type Props = { |
|||
currentDevice: Device | null, |
|||
currentWallet: Object | null, |
|||
} |
|||
type State = { |
|||
address: Object | null, |
|||
} |
|||
|
|||
class AccountPage extends PureComponent<Props, State> { |
|||
state = { |
|||
address: null, |
|||
} |
|||
|
|||
componentDidMount() { |
|||
this.getWalletInfos() |
|||
} |
|||
|
|||
componentWillReceiveProps(nextProps) { |
|||
const { currentWallet } = nextProps |
|||
|
|||
if (currentWallet !== null && !currentWallet.err) { |
|||
this.setState({ |
|||
address: currentWallet.data.bitcoinAddress, |
|||
}) |
|||
} else { |
|||
this._timeout = setTimeout(() => this.getWalletInfos(), 2e3) |
|||
} |
|||
} |
|||
|
|||
componentWillUnmount() { |
|||
clearTimeout(this._timeout) |
|||
} |
|||
|
|||
getWalletInfos() { |
|||
const { currentDevice } = this.props |
|||
|
|||
if (currentDevice !== null) { |
|||
sendEvent('usb', 'wallet.infos.request', { |
|||
path: currentDevice.path, |
|||
wallet: 'btc', |
|||
}) |
|||
} |
|||
} |
|||
|
|||
_timeout = undefined |
|||
|
|||
class AccountPage extends PureComponent<Props> { |
|||
render() { |
|||
return <Box>{'account'}</Box> |
|||
const { address } = this.state |
|||
|
|||
return <Box>{address === null ? 'Select Bitcoin App on your Ledger' : address}</Box> |
|||
} |
|||
} |
|||
|
|||
export default AccountPage |
|||
export default connect(mapStateToProps)(AccountPage) |
|||
|
@ -0,0 +1,12 @@ |
|||
// @flow
|
|||
|
|||
import styled from 'styled-components' |
|||
|
|||
export default styled.div` |
|||
-webkit-app-region: drag; |
|||
height: 40px; |
|||
left: 0; |
|||
position: absolute; |
|||
right: 0; |
|||
top: 0; |
|||
` |
@ -0,0 +1,20 @@ |
|||
// @flow
|
|||
|
|||
import { handleActions } from 'redux-actions' |
|||
|
|||
export type WalletsState = { |
|||
currentWallet: Object | null, |
|||
} |
|||
|
|||
const state: WalletsState = { |
|||
currentWallet: null, |
|||
} |
|||
|
|||
const handlers: Object = { |
|||
SET_CURRENT_WALLET: (state: Object, { payload: currentWallet }: { payload: WalletsState }) => ({ |
|||
...state, |
|||
currentWallet, |
|||
}), |
|||
} |
|||
|
|||
export default handleActions(handlers, state) |
Loading…
Reference in new issue