-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix: calculate genesis id properly #1359
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c4615d2
fix: calculate genesis id properly
brusherru 49789a9
fix: update tests
maparr 83bde18
refactor: add `getShortGenesisId`, `getDefaultPosDir`, `getCustomNode…
brusherru 19da36f
feat: migrate genesis id: rename `node-data` dir and custom `node-con…
brusherru 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
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
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,125 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { WarningType } from '../../../shared/warning'; | ||
import { Button } from '../../basicComponents'; | ||
import Modal from '../../components/common/Modal'; | ||
import { eventsService } from '../../infra/eventsService'; | ||
import { getWarningByType } from '../../redux/ui/selectors'; | ||
import { smColors } from '../../vars'; | ||
import { omitWarning } from '../../redux/ui/actions'; | ||
import ReactPortal from './ReactPortal'; | ||
|
||
const ButtonsWrapper = styled.div<{ hasSingleButton?: boolean }>` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: ${({ hasSingleButton }) => | ||
hasSingleButton ? 'center' : 'space-between'}; | ||
margin: auto 0 15px 0; | ||
padding-top: 30px; | ||
`; | ||
|
||
const ErrorMessage = styled.pre` | ||
font-size: 14px; | ||
line-height: 1.33em; | ||
word-wrap: break-word; | ||
white-space: pre-wrap; | ||
flex: 1; | ||
overflow-y: auto; | ||
height: 150px; | ||
`; | ||
|
||
const Code = styled.pre` | ||
display: inline-block; | ||
padding: 0.1em 0.4em; | ||
background: ${smColors.black20Alpha}; | ||
border-radius: ${({ theme }) => theme.popups.boxRadius / 2}px; | ||
margin-top: 0.2em; | ||
|
||
direction: rtl; | ||
text-overflow: ellipsis; | ||
text-align: right; | ||
max-width: 260px; | ||
overflow: hidden; | ||
|
||
margin-bottom: -0.4em; | ||
margin-top: 0.4em; | ||
|
||
cursor: pointer; | ||
&:hover, | ||
&:focus { | ||
background: ${smColors.black30Alpha}; | ||
} | ||
`; | ||
|
||
const RedText = styled.span` | ||
color: ${smColors.red}; | ||
`; | ||
|
||
const GenesisIDMigrationFailed = () => { | ||
const dispatch = useDispatch(); | ||
const warning = useSelector( | ||
getWarningByType(WarningType.GenesisIDMigrationFailed) | ||
); | ||
if (!warning) { | ||
return null; | ||
} | ||
const handleDismiss = () => { | ||
dispatch(omitWarning(warning)); | ||
}; | ||
|
||
const revealInFinder = (filePath: string) => () => | ||
eventsService.showFileInFolder({ filePath }); | ||
|
||
return ( | ||
<ReactPortal modalId="spacemesh-genesis-id-migration-failed"> | ||
<Modal | ||
header="Error" | ||
subHeader="Cannot move files under correct Genesis ID" | ||
width={600} | ||
height={450} | ||
> | ||
<ErrorMessage> | ||
<RedText>{warning.message}</RedText> | ||
{'\n\n'} | ||
<ul style={{ fontSize: '12px' }}> | ||
<li>Please, check and rename these files/directories:</li> | ||
<li> | ||
1. | ||
<Code onClick={revealInFinder(warning.payload.nodeConfig.prev)}> | ||
{warning.payload.nodeConfig.prev} | ||
</Code> | ||
→ | ||
<Code onClick={revealInFinder(warning.payload.nodeConfig.next)}> | ||
{warning.payload.nodeConfig.next} | ||
</Code> | ||
</li> | ||
<li> | ||
2. | ||
<Code onClick={revealInFinder(warning.payload.nodeData.prev)}> | ||
{warning.payload.nodeData.prev} | ||
</Code> | ||
→ | ||
<Code onClick={revealInFinder(warning.payload.nodeData.next)}> | ||
{warning.payload.nodeData.next} | ||
</Code> | ||
</li> | ||
<li style={{ marginTop: '1em' }}> | ||
Note: Smapp does not rename the PoS directory. | ||
<br /> | ||
<RedText> | ||
Please, ensure that Smapp is using correct node-config and PoS | ||
data. | ||
</RedText> | ||
</li> | ||
</ul> | ||
</ErrorMessage> | ||
<ButtonsWrapper> | ||
<Button isPrimary={false} onClick={handleDismiss} text="DISMISS" /> | ||
</ButtonsWrapper> | ||
</Modal> | ||
</ReactPortal> | ||
); | ||
}; | ||
|
||
export default GenesisIDMigrationFailed; |
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
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
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
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.
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.
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.
parseISODate returns milliseconds?
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.
Yeah
Agree about fetching from grpc, but we're indexing networks by genesis id (auto-connect to them, store logs using it and etc) — so we need it earlier (and even if Node does not work).
But probably Smapp should show some alerts in case the calculated genesis id and the one returned from API are different.