Skip to content
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/network error #194

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/forms/ConfigConnectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const ConfigConnectionForm: FC<ConfigConnectionFormProps> = ({ children }) => {
validatorClient,
)

const handleError = (e: unknown) => {
const handleError = (e: unknown, autoClose?: false | number) => {
let message = 'Unknown Error'
const requiredErrors = [
'beaconDataRequired',
Expand All @@ -162,7 +162,7 @@ const ConfigConnectionForm: FC<ConfigConnectionFormProps> = ({ children }) => {
if (e instanceof AxiosError && e.response?.status === 403) {
message = t('error.invalidApiToken')
}
displayToast(message, ToastType.ERROR)
displayToast(message, ToastType.ERROR, { autoClose })
}

const handleValidationErrors = (values: ConnectionForm) => {
Expand Down Expand Up @@ -285,11 +285,11 @@ const ConfigConnectionForm: FC<ConfigConnectionFormProps> = ({ children }) => {
} catch (e) {
if (!isValidBeaconNode || !isValidValidatorClient) {
if (!isValidBeaconNode) {
handleError('invalidBeacon')
handleError('invalidBeacon', false)
}

if (!isValidValidatorClient) {
handleError('invalidValidator')
handleError('invalidValidator', false)
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/locales/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
},
"invalidJson": "Invalid JSON data. Please ensure to use correct format.",
"executionFailure": "Execution broadcast failed. Please ensure all fields and signature are valid.",
"networkError": "{{type}} NODE NETWORK ERROR: Make sure your IP is correct and/or CORS is correctly configured. Use --http-allow-origin in {{type}} config",
"networkError": "{{type}} NODE NETWORK ERROR: Make sure your IP is correct and/or CORS is correctly configured. Use --http-allow-origin \"*\" in {{type}} config",
"unknownError": "Unknown {{type}} NODE error.",
"validatorInfo": "Error Loading Validator Info...",
"missingValidatorData": "Invalid Validator Node Data",
Expand Down
5 changes: 3 additions & 2 deletions src/utilities/displayToast.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { toast } from 'react-toastify'
import { ToastType } from '../types'
import { ToastOptions } from 'react-toastify/dist/types'

const displayToast = (message: string, type: ToastType, options?: any) => {
const displayToast = (message: string, type: ToastType, options?: ToastOptions) => {
const toastOptions = {
position: options?.position || 'top-right',
autoClose: options?.autoClose || 5000,
autoClose: options?.autoClose ?? 5000,
style: type === ToastType.SUCCESS ? { background: '#70D370' } : undefined,
theme: options?.theme || 'colored',
hideProgressBar: options?.hideProgressBar || true,
Expand Down
Loading