From 352ef9d78f96c1354be0d7933d1178774e04b55e Mon Sep 17 00:00:00 2001 From: 0xfirefist Date: Tue, 28 Nov 2023 15:25:09 +0530 Subject: [PATCH] initialise pyth plugin in a separate use effect --- hooks/useVotingPlugins.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hooks/useVotingPlugins.ts b/hooks/useVotingPlugins.ts index 55a4d7389f..f67faa9acf 100644 --- a/hooks/useVotingPlugins.ts +++ b/hooks/useVotingPlugins.ts @@ -42,7 +42,7 @@ export function useVotingPlugins() { handleSetNftRegistrar, handleSetGatewayRegistrar, handleSetCurrentRealmVotingClient, - handleSetPythClient + handleSetPythClient, } = useVotePluginsClientStore() const [ @@ -69,7 +69,7 @@ export function useVotingPlugins() { nftClient, nftMintRegistrar, heliumVsrClient, - pythClient + pythClient, ] = useVotePluginsClientStore((s) => [ s.state.currentRealmVotingClient, s.state.vsrClient, @@ -132,6 +132,18 @@ export function useVotingPlugins() { [usedCollectionsPks] ) + // initialise pyth plugin + useEffect(() => { + if ( + wallet && + connection && + currentPluginPk && + PYTH_PLUGIN_PK.includes(currentPluginPk.toBase58()) + ) { + handleSetPythClient(wallet, connection) + } + }, [connection, currentPluginPk, handleSetPythClient, wallet]) + useEffect(() => { if (wallet && connection) { if (currentPluginPk) { @@ -141,9 +153,6 @@ export function useVotingPlugins() { if (HELIUM_VSR_PLUGINS_PKS.includes(currentPluginPk.toBase58())) { handleSetHeliumVsrClient(wallet, connection, currentPluginPk) } - if (PYTH_PLUGIN_PK.includes(currentPluginPk.toBase58())) { - handleSetPythClient(wallet, connection) - } } handleSetNftClient(wallet, connection) handleSetGatewayClient(wallet, connection) @@ -155,7 +164,6 @@ export function useVotingPlugins() { handleSetHeliumVsrClient, handleSetNftClient, handleSetVsrClient, - handleSetPythClient, wallet, ]) @@ -280,6 +288,7 @@ export function useVotingPlugins() { voterPk, realm, vsrClient, + pythClient, ]) const handleMaxVoterWeight = useCallback(async () => {