From 44f5f62566943dca9492e1e1ca3421ea40138909 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 26 Feb 2019 14:18:23 +0100 Subject: [PATCH] Added correct url for old beta/stable wallet --- .../modals/confirm/UnverifiedAddress/index.js | 4 ++-- src/utils/url.js | 24 +++++++++++++++++++ .../Wallet/views/DeviceSettings/index.js | 13 +++++++--- .../Wallet/views/FirmwareUpdate/index.js | 12 ++-------- src/views/Wallet/views/Initialize/index.js | 13 +++++++--- src/views/Wallet/views/NoBackup/index.js | 13 ++++++---- yarn.lock | 7 ++++++ 7 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 src/utils/url.js diff --git a/src/components/modals/confirm/UnverifiedAddress/index.js b/src/components/modals/confirm/UnverifiedAddress/index.js index dec2098f..04e8059b 100644 --- a/src/components/modals/confirm/UnverifiedAddress/index.js +++ b/src/components/modals/confirm/UnverifiedAddress/index.js @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; - +import { getOldWalletUrl } from 'utils/url'; import icons from 'config/icons'; import colors from 'config/colors'; @@ -151,7 +151,7 @@ class ConfirmUnverifiedAddress extends PureComponent { - + Create a backup in 3 minutes diff --git a/src/utils/url.js b/src/utils/url.js new file mode 100644 index 00000000..e4ca9992 --- /dev/null +++ b/src/utils/url.js @@ -0,0 +1,24 @@ +/* @flow */ +import urlConstants from 'constants/urls'; +import type { TrezorDevice } from 'flowtype'; + +const getOldWalletUrl = (device: ?TrezorDevice): string => { + if (!device) return urlConstants.OLD_WALLET_BETA; + const release = device.firmwareRelease; + const url = release.channel === 'beta' ? urlConstants.OLD_WALLET_BETA : urlConstants.OLD_WALLET; + return url; +}; + +// TODO: use uri template to build urls +const getOldWalletReleaseUrl = (device: ?TrezorDevice): string => { + if (!device || !device.firmwareRelease) return urlConstants.OLD_WALLET_BETA; + const release = device.firmwareRelease; + const url = getOldWalletUrl(device); + const version = release.version.join('.'); + return `${url}?fw=${version}`; +}; + +export { + getOldWalletUrl, + getOldWalletReleaseUrl, +}; \ No newline at end of file diff --git a/src/views/Wallet/views/DeviceSettings/index.js b/src/views/Wallet/views/DeviceSettings/index.js index 223c9fa6..6874297e 100644 --- a/src/views/Wallet/views/DeviceSettings/index.js +++ b/src/views/Wallet/views/DeviceSettings/index.js @@ -1,3 +1,4 @@ +/* @flow */ import React from 'react'; import styled from 'styled-components'; import { H1 } from 'components/Heading'; @@ -7,10 +8,16 @@ import Button from 'components/Button'; import P from 'components/Paragraph'; import Link from 'components/Link'; import ICONS from 'config/icons'; -import urlConstants from 'constants/urls'; +import { getOldWalletUrl } from 'utils/url'; import Content from 'views/Wallet/components/Content'; import { connect } from 'react-redux'; +import type { TrezorDevice } from 'flowtype'; + +type Props = { + device: ?TrezorDevice; +} + const Section = styled.section` display: flex; flex-direction: column; @@ -33,7 +40,7 @@ const StyledH1 = styled(H1)` text-align: center; `; -const DeviceSettings = () => ( +const DeviceSettings = (props: Props) => (
@@ -44,7 +51,7 @@ const DeviceSettings = () => ( /> Device settings is under construction Please use Bitcoin wallet interface to change your device settings - + diff --git a/src/views/Wallet/views/FirmwareUpdate/index.js b/src/views/Wallet/views/FirmwareUpdate/index.js index 0a5c604e..40fad54e 100644 --- a/src/views/Wallet/views/FirmwareUpdate/index.js +++ b/src/views/Wallet/views/FirmwareUpdate/index.js @@ -3,7 +3,7 @@ import React from 'react'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import urlConstants from 'constants/urls'; +import { getOldWalletReleaseUrl } from 'utils/url'; import styled from 'styled-components'; import { H1 } from 'components/Heading'; @@ -50,14 +50,6 @@ const StyledP = styled(P)` text-align: center; `; -const getFirmwareReleaseLink = (device: ?TrezorDevice): string => { - if (!device || !device.firmwareRelease) return urlConstants.OLD_WALLET_BETA; - const release = device.firmwareRelease; - const url = release.channel === 'beta' ? urlConstants.OLD_WALLET_BETA : urlConstants.OLD_WALLET; - const version = release.version.join('.'); - return `${url}?fw=${version}`; -}; - const FirmwareUpdate = (props: Props) => ( @@ -138,7 +130,7 @@ const FirmwareUpdate = (props: Props) => (

It’s time to update your firmware

Please use Bitcoin wallet interface to update your firmware. - + {deviceUtils.isDeviceAccessible(props.device) && ( diff --git a/src/views/Wallet/views/Initialize/index.js b/src/views/Wallet/views/Initialize/index.js index 1b266678..2447c7f6 100644 --- a/src/views/Wallet/views/Initialize/index.js +++ b/src/views/Wallet/views/Initialize/index.js @@ -1,11 +1,18 @@ +/* @flow */ import styled from 'styled-components'; import { H1 } from 'components/Heading'; import Button from 'components/Button'; -import urlConstants from 'constants/urls'; +import { getOldWalletUrl } from 'utils/url'; import Paragraph from 'components/Paragraph'; import React from 'react'; import { connect } from 'react-redux'; +import type { TrezorDevice } from 'flowtype'; + +type Props = { + device: ?TrezorDevice; +} + const Wrapper = styled.div` display: flex; flex-direction: column; @@ -26,12 +33,12 @@ const StyledParagraph = styled(Paragraph)` text-align: center; `; -const Initialize = () => ( +const Initialize = (props: Props) => (

Your device is not initialized

Please use Bitcoin wallet interface to start initialization process - +
diff --git a/src/views/Wallet/views/NoBackup/index.js b/src/views/Wallet/views/NoBackup/index.js index 62d2b982..f34dfd61 100644 --- a/src/views/Wallet/views/NoBackup/index.js +++ b/src/views/Wallet/views/NoBackup/index.js @@ -1,17 +1,22 @@ /* @flow */ - import React from 'react'; import styled from 'styled-components'; import { H1 } from 'components/Heading'; import P from 'components/Paragraph'; import Link from 'components/Link'; +import { getOldWalletUrl } from 'utils/url'; import Button from 'components/Button'; import Icon from 'components/Icon'; - import { FONT_SIZE } from 'config/variables'; import colors from 'config/colors'; import icons from 'config/icons'; +import type { TrezorDevice } from 'flowtype'; + +type Props = { + device: ?TrezorDevice; +} + const Wrapper = styled.section` display: flex; flex-direction: column; @@ -40,7 +45,7 @@ const Message = styled.div` padding: 0 0 15px 0; `; -const FirmwareUpdate = () => ( +const FirmwareUpdate = (props: Props) => ( ( If your device is ever lost or damaged, your funds will be lost. Backup your device first, to protect your coins against such events.

Please use Bitcoin wallet interface to create a backup.

- + I’ll do that later. diff --git a/yarn.lock b/yarn.lock index 32b11a19..f75446a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -738,6 +738,13 @@ dependencies: regenerator-runtime "^0.12.0" +"@babel/runtime@^7.3.1": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83" + integrity sha512-IvfvnMdSaLBateu0jfsYIpZTxAc2cKEXEMiezGGN75QcBcecDUKd3PgLAncT0oOgxKy8dd8hrJKj9MfzgfZd6g== + dependencies: + regenerator-runtime "^0.12.0" + "@babel/template@^7.0.0", "@babel/template@^7.1.0", "@babel/template@^7.1.2", "@babel/template@^7.2.2": version "7.2.2" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907"