Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5012cbf
chore: bump typeorm to 0.2.20
classicalliu Oct 23, 2019
ca3e850
Merge pull request #1014 from nervosnetwork/bump-typeorm-to-0.2.20
classicalliu Oct 23, 2019
dc415f3
feat(neuron-ui): update the Send View according to the new transactio…
Keith-CY Oct 23, 2019
1d579bc
feat(neuron-wallet0: remove the calculate fee method from neuron-wallet
Keith-CY Oct 23, 2019
60af027
Merge pull request #1015 from Keith-CY/update-ui-for-new-tx-fee-model
ashchan Oct 23, 2019
9aebede
feat(neuron-ui): display confirmations of pending transactions in the…
Keith-CY Oct 23, 2019
0e1c4b3
Merge pull request #1016 from Keith-CY/display-confirmatinos-of-pendi…
ashchan Oct 23, 2019
35d8b87
feat(neuron-ui): update history list to make it more compact
Keith-CY Oct 24, 2019
e46f3fa
Merge pull request #1017 from Keith-CY/update-history-ui
ashchan Oct 24, 2019
9e52fef
feat(neuron-ui): add a tooltip to display synchronized block number a…
Keith-CY Oct 25, 2019
273588b
refactor(neuron-ui): add spaces in the tooltip of synchornization status
Keith-CY Oct 25, 2019
5443c2f
chore(lint): Update eslint to not treat _xxx as unused arg
ashchan Oct 25, 2019
2d5ff5a
refactor: Rename IndexerRPC.getTransactionByLockHash to getTransactio…
ashchan Oct 25, 2019
8415627
Merge pull request #1018 from Keith-CY/add-tooltip-on-sync
ashchan Oct 25, 2019
f17c701
Merge pull request #1020 from nervosnetwork/eslint-no-unused-vars
ashchan Oct 25, 2019
e866c66
feat: display disconnection errors and dismiss them on getting connec…
Keith-CY Oct 25, 2019
97b8ea4
fix: return => break
classicalliu Oct 26, 2019
2db32f9
refactor(neuron-wallet): all errors will be caught in api controller …
Keith-CY Oct 26, 2019
d14802b
Merge pull request #1024 from nervosnetwork/fix-break-in-loop
classicalliu Oct 26, 2019
05ae69e
fix: break => continue
classicalliu Oct 26, 2019
e52ea69
Merge pull request #1025 from nervosnetwork/break-continue
classicalliu Oct 26, 2019
1f4d4ea
feat: stringify the result from api controller
Keith-CY Oct 26, 2019
5f5eaeb
Merge pull request #1023 from Keith-CY/stringify-api-result
ashchan Oct 27, 2019
feb75aa
refactor: Only load inputs relation when querying transactions from DB
ashchan Oct 25, 2019
d948a59
refactor: Do not process output multiple times if its status is dead
ashchan Oct 25, 2019
68e0021
chore: Log DB queries that take more than 100ms to execute
ashchan Oct 25, 2019
c31fd2b
chore: Always log DB under dev or test mode
ashchan Oct 25, 2019
6163b89
chore: Log indexer tx process
ashchan Oct 25, 2019
2fc14bc
chore: Do not log query by default
ashchan Oct 25, 2019
83dffb5
feat: Add a few db indices
ashchan Oct 25, 2019
c41ae8e
chore: Set maxQueryExecutionTime to 70ms
ashchan Oct 25, 2019
a50701c
refactor: Add index on transaction timestamp column
ashchan Oct 27, 2019
d01101e
chore(db): Congifure chain sqlite db parameters
ashchan Oct 27, 2019
2779ab6
refactor: Only order txs by timestamp
ashchan Oct 27, 2019
9de193b
chore: Lower maxQueryExecutionTime to 30
ashchan Oct 28, 2019
6e36550
feat: Optimize output db query
ashchan Oct 28, 2019
42fec86
Merge pull request #1021 from nervosnetwork/tweak-batch-tx-import
ashchan Oct 28, 2019
b451e0d
chore: Delete inline eslint comments(rules)
ashchan Oct 28, 2019
e8bdf53
refactor: Don't have to async wait rangeForCheck.clearRange()
ashchan Oct 28, 2019
4a9ed70
refactor: Convert several functions from async to normal
ashchan Oct 28, 2019
44bb8f8
refactor: Cache inputs' txs from the same block
ashchan Oct 28, 2019
b37ff3f
Merge pull request #1026 from nervosnetwork/remove-inline-eslint-comment
ashchan Oct 28, 2019
f8b0c7e
Merge pull request #1027 from nervosnetwork/optimize-non-indexer-sync
ashchan Oct 28, 2019
c5b5c86
chore: Bump to v0.23.1
ashchan Oct 28, 2019
f53e258
docs: Update changelog
ashchan Oct 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## [0.23.1](https://github.com/nervosnetwork/neuron/compare/v0.23.0...v0.23.1) (2019-10-28)


### Bug Fixes

* break => continue ([05ae69e](https://github.com/nervosnetwork/neuron/commit/05ae69e))
* return => break ([97b8ea4](https://github.com/nervosnetwork/neuron/commit/97b8ea4))


### Features

* Add a few db indices ([83dffb5](https://github.com/nervosnetwork/neuron/commit/83dffb5))
* display disconnection errors and dismiss them on getting connec… ([#1019](https://github.com/nervosnetwork/neuron/issues/1019)) ([e866c66](https://github.com/nervosnetwork/neuron/commit/e866c66))
* Optimize output db query ([6e36550](https://github.com/nervosnetwork/neuron/commit/6e36550))
* stringify the result from api controller ([1f4d4ea](https://github.com/nervosnetwork/neuron/commit/1f4d4ea))
* **neuron-ui:** add a tooltip to display synchronized block number and the tip block number ([9e52fef](https://github.com/nervosnetwork/neuron/commit/9e52fef))
* **neuron-ui:** display confirmations of pending transactions in the recent activity list ([9aebede](https://github.com/nervosnetwork/neuron/commit/9aebede))
* **neuron-ui:** update history list to make it more compact ([35d8b87](https://github.com/nervosnetwork/neuron/commit/35d8b87))
* **neuron-ui:** update the Send View according to the new transaction fee model. ([dc415f3](https://github.com/nervosnetwork/neuron/commit/dc415f3))



# [0.23.0](https://github.com/nervosnetwork/neuron/compare/v0.22.2...v0.23.0) (2019-10-23)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.23.0",
"version": "0.23.1",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "neuron",
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"version": "0.23.0",
"version": "0.23.1",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neuron-ui",
"version": "0.23.0",
"version": "0.23.1",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/CustomRows/ActivityRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ const ActivityRow = (props?: ActivityRowProps) => {
return (
<div
className={`${styles.activityRow} ${styles[status]}`}
title={`${hash}: ${description}`}
title={`${hash}: ${description || ''}`}
onDoubleClick={onDoubleClick}
>
<div className={styles.action}>{`${typeLabel} ${shannonToCKBFormatter(value)} CKB`}</div>
<div className={styles.status}>{statusLabel}</div>
<div className={styles.time}>{time}</div>
<div className={styles.meta}>{status === 'success' ? confirmations : ''}</div>
<div className={styles.meta}>{confirmations}</div>
</div>
)
}
Expand Down
27 changes: 27 additions & 0 deletions packages/neuron-ui/src/components/CustomRows/GroupHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { Stack, Text, getTheme } from 'office-ui-fabric-react'

const {
palette: { neutralLighterAlt, neutralSecondary, neutralLighter },
} = getTheme()

const GroupHeader = ({ group }: any) => {
const { name } = group
return (
<Stack
tokens={{ padding: 15 }}
styles={{
root: {
background: neutralLighterAlt,
borderTop: `1px solid ${neutralSecondary}`,
borderBottom: `1px solid ${neutralLighter}`,
padding: `15px 12px 5px`,
minWidth: '100%!important',
},
}}
>
<Text variant="medium">{name}</Text>
</Stack>
)
}
export default GroupHeader
22 changes: 22 additions & 0 deletions packages/neuron-ui/src/components/CustomRows/HistoryRow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import { DetailsRow, IDetailsRowProps } from 'office-ui-fabric-react'

const HistoryRow = (props?: IDetailsRowProps) => {
return props ? (
<DetailsRow
{...props}
styles={{
root: {
animationDuration: '0!important',
minWidth: '100%!important',
},
cell: {
paddingTop: 0,
paddingBottom: 0,
},
}}
/>
) : null
}

export default HistoryRow
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const Overview = ({
const activityItems: ActivityItem[] = useMemo(
() =>
items.map(item => {
let confirmations = '(-)'
let confirmations = ''
let typeLabel: string = item.type
let { status } = item
if (item.blockNumber !== undefined) {
Expand Down Expand Up @@ -147,7 +147,7 @@ const Overview = ({
status,
statusLabel: t(`overview.statusLabel.${status}`),
value: item.value.replace(/^-/, ''),
confirmations: item.status === 'success' ? confirmations : '',
confirmations: ['success', 'pending'].includes(item.status) ? confirmations : '',
typeLabel: t(`overview.${typeLabel}`),
}
}),
Expand Down
12 changes: 3 additions & 9 deletions packages/neuron-ui/src/components/PasswordRequest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { useTranslation } from 'react-i18next'
import { Stack, Text, Label, Modal, TextField, PrimaryButton, DefaultButton } from 'office-ui-fabric-react'
import { StateWithDispatch, AppActions } from 'states/stateProvider/reducer'
import { sendTransaction, deleteWallet, backupWallet } from 'states/stateProvider/actionCreators'
import { priceToFee, CKBToShannonFormatter } from 'utils/formatters'

const PasswordRequest = ({
app: {
send: { txID, outputs, description, price, cycles },
send: { description, generatedTx },
loadings: { sending: isSending = false },
passwordRequest: { walletID = '', actionType = null, password = '' },
},
Expand All @@ -32,15 +31,10 @@ const PasswordRequest = ({
break
}
sendTransaction({
id: txID,
walletID,
items: outputs.map(output => ({
address: output.address,
capacity: CKBToShannonFormatter(output.amount, output.unit),
})),
tx: generatedTx,
description,
password,
fee: priceToFee(price, cycles),
})(dispatch, history)
break
}
Expand All @@ -62,7 +56,7 @@ const PasswordRequest = ({
break
}
}
}, [dispatch, walletID, password, actionType, txID, description, outputs, cycles, price, history, isSending])
}, [dispatch, walletID, password, actionType, description, history, isSending, generatedTx])

const onChange = useCallback(
(_e, value?: string) => {
Expand Down
63 changes: 31 additions & 32 deletions packages/neuron-ui/src/components/Send/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React, { useState, useCallback, useEffect, useMemo } from 'react'

import { AppActions, StateDispatch } from 'states/stateProvider/reducer'
import { calculateCycles } from 'services/remote/wallets'
import { generateTx } from 'services/remote/wallets'

import { outputsToTotalAmount, priceToFee } from 'utils/formatters'
import { outputsToTotalAmount, CKBToShannonFormatter } from 'utils/formatters'
import { verifyAddress, verifyAmount, verifyAmountRange, verifyTransactionOutputs } from 'utils/validators'
import { ErrorCode } from 'utils/const'
import { MAX_DECIMAL_DIGITS } from '../../utils/const'
import { ErrorCode, MAX_DECIMAL_DIGITS } from 'utils/const'
import calculateFee from 'utils/calculateFee'

import { TransactionOutput } from '.'

let cyclesTimer: ReturnType<typeof setTimeout>
let generateTxTimer: ReturnType<typeof setTimeout>

const useUpdateTransactionOutput = (dispatch: StateDispatch) =>
useCallback(
Expand Down Expand Up @@ -49,49 +50,47 @@ const useRemoveTransactionOutput = (dispatch: StateDispatch) =>
const useOnTransactionChange = (
walletID: string,
items: TransactionOutput[],
price: string,
dispatch: StateDispatch,
setIsTransactionValid: Function,
setTotalAmount: Function
) => {
useEffect(() => {
clearTimeout(cyclesTimer)
cyclesTimer = setTimeout(() => {
clearTimeout(generateTxTimer)
generateTxTimer = setTimeout(() => {
dispatch({
type: AppActions.UpdateGeneratedTx,
payload: null,
})
if (verifyTransactionOutputs(items)) {
setIsTransactionValid(true)
const totalAmount = outputsToTotalAmount(items)
setTotalAmount(totalAmount)
calculateCycles({
const realParams = {
walletID,
capacities: totalAmount,
})
.then(response => {
if (response.status) {
if (Number.isNaN(+response.result)) {
throw new Error('Invalid Cycles')
}
items: items.map(item => ({
address: item.address,
capacity: CKBToShannonFormatter(item.amount, item.unit),
})),
feeRate: price,
}
generateTx(realParams)
.then((res: any) => {
if (res.status === 1) {
dispatch({
type: AppActions.UpdateSendCycles,
payload: response.result,
type: AppActions.UpdateGeneratedTx,
payload: res.result,
})
} else {
throw new Error('Cycles Not Calculated')
}
})
.catch(() => {
dispatch({
type: AppActions.UpdateSendCycles,
payload: '0',
})
.catch((err: Error) => {
console.error(err)
})
} else {
setIsTransactionValid(false)
dispatch({
type: AppActions.UpdateSendCycles,
payload: '0',
})
}
}, 300)
}, [walletID, items, dispatch, setIsTransactionValid, setTotalAmount])
}, [walletID, items, price, dispatch, setIsTransactionValid, setTotalAmount])
}

const useOnSubmit = (items: TransactionOutput[], dispatch: StateDispatch) =>
Expand Down Expand Up @@ -170,12 +169,12 @@ const useClear = (dispatch: StateDispatch) => useCallback(() => clear(dispatch),

export const useInitialize = (
items: TransactionOutput[],
price: string,
cycles: string,
generatedTx: any | null,
dispatch: React.Dispatch<any>,
t: any
) => {
const fee = useMemo(() => priceToFee(price, cycles), [price, cycles]) // in shannon
const fee = useMemo(() => calculateFee(generatedTx), [generatedTx])

const [isTransactionValid, setIsTransactionValid] = useState(false)
const [totalAmount, setTotalAmount] = useState('0')

Expand Down
11 changes: 3 additions & 8 deletions packages/neuron-ui/src/components/Send/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const Send = ({
onGetAddressErrorMessage,
onGetAmountErrorMessage,
onClear,
} = useInitialize(send.outputs, send.price, send.cycles, dispatch, t)
useOnTransactionChange(walletID, send.outputs, dispatch, setIsTransactionValid, setTotalAmount)
} = useInitialize(send.outputs, send.generatedTx, dispatch, t)
useOnTransactionChange(walletID, send.outputs, send.price, dispatch, setIsTransactionValid, setTotalAmount)
const leftStackWidth = '70%'
const labelWidth = '140px'

Expand Down Expand Up @@ -211,12 +211,7 @@ const Send = ({
</Stack>
</Stack>

<TransactionFeePanel
fee={shannonToCKBFormatter(fee)}
cycles={send.cycles}
price={send.price}
onPriceChange={updateTransactionPrice}
/>
<TransactionFeePanel fee={shannonToCKBFormatter(fee)} price={send.price} onPriceChange={updateTransactionPrice} />

<Stack horizontal verticalAlign="center" tokens={{ childrenGap: 20 }}>
<Stack.Item styles={{ root: { width: labelWidth } }}>
Expand Down
9 changes: 8 additions & 1 deletion packages/neuron-ui/src/components/Transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,15 @@ const Transaction = () => {
const currentWallet = currentWalletCache.load()
if (currentWallet) {
const hash = window.location.href.split('/').pop()
if (!hash) {
showErrorMessage(
t(`messages.error`),
t(`messages.codes.${ErrorCode.FieldNotFound}`, { fieldName: 'transaction hash' })
)
return
}
getTransaction({ hash, walletID: currentWallet.id })
.then(res => {
.then((res: any) => {
if (res.status) {
setTransaction(res.result)
} else {
Expand Down
Loading