Skip to content

Commit

Permalink
feat(neuron-ui): remove the user-confirmation from phase2 of nervos dao
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 12, 2019
1 parent 15d0cc8 commit 7e9e9e3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
Expand Up @@ -109,7 +109,7 @@ const DAORecord = ({
}
}
return onClick
}, [onClick, epoch, depositEpoch, withdrawingEpoch])
}, [onClick, epoch, depositEpoch, withdrawingEpoch, t])

return (
<div className={`${styles.daoRecord} ${depositOutPoint ? styles.isClaim : ''}`}>
Expand Down
Expand Up @@ -65,6 +65,7 @@ const WithdrawDialog = ({
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
days: localNumberFormatter(epochs / BigInt(6)),
})

const alert =
epochs <= BigInt(5)
? t('nervos-dao.withdraw-alert', {
Expand All @@ -73,6 +74,7 @@ const WithdrawDialog = ({
days: (epochs + BigInt(180)) / BigInt(6),
})
: ''

return (
<Dialog
hidden={!record}
Expand Down
59 changes: 44 additions & 15 deletions packages/neuron-ui/src/components/NervosDAO/index.tsx
Expand Up @@ -117,19 +117,11 @@ const NervosDAO = ({
const onWithdrawDialogSubmit = () => {
setErrorMessage('')
if (activeRecord) {
;(activeRecord.depositOutPoint
? generateClaimTx({
walletID: wallet.id,
withdrawingOutPoint: activeRecord.outPoint,
depositOutPoint: activeRecord.depositOutPoint,
feeRate: `${MEDIUM_FEE_RATE}`,
})
: generateWithdrawTx({
walletID: wallet.id,
outPoint: activeRecord.outPoint,
feeRate: `${MEDIUM_FEE_RATE}`,
})
)
generateWithdrawTx({
walletID: wallet.id,
outPoint: activeRecord.outPoint,
feeRate: `${MEDIUM_FEE_RATE}`,
})
.then((res: any) => {
if (res.status === 1) {
dispatch({
Expand Down Expand Up @@ -171,10 +163,47 @@ const NervosDAO = ({
}
const record = records.find(r => r.outPoint.txHash === outPoint.txHash && r.outPoint.index === outPoint.index)
if (record) {
setActiveRecord(record)
if (record.depositOutPoint) {
generateClaimTx({
walletID: wallet.id,
withdrawingOutPoint: record.outPoint,
depositOutPoint: record.depositOutPoint,
feeRate: `${MEDIUM_FEE_RATE}`,
})
.then((res: any) => {
if (res.status === 1) {
dispatch({
type: AppActions.UpdateGeneratedTx,
payload: res.result,
})
dispatch({
type: AppActions.RequestPassword,
payload: {
walletID: wallet.id,
actionType: 'send',
},
})
} else {
clearGeneratedTx()
setErrorMessage(`${typeof res.message === 'string' ? res.message : res.message.content}`)
}
})
.catch((err: Error) => {
dispatch({
type: AppActions.AddNotification,
payload: {
type: 'alert',
timestamp: +new Date(),
content: err.message,
},
})
})
} else {
setActiveRecord(record)
}
}
},
[records]
[records, clearGeneratedTx, dispatch, wallet.id]
)

const fee = `${shannonToCKBFormatter(
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/components/Transaction/index.tsx
Expand Up @@ -254,7 +254,7 @@ const Transaction = () => {
{ label: t('transaction.transaction-hash'), value: transaction.hash || 'none' },
{
label: t('transaction.block-number'),
value: localNumberFormatter(transaction.blockNumber) || 'none',
value: transaction.blockNumber ? localNumberFormatter(transaction.blockNumber) : 'none',
},
{
label: t('transaction.date'),
Expand Down

0 comments on commit 7e9e9e3

Please sign in to comment.