forked from nervosnetwork/neuron
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into chore-update-typeorm
- Loading branch information
Showing
77 changed files
with
1,793 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v0.113.0 | ||
v0.113.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/neuron-ui/src/components/BroadcastTransaction/broadcastTransaction.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.main { | ||
tr { | ||
td { | ||
font-size: 14px; | ||
line-height: 26px; | ||
color: var(--main-text-color); | ||
svg { | ||
width: 14px; | ||
height: 14px; | ||
margin-right: 4px; | ||
position: relative; | ||
top: 2px; | ||
} | ||
} | ||
.first { | ||
padding-right: 24px; | ||
color: var(--input-second-color); | ||
} | ||
} | ||
} | ||
|
||
.warningDialog { | ||
width: 680px; | ||
.content { | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 24px; | ||
color: var(--main-text-color); | ||
} | ||
} | ||
|
||
.textarea { | ||
color: var(--main-text-color); | ||
margin-top: 17px; | ||
width: 648px; | ||
height: 206px; | ||
resize: none; | ||
background: var(--secondary-background-color); | ||
border: 1px solid var(--divide-line-color); | ||
border-radius: 8px; | ||
padding: 16px; | ||
} |
136 changes: 136 additions & 0 deletions
136
packages/neuron-ui/src/components/BroadcastTransaction/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import React, { useCallback, useMemo, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useNavigate } from 'react-router-dom' | ||
import { isSuccessResponse, RoutePath, isMainnet as isMainnetUtil, useGoBack, getExplorerUrl } from 'utils' | ||
import Dialog from 'widgets/Dialog' | ||
import AlertDialog from 'widgets/AlertDialog' | ||
import { useDispatch, useState as useGlobalState } from 'states' | ||
import { broadcastSignedTransaction, OfflineSignStatus, openExternal, getTransactionList } from 'services/remote' | ||
|
||
import styles from './broadcastTransaction.module.scss' | ||
|
||
const BroadcastTransaction = () => { | ||
const { | ||
app: { loadedTransaction = {} }, | ||
chain: { networkID }, | ||
settings: { networks }, | ||
wallet, | ||
} = useGlobalState() | ||
|
||
const [isBroadcasting, setIsBroadcasting] = useState(false) | ||
const [broadcastedTxHash, setBroadcastedTxHash] = useState<string | null>('') | ||
const [t] = useTranslation() | ||
const dispatch = useDispatch() | ||
const [errMsg, setErrMsg] = useState('') | ||
const isMainnet = isMainnetUtil(networks, networkID) | ||
|
||
const { filePath, json } = loadedTransaction | ||
|
||
const jsonContent = useMemo(() => { | ||
return JSON.stringify(json, null, 2) | ||
}, [json]) | ||
|
||
const signStatus: OfflineSignStatus = json.status | ||
|
||
const isSigned = useMemo(() => signStatus === OfflineSignStatus.Signed, [signStatus]) | ||
|
||
const onBack = useGoBack() | ||
|
||
const navigate = useNavigate() | ||
const onBroadcast = useCallback(async () => { | ||
if (broadcastedTxHash) { | ||
openExternal(`${getExplorerUrl(isMainnet)}/transaction/${broadcastedTxHash}`) | ||
return | ||
} | ||
|
||
setIsBroadcasting(true) | ||
|
||
const res = await broadcastSignedTransaction({ | ||
...json, | ||
}) | ||
|
||
setIsBroadcasting(false) | ||
|
||
if (isSuccessResponse(res)) { | ||
if (!wallet?.id) { | ||
setBroadcastedTxHash(res.result) | ||
return | ||
} | ||
|
||
if (res.result) { | ||
getTransactionList({ | ||
walletID: wallet.id, | ||
pageNo: 1, | ||
pageSize: 10, | ||
keywords: res.result, | ||
}).then(txRes => { | ||
if (isSuccessResponse(txRes) && txRes.result.items.length) { | ||
navigate(RoutePath.History) | ||
} else { | ||
setBroadcastedTxHash(res.result) | ||
} | ||
}) | ||
} | ||
} else { | ||
setErrMsg(typeof res.message === 'string' ? res.message : res.message.content || '') | ||
} | ||
}, [wallet, json, navigate, dispatch, broadcastedTxHash, setBroadcastedTxHash]) | ||
|
||
return ( | ||
<> | ||
<Dialog | ||
show={isSigned} | ||
title={t('offline-sign.broadcast-transaction')} | ||
cancelText={t('offline-sign.actions.cancel')} | ||
onCancel={onBack} | ||
confirmText={ | ||
broadcastedTxHash ? t('offline-sign.actions.view-in-explorer') : t('offline-sign.actions.broadcast') | ||
} | ||
isLoading={isBroadcasting} | ||
onConfirm={onBroadcast} | ||
> | ||
<div className={styles.main}> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td className={styles.first}>{t('offline-sign.json-file')}</td> | ||
<td>{filePath}</td> | ||
</tr> | ||
<tr> | ||
<td className={styles.first}>{t('offline-sign.status.label')}</td> | ||
<td>{t('offline-sign.status.signed')}</td> | ||
</tr> | ||
<tr> | ||
<td className={styles.first}>{t('offline-sign.content')}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<textarea disabled value={jsonContent} className={styles.textarea} /> | ||
</div> | ||
</Dialog> | ||
|
||
<Dialog | ||
show={!isSigned} | ||
className={styles.warningDialog} | ||
title={t('offline-sign.import-transaction-to-sign')} | ||
cancelText={t('offline-sign.actions.cancel')} | ||
onCancel={onBack} | ||
onConfirm={onBack} | ||
> | ||
<div className={styles.content}>{t('offline-sign.import-unsigned-transaction-detail')}</div> | ||
</Dialog> | ||
|
||
<AlertDialog | ||
show={!!errMsg} | ||
title={t('message-types.alert')} | ||
message={errMsg} | ||
type="failed" | ||
onCancel={() => setErrMsg('')} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
BroadcastTransaction.displayName = 'BroadcastTransaction' | ||
|
||
export default BroadcastTransaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
cd78f32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packaging for test is done in 7772632360