Browse Source

Merge branch 'develop' into live-common-refactoring-1

gre-patch-1
Gaëtan Renaudeau 6 years ago
parent
commit
67932d14bb
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 2
      package.json
  2. 3
      src/commands/libcoreGetFees.js
  3. 3
      src/commands/libcoreSignAndBroadcast.js
  4. 65
      src/components/ProgressBar/index.js
  5. 16
      src/components/ProgressBar/stories.js
  6. 98
      src/components/ProgressCircle/index.js
  7. 16
      src/components/ProgressCircle/stories.js
  8. 44
      yarn.lock

2
package.json

@ -40,7 +40,7 @@
"@ledgerhq/hw-app-xrp": "^4.32.0",
"@ledgerhq/hw-transport": "^4.32.0",
"@ledgerhq/hw-transport-node-hid": "^4.32.0",
"@ledgerhq/ledger-core": "2.0.0-rc.12",
"@ledgerhq/ledger-core": "2.0.0-rc.14",
"@ledgerhq/live-common": "4.8.0-beta.4",
"animated": "^0.2.2",
"async": "^2.6.1",

3
src/commands/libcoreGetFees.js

@ -75,7 +75,8 @@ const cmd: Command<Input, Result> = createCommand(
njsWalletCurrency,
BigNumber(transaction.feePerByte),
)
const transactionBuilder = bitcoinLikeAccount.buildTransaction()
const isPartial = true
const transactionBuilder = bitcoinLikeAccount.buildTransaction(isPartial)
if (!isValidAddress(core, njsWalletCurrency, transaction.recipient)) {
// FIXME this is a bug in libcore. later it will probably check this and we can remove this check
throw new InvalidAddress()

3
src/commands/libcoreSignAndBroadcast.js

@ -227,7 +227,8 @@ export async function doSignAndBroadcast({
const njsWalletCurrency = njsWallet.getCurrency()
const amount = bigNumberToLibcoreAmount(core, njsWalletCurrency, BigNumber(transaction.amount))
const fees = bigNumberToLibcoreAmount(core, njsWalletCurrency, BigNumber(transaction.feePerByte))
const transactionBuilder = bitcoinLikeAccount.buildTransaction()
const isPartial = false
const transactionBuilder = bitcoinLikeAccount.buildTransaction(isPartial)
// TODO: check if is valid address. if not, it will fail silently on invalid

65
src/components/ProgressBar/index.js

@ -0,0 +1,65 @@
// @flow
import React, { PureComponent } from 'react'
import styled, { css, keyframes } from 'styled-components'
import { colors } from 'styles/theme'
const animIndeterminate = keyframes`
0% {
transform: scaleX(0) translate3d(0, 0, 0);
}
50% {
transform: scaleX(1) translate3d(100%, 0, 0);
}
100% {
transform: scaleX(0) translate3d(0, 0, 0);
}
`
const Outer = styled.div`
background-color: ${colors.fog};
border-radius: 3px;
overflow: hidden;
height: 10px;
width: ${p => p.width}px;
position: relative;
`
const Inner = styled.div`
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: ${colors.wallet};
transform-origin: center left;
${p =>
p.progress === 0
? css`
animation: ${animIndeterminate} 2s cubic-bezier(0.61, 0.01, 0.39, 1.03) infinite;
`
: css`
transform: scaleX(${p => p.progress});
transition: 150ms ease-out transform;
`};
`
type Props = {
progress: number,
width: number,
}
class ProgressBar extends PureComponent<Props> {
render() {
const { progress, width } = this.props
return (
<Outer width={width}>
<Inner progress={progress} />
</Outer>
)
}
}
export default ProgressBar

16
src/components/ProgressBar/stories.js

@ -0,0 +1,16 @@
// @flow
import React from 'react'
import { storiesOf } from '@storybook/react'
import { number } from '@storybook/addon-knobs'
import ProgressBar from 'components/ProgressBar'
const stories = storiesOf('Components', module)
stories.add('ProgressBar', () => (
<ProgressBar
progress={number('progress', 0, { min: 0, max: 1, step: 0.05 })}
width={number('width', 200, { min: 50, max: 500, step: 10 })}
/>
))

98
src/components/ProgressCircle/index.js

@ -0,0 +1,98 @@
// @flow
import React, { PureComponent } from 'react'
import styled, { css, keyframes } from 'styled-components'
import { colors } from 'styles/theme'
import Text from 'components/base/Text'
const STROKE_WIDTH = 10
type Props = {
progress: number,
size: number,
}
const animIndeterminate = keyframes`
0% {
}
50% {
}
100% {
}
`
const InnerCircle = styled.circle`
transform-origin: 50% 50%;
${p =>
p.progress === 0
? css`
animation: ${animIndeterminate} 3s cubic-bezier(0.61, 0.01, 0.39, 1.03) infinite;
`
: css`
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
`};
`
const Container = styled.div`
position: relative;
width: ${p => p.size}px;
height: ${p => p.size}px;
`
const TextContainer = styled.div`
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
`
class ProgressCircle extends PureComponent<Props> {
render() {
const { size, progress } = this.props
const radius = size / 2
const normalizedRadius = radius - STROKE_WIDTH / 2
const circumference = normalizedRadius * 2 * Math.PI
const strokeDashoffset = circumference - progress * circumference
return (
<Container size={size}>
<TextContainer>
<Text ff="Museo Sans|Bold" color="graphite" fontSize={6}>
{`${Math.round(progress * 100)}%`}
</Text>
</TextContainer>
<svg height={size} width={size}>
<circle
stroke={colors.fog}
fill="transparent"
strokeWidth={STROKE_WIDTH}
style={{ strokeDashoffset }}
r={normalizedRadius}
cx={radius}
cy={radius}
/>
<InnerCircle
progress={progress}
stroke={colors.wallet}
fill="transparent"
strokeWidth={STROKE_WIDTH}
strokeDasharray={`${circumference} ${circumference}`}
style={{ strokeDashoffset }}
r={normalizedRadius}
cx={radius}
cy={radius}
/>
</svg>
</Container>
)
}
}
export default ProgressCircle

16
src/components/ProgressCircle/stories.js

@ -0,0 +1,16 @@
// @flow
import React from 'react'
import { storiesOf } from '@storybook/react'
import { number } from '@storybook/addon-knobs'
import ProgressCircle from 'components/ProgressCircle'
const stories = storiesOf('Components', module)
stories.add('ProgressCircle', () => (
<ProgressCircle
progress={number('progress', 0, { min: 0, max: 1, step: 0.01 })}
size={number('width', 150, { min: 50, max: 500, step: 10 })}
/>
))

44
yarn.lock

@ -1685,14 +1685,6 @@
"@ledgerhq/hw-transport" "^4.32.0"
create-hash "^1.1.3"
"@ledgerhq/hw-app-btc@^4.7.3":
version "4.15.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-btc/-/hw-app-btc-4.15.0.tgz#8bea2908c4c67f47f85641eb8d82c54df50fef19"
integrity sha1-i+opCMTGf0f4VkHrjYLFTfUP7xk=
dependencies:
"@ledgerhq/hw-transport" "^4.15.0"
create-hash "^1.1.3"
"@ledgerhq/hw-app-eth@^4.32.0":
version "4.32.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.32.0.tgz#7d43ca2c7952f1fb726e02c3b4485be10af481a2"
@ -1718,44 +1710,18 @@
node-hid "^0.7.2"
usb "^1.3.3"
"@ledgerhq/hw-transport-node-hid@^4.7.6":
version "4.16.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-4.16.0.tgz#de8d7ffd37e01c77aed566d8c534fe3937c3c35c"
integrity sha1-3o1//TfgHHeu1WbYxTT+OTfDw1w=
dependencies:
"@ledgerhq/hw-transport" "^4.15.0"
node-hid "^0.7.2"
"@ledgerhq/hw-transport@^4.15.0":
version "4.19.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-4.19.0.tgz#19a804aee1bfc4abac1dc9a2a7a582e79273f991"
integrity sha1-GagEruG/xKusHcmip6WC55Jz+ZE=
dependencies:
events "^2.0.0"
"@ledgerhq/hw-transport@^4.21.0":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-4.24.0.tgz#8def925d8c2e1f73d15128d9e27ead729870be58"
integrity sha512-L34TG1Ss7goRB+5BxtvBwUuu0CmDSIxS33oUqkpEy6rCs31k7XicV48iUGAnRnt8hNY2DvJ9WFyaOroUE9h6wQ==
dependencies:
events "^3.0.0"
"@ledgerhq/hw-transport@^4.32.0":
"@ledgerhq/hw-transport@^4.21.0", "@ledgerhq/hw-transport@^4.32.0":
version "4.32.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-4.32.0.tgz#592b9dc51459cb1cd31ce9444cf943f627bc4beb"
integrity sha512-Wgsk9UHC4RShqYoDeIEeKgHZOvNCtB0WWIG0xqlVPzS+IcKDkIxtXQw7hTA7GQSuDuGeauVtlbTQ5yat6+2/BA==
dependencies:
events "^3.0.0"
"@ledgerhq/ledger-core@2.0.0-rc.12":
version "2.0.0-rc.12"
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.12.tgz#bdd3e4b601acb0c74c640f40bea2609bb5e4b0f4"
integrity sha512-nwPAmDlGGSx/nRzwxKodmN1KBKtFmElE0FkbbAn1s0xiX6C8wMPRWPtD7oTufJ5MsfSfJg4ELsscEiaHFbZFKA==
"@ledgerhq/ledger-core@2.0.0-rc.14":
version "2.0.0-rc.14"
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.14.tgz#538b771e9d837ce1d26aabaa1dfe58a6b882e3cd"
integrity sha512-WIq6DyOoqtPPt+pS8K6NQ8EJD9GIn/VD1HLehWvJYqZhUf1IOIEIaOqxCnayHMQ/7b4c68xANgmKggUBdQ0M+A==
dependencies:
"@ledgerhq/hw-app-btc" "^4.7.3"
"@ledgerhq/hw-transport-node-hid" "^4.7.6"
axios "^0.18.0"
babel-runtime "^6.26.0"
bindings "^1.3.0"
nan "^2.6.2"

Loading…
Cancel
Save