1- import { AnchorProvider , Program , Wallet } from '@coral-xyz/anchor'
1+ import { AnchorProvider , Program } from '@coral-xyz/anchor'
22import { AccountType , getPythProgramKeyForCluster } from '@pythnetwork/client'
33import { PythOracle , pythOracleProgram } from '@pythnetwork/client/lib/anchor'
4- import { useAnchorWallet , useWallet } from '@solana/wallet-adapter-react'
4+ import { useWallet } from '@solana/wallet-adapter-react'
55import { WalletModalButton } from '@solana/wallet-adapter-react-ui'
66import { Cluster , PublicKey , TransactionInstruction } from '@solana/web3.js'
77import { useCallback , useContext , useEffect , useState } from 'react'
@@ -15,8 +15,9 @@ import {
1515 WORMHOLE_ADDRESS ,
1616} from 'xc_admin_common'
1717import { ClusterContext } from '../../contexts/ClusterContext'
18+ import { useMultisigContext } from '../../contexts/MultisigContext'
1819import { usePythContext } from '../../contexts/PythContext'
19- import { PRICE_FEED_MULTISIG , useMultisig } from '../../hooks/useMultisig'
20+ import { PRICE_FEED_MULTISIG } from '../../hooks/useMultisig'
2021import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'
2122import ClusterSwitch from '../ClusterSwitch'
2223import Modal from '../common/Modal'
@@ -35,11 +36,7 @@ const General = () => {
3536 const isRemote : boolean = isRemoteCluster ( cluster ) // Move to multisig context
3637 const multisigCluster : Cluster | 'localnet' = getMultisigCluster ( cluster ) // Move to multisig context
3738 const wormholeAddress = WORMHOLE_ADDRESS [ multisigCluster ] // Move to multisig context
38-
39- const anchorWallet = useAnchorWallet ( )
40- const { isLoading : isMultisigLoading , squads } = useMultisig (
41- anchorWallet as Wallet
42- )
39+ const { isLoading : isMultisigLoading , proposeSquads } = useMultisigContext ( )
4340 const { rawConfig, dataIsLoading, connection } = usePythContext ( )
4441 const { connected } = useWallet ( )
4542 const [ pythProgramClient , setPythProgramClient ] =
@@ -268,10 +265,15 @@ const General = () => {
268265 }
269266
270267 const handleSendProposalButtonClick = async ( ) => {
271- if ( pythProgramClient && dataChanges && ! isMultisigLoading && squads ) {
268+ if (
269+ pythProgramClient &&
270+ dataChanges &&
271+ ! isMultisigLoading &&
272+ proposeSquads
273+ ) {
272274 const instructions : TransactionInstruction [ ] = [ ]
273275 for ( const symbol of Object . keys ( dataChanges ) ) {
274- const multisigAuthority = squads . getAuthorityPDA (
276+ const multisigAuthority = proposeSquads . getAuthorityPDA (
275277 PRICE_FEED_MULTISIG [ getMultisigCluster ( cluster ) ] ,
276278 1
277279 )
@@ -447,7 +449,7 @@ const General = () => {
447449 setIsSendProposalButtonLoading ( true )
448450 try {
449451 const proposalPubkey = await proposeInstructions (
450- squads ,
452+ proposeSquads ,
451453 PRICE_FEED_MULTISIG [ getMultisigCluster ( cluster ) ] ,
452454 instructions ,
453455 isRemote ,
@@ -714,17 +716,17 @@ const General = () => {
714716
715717 // create anchor wallet when connected
716718 useEffect ( ( ) => {
717- if ( connected ) {
719+ if ( connected && proposeSquads ) {
718720 const provider = new AnchorProvider (
719721 connection ,
720- anchorWallet as Wallet ,
722+ proposeSquads . wallet ,
721723 AnchorProvider . defaultOptions ( )
722724 )
723725 setPythProgramClient (
724726 pythOracleProgram ( getPythProgramKeyForCluster ( cluster ) , provider )
725727 )
726728 }
727- } , [ anchorWallet , connection , connected , cluster ] )
729+ } , [ connection , connected , cluster , proposeSquads ] )
728730
729731 return (
730732 < div className = "relative" >
@@ -749,12 +751,12 @@ const General = () => {
749751 < PermissionDepermissionKey
750752 isPermission = { true }
751753 pythProgramClient = { pythProgramClient }
752- squads = { squads }
754+ squads = { proposeSquads }
753755 />
754756 < PermissionDepermissionKey
755757 isPermission = { false }
756758 pythProgramClient = { pythProgramClient }
757- squads = { squads }
759+ squads = { proposeSquads }
758760 />
759761 </ div >
760762 < div className = "relative mt-6" >
0 commit comments