diff --git a/src/components/Minting/Minting.tsx b/src/components/Minting/Minting.tsx
index afaba36..1745c2f 100644
--- a/src/components/Minting/Minting.tsx
+++ b/src/components/Minting/Minting.tsx
@@ -51,10 +51,11 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
const [accountInfo, setAccountInfo] = useState(null);
const [mintingKey, setMintingKey] = useState('');
const [rewardShares, setRewardShares] = useState([]);
- const [nodeInfos, setNodeInfos] = useState({});
+ const [nodeStatus, setNodeStatus] = useState({});
const [openSnack, setOpenSnack] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [adminInfo, setAdminInfo] = useState({});
+ const [nodeHeightBlock, setNodeHeightBlock] = useState(null);
const [valueMintingTab, setValueMintingTab] = useState(0);
const { isShow: isShowNext, onOk, show: showNext } = useModal();
const theme = useTheme();
@@ -178,21 +179,51 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
return address;
};
- const getNodeInfos = async () => {
+ const getAdminInfo = useCallback(async () => {
+ try {
+ const url = `${getBaseApiReact()}/admin/info`;
+ const response = await fetch(url);
+ const data = await response.json();
+ setAdminInfo(data);
+ } catch (error) {
+ console.log(error);
+ }
+ }, []);
+
+ const getNodeStatus = useCallback(async () => {
try {
const url = `${getBaseApiReact()}/admin/status`;
- const response = await fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- });
+ const response = await fetch(url);
const data = await response.json();
- setNodeInfos(data);
+ setNodeStatus(data);
} catch (error) {
console.error('Request failed', error);
}
- };
+ }, []);
+
+ const getNodeHeightBlock = useCallback(async () => {
+ try {
+ const nodeBlock = parseFloat(nodeStatus?.height) - 1440;
+ const url = `${getBaseApiReact()}/blocks/byheight/${nodeBlock}`;
+ const response = await fetch(url);
+ const data = await response.json();
+ setNodeHeightBlock(data);
+ } catch (error) {
+ console.error('Request failed', error);
+ }
+ }, []);
+
+ const getAddressLevel = useCallback(async () => {
+ try {
+ const url = `${getBaseApiReact()}/addresses/online/levels`;
+ const response = await fetch(url);
+ const data = await response.json();
+ // this.tier4Online = parseFloat(this.addressLevel[7].count) + parseFloat(this.addressLevel[8].count)
+ // setNodeStatus(data);
+ } catch (error) {
+ console.error('Request failed', error);
+ }
+ }, []);
const getRewardShares = useCallback(async (address) => {
try {
@@ -209,17 +240,6 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
}
}, []);
- const getAdminInfo = async () => {
- try {
- const url = `${getBaseApiReact()}/admin/info`;
- const response = await fetch(url);
- const data = await response.json();
- setAdminInfo(data);
- } catch (error) {
- console.log(error);
- }
- };
-
const addMintingAccount = useCallback(async (val) => {
try {
setIsLoading(true);
@@ -464,14 +484,16 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
};
useEffect(() => {
- getNodeInfos();
+ getAddressLevel();
+ getAdminInfo();
getMintingAccounts();
+ getNodeHeightBlock();
+ getNodeStatus();
}, []);
useEffect(() => {
if (!myAddress) return;
getRewardShares(myAddress);
-
getAccountInfo(myAddress);
}, [myAddress]);
@@ -509,7 +531,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
const _levelUpBlocks = () => {
if (
accountInfo?.blocksMinted === undefined ||
- nodeInfos?.height === undefined
+ nodeStatus?.height === undefined
)
return null;
let countBlocks =
@@ -521,13 +543,15 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
};
const StatCard = ({ label, value }: { label: string; value: string }) => (
-
-
-
- {label}
-
- {value}
-
+
+
+
+
+ {label}
+
+ {value}
+
+
);
@@ -626,8 +650,12 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
}}
>
-
-
+
+
Blockchain Statistics
@@ -636,19 +664,30 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
label="Avg. Qortal Blocktime"
value="72.84 Seconds"
/>
+
+
+
+
-
-
+
+
Minting Account Details
@@ -656,21 +695,25 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
-
+
With a 24/7 Minting you will reach level 5 in{' '}
117.58 days!
-
-
+
+
Minting Rewards Info
@@ -762,7 +805,7 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
{t('group:message.generic.node_minting', {
postProcess: 'capitalizeFirstChar',
})}{' '}
- {nodeInfos?.isMintingPossible?.toString()}
+ {nodeStatus?.isMintingPossible?.toString()}