|
|
@@ -6,6 +6,7 @@ import { useWallet } from '@solana/wallet-adapter-react'
|
|
|
import { WalletModalButton } from '@solana/wallet-adapter-react-ui'
|
|
|
import { Cluster, PublicKey, TransactionInstruction } from '@solana/web3.js'
|
|
|
import SquadsMesh from '@sqds/mesh'
|
|
|
+import axios from 'axios'
|
|
|
import { Fragment, useContext, useEffect, useState } from 'react'
|
|
|
import toast from 'react-hot-toast'
|
|
|
import {
|
|
|
@@ -77,39 +78,46 @@ const PermissionDepermissionKey = ({
|
|
|
const fundingAccount = isRemote
|
|
|
? mapKey(multisigAuthority)
|
|
|
: multisigAuthority
|
|
|
- priceAccounts.map((priceAccount) => {
|
|
|
- isPermission
|
|
|
- ? pythProgramClient.methods
|
|
|
+
|
|
|
+ for (const priceAccount of priceAccounts) {
|
|
|
+ if (isPermission) {
|
|
|
+ instructions.push(
|
|
|
+ await pythProgramClient.methods
|
|
|
.addPublisher(new PublicKey(publisherKey))
|
|
|
.accounts({
|
|
|
fundingAccount,
|
|
|
priceAccount: priceAccount,
|
|
|
})
|
|
|
.instruction()
|
|
|
- .then((instruction) => instructions.push(instruction))
|
|
|
- : pythProgramClient.methods
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ instructions.push(
|
|
|
+ await pythProgramClient.methods
|
|
|
.delPublisher(new PublicKey(publisherKey))
|
|
|
.accounts({
|
|
|
fundingAccount,
|
|
|
priceAccount: priceAccount,
|
|
|
})
|
|
|
.instruction()
|
|
|
- .then((instruction) => instructions.push(instruction))
|
|
|
- })
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
setIsSubmitButtonLoading(true)
|
|
|
try {
|
|
|
- const proposalPubkey = await proposeInstructions(
|
|
|
- squads,
|
|
|
- PRICE_FEED_MULTISIG[getMultisigCluster(cluster)],
|
|
|
- instructions,
|
|
|
- isRemote,
|
|
|
- wormholeAddress
|
|
|
+ const response = await axios.post(
|
|
|
+ process.env.NEXT_PUBLIC_PROPOSER_SERVER_URL + '/api/propose',
|
|
|
+ { instructions, cluster }
|
|
|
)
|
|
|
+ const { proposalPubkey } = response.data
|
|
|
toast.success(`Proposal sent! 🚀 Proposal Pubkey: ${proposalPubkey}`)
|
|
|
setIsSubmitButtonLoading(false)
|
|
|
closeModal()
|
|
|
- } catch (e: any) {
|
|
|
- toast.error(capitalizeFirstLetter(e.message))
|
|
|
+ } catch (error: any) {
|
|
|
+ if (error.response) {
|
|
|
+ toast.error(capitalizeFirstLetter(error.response.data))
|
|
|
+ } else {
|
|
|
+ toast.error(capitalizeFirstLetter(error.message))
|
|
|
+ }
|
|
|
setIsSubmitButtonLoading(false)
|
|
|
}
|
|
|
}
|