-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from AvadoDServer/0.1.91
0.1.91
- Loading branch information
Showing
8 changed files
with
78 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
function IsBootStrapped({ chain }: { chain: string }) { | ||
const [isBootStrapped, setIsBootStrapped] = useState(false); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState(null); | ||
|
||
useEffect(() => { | ||
// Function to fetch network info | ||
const fetchBootstrapped = async () => { | ||
setIsLoading(true); | ||
try { | ||
const response = await fetch('https://avalanchego.my.ava.do:9650/ext/info', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
jsonrpc: '2.0', | ||
id: 1, | ||
method: 'info.isBootstrapped', | ||
"params": { | ||
"chain": chain | ||
} | ||
}), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const data = await response.json(); | ||
if (data.error){ | ||
throw new Error(data.error.message); | ||
} | ||
|
||
setIsBootStrapped(data?.result?.isBootStrapped === true); | ||
|
||
} catch (error) { | ||
console.error('Error fetching bootstrap info:', error); | ||
setError(error.message); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
fetchBootstrapped(); | ||
}, [chain]); // Empty dependency array means this effect runs once on mount | ||
|
||
|
||
if (isLoading) return <div>{chain}-chain: Loading...</div>; | ||
if (error) return <div>{chain}-chain: Error: {error}</div>; | ||
|
||
return ( | ||
<div> | ||
<p>{chain}-chain: {isBootStrapped ? "ready" : "not ready yet"}</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default IsBootStrapped; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters