2021-07-08 19:02:42 +00:00
|
|
|
import { useState, useEffect } from "react";
|
|
|
|
|
|
|
|
export type OtterscanConfig = {
|
2021-07-09 17:13:31 +00:00
|
|
|
erigonURL?: string;
|
|
|
|
assetsURLPrefix?: string;
|
2021-07-08 19:02:42 +00:00
|
|
|
};
|
|
|
|
|
2021-07-09 05:07:20 +00:00
|
|
|
export const useConfig = (): [boolean?, OtterscanConfig?] => {
|
2021-07-08 19:02:42 +00:00
|
|
|
const [configOK, setConfigOK] = useState<boolean>();
|
|
|
|
const [config, setConfig] = useState<OtterscanConfig>();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const readConfig = async () => {
|
|
|
|
const res = await fetch("/config.json");
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
const _config: OtterscanConfig = await res.json();
|
2021-07-09 16:54:59 +00:00
|
|
|
console.info("Loaded app config");
|
|
|
|
console.info(_config);
|
2021-07-08 19:02:42 +00:00
|
|
|
setConfig(_config);
|
|
|
|
setConfigOK(res.ok);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
readConfig();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return [configOK, config];
|
|
|
|
};
|