Skip to content

Commit

Permalink
initialise pyth plugin in a separate use effect
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfirefist committed Nov 28, 2023
1 parent 5cd05f4 commit 352ef9d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions hooks/useVotingPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function useVotingPlugins() {
handleSetNftRegistrar,
handleSetGatewayRegistrar,
handleSetCurrentRealmVotingClient,
handleSetPythClient
handleSetPythClient,
} = useVotePluginsClientStore()

const [
Expand All @@ -69,7 +69,7 @@ export function useVotingPlugins() {
nftClient,
nftMintRegistrar,
heliumVsrClient,
pythClient
pythClient,
] = useVotePluginsClientStore((s) => [
s.state.currentRealmVotingClient,
s.state.vsrClient,
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -155,7 +164,6 @@ export function useVotingPlugins() {
handleSetHeliumVsrClient,
handleSetNftClient,
handleSetVsrClient,
handleSetPythClient,
wallet,
])

Expand Down Expand Up @@ -280,6 +288,7 @@ export function useVotingPlugins() {
voterPk,
realm,
vsrClient,
pythClient,
])

const handleMaxVoterWeight = useCallback(async () => {
Expand Down

0 comments on commit 352ef9d

Please sign in to comment.