meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
4 changed files with
63 additions and
41 deletions
-
src/components/CurrentAddressForAccount.js
-
src/components/DeviceCheckAddress.js
-
src/components/modals/Receive/03-step-confirm-address.js
-
src/components/modals/Receive/04-step-receive-funds.js
|
|
@ -0,0 +1,22 @@ |
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react' |
|
|
|
import type { Account } from '@ledgerhq/live-common/lib/types' |
|
|
|
|
|
|
|
import CurrentAddress from 'components/CurrentAddress' |
|
|
|
|
|
|
|
type Props = { |
|
|
|
account: Account, |
|
|
|
} |
|
|
|
|
|
|
|
export default function CurrentAddressForAccount(props: Props) { |
|
|
|
const { account, ...p } = props |
|
|
|
|
|
|
|
// TODO: handle other cryptos than BTC-like
|
|
|
|
let freshAddress = account.addresses[0] |
|
|
|
if (!freshAddress) { |
|
|
|
freshAddress = { str: '', path: '' } |
|
|
|
} |
|
|
|
|
|
|
|
return <CurrentAddress accountName={account.name} address={freshAddress.str} {...p} /> |
|
|
|
} |
|
|
@ -27,35 +27,34 @@ class CheckAddress extends PureComponent<Props, State> { |
|
|
|
this.verifyAddress({ device, account }) |
|
|
|
} |
|
|
|
|
|
|
|
componentDidUnmount() { |
|
|
|
if (this.sub) this.sub.unsubscribe() |
|
|
|
verifyAddress = async ({ device, account }: { device: Device, account: Account }) => { |
|
|
|
try { |
|
|
|
// TODO: this will work only for BTC-like accounts
|
|
|
|
const freshAddress = account.addresses[0] |
|
|
|
if (!freshAddress) { |
|
|
|
throw new Error('Account doesnt have fresh addresses') |
|
|
|
} |
|
|
|
|
|
|
|
sub: * |
|
|
|
|
|
|
|
verifyAddress = ({ device, account }: { device: Device, account: Account }) => { |
|
|
|
this.sub = getAddress |
|
|
|
const { address } = await getAddress |
|
|
|
.send({ |
|
|
|
currencyId: account.currency.id, |
|
|
|
devicePath: device.path, |
|
|
|
path: account.path, |
|
|
|
path: freshAddress.path, |
|
|
|
segwit: account.isSegwit, |
|
|
|
verify: true, |
|
|
|
}) |
|
|
|
.subscribe({ |
|
|
|
next: () => { |
|
|
|
this.setState({ |
|
|
|
isVerified: true, |
|
|
|
}) |
|
|
|
.toPromise() |
|
|
|
|
|
|
|
if (address !== freshAddress.str) { |
|
|
|
throw new Error('Confirmed address is different') |
|
|
|
} |
|
|
|
|
|
|
|
this.setState({ isVerified: true }) |
|
|
|
this.props.onCheck(true) |
|
|
|
}, |
|
|
|
error: () => { |
|
|
|
this.setState({ |
|
|
|
isVerified: false, |
|
|
|
}) |
|
|
|
} catch (err) { |
|
|
|
this.setState({ isVerified: false }) |
|
|
|
this.props.onCheck(false) |
|
|
|
}, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
render() { |
|
|
|
|
|
@ -7,7 +7,7 @@ import type { Account } from '@ledgerhq/live-common/lib/types' |
|
|
|
import type { Device, T } from 'types/common' |
|
|
|
|
|
|
|
import Box from 'components/base/Box' |
|
|
|
import CurrentAddress from 'components/CurrentAddress' |
|
|
|
import CurrentAddressForAccount from 'components/CurrentAddressForAccount' |
|
|
|
import DeviceConfirm from 'components/DeviceConfirm' |
|
|
|
import DeviceCheckAddress from 'components/DeviceCheckAddress' |
|
|
|
|
|
|
@ -50,7 +50,7 @@ export default (props: Props) => ( |
|
|
|
<Fragment> |
|
|
|
<Title>{props.t('receive:steps.confirmAddress.action')}</Title> |
|
|
|
<Text>{props.t('receive:steps.confirmAddress.text')}</Text> |
|
|
|
{props.account && <CurrentAddress address={props.account.address} />} |
|
|
|
{props.account && <CurrentAddressForAccount account={props.account} />} |
|
|
|
{props.device && |
|
|
|
props.account && ( |
|
|
|
<Box mb={2} mt={-1}> |
|
|
|
|
|
@ -6,7 +6,7 @@ import type { Account } from '@ledgerhq/live-common/lib/types' |
|
|
|
import type { T } from 'types/common' |
|
|
|
|
|
|
|
import Box from 'components/base/Box' |
|
|
|
import CurrentAddress from 'components/CurrentAddress' |
|
|
|
import CurrentAddressForAccount from 'components/CurrentAddressForAccount' |
|
|
|
import Label from 'components/base/Label' |
|
|
|
import RequestAmount from 'components/RequestAmount' |
|
|
|
|
|
|
@ -30,9 +30,9 @@ export default (props: Props) => ( |
|
|
|
withMax={false} |
|
|
|
/> |
|
|
|
</Box> |
|
|
|
<CurrentAddress |
|
|
|
accountName={props.account && props.account.name} |
|
|
|
address={props.account && props.account.address} |
|
|
|
{props.account && ( |
|
|
|
<CurrentAddressForAccount |
|
|
|
account={props.account} |
|
|
|
addressVerified={props.addressVerified} |
|
|
|
amount={props.amount} |
|
|
|
onVerify={props.onVerify} |
|
|
@ -41,5 +41,6 @@ export default (props: Props) => ( |
|
|
|
withQRCode |
|
|
|
withVerify={props.addressVerified === false} |
|
|
|
/> |
|
|
|
)} |
|
|
|
</Box> |
|
|
|
) |
|
|
|