Skip to content

Commit

Permalink
feat(oracles): updating the suggestor
Browse files Browse the repository at this point in the history
  • Loading branch information
tomrpl committed Aug 7, 2024
1 parent 6bd7a81 commit bf4fa51
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 67 deletions.
22 changes: 16 additions & 6 deletions src/component/OracleSuggestor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ const OracleSuggestor = () => {
return `${baseUrl}${address}`;
};

const handleNetworkChange = (selectedOption: any) => {
setSelectedNetwork(selectedOption || networkOptions[0]);
// Reset collateral and loan asset states
setCollateralAsset("");
setLoanAsset("");
setCollateralAssetTouched(false);
setLoanAssetTouched(false);
setShowOracleDetails(false); // Hide oracle details when network changes
};

return (
<div className="main-background">
<div className="oracle-container">
Expand Down Expand Up @@ -239,9 +249,7 @@ const OracleSuggestor = () => {
<Select
options={networkOptions}
value={selectedNetwork}
onChange={(selectedOption) => {
setSelectedNetwork(selectedOption || networkOptions[0]);
}}
onChange={handleNetworkChange}
styles={{
control: (base) => ({
...base,
Expand All @@ -259,6 +267,9 @@ const OracleSuggestor = () => {
</label>
<Select
options={assets}
value={assets.find(
(asset) => asset.value === collateralAsset
)}
onChange={(selectedOption) => {
setCollateralAsset(selectedOption?.value || "");
setCollateralAssetTouched(true);
Expand All @@ -280,6 +291,7 @@ const OracleSuggestor = () => {
</label>
<Select
options={assets}
value={assets.find((asset) => asset.value === loanAsset)}
onChange={(selectedOption) => {
setLoanAsset(selectedOption?.value || "");
setLoanAssetTouched(true);
Expand Down Expand Up @@ -312,9 +324,7 @@ const OracleSuggestor = () => {
</div>

<div className="checks-section">
<h2 style={{ marginLeft: "10px" }}>
Existing Oracles for such pair:
</h2>
<h2 style={{ marginLeft: "10px" }}>Existing Oracles?</h2>
<CheckItemOraclesDeployed
title=""
isVerified={deployedResult?.isValid ?? null}
Expand Down
132 changes: 71 additions & 61 deletions src/component/common/CheckItemOraclesDeployed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const CheckItemOraclesDeployed: React.FC<CheckItemProps> = ({
const toggleOracleDetails = (index: number) => {
setExpandedOracles((prev) => ({ ...prev, [index]: !prev[index] }));
};

if (!showDetails) {
return null; // Return null if showDetails is false
}
return (
<div
style={{
Expand Down Expand Up @@ -110,7 +112,7 @@ const CheckItemOraclesDeployed: React.FC<CheckItemProps> = ({
)}
</button>
</div>
{expandedOracles[index] && oracleItem.oracle.data && (
{expandedOracles[index] && (
<div
style={{
backgroundColor: "#f7fafc",
Expand All @@ -120,66 +122,74 @@ const CheckItemOraclesDeployed: React.FC<CheckItemProps> = ({
fontSize: "0.7rem",
}}
>
<p
style={{
fontWeight: "600",
marginBottom: "8px",
fontSize: "0.8rem",
}}
>
Feed Information:
</p>
<div
style={{
display: "grid",
gridTemplateColumns: "1fr 1fr",
gap: "16px",
fontSize: "0.6rem",
}}
>
<FeedInfo
title="Base Feed One"
feed={oracleItem.oracle.data.baseFeedOne}
/>
<FeedInfo
title="Base Feed Two"
feed={oracleItem.oracle.data.baseFeedTwo}
/>
<FeedInfo
title="Quote Feed One"
feed={oracleItem.oracle.data.quoteFeedOne}
/>
<FeedInfo
title="Quote Feed Two"
feed={oracleItem.oracle.data.quoteFeedTwo}
/>
</div>
<div
style={{
marginTop: "16px",
display: "grid",
gridTemplateColumns: "1fr 1fr",
gap: "16px",
fontSize: "0.6rem",
}}
>
<p>
<strong>Base Vault:</strong>{" "}
{oracleItem.oracle.data.baseVault}
</p>
<p>
<strong>Quote Vault:</strong>{" "}
{oracleItem.oracle.data.quoteVault}
</p>
<p>
<strong>Base Vault Conversion Sample:</strong>{" "}
{oracleItem.oracle.data.baseVaultConversionSample}
</p>
<p>
<strong>Quote Vault Conversion Sample:</strong>{" "}
{oracleItem.oracle.data.quoteVaultConversionSample}
{oracleItem.oracle.data ? (
<>
<p
style={{
fontWeight: "600",
marginBottom: "8px",
fontSize: "0.8rem",
}}
>
Feed Information:
</p>
<div
style={{
display: "grid",
gridTemplateColumns: "1fr 1fr",
gap: "16px",
fontSize: "0.6rem",
}}
>
<FeedInfo
title="Base Feed One"
feed={oracleItem.oracle.data.baseFeedOne}
/>
<FeedInfo
title="Base Feed Two"
feed={oracleItem.oracle.data.baseFeedTwo}
/>
<FeedInfo
title="Quote Feed One"
feed={oracleItem.oracle.data.quoteFeedOne}
/>
<FeedInfo
title="Quote Feed Two"
feed={oracleItem.oracle.data.quoteFeedTwo}
/>
</div>
<div
style={{
marginTop: "16px",
display: "grid",
gridTemplateColumns: "1fr 1fr",
gap: "16px",
fontSize: "0.6rem",
}}
>
<p>
<strong>Base Vault:</strong>{" "}
{oracleItem.oracle.data.baseVault}
</p>
<p>
<strong>Quote Vault:</strong>{" "}
{oracleItem.oracle.data.quoteVault}
</p>
<p>
<strong>Base Vault Conversion Sample:</strong>{" "}
{oracleItem.oracle.data.baseVaultConversionSample}
</p>
<p>
<strong>Quote Vault Conversion Sample:</strong>{" "}
{oracleItem.oracle.data.quoteVaultConversionSample}
</p>
</div>
</>
) : (
<p style={{ color: "#e53e3e", fontWeight: "bold" }}>
No info is provided on this oracle. Do not use it!
</p>
</div>
)}
</div>
)}
</div>
Expand Down

0 comments on commit bf4fa51

Please sign in to comment.