From a1447378f527add7fd767c0257c7d1bc28c05597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Sun, 31 Dec 2023 13:47:32 +0100 Subject: [PATCH] throw switchboard errors --- .../modals/CreateSwitchboardOracleModal.tsx | 20 +++++++++++-------- public/locales/en/governance.json | 2 +- public/locales/es/governance.json | 2 +- public/locales/ru/governance.json | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/components/modals/CreateSwitchboardOracleModal.tsx b/components/modals/CreateSwitchboardOracleModal.tsx index d740bed8..67f1bd8e 100644 --- a/components/modals/CreateSwitchboardOracleModal.tsx +++ b/components/modals/CreateSwitchboardOracleModal.tsx @@ -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', + }) } } }, [ diff --git a/public/locales/en/governance.json b/public/locales/en/governance.json index ca1783c4..a9440ed3 100644 --- a/public/locales/en/governance.json +++ b/public/locales/en/governance.json @@ -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.", diff --git a/public/locales/es/governance.json b/public/locales/es/governance.json index ca1783c4..a9440ed3 100644 --- a/public/locales/es/governance.json +++ b/public/locales/es/governance.json @@ -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.", diff --git a/public/locales/ru/governance.json b/public/locales/ru/governance.json index ca1783c4..a9440ed3 100644 --- a/public/locales/ru/governance.json +++ b/public/locales/ru/governance.json @@ -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.",