-
Notifications
You must be signed in to change notification settings - Fork 92
fix: Hot/cold combination of a wallet doesn't work smooth #3000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
12dccc8
fix: issue 288
devchenyan 9a6a3de
Merge branch 'develop' into fix-288
devchenyan 7628599
Merge branch 'develop' into fix-288
Keith-CY 3bb57b7
Merge branch 'develop' into fix-288
Keith-CY 12c6c7c
fix: broadcastTransaction
devchenyan add3673
Merge branch 'develop' into fix-288
devchenyan bf3ea9b
Merge branch 'develop' into fix-288
devchenyan 17cc1a7
fix: BroadcastTransaction
devchenyan 994dc94
fix: French
devchenyan b245751
fix: broadcastTransactionOnly
devchenyan 91fbcf7
fix: comments
devchenyan d8416fd
fix: broadcastSignedTransaction
devchenyan 7030d9d
fix
devchenyan 2068f3d
feat: remove Wallet field
devchenyan 4792496
Merge branch 'develop' into fix-288
devchenyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/neuron-ui/src/components/BroadcastTransaction/broadcastTransaction.module.scss
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.