feat: add prerequisite checks before swap (#588)

* feat: add prerequisite checks before swap

* fix: add missing authentication on desktop config call

* refactor(wip): introduce swap error

* refactor: use wrapWithSwapError

* fix: log originalError instead of error

* fix: show snackbar when error is unexpected
This commit is contained in:
Cafe137
2022-11-23 14:20:55 +01:00
committed by GitHub
parent 1c53364fcd
commit 4e564dd5c0
5 changed files with 97 additions and 26 deletions
+2 -19
View File
@@ -1,8 +1,7 @@
import axios from 'axios'
import { useEffect, useState } from 'react'
import { getLatestBeeDesktopVersion } from '../utils/desktop'
import { getJson } from '../utils/net'
import { GITHUB_REPO_URL } from '../constants'
import { BeeConfig, getDesktopConfiguration, getLatestBeeDesktopVersion } from '../utils/desktop'
export interface LatestBeeReleaseHook {
latestBeeRelease: LatestBeeRelease | null
@@ -109,22 +108,6 @@ export function useNewBeeDesktopVersion(
return { newBeeDesktopVersion }
}
export interface BeeConfig {
'api-addr': string
'debug-api-addr': string
'debug-api-enable': boolean
password: string
'swap-enable': boolean
'swap-initial-deposit': bigint
mainnet: boolean
'full-node': boolean
'cors-allowed-origins': string
'resolver-options': string
'use-postage-snapshot': boolean
'data-dir': string
'swap-endpoint'?: string
}
export interface GetBeeConfig {
config: BeeConfig | null
isLoading: boolean
@@ -137,7 +120,7 @@ export const useGetBeeConfig = (desktopUrl: string): GetBeeConfig => {
const [error, setError] = useState<Error | null>(null)
useEffect(() => {
getJson<BeeConfig>(`${desktopUrl}/config`)
getDesktopConfiguration(desktopUrl)
.then(beeConf => {
setBeeConfig(beeConf)
setError(null)