Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -77,39 +78,46 @@ const PermissionDepermissionKey = ({
const fundingAccount = isRemote
? mapKey(multisigAuthority)
: multisigAuthority
priceAccounts.map((priceAccount) => {
isPermission
? pythProgramClient.methods

for (const priceAccount of priceAccounts) {
Copy link
Contributor Author

@guibescos guibescos May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to rewrite this logic to await for the instructions, otherwise there's a race condition.

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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AccountType, getPythProgramKeyForCluster } from '@pythnetwork/client'
import { PythOracle, pythOracleProgram } from '@pythnetwork/client/lib/anchor'
import { useWallet } from '@solana/wallet-adapter-react'
import { Cluster, PublicKey, TransactionInstruction } from '@solana/web3.js'
import axios from 'axios'
import { useCallback, useContext, useEffect, useState } from 'react'
import toast from 'react-hot-toast'
import {
Expand Down Expand Up @@ -464,18 +465,20 @@ const General = () => {

setIsSendProposalButtonLoading(true)
try {
const proposalPubkey = await proposeInstructions(
proposeSquads,
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}`)
setIsSendProposalButtonLoading(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))
}
setIsSendProposalButtonLoading(false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@types/node": "^18.11.18",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
"axios": "^1.4.0",
"copy-to-clipboard": "^3.3.3",
"gsap": "^3.11.4",
"next": "12.2.5",
Expand Down
19 changes: 2 additions & 17 deletions governance/xc_admin/packages/xc_admin_frontend/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ import { StatusFilterProvider } from '../contexts/StatusFilterContext'
import { classNames } from '../utils/classNames'

export const getServerSideProps: GetServerSideProps = async () => {
const KEYPAIR_BASE_PATH = process.env.KEYPAIR_BASE_PATH || ''
const OPS_WALLET = fs.existsSync(`${KEYPAIR_BASE_PATH}/ops-key`)
? JSON.parse(fs.readFileSync(`${KEYPAIR_BASE_PATH}/ops-key`, 'ascii'))
: null

const MAPPINGS_BASE_PATH = process.env.MAPPINGS_BASE_PATH || ''
const PUBLISHER_PYTHNET_MAPPING_PATH = `${MAPPINGS_BASE_PATH}/publishers-pythnet.json`
const PUBLISHER_PYTHTEST_MAPPING_PATH = `${MAPPINGS_BASE_PATH}/publishers-pythtest.json`
Expand Down Expand Up @@ -53,7 +48,6 @@ export const getServerSideProps: GetServerSideProps = async () => {

return {
props: {
OPS_WALLET,
publisherKeyToNameMapping,
multisigSignerKeyToNameMapping,
},
Expand Down Expand Up @@ -81,22 +75,13 @@ const TAB_INFO = {
const DEFAULT_TAB = 'general'

const Home: NextPage<{
OPS_WALLET: number[] | null
publisherKeyToNameMapping: Record<string, Record<string, string>>
multisigSignerKeyToNameMapping: Record<string, string>
}> = ({
OPS_WALLET,
publisherKeyToNameMapping,
multisigSignerKeyToNameMapping,
}) => {
}> = ({ publisherKeyToNameMapping, multisigSignerKeyToNameMapping }) => {
const [currentTabIndex, setCurrentTabIndex] = useState(0)
const tabInfoArray = Object.values(TAB_INFO)
const anchorWallet = useAnchorWallet()
const wallet = OPS_WALLET
? (new NodeWallet(
Keypair.fromSecretKey(Uint8Array.from(OPS_WALLET))
) as Wallet)
: (anchorWallet as Wallet)
const wallet = anchorWallet as Wallet

const router = useRouter()

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.