throw switchboard errors

This commit is contained in:
Adrian Brzeziński 2023-12-31 13:47:32 +01:00
parent 399c0c9d98
commit a1447378f5
4 changed files with 15 additions and 11 deletions

View File

@ -20,7 +20,6 @@ import { useCallback, useState } from 'react'
import Loading from '@components/shared/Loading'
import { WhirlpoolContext, buildWhirlpoolClient } from '@orca-so/whirlpools-sdk'
import { LIQUIDITY_STATE_LAYOUT_V4 } from '@raydium-io/raydium-sdk'
import { createComputeBudgetIx } from '@blockworks-foundation/mango-v4'
import { LISTING_PRESETS_KEY } from '@blockworks-foundation/mango-v4-settings/lib/helpers/listingTools'
const poolAddressError = 'no-pool-address-found'
@ -59,7 +58,6 @@ const CreateSwitchboardOracleModal = ({
}: RaydiumProps | OrcaProps) => {
const { t } = useTranslation(['governance'])
const connection = mangoStore((s) => s.connection)
const fee = mangoStore((s) => s.priorityFee)
const wallet = useWallet()
const quoteTokenName = 'USD'
const pythUsdOracle = 'Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD'
@ -188,6 +186,7 @@ const CreateSwitchboardOracleModal = ({
]
}
const settingFromLib = tierSettings[tierKey]
if (!settingFromLib) {
throw wrongTierPassedForCreation
}
@ -330,14 +329,14 @@ const CreateSwitchboardOracleModal = ({
const transferAuthIx = aggregatorAccount.setAuthorityInstruction(payer, {
newAuthority: MANGO_DAO_WALLET,
})
const latestBlockhash = await connection.getLatestBlockhash('confirmed')
const txChunks = chunk([...txArray1, lockTx, transferAuthIx], 1)
const transactions: Transaction[] = []
const latestBlockhash = await connection.getLatestBlockhash('confirmed')
for (const chunk of txChunks) {
for (const chunkIndex in txChunks) {
const chunk = txChunks[chunkIndex]
const tx = new Transaction()
const singers = [...chunk.flatMap((x) => x.signers)]
tx.add(createComputeBudgetIx(fee))
tx.add(...chunk.flatMap((x) => x.ixns))
tx.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight
tx.recentBlockhash = latestBlockhash.blockhash
@ -375,14 +374,19 @@ const CreateSwitchboardOracleModal = ({
description: 'Wrong tier passed for oracle creation',
type: 'error',
})
} else {
if (!isMangoError(e)) return
} else if (isMangoError(e)) {
notify({
title: 'Transaction failed',
description: e.message,
txid: e?.txid,
type: 'error',
})
} else {
notify({
title: 'Transaction failed',
description: `${e}`,
type: 'error',
})
}
}
}, [

View File

@ -106,7 +106,7 @@
"yes-votes": "Yes Votes",
"your-votes": "Your Votes:",
"create-switch-oracle": "Create switchboard oracle for",
"estimated-oracle-cost": "Estimated cost with funding oracle for ~12 months",
"estimated-oracle-cost": "Estimated cost with funding oracle for ~3 months",
"create-oracle": "Create oracle",
"tier": "Tier",
"on-boarding-description-1": "If you want to use delegated tokens go to vote view and select wallet in top right corner.",

View File

@ -106,7 +106,7 @@
"yes-votes": "Yes Votes",
"your-votes": "Your Votes:",
"create-switch-oracle": "Create switchboard oracle for",
"estimated-oracle-cost": "Estimated cost with funding oracle for ~12 months",
"estimated-oracle-cost": "Estimated cost with funding oracle for ~3 months",
"create-oracle": "Create oracle",
"tier": "Tier",
"on-boarding-description-1": "If you want to use delegated tokens go to vote view and select wallet in top right corner.",

View File

@ -106,7 +106,7 @@
"yes-votes": "Yes Votes",
"your-votes": "Your Votes:",
"create-switch-oracle": "Create switchboard oracle for",
"estimated-oracle-cost": "Estimated cost with funding oracle for ~12 months",
"estimated-oracle-cost": "Estimated cost with funding oracle for ~3 months",
"create-oracle": "Create oracle",
"tier": "Tier",
"on-boarding-description-1": "If you want to use delegated tokens go to vote view and select wallet in top right corner.",