feat: add bee desktop toolkit (#311)

* feat: add light node upgrade

* refactor: improve upgrade page

* feat: pretty print xdai and add xbzz faucets

* feat: display xBZZ balance (#312)

* refactor: change rpc provider

* fix: remove version alert

* fix: load really xBZZ balance instead of xDAI (#314)

* feat: add bee desktop api key support

* chore: remove dead code

* chore: revert useless change

* refactor: extract desktop utils module (#339)

* refactor: extract desktop utils module

* fix: add 0x prefix if it missing from address

* refactor: extract BalanceProvider

* fix: remove double finally

* fix: remove token fallbacks

* fix: reuse address and handle balance errors

* chore: disable eslint for any

* refactor: remove upgrade page

* refactor: cleanup, debounce and axios

* refactor: change fetch to axios

* chore: remove dead code

* chore: revert import ordering

* refactor: use axios instead of fetch

* refactor: use token instead of string

Co-authored-by: Cafe137 <aron@aronsoos.com>
Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>
This commit is contained in:
Cafe137
2022-04-21 16:29:50 +02:00
committed by GitHub
parent 9b5b2973cb
commit ecaf2054fc
8 changed files with 1366 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import axios from 'axios'
export function getJson(url: string): Promise<Record<string, any>> {
return sendRequest(url, 'GET')
}
export function postJson(url: string, data?: Record<string, any>): Promise<Record<string, unknown>> {
return sendRequest(url, 'POST', data)
}
async function sendRequest(
url: string,
method: 'GET' | 'POST',
data?: Record<string, unknown>,
): Promise<Record<string, any>> {
const authorization = localStorage.getItem('apiKey')
if (!authorization) {
throw Error('API key not found in local storage')
}
const headers = {
authorization,
}
const response = await axios(url, {
method,
headers,
data,
})
return response.data
}