Skip to content

Commit 7e9e9e3

Browse files
committed
feat(neuron-ui): remove the user-confirmation from phase2 of nervos dao
1 parent 15d0cc8 commit 7e9e9e3

4 files changed

Lines changed: 48 additions & 17 deletions

File tree

packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const DAORecord = ({
109109
}
110110
}
111111
return onClick
112-
}, [onClick, epoch, depositEpoch, withdrawingEpoch])
112+
}, [onClick, epoch, depositEpoch, withdrawingEpoch, t])
113113

114114
return (
115115
<div className={`${styles.daoRecord} ${depositOutPoint ? styles.isClaim : ''}`}>

packages/neuron-ui/src/components/NervosDAO/WithdrawDialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const WithdrawDialog = ({
6565
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
6666
days: localNumberFormatter(epochs / BigInt(6)),
6767
})
68+
6869
const alert =
6970
epochs <= BigInt(5)
7071
? t('nervos-dao.withdraw-alert', {
@@ -73,6 +74,7 @@ const WithdrawDialog = ({
7374
days: (epochs + BigInt(180)) / BigInt(6),
7475
})
7576
: ''
77+
7678
return (
7779
<Dialog
7880
hidden={!record}

packages/neuron-ui/src/components/NervosDAO/index.tsx

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,11 @@ const NervosDAO = ({
117117
const onWithdrawDialogSubmit = () => {
118118
setErrorMessage('')
119119
if (activeRecord) {
120-
;(activeRecord.depositOutPoint
121-
? generateClaimTx({
122-
walletID: wallet.id,
123-
withdrawingOutPoint: activeRecord.outPoint,
124-
depositOutPoint: activeRecord.depositOutPoint,
125-
feeRate: `${MEDIUM_FEE_RATE}`,
126-
})
127-
: generateWithdrawTx({
128-
walletID: wallet.id,
129-
outPoint: activeRecord.outPoint,
130-
feeRate: `${MEDIUM_FEE_RATE}`,
131-
})
132-
)
120+
generateWithdrawTx({
121+
walletID: wallet.id,
122+
outPoint: activeRecord.outPoint,
123+
feeRate: `${MEDIUM_FEE_RATE}`,
124+
})
133125
.then((res: any) => {
134126
if (res.status === 1) {
135127
dispatch({
@@ -171,10 +163,47 @@ const NervosDAO = ({
171163
}
172164
const record = records.find(r => r.outPoint.txHash === outPoint.txHash && r.outPoint.index === outPoint.index)
173165
if (record) {
174-
setActiveRecord(record)
166+
if (record.depositOutPoint) {
167+
generateClaimTx({
168+
walletID: wallet.id,
169+
withdrawingOutPoint: record.outPoint,
170+
depositOutPoint: record.depositOutPoint,
171+
feeRate: `${MEDIUM_FEE_RATE}`,
172+
})
173+
.then((res: any) => {
174+
if (res.status === 1) {
175+
dispatch({
176+
type: AppActions.UpdateGeneratedTx,
177+
payload: res.result,
178+
})
179+
dispatch({
180+
type: AppActions.RequestPassword,
181+
payload: {
182+
walletID: wallet.id,
183+
actionType: 'send',
184+
},
185+
})
186+
} else {
187+
clearGeneratedTx()
188+
setErrorMessage(`${typeof res.message === 'string' ? res.message : res.message.content}`)
189+
}
190+
})
191+
.catch((err: Error) => {
192+
dispatch({
193+
type: AppActions.AddNotification,
194+
payload: {
195+
type: 'alert',
196+
timestamp: +new Date(),
197+
content: err.message,
198+
},
199+
})
200+
})
201+
} else {
202+
setActiveRecord(record)
203+
}
175204
}
176205
},
177-
[records]
206+
[records, clearGeneratedTx, dispatch, wallet.id]
178207
)
179208

180209
const fee = `${shannonToCKBFormatter(

packages/neuron-ui/src/components/Transaction/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const Transaction = () => {
254254
{ label: t('transaction.transaction-hash'), value: transaction.hash || 'none' },
255255
{
256256
label: t('transaction.block-number'),
257-
value: localNumberFormatter(transaction.blockNumber) || 'none',
257+
value: transaction.blockNumber ? localNumberFormatter(transaction.blockNumber) : 'none',
258258
},
259259
{
260260
label: t('transaction.date'),

0 commit comments

Comments
 (0)