1
- import { AnchorProvider , Program , Wallet } from '@coral-xyz/anchor'
1
+ import { AnchorProvider , Program } from '@coral-xyz/anchor'
2
2
import { AccountType , getPythProgramKeyForCluster } from '@pythnetwork/client'
3
3
import { PythOracle , pythOracleProgram } from '@pythnetwork/client/lib/anchor'
4
- import { useAnchorWallet , useWallet } from '@solana/wallet-adapter-react'
4
+ import { useWallet } from '@solana/wallet-adapter-react'
5
5
import { WalletModalButton } from '@solana/wallet-adapter-react-ui'
6
6
import { Cluster , PublicKey , TransactionInstruction } from '@solana/web3.js'
7
7
import { useCallback , useContext , useEffect , useState } from 'react'
@@ -15,8 +15,9 @@ import {
15
15
WORMHOLE_ADDRESS ,
16
16
} from 'xc_admin_common'
17
17
import { ClusterContext } from '../../contexts/ClusterContext'
18
+ import { useMultisigContext } from '../../contexts/MultisigContext'
18
19
import { usePythContext } from '../../contexts/PythContext'
19
- import { PRICE_FEED_MULTISIG , useMultisig } from '../../hooks/useMultisig'
20
+ import { PRICE_FEED_MULTISIG } from '../../hooks/useMultisig'
20
21
import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'
21
22
import ClusterSwitch from '../ClusterSwitch'
22
23
import Modal from '../common/Modal'
@@ -35,11 +36,7 @@ const General = () => {
35
36
const isRemote : boolean = isRemoteCluster ( cluster ) // Move to multisig context
36
37
const multisigCluster : Cluster | 'localnet' = getMultisigCluster ( cluster ) // Move to multisig context
37
38
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 ( )
43
40
const { rawConfig, dataIsLoading, connection } = usePythContext ( )
44
41
const { connected } = useWallet ( )
45
42
const [ pythProgramClient , setPythProgramClient ] =
@@ -268,10 +265,15 @@ const General = () => {
268
265
}
269
266
270
267
const handleSendProposalButtonClick = async ( ) => {
271
- if ( pythProgramClient && dataChanges && ! isMultisigLoading && squads ) {
268
+ if (
269
+ pythProgramClient &&
270
+ dataChanges &&
271
+ ! isMultisigLoading &&
272
+ proposeSquads
273
+ ) {
272
274
const instructions : TransactionInstruction [ ] = [ ]
273
275
for ( const symbol of Object . keys ( dataChanges ) ) {
274
- const multisigAuthority = squads . getAuthorityPDA (
276
+ const multisigAuthority = proposeSquads . getAuthorityPDA (
275
277
PRICE_FEED_MULTISIG [ getMultisigCluster ( cluster ) ] ,
276
278
1
277
279
)
@@ -447,7 +449,7 @@ const General = () => {
447
449
setIsSendProposalButtonLoading ( true )
448
450
try {
449
451
const proposalPubkey = await proposeInstructions (
450
- squads ,
452
+ proposeSquads ,
451
453
PRICE_FEED_MULTISIG [ getMultisigCluster ( cluster ) ] ,
452
454
instructions ,
453
455
isRemote ,
@@ -714,17 +716,17 @@ const General = () => {
714
716
715
717
// create anchor wallet when connected
716
718
useEffect ( ( ) => {
717
- if ( connected ) {
719
+ if ( connected && proposeSquads ) {
718
720
const provider = new AnchorProvider (
719
721
connection ,
720
- anchorWallet as Wallet ,
722
+ proposeSquads . wallet ,
721
723
AnchorProvider . defaultOptions ( )
722
724
)
723
725
setPythProgramClient (
724
726
pythOracleProgram ( getPythProgramKeyForCluster ( cluster ) , provider )
725
727
)
726
728
}
727
- } , [ anchorWallet , connection , connected , cluster ] )
729
+ } , [ connection , connected , cluster , proposeSquads ] )
728
730
729
731
return (
730
732
< div className = "relative" >
@@ -749,12 +751,12 @@ const General = () => {
749
751
< PermissionDepermissionKey
750
752
isPermission = { true }
751
753
pythProgramClient = { pythProgramClient }
752
- squads = { squads }
754
+ squads = { proposeSquads }
753
755
/>
754
756
< PermissionDepermissionKey
755
757
isPermission = { false }
756
758
pythProgramClient = { pythProgramClient }
757
- squads = { squads }
759
+ squads = { proposeSquads }
758
760
/>
759
761
</ div >
760
762
< div className = "relative mt-6" >
0 commit comments