Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Header,
Menu,
UserWallet,
ApplyBetaHeader,
Toasts,
Footer
] = childComponents;
// Init and set base state
const [loading, setLoading] = useState("LOADING");
const [lastError, setLastError] = useState(null);
const [syncTime, setSyncTime] = useState(moduleLoadTime);
const triggerSync = useCallback(() => {
setSyncTime(Date.now());
});
useInterval(triggerSync, SYNC_INTERVAL);
const [toasts, setToasts] = useState([]);
const [web3, setWeb3] = useState(null);
const [account, setAccount] = useState(null);
const [collateral, setCollateral] = useState(null);
const [markets, setMarkets] = useState(null);
const [positions, setPositions] = useState(null);
const lmsrAddress = match.params.lmsrAddress
? match.params.lmsrAddress
: conf.lmsrAddress;
const init = useCallback(async () => {
const { networkId } = conf;
try {
console.groupCollapsed("Configuration");
const ResolutionDate = ({ date }) => {
// use for testing many different random dates
//const [date, setDate] = useState(Date.now())
const [timeUntil, setTimeUntil] = useState("");
const updateCountdown = useCallback(() => {
// use for testing many different random dates
//setDate(Date.now() + (Math.random() * 100000000))
setScalarLocale();
setTimeUntil(fromNow(date));
});
useEffect(updateCountdown, []);
useInterval(updateCountdown, 1000);
return <span>{timeUntil}</span>;
};
(async () => {
const whitelistStatus = await getWhitelistState(account);
setWhitelistState(whitelistStatus);
if (
whitelistStatus === "WHITELISTED" ||
whitelistStatus === "BLOCKED"
) {
setWhitelistCheckIntervalTime(null); // stops the refresh
}
})();
} else {
setWhitelistState("NOT_FOUND");
}
}, [account]);
useInterval(updateWhitelist, whitelistIntervalTime);
useEffect(() => {
updateWhitelist();
}, [account]);
const asWrappedTransaction = useCallback(
(wrappedTransactionType, transactionFn) => {
return async function wrappedAction() {
if (ongoingTransactionType != null) {
throw new Error(
`Attempted to ${wrappedTransactionType} while transaction to ${ongoingTransactionType} is ongoing`
);
}
if (whitelistEnabled && whitelistState !== "WHITELISTED") {
openModal("applyBeta", { whitelistState });
const defaultExample = examples.find((e) => e.name === "petstore");
if (!defaultValue && !searchUrl && defaultExample) {
setSearchUrl(defaultExample.url);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [defaultValue]);
useEffect(() => {
setReactJsonOptions({
...reactJsonOptions,
theme: UISchema.appBar["ui:darkMode"] ? "summerfruit" : "summerfruit:inverted",
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [UISchema.appBar["ui:darkMode"]]);
useInterval(() => {
const modelUriString = "inmemory://openrpc-playground.json";
const modelUri = monaco.Uri.parse(modelUriString);
const mk = monaco.editor.getModelMarkers({
resource: modelUri,
});
setMarkers(mk);
}, 5000);
useEffect(() => {
if (results && editor) {
editor.setValue(results);
}
if (results) {
setParsedSchema(results);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// Load initial list of policies
useEffect(() => {
fetchPolicies();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [showInactive]);
// Update agents if pagination, query, or policy filter state changes
useEffect(() => {
fetchAgents();
setAreAllAgentsSelected(false);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pagination, search, showInactive, selectedPolicies]);
// Poll for agents on interval
useInterval(() => {
if (new Date().getTime() - lastPolledAgentsMs >= AGENT_POLLING_INTERVAL) {
fetchAgents();
}
}, AGENT_POLLING_INTERVAL);
// Some agents retrieved, set up table props
const columns = [
{
field: 'local_metadata.host',
name: i18n.translate('xpack.fleet.agentList.hostColumnTitle', {
defaultMessage: 'Host',
}),
footer: () => {
if (selectedAgents.length === agents.length && totalAgents > selectedAgents.length) {
return areAllAgentsSelected ? (
export const AgentDetailsPage: React.FC = ({
match: {
params: { agentId },
},
}) => {
const [lastPolledAgentsMs, setLastPolledAgentsMs] = useState(0);
const { agent, isLoading, error, refreshAgent } = useGetAgent(agentId);
// Poll for agents on interval
useInterval(() => {
if (new Date().getTime() - lastPolledAgentsMs >= AGENT_POLLING_INTERVAL) {
setLastPolledAgentsMs(new Date().getTime());
refreshAgent();
}
}, AGENT_POLLING_INTERVAL);
if (isLoading) {
return ;
}
if (error) {
return (
...entry,
meta: getAdditionalEntryInformation(entry, allContentTypes, sdk.locales.default)
};
actions.setEntry(id, data);
return entry;
})
.catch(() => {
setError(true);
});
}, [actions, allContentTypes, id, sdk.locales.default, sdk.space]);
useEffect(() => {
fetchEntry();
}, [fetchEntry]);
useInterval(() => {
fetchEntry();
}, 3000);
return {
entry,
loading: !entry,
error
};
}
}
};
const onClick = () => {
setDark(!dark);
setSpeed(interval);
};
const onMouseEnter = () => {
setHovered(true);
};
const onMouseLeave = () => {
setHovered(false);
};
useInterval(incrementPhase, speed);
return (
<button type="button">
{hovered && peekOnHover
? phases[getNextPhase(phaseIndex)]
: phases[phaseIndex]}
</button>
);
};
*/
useEffect(() => {
fetchInitialData(props.sdk, props.client)
.then(data => {
actions.setInitialData(data);
return data;
})
.catch(() => {
actions.setError('Unable to load initial data');
});
}, [actions, props.client, props.sdk]);
/**
* Pulling current experiment every 5s to get new status and variations
*/
useInterval(() => {
if (state.experimentId) {
props.client
.getExperiment(state.experimentId)
.then(experiment => {
actions.updateExperiment(state.experimentId, experiment);
return experiment;
})
.catch(() => {});
}
}, 5000);
/*
* Poll to see if we need to show the reauth flow preemptively
*/
useInterval(() => {
setShowAuth(isCloseToExpiration(props.expires));