diff --git a/apps/main/.env.development b/apps/main/.env.development index d140119f2..faf63a952 100644 --- a/apps/main/.env.development +++ b/apps/main/.env.development @@ -9,4 +9,4 @@ VITE_TRSRY_ADDR=7L53bUTBopuwFt3mKUfmkzgGLayYa1Yvn1hAg9v5UMrQzTfh VITE_EVM_CHAIN_ID=222222 VITE_DISPLAY_ASSET_ID="10" VITE_HSM_ENABLED=false -VITE_DRY_RUN_ENABLED=false \ No newline at end of file +VITE_DRY_RUN_ENABLED=true \ No newline at end of file diff --git a/apps/main/.env.production b/apps/main/.env.production index 30df85e23..d66cb9760 100644 --- a/apps/main/.env.production +++ b/apps/main/.env.production @@ -9,4 +9,4 @@ VITE_TRSRY_ADDR=7L53bUTBopuwFt3mKUfmkzgGLayYa1Yvn1hAg9v5UMrQzTfh VITE_EVM_CHAIN_ID=222222 VITE_DISPLAY_ASSET_ID="10" VITE_HSM_ENABLED=false -VITE_DRY_RUN_ENABLED=false \ No newline at end of file +VITE_DRY_RUN_ENABLED=true \ No newline at end of file diff --git a/apps/main/src/api/dryRun.ts b/apps/main/src/api/dryRun.ts index 3ea8e7356..84ddfc55d 100644 --- a/apps/main/src/api/dryRun.ts +++ b/apps/main/src/api/dryRun.ts @@ -1,20 +1,20 @@ -import { QUERY_KEY_BLOCK_PREFIX } from "@galacticcouncil/utils" import { queryOptions } from "@tanstack/react-query" +import { Enum } from "polkadot-api" import { decodeTx } from "@/modules/transactions/review/ReviewTransactionJsonView/ReviewTransactionJsonView.utils" -import { AnyPapiTx } from "@/modules/transactions/types" +import { AnyTransaction } from "@/modules/transactions/types" +import { isPapiTransaction } from "@/modules/transactions/utils/polkadot" import { getPapiTransactionCallData } from "@/modules/transactions/utils/tx" import { TProviderContext } from "@/providers/rpcProvider" export const papiDryRunErrorQuery = ( { papi, dryRunErrorDecoder, papiCompatibilityToken }: TProviderContext, address: string, - tx: AnyPapiTx, + tx: AnyTransaction, debug?: boolean, ) => queryOptions({ queryKey: [ - QUERY_KEY_BLOCK_PREFIX, "dryRun", "papi", address, @@ -22,20 +22,20 @@ export const papiDryRunErrorQuery = ( ], queryFn: async () => { try { - const json = decodeTx(tx) + if (!isPapiTransaction(tx)) { + return null + } + + const rawOrigin = Enum("Signed", address) + const origin = Enum("system", rawOrigin) + const result = await papi.apis.DryRunApi.dry_run_call( - { - type: "system", - value: { - type: "Signed", - value: address, - }, - }, + origin, // @ts-expect-error contains structured call data - json, + tx.decodedCall, 1, ) - + console.log(result) if (!result.success || result.value.execution_result.success) { return null } @@ -44,6 +44,8 @@ export const papiDryRunErrorQuery = ( result.value.execution_result.value.error, ) + const json = decodeTx(tx) + if (debug && error) { console.log(new Date().toLocaleTimeString(), error.name, json) } diff --git a/apps/main/src/api/trade.ts b/apps/main/src/api/trade.ts index b2048471a..8be4345c4 100644 --- a/apps/main/src/api/trade.ts +++ b/apps/main/src/api/trade.ts @@ -3,9 +3,7 @@ import { QUERY_KEY_BLOCK_PREFIX } from "@galacticcouncil/utils" import { QueryKey, queryOptions } from "@tanstack/react-query" import Big from "big.js" -import { papiDryRunErrorQuery } from "@/api/dryRun" import { getTimeFrameMillis } from "@/components/TimeFrame/TimeFrame.utils" -import { ENV } from "@/config/env" import { DcaFormValues, DcaOrdersMode, @@ -84,24 +82,17 @@ export const bestSellTxQuery = ( type BestSellWithTxArgs = BestSellArgs & { readonly slippage: number readonly address: string - readonly dryRun?: boolean } export const bestSellWithTxQuery = ( rpc: TProviderContext, - { slippage, address, dryRun, ...bestSellArgs }: BestSellWithTxArgs, + { slippage, address, ...bestSellArgs }: BestSellWithTxArgs, ) => { const { queryClient } = rpc const bestSell = bestSellQuery(rpc, bestSellArgs) return queryOptions({ - queryKey: [ - QUERY_KEY_BLOCK_PREFIX, - bestSell.queryKey, - slippage, - address, - dryRun, - ], + queryKey: [QUERY_KEY_BLOCK_PREFIX, bestSell.queryKey, slippage, address], queryFn: async () => { const swap = await queryClient.ensureQueryData(bestSell) @@ -117,17 +108,9 @@ export const bestSellWithTxQuery = ( ? await queryClient.ensureQueryData(txQuery) : null - const dryRunError = - tx && dryRun && ENV.VITE_DRY_RUN_ENABLED - ? await queryClient.ensureQueryData( - papiDryRunErrorQuery(rpc, address, tx, bestSellArgs.debug), - ) - : null - return { swap, tx, - dryRunError, } }, enabled: bestSell.enabled as boolean, @@ -189,7 +172,6 @@ type BestSellTwapWithTxArgs = BestSellTwapArgs & { readonly slippage: number readonly address: string readonly maxRetries: number - readonly dryRun?: boolean } export const bestSellTwapWithTxQuery = ( @@ -198,7 +180,6 @@ export const bestSellTwapWithTxQuery = ( slippage, maxRetries, address, - dryRun, ...bestSellTwapArgs }: BestSellTwapWithTxArgs, enabled = true, @@ -213,7 +194,6 @@ export const bestSellTwapWithTxQuery = ( slippage, maxRetries, address, - dryRun, ], queryFn: async () => { const twap = await queryClient.ensureQueryData(bestSellTwap) @@ -231,14 +211,7 @@ export const bestSellTwapWithTxQuery = ( ? await queryClient.ensureQueryData(txQuery) : null - const dryRunError = - tx && dryRun && ENV.VITE_DRY_RUN_ENABLED - ? await queryClient.ensureQueryData( - papiDryRunErrorQuery(rpc, address, tx), - ) - : null - - return { twap, tx, dryRunError } + return { twap, tx } }, enabled: enabled && (bestSellTwap.enabled as boolean), }) @@ -303,24 +276,17 @@ export const bestBuyTxQuery = ( type BestBuyWithTxArgs = BestBuyArgs & { readonly slippage: number readonly address: string - readonly dryRun?: boolean } export const bestBuyWithTxQuery = ( rpc: TProviderContext, - { slippage, address, dryRun, ...bestBuyArgs }: BestBuyWithTxArgs, + { slippage, address, ...bestBuyArgs }: BestBuyWithTxArgs, ) => { const { queryClient } = rpc const bestBuy = bestBuyQuery(rpc, bestBuyArgs) return queryOptions({ - queryKey: [ - QUERY_KEY_BLOCK_PREFIX, - bestBuy.queryKey, - slippage, - address, - dryRun, - ], + queryKey: [QUERY_KEY_BLOCK_PREFIX, bestBuy.queryKey, slippage, address], queryFn: async () => { const swap = await queryClient.ensureQueryData(bestBuy) @@ -336,17 +302,9 @@ export const bestBuyWithTxQuery = ( ? await queryClient.ensureQueryData(txQuery) : null - const dryRunError = - tx && dryRun && ENV.VITE_DRY_RUN_ENABLED - ? await queryClient.ensureQueryData( - papiDryRunErrorQuery(rpc, address, tx, bestBuyArgs.debug), - ) - : null - return { swap, tx, - dryRunError, } }, enabled: bestBuy.enabled as boolean, @@ -408,18 +366,11 @@ type BestBuyTwapWithTxArgs = BestBuyTwapArgs & { readonly slippage: number readonly address: string readonly maxRetries: number - readonly dryRun?: boolean } export const bestBuyTwapWithTxQuery = ( rpc: TProviderContext, - { - slippage, - maxRetries, - address, - dryRun, - ...bestBuyTwapArgs - }: BestBuyTwapWithTxArgs, + { slippage, maxRetries, address, ...bestBuyTwapArgs }: BestBuyTwapWithTxArgs, enabled = true, ) => { const { queryClient } = rpc @@ -432,7 +383,6 @@ export const bestBuyTwapWithTxQuery = ( slippage, maxRetries, address, - dryRun, ], queryFn: async () => { const twap = await queryClient.ensureQueryData(bestBuyTwap) @@ -450,14 +400,7 @@ export const bestBuyTwapWithTxQuery = ( ? await queryClient.ensureQueryData(txQuery) : null - const dryRunError = - tx && dryRun && ENV.VITE_DRY_RUN_ENABLED - ? await queryClient.ensureQueryData( - papiDryRunErrorQuery(rpc, address, tx), - ) - : null - - return { twap, tx, dryRunError } + return { twap, tx } }, enabled: enabled && (bestBuyTwap.enabled as boolean), }) @@ -541,18 +484,17 @@ type DcaTradeOrderArgs = { readonly slippage: number readonly maxRetries: number readonly address: string - readonly dryRun?: boolean } export const dcaTradeOrderQuery = ( rpc: TProviderContext, - { form, slippage, maxRetries, address, dryRun }: DcaTradeOrderArgs, + { form, slippage, maxRetries, address }: DcaTradeOrderArgs, ) => { const { queryClient } = rpc const dcaOrder = dcaOrderQuery(rpc, form) return queryOptions({ - queryKey: [...dcaOrder.queryKey, slippage, maxRetries, address, dryRun], + queryKey: [...dcaOrder.queryKey, slippage, maxRetries, address], queryFn: async () => { const order = await queryClient.ensureQueryData(dcaOrder) @@ -571,14 +513,7 @@ export const dcaTradeOrderQuery = ( ? await queryClient.ensureQueryData(txQuery) : null - const dryRunError = - orderTx && dryRun && ENV.VITE_DRY_RUN_ENABLED - ? await queryClient.ensureQueryData( - papiDryRunErrorQuery(rpc, address, orderTx), - ) - : null - - return { order, orderTx, dryRunError } + return { order, orderTx } }, enabled: dcaOrder.enabled as boolean, }) diff --git a/apps/main/src/api/xcm.ts b/apps/main/src/api/xcm.ts index 3c11d64dc..27729e581 100644 --- a/apps/main/src/api/xcm.ts +++ b/apps/main/src/api/xcm.ts @@ -14,7 +14,7 @@ import { import { secondsToMilliseconds } from "date-fns" import { useEffect, useRef, useState } from "react" -import { TProviderContext, useRpcProvider } from "@/providers/rpcProvider" +import { useRpcProvider } from "@/providers/rpcProvider" export const useCrossChainConfig = () => { const { sdk } = useRpcProvider() @@ -199,34 +199,18 @@ export const xcmTransferReportQuery = ( }) export const xcmTransferCallQuery = ( - { dryRunErrorDecoder }: TProviderContext, transfer: Transfer | null, amount: string, transferArgs: XcmTransferArgs, - dryRun?: boolean, ) => queryOptions({ enabled: !!transfer && !!amount, placeholderData: keepPreviousData, - queryKey: ["xcm", "call", amount, transferArgs, dryRun], + queryKey: ["xcm", "call", amount, transferArgs], queryFn: async () => { if (!transfer) throw new Error("Invalid transfer") const call = await transfer.buildCall(amount) - const dryRunError = await (async () => { - if (!dryRun) { - return null - } - - const result = await call?.dryRun() - - if (result?.error) { - return await dryRunErrorDecoder.parseError(result.error) - } - - return null - })() - - return { call, dryRunError } + return { call } }, }) diff --git a/apps/main/src/i18n/locales/en/common.json b/apps/main/src/i18n/locales/en/common.json index b648eaec0..d03ee73ec 100644 --- a/apps/main/src/i18n/locales/en/common.json +++ b/apps/main/src/i18n/locales/en/common.json @@ -317,6 +317,7 @@ "transaction.alert.pendingDispatchPermit": "Permit transaction is pending. Please wait.", "transaction.alert.sellAll": "You are selling your entire balance of {{ value, currency }}.", "transaction.alert.acceptRisk": "I accept the risk involved.", + "transaction.alert.dryRunWarning": "Transaction might fail. Reason: {{reason}}", "transaction.batch.warning": "Your transaction would exhaust block limit, we need to split it into multiple transactions", "transaction.batch.step.label": "Transaction {{ index }}", "transaction.error.unsupportedTransaction": "Unsupported transaction or signer type", diff --git a/apps/main/src/modules/trade/swap/sections/DCA/Dca.tsx b/apps/main/src/modules/trade/swap/sections/DCA/Dca.tsx index 75cb224ea..8b6264565 100644 --- a/apps/main/src/modules/trade/swap/sections/DCA/Dca.tsx +++ b/apps/main/src/modules/trade/swap/sections/DCA/Dca.tsx @@ -32,7 +32,6 @@ export const Dca: FC = () => { const { order, orderTx, - dryRunError, healthFactor: initialHealthFactor, isLoading, } = useDcaTradeOrder(form) @@ -150,11 +149,7 @@ export const Dca: FC = () => { } isLoading={isLoading} /> - + - readonly dryRunError?: DryRunError | null } -export const DcaErrors: FC = ({ priceImpact, errors, dryRunError }) => { +export const DcaErrors: FC = ({ priceImpact, errors }) => { const { t } = useTranslation(["common", "trade"]) - if (!errors.length && !dryRunError) { + if (!errors.length) { return null } @@ -37,13 +35,6 @@ export const DcaErrors: FC = ({ priceImpact, errors, dryRunError }) => { description={errorDescriptions[error]} /> ))} - {dryRunError && ( - - )} ) diff --git a/apps/main/src/modules/trade/swap/sections/DCA/useDcaTradeOrder.ts b/apps/main/src/modules/trade/swap/sections/DCA/useDcaTradeOrder.ts index 468e5e4fa..3491cc428 100644 --- a/apps/main/src/modules/trade/swap/sections/DCA/useDcaTradeOrder.ts +++ b/apps/main/src/modules/trade/swap/sections/DCA/useDcaTradeOrder.ts @@ -32,7 +32,6 @@ export const useDcaTradeOrder = (form: UseFormReturn) => { slippage, maxRetries, address, - dryRun: form.formState.isValid, }), ) @@ -74,7 +73,6 @@ export const useDcaTradeOrder = (form: UseFormReturn) => { return { order: orderData?.order, orderTx: orderData?.orderTx, - dryRunError: orderData?.dryRunError ?? null, healthFactor: healthFactorData, isLoading: isOrderLoading || isHealthFactorLoading, } diff --git a/apps/main/src/modules/transactions/TransactionProvider.tsx b/apps/main/src/modules/transactions/TransactionProvider.tsx index e3442bad6..0a5e7b4c4 100644 --- a/apps/main/src/modules/transactions/TransactionProvider.tsx +++ b/apps/main/src/modules/transactions/TransactionProvider.tsx @@ -1,4 +1,4 @@ -import { HYDRATION_CHAIN_KEY } from "@galacticcouncil/utils" +import { DryRunError, HYDRATION_CHAIN_KEY } from "@galacticcouncil/utils" import { CallType } from "@galacticcouncil/xc-core" import { useQueryClient } from "@tanstack/react-query" import { createContext, useCallback, useContext, useReducer } from "react" @@ -7,6 +7,7 @@ import { useLatest } from "react-use" import { useEstimateFee } from "@/modules/transactions/hooks/useEstimateFee" import { useNonce } from "@/modules/transactions/hooks/useNonce" import { useSignAndSubmit } from "@/modules/transactions/hooks/useSignAndSubmit" +import { useTransactionDryRun } from "@/modules/transactions/hooks/useTransactionDryRun" import { useTransactionEcosystem } from "@/modules/transactions/hooks/useTransactionEcosystem" import { useTransactionPaymentInfo } from "@/modules/transactions/hooks/useTransactionPaymentInfo" import { useTransactionTip } from "@/modules/transactions/hooks/useTransactionTip" @@ -50,6 +51,8 @@ export type TransactionContext = SingleTransaction & isLoading: boolean isUsingPermit: boolean + dryRunError?: DryRunError | null + setTip: (tip: string) => void setStatus: (status: TxStatus) => void setFeePaymentModalOpen: (open: boolean) => void @@ -99,6 +102,8 @@ export const TransactionProvider: React.FC = ({ const feeAssetId = fee?.feeAssetId ?? NATIVE_ASSET_ID const feeAssetBalance = fee?.feeAssetBalance + const { data: dryRunError } = useTransactionDryRun(transaction.tx) + const { nonce, isLoading: isLoadingNonce, @@ -223,6 +228,8 @@ export const TransactionProvider: React.FC = ({ isLoading, isUsingPermit, + dryRunError, + setTip, setFeePaymentModalOpen, setIsChangingFeePaymentAsset, diff --git a/apps/main/src/modules/transactions/hooks/useTransactionDryRun.tsx b/apps/main/src/modules/transactions/hooks/useTransactionDryRun.tsx new file mode 100644 index 000000000..52a61cdb5 --- /dev/null +++ b/apps/main/src/modules/transactions/hooks/useTransactionDryRun.tsx @@ -0,0 +1,17 @@ +import { useAccount } from "@galacticcouncil/web3-connect" +import { useQuery } from "@tanstack/react-query" + +import { papiDryRunErrorQuery } from "@/api/dryRun" +import { ENV } from "@/config/env" +import { useRpcProvider } from "@/providers/rpcProvider" +import { SingleTransaction } from "@/states/transactions" + +export const useTransactionDryRun = (tx: SingleTransaction["tx"]) => { + const rpc = useRpcProvider() + const { account } = useAccount() + + return useQuery({ + ...papiDryRunErrorQuery(rpc, account?.address ?? "", tx, true), + enabled: ENV.VITE_DRY_RUN_ENABLED, + }) +} diff --git a/apps/main/src/modules/transactions/review/ReviewTransactionFee.tsx b/apps/main/src/modules/transactions/review/ReviewTransactionFee.tsx index 25d09d2e7..e2554cede 100644 --- a/apps/main/src/modules/transactions/review/ReviewTransactionFee.tsx +++ b/apps/main/src/modules/transactions/review/ReviewTransactionFee.tsx @@ -7,6 +7,7 @@ import { import { getToken } from "@galacticcouncil/ui/utils" import { useTranslation } from "react-i18next" +import { useDisplayAssetPrice } from "@/components/AssetPrice" import { useTransaction } from "@/modules/transactions/TransactionProvider" import { useAssets } from "@/providers/assetsProvider" @@ -22,6 +23,10 @@ export const ReviewTransactionFee = () => { setFeePaymentModalOpen, } = useTransaction() + const [feeDisplay] = useDisplayAssetPrice(feeAssetId, feeEstimate ?? "", { + maximumFractionDigits: 4, + }) + const feeAsset = getAsset(feeAssetId) const isFeeOverride = !!fee?.feeAmount && !!fee?.feeSymbol @@ -49,11 +54,13 @@ export const ReviewTransactionFee = () => { return ( - {t("approx.short")}{" "} + {t("approx.short")} + {feeDisplay} ( {t("currency", { symbol: feeAsset?.symbol, value: feeEstimate, })} + ) {!isChangingFeeAsset && ( setFeePaymentModalOpen(true)}> diff --git a/apps/main/src/modules/transactions/review/ReviewTransactionFooter.tsx b/apps/main/src/modules/transactions/review/ReviewTransactionFooter.tsx index 9e44eb17d..0b5d84eab 100644 --- a/apps/main/src/modules/transactions/review/ReviewTransactionFooter.tsx +++ b/apps/main/src/modules/transactions/review/ReviewTransactionFooter.tsx @@ -22,7 +22,7 @@ type ReviewTransactionFooterProps = { export const ReviewTransactionFooter: React.FC< ReviewTransactionFooterProps > = ({ closable = true }) => { - const { t } = useTranslation() + const { t } = useTranslation("common") const { onClose, @@ -30,6 +30,7 @@ export const ReviewTransactionFooter: React.FC< isSigning, isSubmitted, alerts: txAlerts, + dryRunError, } = useTransaction() const { alerts: genericAlerts } = useTransactionAlerts() @@ -44,7 +45,7 @@ export const ReviewTransactionFooter: React.FC< const hasGenericAlerts = genericAlerts.length > 0 const hasTxAlerts = !!txAlerts && txAlerts.length > 0 - const hasAlerts = hasGenericAlerts || hasTxAlerts + const hasAlerts = hasGenericAlerts || hasTxAlerts || !!dryRunError if (isIdle) { return ( @@ -73,7 +74,7 @@ export const ReviewTransactionFooter: React.FC< }) }} /> - + {isString(alert.requiresUserConsent) ? alert.requiresUserConsent : t("transaction.alert.acceptRisk")} @@ -84,6 +85,19 @@ export const ReviewTransactionFooter: React.FC< /> ))} + {dryRunError && ( + + {t("transaction.alert.dryRunWarning", { + reason: dryRunError.name, + })} + + } + /> + )} + {hasAlerts && } { const { status, transfer, - dryRunError, sourceChainAssetPairs, destChainAssetPairs, isLoading, @@ -282,13 +280,6 @@ export const XcmForm = () => { - {dryRunError && ( - - )} = ({ children }) => { isLoadingTransfer, isLoadingCall, call, - dryRunError, + report, } = useXcmTransfer(form) @@ -192,7 +192,6 @@ export const XcmProvider: React.FC = ({ children }) => { alerts, transfer, call, - dryRunError, registryChain: chainsMap.get(HYDRATION_CHAIN_KEY) as EvmParachain, status: getTransferStatus(form.getValues(), transfer, call, alerts), }} diff --git a/apps/main/src/modules/xcm/transfer/hooks/useXcmProvider.ts b/apps/main/src/modules/xcm/transfer/hooks/useXcmProvider.ts index e0a8f23c6..dbf22cf0d 100644 --- a/apps/main/src/modules/xcm/transfer/hooks/useXcmProvider.ts +++ b/apps/main/src/modules/xcm/transfer/hooks/useXcmProvider.ts @@ -1,4 +1,3 @@ -import { DryRunError } from "@galacticcouncil/utils" import { EvmParachain } from "@galacticcouncil/xc-core" import { Call, Transfer } from "@galacticcouncil/xc-sdk" import { createContext, useContext } from "react" @@ -18,7 +17,6 @@ type XcmContextValue = { readonly isConnectedAccountValid: boolean readonly transfer: Transfer | null readonly call: Call | null - readonly dryRunError: DryRunError | null readonly alerts: XcmAlert[] readonly sourceChainAssetPairs: ChainAssetPair[] readonly destChainAssetPairs: ChainAssetPair[] @@ -33,7 +31,6 @@ export const XcmContext = createContext({ isConnectedAccountValid: false, transfer: null, call: null, - dryRunError: null, alerts: [], sourceChainAssetPairs: [], destChainAssetPairs: [], diff --git a/apps/main/src/modules/xcm/transfer/hooks/useXcmTransfer.ts b/apps/main/src/modules/xcm/transfer/hooks/useXcmTransfer.ts index cd03db3ef..759e0f734 100644 --- a/apps/main/src/modules/xcm/transfer/hooks/useXcmTransfer.ts +++ b/apps/main/src/modules/xcm/transfer/hooks/useXcmTransfer.ts @@ -8,13 +8,10 @@ import { xcmTransferQuery, xcmTransferReportQuery, } from "@/api/xcm" -import { ENV } from "@/config/env" import { XcmFormValues } from "@/modules/xcm/transfer/hooks/useXcmFormSchema" import { getXcmTransferArgs } from "@/modules/xcm/transfer/utils/transfer" -import { useRpcProvider } from "@/providers/rpcProvider" export const useXcmTransfer = (form: UseFormReturn) => { - const rpc = useRpcProvider() const wallet = useCrossChainWallet() const { account } = useAccount() @@ -29,13 +26,7 @@ export const useXcmTransfer = (form: UseFormReturn) => { const [reportQuery, callQuery] = useQueries({ queries: [ xcmTransferReportQuery(transfer ?? null, transferArgs), - xcmTransferCallQuery( - rpc, - transfer ?? null, - values.srcAmount, - transferArgs, - form.formState.isValid && ENV.VITE_DRY_RUN_ENABLED, - ), + xcmTransferCallQuery(transfer ?? null, values.srcAmount, transferArgs), ], }) @@ -48,7 +39,6 @@ export const useXcmTransfer = (form: UseFormReturn) => { report: report ?? null, isLoadingReport, call: callData?.call ?? null, - dryRunError: callData?.dryRunError ?? null, isLoadingCall, } } diff --git a/packages/utils/src/helpers/meta.ts b/packages/utils/src/helpers/meta.ts index 6f850f06a..7fa46b9db 100644 --- a/packages/utils/src/helpers/meta.ts +++ b/packages/utils/src/helpers/meta.ts @@ -1,7 +1,7 @@ import { hydration } from "@galacticcouncil/descriptors" import { metadata as metadataCodec, - V15, + V16, } from "@polkadot-api/substrate-bindings" import { PolkadotClient, TypedApi } from "polkadot-api" @@ -19,8 +19,8 @@ type DryRunExecutionError = Extract< { success: false } >["value"]["error"] -type Pallet = V15["pallets"][number] -type Lookup = V15["lookup"][number] +type Pallet = V16["pallets"][number] +type Lookup = V16["lookup"][number] export type DryRunError = { readonly name: string @@ -77,7 +77,7 @@ export class DryRunErrorDecoder { return } - const errorType = this.#lookupById.get(pallet.errors) + const errorType = this.#lookupById.get(pallet.errors.type) if (!errorType || errorType.def.tag !== "variant") { return @@ -107,7 +107,7 @@ export class DryRunErrorDecoder { ) const { metadata } = metadataCodec.dec(metadataBytes) - const { pallets, lookup } = metadata.value as V15 + const { pallets, lookup } = metadata.value as V16 this.#palletByName = new Map(pallets.map((p) => [p.name, p] as const)) this.#lookupById = new Map(lookup.map((t) => [t.id, t] as const))