@velora-dex/widget 0.3.3-dev.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/widget/AppHeader/Activities/Drawers.js.map +1 -1
- package/dist/components/widget/LimitOrderItem/LimitOrderDetails/Controls.d.ts +3 -3
- package/dist/components/widget/LimitOrderItem/LimitOrderDetails/Controls.d.ts.map +1 -1
- package/dist/components/widget/LimitOrderItem/LimitOrderDetails/Controls.js +96 -68
- package/dist/components/widget/LimitOrderItem/LimitOrderDetails/Controls.js.map +1 -1
- package/dist/components/widget/OtcOrderItem/OtcOrderDetails/Controls.d.ts.map +1 -1
- package/dist/components/widget/OtcOrderItem/OtcOrderDetails/Controls.js +94 -66
- package/dist/components/widget/OtcOrderItem/OtcOrderDetails/Controls.js.map +1 -1
- package/dist/components/widget/ReceiverAddress/state/subscriptions.d.ts.map +1 -1
- package/dist/components/widget/ReceiverAddress/state/subscriptions.js +8 -0
- package/dist/components/widget/ReceiverAddress/state/subscriptions.js.map +1 -1
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/FillOtcControls.d.ts +2 -2
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/FillOtcControls.d.ts.map +1 -1
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/FillOtcControls.js +115 -46
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/FillOtcControls.js.map +1 -1
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/FillOtcReviewAndConfirm.d.ts.map +1 -1
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/FillOtcReviewAndConfirm.js +41 -35
- package/dist/components/widget/ReviewAndConfirm/FillOtcReviewAndConfirm/FillOtcReviewAndConfirm.js.map +1 -1
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.d.ts +2 -2
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.js +31 -25
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/utils.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/utils.js +5 -0
- package/dist/components/widget/TradeOverview/TradeError/utils.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverview.js +12 -11
- package/dist/components/widget/TradeOverview/TradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.d.ts +3 -2
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.js +50 -42
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.js.map +1 -1
- package/dist/core/Updaters.d.ts.map +1 -1
- package/dist/core/Updaters.js +2 -0
- package/dist/core/Updaters.js.map +1 -1
- package/dist/core/button/hooks/useWidgetButtonExtraProps.d.ts.map +1 -1
- package/dist/core/button/hooks/useWidgetButtonExtraProps.js +4 -5
- package/dist/core/button/hooks/useWidgetButtonExtraProps.js.map +1 -1
- package/dist/core/screen/hooks/useOnClickOutside.d.ts.map +1 -1
- package/dist/core/screen/hooks/useOnClickOutside.js +9 -4
- package/dist/core/screen/hooks/useOnClickOutside.js.map +1 -1
- package/dist/hooks/otc/tradeFlow/useOtcOrderFlow.d.ts.map +1 -1
- package/dist/hooks/otc/tradeFlow/useOtcOrderFlow.js +19 -2
- package/dist/hooks/otc/tradeFlow/useOtcOrderFlow.js.map +1 -1
- package/dist/hooks/otc/tradeFlow/useOtcOrderStep.js.map +1 -1
- package/dist/hooks/swap/prices/delta/mutations/useCancelDeltaOrders.d.ts +28 -0
- package/dist/hooks/swap/prices/delta/mutations/useCancelDeltaOrders.d.ts.map +1 -0
- package/dist/hooks/swap/prices/delta/mutations/{useCancelLimitDeltaOrders.js → useCancelDeltaOrders.js} +5 -5
- package/dist/hooks/swap/prices/delta/mutations/useCancelDeltaOrders.js.map +1 -0
- package/dist/hooks/swap/prices/delta/orders/types.d.ts +1 -1
- package/dist/hooks/swap/prices/delta/orders/types.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/orders/utils.d.ts +3 -0
- package/dist/hooks/swap/prices/delta/orders/utils.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/orders/utils.js +6 -3
- package/dist/hooks/swap/prices/delta/orders/utils.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/errors.d.ts +10 -0
- package/dist/hooks/swap/prices/delta/queries/errors.d.ts.map +1 -0
- package/dist/hooks/swap/prices/delta/queries/errors.js +21 -0
- package/dist/hooks/swap/prices/delta/queries/errors.js.map +1 -0
- package/dist/hooks/swap/prices/delta/queries/useWatchDeltaOrder.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useWatchDeltaOrder.js +7 -4
- package/dist/hooks/swap/prices/delta/queries/useWatchDeltaOrder.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts +10 -0
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js +70 -10
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.d.ts +2 -0
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.js +42 -23
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js +22 -5
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js.map +1 -1
- package/dist/hooks/txs/queries/useAwaitTx.d.ts.map +1 -1
- package/dist/hooks/txs/queries/useAwaitTx.js +9 -4
- package/dist/hooks/txs/queries/useAwaitTx.js.map +1 -1
- package/dist/hooks/useChainMatches.d.ts +7 -0
- package/dist/hooks/useChainMatches.d.ts.map +1 -0
- package/dist/hooks/useChainMatches.js +31 -0
- package/dist/hooks/useChainMatches.js.map +1 -0
- package/dist/hooks/useMinViemClient.d.ts +16 -0
- package/dist/hooks/useMinViemClient.d.ts.map +1 -1
- package/dist/hooks/useMinViemClient.js +62 -7
- package/dist/hooks/useMinViemClient.js.map +1 -1
- package/dist/hooks/useSwitchChainWithGuard.d.ts +12 -0
- package/dist/hooks/useSwitchChainWithGuard.d.ts.map +1 -0
- package/dist/hooks/useSwitchChainWithGuard.js +70 -0
- package/dist/hooks/useSwitchChainWithGuard.js.map +1 -0
- package/dist/lib/web3/wagmi/transports.js +1 -1
- package/dist/lib/web3/wagmi/transports.js.map +1 -1
- package/dist/transactions/queries/ensureTxReceipt.d.ts +2 -1
- package/dist/transactions/queries/ensureTxReceipt.d.ts.map +1 -1
- package/dist/transactions/queries/ensureTxReceipt.js +22 -26
- package/dist/transactions/queries/ensureTxReceipt.js.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/swap/prices/delta/mutations/useCancelLimitDeltaOrders.d.ts +0 -28
- package/dist/hooks/swap/prices/delta/mutations/useCancelLimitDeltaOrders.d.ts.map +0 -1
- package/dist/hooks/swap/prices/delta/mutations/useCancelLimitDeltaOrders.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLimitOrderFlow.js","sources":["../../../../src/hooks/swap/tradeFlow/useLimitOrderFlow.ts"],"sourcesContent":["import { useAccount, useChainId } from \"wagmi\";\nimport { assert } from \"ts-essentials\";\nimport { useEnsureTxReceipt } from \"@/hooks/txs/queries/useAwaitTx\";\nimport type { Address, Hash, TransactionReceipt } from \"viem\";\nimport { type SubmittedDeltaOrderFromAPI } from \"../prices/delta/queries/useDeltaOrders\";\nimport type { ApprovalFlowResult, SubmitTxResult } from \"./common/types\";\nimport {\n useCreateDeltaOrder,\n type CreateDeltaOrderInput,\n} from \"../prices/delta/mutations/useCreateDeltaOrder\";\nimport { useMinViemClient } from \"@/hooks/useMinViemClient\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useRef } from \"react\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { UserCancelledError } from \"./common/errors\";\nimport type {\n CallsSentObject,\n TxSentObject,\n} from \"@/lib/utils/transactionHandlers\";\nimport { useApproveOrPermit } from \"./common/useApproveOrPermit\";\n\nimport { useLogger } from \"@/core/logger\";\n\nimport { usePartner } from \"@/hooks/usePartner\";\nimport { useLimitDeadline } from \"@/core/limit/state/deadlineAtom\";\nimport {\n useCancelDeltaOrderEventCallbacks,\n useCancelLimitDeltaOrders,\n} from \"../prices/delta/mutations/useCancelLimitDeltaOrders\";\nimport { getOverallOrderStatus } from \"../prices/delta/orders/utils\";\nimport {\n deltaAuctionPollingQueryKey,\n useWatchDeltaAuction,\n type MaybeVeloraDeltaAuction,\n} from \"../prices/delta/queries/useWatchDeltaOrder\";\nimport { useWidgetEvents } from \"@/core/state/widgetEventsAtom\";\nimport {\n shouldApproveOrBatch,\n usePreSignAndSubmitDeltaOrder,\n} from \"./common/usePreSignAndSubmitDeltaOrder\";\nimport type { BridgePrice, DeltaOrderApiResponse } from \"@velora-dex/sdk\";\nimport { DEFAULT_DELTA_BRIDGE } from \"../prices/delta/bridge/const\";\nimport { useLimitReceiverAddressValue } from \"@/core/limit/state/receiverAddressAtom\";\n\nconst limitOrderFlowType = \"limitOrder\";\n\nexport type UserDefinedLimitPrice = {\n srcTokenAddress: string;\n destTokenAddress: string;\n srcAmount: string;\n destAmount: string;\n bridgePrice?: BridgePrice;\n};\n\nexport type UseLimitOrderFlowInput = {\n limitPrice?: UserDefinedLimitPrice;\n preWrapETH?: boolean;\n};\n\nexport type SubmitLimitOrderResult = {\n tradeFlowType: typeof limitOrderFlowType;\n approve: SubmitTxResult;\n limitOrder: {\n sentOrder: SubmittedDeltaOrderFromAPI;\n };\n limitPrice: UserDefinedLimitPrice;\n account: Address;\n receiverAddress?: Address;\n};\n\ntype OnTxSent = (txSent: TxSentObject | CallsSentObject) => void;\n\ntype RunLimitOrderOptions = {\n onTxSent?: OnTxSent;\n};\n\nexport type UseLimitOrderFlowResult = {\n tradeFlowType: typeof limitOrderFlowType;\n chainId: SupportedChainId;\n runLimitOrderFlow: (\n options?: RunLimitOrderOptions\n ) => Promise<SubmitLimitOrderResult>;\n reset: () => void; // reset on Error to retry\n cancelFlow: () => void; // cancel flow\n retryFlow: (\n options?: RunLimitOrderOptions\n ) => Promise<SubmitLimitOrderResult>; // reset and retry flow\n cancelLimitOrder: () => void;\n approval: ApprovalFlowResult;\n limitOrderSubmission: {\n order?: SubmittedDeltaOrderFromAPI;\n isCreatingOrder: boolean;\n isOrderSent: boolean;\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n error: Error | null;\n };\n limitOrderExecution: {\n sentOrder?: SubmittedDeltaOrderFromAPI;\n lastOrderState?: MaybeVeloraDeltaAuction;\n isOrderPending: boolean;\n isOrderExecuting: boolean;\n isOrderExecuted: boolean;\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n error: Error | null;\n };\n limitOrderCancelation: {\n isCancelingOrder: boolean;\n isOrderCanceled: boolean;\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n error: Error | null;\n };\n isPending: boolean;\n isSuccess: boolean;\n isError: boolean;\n error: Error | null;\n result?: SubmitLimitOrderResult;\n limitPrice?: UserDefinedLimitPrice;\n};\n\nconst LIMIT_ORDER_MUTATION_KEY = \"runLimitOrderFlow\";\n\nexport function useLimitOrderFlow({\n limitPrice,\n preWrapETH,\n}: UseLimitOrderFlowInput): UseLimitOrderFlowResult {\n const logger = useLogger(\"LimitOrderFlow\");\n const chainId = useChainId();\n const queryClient = useQueryClient();\n\n /* Inside useApproveOrPermit:\n 1. Get allowance for tokenFrom \n 2.1. submit Approve tx if necessary \n\n 3. await Approve tx\n */\n\n const {\n approval,\n approveTxMut,\n events: approveOrPermitEvents,\n } = useApproveOrPermit({\n srcToken: limitPrice?.srcTokenAddress,\n srcAmount: limitPrice?.srcAmount,\n spenderContractType: \"ParaswapDelta\",\n swapSide: \"SELL\",\n tradeMode: \"limit\",\n });\n\n /* 4.1. Build and Submit Delta Order */\n\n const { address: account } = useAccount();\n\n const { minClient } = useMinViemClient({\n chainId,\n account,\n });\n\n const createOrderMut = useCreateDeltaOrder({\n chainId,\n account,\n client: minClient,\n mutationOptions: {\n onSuccess: (order) => {\n logger.log(\"Create Limit Order success\", order);\n },\n onError: (error) => {\n logger.error(\"Create Limit Order error\", error);\n },\n },\n });\n\n const limitOrderCreateAndSubmit: UseLimitOrderFlowResult[\"limitOrderSubmission\"] =\n {\n order: createOrderMut.data,\n isCreatingOrder: createOrderMut.isPending,\n isOrderSent: createOrderMut.isSuccess,\n isPending: createOrderMut.isPending,\n isError: createOrderMut.isError,\n isSuccess: createOrderMut.isSuccess,\n error: createOrderMut.error,\n };\n\n /* 4.2.\n 1. submit Batch tx (Approve + Delta pre-sign)\n 2. await Batch tx\n 3. post Pre-signed Order\n */\n\n const {\n deltaOrderPreSign,\n canBatchTxs,\n isConnectedToSafe,\n preSignAndSubmitDeltaOrder,\n reset: resetPreSignAndSubmitDeltaOrder,\n } = usePreSignAndSubmitDeltaOrder({\n chainId,\n account,\n logger,\n viemClient: minClient,\n });\n\n /* final Delta Order submission for step 4 */\n const limitOrderSubmission: UseLimitOrderFlowResult[\"limitOrderSubmission\"] =\n {\n order: limitOrderCreateAndSubmit.order || deltaOrderPreSign.order,\n isCreatingOrder:\n limitOrderCreateAndSubmit.isPending ||\n deltaOrderPreSign.isCreatingOrder,\n isOrderSent:\n limitOrderCreateAndSubmit.isSuccess || deltaOrderPreSign.isOrderSent,\n isPending:\n limitOrderCreateAndSubmit.isPending || deltaOrderPreSign.isPending,\n isError: limitOrderCreateAndSubmit.isError || deltaOrderPreSign.isError,\n isSuccess:\n limitOrderCreateAndSubmit.isSuccess || deltaOrderPreSign.isSuccess,\n error: limitOrderCreateAndSubmit.error || deltaOrderPreSign.error,\n };\n\n const watchOrderExecution = useWatchDeltaAuction({\n orderId: limitOrderSubmission.order?.id,\n onAuctionSuccess: (order) => {\n logger.log(\"Limit Order success\", order);\n },\n onAuctionFailure: (order) => {\n logger.log(\"Limit Order failure\", order);\n },\n onUpdatedAuction: (order) => {\n logger.log(\"Limit Order updated\", order);\n },\n onTimeoutGettingOrder: (order) => {\n logger.log(\"Limit Order timeout\", order);\n },\n });\n\n const orderStatus = watchOrderExecution.data\n ? getOverallOrderStatus(watchOrderExecution.data)\n : null;\n\n // refetching stops after one minute of not finding an order (order==null)\n const neverFetchedFinishedOrder =\n watchOrderExecution.data === null && watchOrderExecution.isSuccess;\n\n const limitOrderExecution: UseLimitOrderFlowResult[\"limitOrderExecution\"] = {\n sentOrder: createOrderMut.data,\n lastOrderState: watchOrderExecution.data,\n isOrderPending: orderStatus === \"pending\",\n isOrderExecuting: orderStatus === \"executing\",\n isOrderExecuted: orderStatus === \"confirmed\",\n isPending:\n watchOrderExecution.isLoading ||\n watchOrderExecution.isRefetching ||\n orderStatus === \"pending\" ||\n orderStatus === \"executing\",\n isError:\n watchOrderExecution.isError ||\n orderStatus === \"failed\" ||\n neverFetchedFinishedOrder,\n isSuccess: orderStatus === \"confirmed\",\n error: watchOrderExecution.error,\n };\n\n const cancelOrderEvents = useCancelDeltaOrderEventCallbacks(\n createOrderMut.data\n );\n\n const cancelOrderMut = useCancelLimitDeltaOrders({\n chainId,\n account,\n client: minClient,\n mutationOptions: {\n onMutate: cancelOrderEvents.onMutate,\n onSuccess: (successResponse, vars) => {\n logger.log(\"Cancel Limit Order success\", successResponse);\n if (limitOrderExecution.sentOrder?.id) {\n // refetch the order to get updated status\n queryClient.invalidateQueries({\n queryKey: deltaAuctionPollingQueryKey({\n orderId: limitOrderExecution.sentOrder.id,\n }),\n });\n }\n cancelOrderEvents.onSuccess?.(successResponse, vars);\n },\n onError: (error, vars) => {\n logger.error(\"Cancel Limit Order error\", error);\n cancelOrderEvents.onError?.(error, vars);\n },\n },\n });\n\n const limitOrderCancelation: UseLimitOrderFlowResult[\"limitOrderCancelation\"] =\n {\n isCancelingOrder: cancelOrderMut.isPending,\n isOrderCanceled:\n cancelOrderMut.isSuccess && !!cancelOrderMut.data?.success,\n isPending: cancelOrderMut.isPending,\n isError: cancelOrderMut.isError,\n isSuccess: cancelOrderMut.isSuccess,\n error: cancelOrderMut.error,\n };\n\n const ensureTxReceipt = useEnsureTxReceipt();\n\n const currentAbortControllerRef = useRef<AbortController | null>(null);\n\n const cancelFlow = () => {\n currentAbortControllerRef.current?.abort(new UserCancelledError());\n currentAbortControllerRef.current = null;\n };\n\n const partner = usePartner();\n const receiverAddress = useLimitReceiverAddressValue();\n const deadline = useLimitDeadline();\n\n const { onLimitOrder } = useWidgetEvents();\n\n const submitLimitOrder = async ({\n onTxSent,\n }: RunLimitOrderOptions = {}): Promise<SubmitLimitOrderResult> => {\n // reset all mutations except the current one,\n // otherwise we'll have previous data (txs) as mutation results\n approveTxMut.reset();\n createOrderMut.reset();\n cancelOrderMut.reset();\n resetPreSignAndSubmitDeltaOrder();\n\n // no sense in starting flow without a price data,\n // Otherwise this flow will be stopped by disabling ReviewOrder button in the first place\n assert(limitPrice, \"Limit price data is not available\");\n\n const abortController = new AbortController();\n currentAbortControllerRef.current = abortController;\n\n const signal = abortController.signal;\n\n let approveTxHash: Hash | undefined;\n let approveTxReceipt: TransactionReceipt | undefined;\n\n // at this point this is the syncronously available price\n const allowanceToSet = approval.allowanceToSet;\n\n /* \n if connected to Safe, or needs to approve a token with a tx, or needs to pre-wrap ETH\n and can batch txs, then pre-sign the batch;\n that way Safe does only one action (wrapETH?+Approve+setPreSignature batch tx)\n and a wallet that would otherwise potentially wrap ETH and then Approve Token (tx, no Permit for Limit Orders)\n and then sign Order, basically has to make at least one tx, does only one action as well.\n */\n const {\n shouldDoApprovalTxOrPermit: shouldDoApprovalTx,\n shouldPreSignBatch,\n } = shouldApproveOrBatch({\n approval,\n preWrapETH,\n signPermit: {\n isPermitSupported: false,\n isPermitReadyToSign: false,\n },\n canBatchTxs,\n isConnectedToSafe,\n });\n\n try {\n if (shouldDoApprovalTx && allowanceToSet) {\n try {\n approveOrPermitEvents.onApproveTx.request({ allowanceToSet });\n\n approveTxHash = await approveTxMut.approveAsync({\n allowanceData: {\n allowanceToSet,\n },\n });\n\n approveOrPermitEvents.onApproveTx.sent({\n allowanceToSet,\n txHash: approveTxHash,\n });\n\n // if aborted by this point, throw an error\n signal.throwIfAborted();\n\n const approveTxReceiptPromise = ensureTxReceipt({\n hash: approveTxHash,\n chainId,\n onReplaced: (data) => {\n logger.log(\"onReplaced:approveTx\", approveTxHash, data);\n },\n });\n\n if (onTxSent) {\n onTxSent({\n chainId,\n action: \"approve\",\n transactionHash: approveTxHash,\n receiptPromise: approveTxReceiptPromise,\n transactionSpecificData: {\n action: \"approve\",\n approvedAmount: allowanceToSet,\n tokenAddress: approval.token as Address,\n spenderAddress: approval.spender as Address,\n },\n });\n }\n\n approveTxReceipt = await approveTxReceiptPromise;\n\n approveOrPermitEvents.onApproveTx.confirmed({\n allowanceToSet,\n txHash: approveTxHash,\n txReceipt: approveTxReceipt,\n });\n\n logger.log(\"~ approveTx ~ receipt:\", approveTxReceipt);\n // @TODO check if we need to see if receipt.status === \"reverted\" and throw,\n // or if waitForTransactionReceipt already throws on such receipts\n } catch (error) {\n approveOrPermitEvents.onApproveTx.failed({\n allowanceToSet,\n error: error as Error,\n txHash: approveTxHash, // won't necessarily be available\n });\n throw error;\n }\n }\n\n // if aborted by this point, throw an error\n signal.throwIfAborted();\n\n assert(account, \"Account is not connected\");\n\n assert(limitPrice, \"limitPrice is not available\");\n\n onLimitOrder?.({\n event: {\n name: \"LimitOrder:request\",\n params: {\n price: limitPrice,\n },\n },\n });\n const bridgePrice = limitPrice.bridgePrice;\n const destChainId = bridgePrice?.bridge.destinationChainId;\n\n let createOrderInput: CreateDeltaOrderInput;\n if (bridgePrice) {\n // crosschain order\n createOrderInput = {\n signal,\n type: \"LIMIT\",\n orderInput: {\n owner: account,\n beneficiary: receiverAddress,\n srcToken: limitPrice.srcTokenAddress,\n destToken: limitPrice.destTokenAddress,\n srcAmount: bridgePrice.srcAmount,\n destAmount: bridgePrice.receivedDestAmount,\n destChainId,\n deltaPrice: {\n ...bridgePrice,\n bridge: {\n ...bridgePrice.bridge,\n protocolSelector: DEFAULT_DELTA_BRIDGE.protocolSelector,\n protocolData: DEFAULT_DELTA_BRIDGE.protocolData,\n },\n partner,\n partnerFee: 0,\n },\n partner,\n deadline,\n },\n };\n } else {\n // singlechain order\n createOrderInput = {\n signal,\n type: \"LIMIT\",\n orderInput: {\n owner: account,\n beneficiary: receiverAddress,\n srcToken: limitPrice.srcTokenAddress,\n srcAmount: limitPrice.srcAmount,\n destToken: limitPrice.destTokenAddress,\n destAmount: limitPrice.destAmount,\n destChainId,\n deltaPrice: {\n destToken: limitPrice.destTokenAddress,\n destAmount: limitPrice.destAmount,\n srcAmount: limitPrice.srcAmount,\n bridge: DEFAULT_DELTA_BRIDGE,\n partner,\n partnerFee: 0,\n },\n partner,\n deadline,\n },\n };\n }\n\n let orderFromAPI: DeltaOrderApiResponse;\n\n if (!shouldPreSignBatch) {\n // creating signing and POSTing the Order all together in one mutation\n orderFromAPI = await createOrderMut.mutateAsync(createOrderInput);\n } else {\n // prepare Order for pre-signing and POSTing:\n // 1. builds the order\n // 2. hashes the built order\n // 3. construct DeltaContract.setPreSignature(orderHash, true) tx calldata\n\n orderFromAPI = await preSignAndSubmitDeltaOrder({\n createDeltaOrderInput: createOrderInput,\n approval,\n preWrapETH,\n onTxSent,\n });\n }\n\n onLimitOrder?.({\n event: {\n name: \"LimitOrder:sent\",\n params: {\n price: limitPrice,\n order: orderFromAPI,\n },\n },\n });\n\n return {\n tradeFlowType: limitOrderFlowType,\n approve: {\n txHash: approveTxHash,\n receipt: approveTxReceipt,\n },\n limitOrder: {\n sentOrder: orderFromAPI,\n },\n limitPrice: limitPrice,\n account,\n receiverAddress,\n };\n } catch (error) {\n logger.error(\"Order submission error\", error);\n onLimitOrder?.({\n event: {\n name: \"LimitOrder:failed\",\n params: {\n price: limitPrice,\n error: error as Error,\n },\n },\n });\n throw error;\n }\n };\n\n const cancelLimitOrder = () => {\n assert(createOrderMut.data, \"No order to cancel\");\n cancelOrderMut.mutate({\n orderIds: [createOrderMut.data.id],\n });\n };\n\n const limitOrderMut = useMutation({\n mutationFn: submitLimitOrder,\n mutationKey: [LIMIT_ORDER_MUTATION_KEY],\n onSuccess: (data) => {\n logger.log(\"Order submission success\", data);\n },\n onError: (error) => {\n logger.error(\"Order submission error\", error);\n },\n onSettled: () => {\n logger.log(\"Order submission settled\");\n },\n });\n\n const runLimitOrderFlow = limitOrderMut.mutateAsync;\n\n const reset = () => {\n approveTxMut.reset();\n createOrderMut.reset();\n limitOrderMut.reset();\n cancelOrderMut.reset();\n resetPreSignAndSubmitDeltaOrder();\n };\n\n const retryFlow = (\n options?: RunLimitOrderOptions\n ): Promise<SubmitLimitOrderResult> => {\n reset();\n return runLimitOrderFlow(options);\n };\n\n /* 5. return result */\n return {\n tradeFlowType: limitOrderFlowType,\n chainId,\n runLimitOrderFlow,\n reset,\n cancelFlow,\n retryFlow,\n cancelLimitOrder,\n approval,\n limitOrderSubmission,\n limitOrderExecution,\n limitOrderCancelation,\n // deltaOrderMut includes all steps' queries and mutations and returns more precise errors (including cancellation)\n isPending: limitOrderMut.isPending,\n isSuccess: limitOrderSubmission.isSuccess, // approval is an optional step\n isError: limitOrderMut.isError,\n error: limitOrderMut.error,\n result: limitOrderMut.data,\n limitPrice,\n };\n}\n"],"names":["limitOrderFlowType","LIMIT_ORDER_MUTATION_KEY","useLimitOrderFlow","limitPrice","preWrapETH","logger","useLogger","chainId","useChainId","queryClient","useQueryClient","approval","approveTxMut","events","approveOrPermitEvents","useApproveOrPermit","srcToken","srcTokenAddress","srcAmount","spenderContractType","swapSide","tradeMode","address","account","useAccount","minClient","useMinViemClient","createOrderMut","useCreateDeltaOrder","client","mutationOptions","onSuccess","order","log","onError","error","limitOrderCreateAndSubmit","data","isCreatingOrder","isPending","isOrderSent","isSuccess","isError","deltaOrderPreSign","canBatchTxs","isConnectedToSafe","preSignAndSubmitDeltaOrder","reset","resetPreSignAndSubmitDeltaOrder","usePreSignAndSubmitDeltaOrder","viemClient","limitOrderSubmission","watchOrderExecution","useWatchDeltaAuction","orderId","id","onAuctionSuccess","onAuctionFailure","onUpdatedAuction","onTimeoutGettingOrder","orderStatus","getOverallOrderStatus","neverFetchedFinishedOrder","limitOrderExecution","sentOrder","lastOrderState","isOrderPending","isOrderExecuting","isOrderExecuted","isLoading","isRefetching","cancelOrderEvents","useCancelDeltaOrderEventCallbacks","cancelOrderMut","useCancelLimitDeltaOrders","onMutate","successResponse","vars","invalidateQueries","queryKey","deltaAuctionPollingQueryKey","limitOrderCancelation","isCancelingOrder","isOrderCanceled","success","ensureTxReceipt","useEnsureTxReceipt","currentAbortControllerRef","useRef","cancelFlow","current","abort","UserCancelledError","partner","usePartner","receiverAddress","useLimitReceiverAddressValue","deadline","useLimitDeadline","onLimitOrder","useWidgetEvents","submitLimitOrder","onTxSent","assert","abortController","AbortController","signal","approveTxHash","approveTxReceipt","allowanceToSet","shouldDoApprovalTxOrPermit","shouldDoApprovalTx","shouldPreSignBatch","shouldApproveOrBatch","signPermit","isPermitSupported","isPermitReadyToSign","onApproveTx","request","approveAsync","allowanceData","sent","txHash","throwIfAborted","approveTxReceiptPromise","hash","onReplaced","action","transactionHash","receiptPromise","transactionSpecificData","approvedAmount","tokenAddress","token","spenderAddress","spender","confirmed","txReceipt","failed","event","name","params","price","bridgePrice","destChainId","bridge","destinationChainId","createOrderInput","type","orderInput","owner","beneficiary","destToken","destTokenAddress","destAmount","receivedDestAmount","deltaPrice","protocolSelector","DEFAULT_DELTA_BRIDGE","protocolData","partnerFee","orderFromAPI","mutateAsync","createDeltaOrderInput","tradeFlowType","approve","receipt","limitOrder","cancelLimitOrder","mutate","orderIds","limitOrderMut","useMutation","mutationFn","mutationKey","onSettled","runLimitOrderFlow","retryFlow","options","result"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,kBAAAA,GAAqB,YAAA;AAiF3B,MAAMC,wBAAAA,GAA2B,mBAAA;AAE1B,SAASC,iBAAAA,CAAkB;AAAA,EAChCC,UAAAA;AAAAA,EACAC;AACsB,CAAA,EAA4B;AAClD,EAAA,MAAMC,MAAAA,GAASC,UAAU,gBAAgB,CAAA;AACzC,EAAA,MAAMC,UAAUC,UAAAA,EAAW;AAC3B,EAAA,MAAMC,cAAcC,cAAAA,EAAe;AASnC,EAAA,MAAM;AAAA,IACJC,QAAAA;AAAAA,IACAC,YAAAA;AAAAA,IACAC,MAAAA,EAAQC;AAAAA,MACNC,kBAAAA,CAAmB;AAAA,IACrBC,UAAUb,UAAAA,EAAYc,eAAAA;AAAAA,IACtBC,WAAWf,UAAAA,EAAYe,SAAAA;AAAAA,IACvBC,mBAAAA,EAAqB,eAAA;AAAA,IACrBC,QAAAA,EAAU,MAAA;AAAA,IACVC,SAAAA,EAAW;AAAA,GACZ,CAAA;AAID,EAAA,MAAM;AAAA,IAAEC,OAAAA,EAASC;AAAAA,MAAYC,UAAAA,EAAW;AAExC,EAAA,MAAM;AAAA,IAAEC;AAAAA,MAAcC,gBAAAA,CAAiB;AAAA,IACrCnB,OAAAA;AAAAA,IACAgB;AAAAA,GACD,CAAA;AAED,EAAA,MAAMI,iBAAiBC,mBAAAA,CAAoB;AAAA,IACzCrB,OAAAA;AAAAA,IACAgB,OAAAA;AAAAA,IACAM,MAAAA,EAAQJ,SAAAA;AAAAA,IACRK,eAAAA,EAAiB;AAAA,MACfC,WAAYC,CAAAA,KAAAA,KAAU;AACpB3B,QAAAA,MAAAA,CAAO4B,GAAAA,CAAI,8BAA8BD,KAAK,CAAA;AAAA,MAChD,C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ED,EAAA,MAAM+I,oBAAoBL,aAAAA,CAAcT,WAAAA;AAExC,EAAA,MAAMnH,QAAQA,MAAM;AAClBnC,IAAAA,YAAAA,CAAamC,KAAAA,EAAM;AACnBpB,IAAAA,cAAAA,CAAeoB,KAAAA,EAAM;AACrB4H,IAAAA,aAAAA,CAAc5H,KAAAA,EAAM;AACpB0B,IAAAA,cAAAA,CAAe1B,KAAAA,EAAM;AACrBC,IAAAA,+BAAAA,EAAgC;AAAA,EAClC,CAAA;AAEA,EAAA,MAAMiI,SAAAA,GAAYA,CAChBC,OAAAA,KACoC;AACpCnI,IAAAA,KAAAA,EAAM;AACN,IAAA,OAAOiI,kBAAkBE,OAAO,CAAA;AAAA,EAClC,CAAA;AAGA,EAAA,OAAO;AAAA,IACLd,aAAAA,EAAepK,kBAAAA;AAAAA,IACfO,OAAAA;AAAAA,IACAyK,iBAAAA;AAAAA,IACAjI,KAAAA;AAAAA,IACA0C,UAAAA;AAAAA,IACAwF,SAAAA;AAAAA,IACAT,gBAAAA;AAAAA,IACA7J,QAAAA;AAAAA,IACAwC,oBAAAA;AAAAA,IACAY,mBAAAA;AAAAA,IACAkB,qBAAAA;AAAAA;AAAAA,IAEA1C,WAAWoI,aAAAA,CAAcpI,SAAAA;AAAAA,IACzBE,WAAWU,oBAAAA,CAAqBV,SAAAA;AAAAA;AAAAA,IAChCC,SAASiI,aAAAA,CAAcjI,OAAAA;AAAAA,IACvBP,OAAOwI,aAAAA,CAAcxI,KAAAA;AAAAA,IACrBgJ,QAAQR,aAAAA,CAActI,IAAAA;AAAAA,IACtBlC;AAAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useLimitOrderFlow.js","sources":["../../../../src/hooks/swap/tradeFlow/useLimitOrderFlow.ts"],"sourcesContent":["import { useAccount, useChainId } from \"wagmi\";\nimport { assert } from \"ts-essentials\";\nimport { useEnsureTxReceipt } from \"@/hooks/txs/queries/useAwaitTx\";\nimport type { Address, Hash, TransactionReceipt } from \"viem\";\nimport { type SubmittedDeltaOrderFromAPI } from \"../prices/delta/queries/useDeltaOrders\";\nimport type { ApprovalFlowResult, SubmitTxResult } from \"./common/types\";\nimport {\n useCreateDeltaOrder,\n type CreateDeltaOrderInput,\n} from \"../prices/delta/mutations/useCreateDeltaOrder\";\nimport { useMinViemClient } from \"@/hooks/useMinViemClient\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useRef } from \"react\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { UserCancelledError } from \"./common/errors\";\nimport type {\n CallsSentObject,\n TxSentObject,\n} from \"@/lib/utils/transactionHandlers\";\nimport { useApproveOrPermit } from \"./common/useApproveOrPermit\";\n\nimport { useLogger } from \"@/core/logger\";\n\nimport { usePartner } from \"@/hooks/usePartner\";\nimport { useLimitDeadline } from \"@/core/limit/state/deadlineAtom\";\nimport {\n useCancelDeltaOrderEventCallbacks,\n useCancelDeltaOrders,\n} from \"../prices/delta/mutations/useCancelDeltaOrders\";\nimport { getOverallOrderStatus } from \"../prices/delta/orders/utils\";\nimport {\n deltaAuctionPollingQueryKey,\n useWatchDeltaAuction,\n type MaybeVeloraDeltaAuction,\n} from \"../prices/delta/queries/useWatchDeltaOrder\";\nimport { useWidgetEvents } from \"@/core/state/widgetEventsAtom\";\nimport {\n shouldApproveOrBatch,\n usePreSignAndSubmitDeltaOrder,\n} from \"./common/usePreSignAndSubmitDeltaOrder\";\nimport type { BridgePrice, DeltaOrderApiResponse } from \"@velora-dex/sdk\";\nimport { DEFAULT_DELTA_BRIDGE } from \"../prices/delta/bridge/const\";\nimport { useLimitReceiverAddressValue } from \"@/core/limit/state/receiverAddressAtom\";\nimport { useChainMatches } from \"@/hooks/useChainMatches\";\nimport { useSwitchChainWithGuard } from \"@/hooks/useSwitchChainWithGuard\";\n\nconst limitOrderFlowType = \"limitOrder\";\n\nexport type UserDefinedLimitPrice = {\n srcTokenAddress: string;\n destTokenAddress: string;\n srcAmount: string;\n destAmount: string;\n bridgePrice?: BridgePrice;\n};\n\nexport type UseLimitOrderFlowInput = {\n limitPrice?: UserDefinedLimitPrice;\n preWrapETH?: boolean;\n};\n\nexport type SubmitLimitOrderResult = {\n tradeFlowType: typeof limitOrderFlowType;\n approve: SubmitTxResult;\n limitOrder: {\n sentOrder: SubmittedDeltaOrderFromAPI;\n };\n limitPrice: UserDefinedLimitPrice;\n account: Address;\n receiverAddress?: Address;\n};\n\ntype OnTxSent = (txSent: TxSentObject | CallsSentObject) => void;\n\ntype RunLimitOrderOptions = {\n onTxSent?: OnTxSent;\n};\n\nexport type UseLimitOrderFlowResult = {\n tradeFlowType: typeof limitOrderFlowType;\n chainId: SupportedChainId;\n runLimitOrderFlow: (\n options?: RunLimitOrderOptions\n ) => Promise<SubmitLimitOrderResult>;\n reset: () => void; // reset on Error to retry\n cancelFlow: () => void; // cancel flow\n retryFlow: (\n options?: RunLimitOrderOptions\n ) => Promise<SubmitLimitOrderResult>; // reset and retry flow\n cancelLimitOrder: () => void;\n approval: ApprovalFlowResult;\n limitOrderSubmission: {\n order?: SubmittedDeltaOrderFromAPI;\n isCreatingOrder: boolean;\n isOrderSent: boolean;\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n error: Error | null;\n };\n limitOrderExecution: {\n sentOrder?: SubmittedDeltaOrderFromAPI;\n lastOrderState?: MaybeVeloraDeltaAuction;\n isOrderPending: boolean;\n isOrderExecuting: boolean;\n isOrderExecuted: boolean;\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n error: Error | null;\n };\n limitOrderCancelation: {\n isCancelingOrder: boolean;\n isOrderCanceled: boolean;\n isPending: boolean;\n isError: boolean;\n isSuccess: boolean;\n error: Error | null;\n };\n isPending: boolean;\n isSuccess: boolean;\n isError: boolean;\n error: Error | null;\n result?: SubmitLimitOrderResult;\n limitPrice?: UserDefinedLimitPrice;\n};\n\nconst LIMIT_ORDER_MUTATION_KEY = \"runLimitOrderFlow\";\n\nexport function useLimitOrderFlow({\n limitPrice,\n preWrapETH,\n}: UseLimitOrderFlowInput): UseLimitOrderFlowResult {\n const logger = useLogger(\"LimitOrderFlow\");\n const chainId = useChainId();\n const queryClient = useQueryClient();\n\n /* Inside useApproveOrPermit:\n 1. Get allowance for tokenFrom \n 2.1. submit Approve tx if necessary \n\n 3. await Approve tx\n */\n\n const {\n approval,\n approveTxMut,\n events: approveOrPermitEvents,\n } = useApproveOrPermit({\n srcToken: limitPrice?.srcTokenAddress,\n srcAmount: limitPrice?.srcAmount,\n spenderContractType: \"ParaswapDelta\",\n swapSide: \"SELL\",\n tradeMode: \"limit\",\n });\n\n /* 4.1. Build and Submit Delta Order */\n\n const { address: account } = useAccount();\n\n const { minClient } = useMinViemClient({\n chainId,\n account,\n });\n\n const createOrderMut = useCreateDeltaOrder({\n chainId,\n account,\n client: minClient,\n mutationOptions: {\n onSuccess: (order) => {\n logger.log(\"Create Limit Order success\", order);\n },\n onError: (error) => {\n logger.error(\"Create Limit Order error\", error);\n },\n },\n });\n\n const limitOrderCreateAndSubmit: UseLimitOrderFlowResult[\"limitOrderSubmission\"] =\n {\n order: createOrderMut.data,\n isCreatingOrder: createOrderMut.isPending,\n isOrderSent: createOrderMut.isSuccess,\n isPending: createOrderMut.isPending,\n isError: createOrderMut.isError,\n isSuccess: createOrderMut.isSuccess,\n error: createOrderMut.error,\n };\n\n /* 4.2.\n 1. submit Batch tx (Approve + Delta pre-sign)\n 2. await Batch tx\n 3. post Pre-signed Order\n */\n\n const {\n deltaOrderPreSign,\n canBatchTxs,\n isConnectedToSafe,\n preSignAndSubmitDeltaOrder,\n reset: resetPreSignAndSubmitDeltaOrder,\n } = usePreSignAndSubmitDeltaOrder({\n chainId,\n account,\n logger,\n viemClient: minClient,\n });\n\n /* final Delta Order submission for step 4 */\n const limitOrderSubmission: UseLimitOrderFlowResult[\"limitOrderSubmission\"] =\n {\n order: limitOrderCreateAndSubmit.order || deltaOrderPreSign.order,\n isCreatingOrder:\n limitOrderCreateAndSubmit.isPending ||\n deltaOrderPreSign.isCreatingOrder,\n isOrderSent:\n limitOrderCreateAndSubmit.isSuccess || deltaOrderPreSign.isOrderSent,\n isPending:\n limitOrderCreateAndSubmit.isPending || deltaOrderPreSign.isPending,\n isError: limitOrderCreateAndSubmit.isError || deltaOrderPreSign.isError,\n isSuccess:\n limitOrderCreateAndSubmit.isSuccess || deltaOrderPreSign.isSuccess,\n error: limitOrderCreateAndSubmit.error || deltaOrderPreSign.error,\n };\n\n const watchOrderExecution = useWatchDeltaAuction({\n orderId: limitOrderSubmission.order?.id,\n onAuctionSuccess: (order) => {\n logger.log(\"Limit Order success\", order);\n },\n onAuctionFailure: (order) => {\n logger.log(\"Limit Order failure\", order);\n },\n onUpdatedAuction: (order) => {\n logger.log(\"Limit Order updated\", order);\n },\n onTimeoutGettingOrder: (order) => {\n logger.log(\"Limit Order timeout\", order);\n },\n });\n\n const orderStatus = watchOrderExecution.data\n ? getOverallOrderStatus(watchOrderExecution.data)\n : null;\n\n // refetching stops after one minute of not finding an order (order==null)\n const neverFetchedFinishedOrder =\n watchOrderExecution.data === null && watchOrderExecution.isSuccess;\n\n const limitOrderExecution: UseLimitOrderFlowResult[\"limitOrderExecution\"] = {\n sentOrder: createOrderMut.data,\n lastOrderState: watchOrderExecution.data,\n isOrderPending: orderStatus === \"pending\",\n isOrderExecuting: orderStatus === \"executing\",\n isOrderExecuted: orderStatus === \"confirmed\",\n isPending:\n watchOrderExecution.isLoading ||\n watchOrderExecution.isRefetching ||\n orderStatus === \"pending\" ||\n orderStatus === \"executing\",\n isError:\n watchOrderExecution.isError ||\n orderStatus === \"failed\" ||\n neverFetchedFinishedOrder,\n isSuccess: orderStatus === \"confirmed\",\n error: watchOrderExecution.error,\n };\n\n const cancelOrderEvents = useCancelDeltaOrderEventCallbacks(\n createOrderMut.data\n );\n\n const orderChainId = createOrderMut.data?.chainId as\n | SupportedChainId\n | undefined;\n const { forcedChainMatchesWalletChain } = useChainMatches(orderChainId);\n const { mutateAsync: switchChain } = useSwitchChainWithGuard();\n\n const cancelOrderMut = useCancelDeltaOrders({\n chainId,\n account,\n client: minClient,\n mutationOptions: {\n onMutate: async (variables) => {\n assert(orderChainId, \"orderChainId is undefined\");\n if (!forcedChainMatchesWalletChain) {\n await switchChain({\n chainId: orderChainId,\n });\n }\n cancelOrderEvents.onMutate?.(variables);\n },\n onSuccess: (successResponse, vars) => {\n logger.log(\"Cancel Limit Order success\", successResponse);\n if (limitOrderExecution.sentOrder?.id) {\n // refetch the order to get updated status\n queryClient.invalidateQueries({\n queryKey: deltaAuctionPollingQueryKey({\n orderId: limitOrderExecution.sentOrder.id,\n }),\n });\n }\n cancelOrderEvents.onSuccess?.(successResponse, vars);\n },\n onError: (error, vars) => {\n logger.error(\"Cancel Limit Order error\", error);\n cancelOrderEvents.onError?.(error, vars);\n },\n },\n });\n\n const limitOrderCancelation: UseLimitOrderFlowResult[\"limitOrderCancelation\"] =\n {\n isCancelingOrder: cancelOrderMut.isPending,\n isOrderCanceled:\n cancelOrderMut.isSuccess && !!cancelOrderMut.data?.success,\n isPending: cancelOrderMut.isPending,\n isError: cancelOrderMut.isError,\n isSuccess: cancelOrderMut.isSuccess,\n error: cancelOrderMut.error,\n };\n\n const ensureTxReceipt = useEnsureTxReceipt();\n\n const currentAbortControllerRef = useRef<AbortController | null>(null);\n\n const cancelFlow = () => {\n currentAbortControllerRef.current?.abort(new UserCancelledError());\n currentAbortControllerRef.current = null;\n };\n\n const partner = usePartner();\n const receiverAddress = useLimitReceiverAddressValue();\n const deadline = useLimitDeadline();\n\n const { onLimitOrder } = useWidgetEvents();\n\n const submitLimitOrder = async ({\n onTxSent,\n }: RunLimitOrderOptions = {}): Promise<SubmitLimitOrderResult> => {\n // reset all mutations except the current one,\n // otherwise we'll have previous data (txs) as mutation results\n approveTxMut.reset();\n createOrderMut.reset();\n cancelOrderMut.reset();\n resetPreSignAndSubmitDeltaOrder();\n\n // no sense in starting flow without a price data,\n // Otherwise this flow will be stopped by disabling ReviewOrder button in the first place\n assert(limitPrice, \"Limit price data is not available\");\n\n const abortController = new AbortController();\n currentAbortControllerRef.current = abortController;\n\n const signal = abortController.signal;\n\n let approveTxHash: Hash | undefined;\n let approveTxReceipt: TransactionReceipt | undefined;\n\n // at this point this is the syncronously available price\n const allowanceToSet = approval.allowanceToSet;\n\n /* \n if connected to Safe, or needs to approve a token with a tx, or needs to pre-wrap ETH\n and can batch txs, then pre-sign the batch;\n that way Safe does only one action (wrapETH?+Approve+setPreSignature batch tx)\n and a wallet that would otherwise potentially wrap ETH and then Approve Token (tx, no Permit for Limit Orders)\n and then sign Order, basically has to make at least one tx, does only one action as well.\n */\n const {\n shouldDoApprovalTxOrPermit: shouldDoApprovalTx,\n shouldPreSignBatch,\n } = shouldApproveOrBatch({\n approval,\n preWrapETH,\n signPermit: {\n isPermitSupported: false,\n isPermitReadyToSign: false,\n },\n canBatchTxs,\n isConnectedToSafe,\n });\n\n try {\n if (shouldDoApprovalTx && allowanceToSet) {\n try {\n approveOrPermitEvents.onApproveTx.request({ allowanceToSet });\n\n approveTxHash = await approveTxMut.approveAsync({\n allowanceData: {\n allowanceToSet,\n },\n });\n\n approveOrPermitEvents.onApproveTx.sent({\n allowanceToSet,\n txHash: approveTxHash,\n });\n\n // if aborted by this point, throw an error\n signal.throwIfAborted();\n\n const approveTxReceiptPromise = ensureTxReceipt({\n hash: approveTxHash,\n chainId,\n onReplaced: (data) => {\n logger.log(\"onReplaced:approveTx\", approveTxHash, data);\n },\n });\n\n if (onTxSent) {\n onTxSent({\n chainId,\n action: \"approve\",\n transactionHash: approveTxHash,\n receiptPromise: approveTxReceiptPromise,\n transactionSpecificData: {\n action: \"approve\",\n approvedAmount: allowanceToSet,\n tokenAddress: approval.token as Address,\n spenderAddress: approval.spender as Address,\n },\n });\n }\n\n approveTxReceipt = await approveTxReceiptPromise;\n\n approveOrPermitEvents.onApproveTx.confirmed({\n allowanceToSet,\n txHash: approveTxHash,\n txReceipt: approveTxReceipt,\n });\n\n logger.log(\"~ approveTx ~ receipt:\", approveTxReceipt);\n // @TODO check if we need to see if receipt.status === \"reverted\" and throw,\n // or if waitForTransactionReceipt already throws on such receipts\n } catch (error) {\n approveOrPermitEvents.onApproveTx.failed({\n allowanceToSet,\n error: error as Error,\n txHash: approveTxHash, // won't necessarily be available\n });\n throw error;\n }\n }\n\n // if aborted by this point, throw an error\n signal.throwIfAborted();\n\n assert(account, \"Account is not connected\");\n\n assert(limitPrice, \"limitPrice is not available\");\n\n onLimitOrder?.({\n event: {\n name: \"LimitOrder:request\",\n params: {\n price: limitPrice,\n },\n },\n });\n const bridgePrice = limitPrice.bridgePrice;\n const destChainId = bridgePrice?.bridge.destinationChainId;\n\n let createOrderInput: CreateDeltaOrderInput;\n if (bridgePrice) {\n // crosschain order\n createOrderInput = {\n signal,\n type: \"LIMIT\",\n orderInput: {\n owner: account,\n beneficiary: receiverAddress,\n srcToken: limitPrice.srcTokenAddress,\n destToken: limitPrice.destTokenAddress,\n srcAmount: limitPrice.srcAmount,\n destAmount: limitPrice.destAmount,\n destChainId,\n deltaPrice: {\n ...bridgePrice,\n bridge: {\n ...bridgePrice.bridge,\n protocolSelector: DEFAULT_DELTA_BRIDGE.protocolSelector,\n protocolData: DEFAULT_DELTA_BRIDGE.protocolData,\n },\n partner,\n partnerFee: 0,\n },\n partner,\n deadline,\n },\n };\n } else {\n // singlechain order\n createOrderInput = {\n signal,\n type: \"LIMIT\",\n orderInput: {\n owner: account,\n beneficiary: receiverAddress,\n srcToken: limitPrice.srcTokenAddress,\n srcAmount: limitPrice.srcAmount,\n destToken: limitPrice.destTokenAddress,\n destAmount: limitPrice.destAmount,\n destChainId,\n deltaPrice: {\n destToken: limitPrice.destTokenAddress,\n destAmount: limitPrice.destAmount,\n srcAmount: limitPrice.srcAmount,\n bridge: DEFAULT_DELTA_BRIDGE,\n partner,\n partnerFee: 0,\n },\n partner,\n deadline,\n },\n };\n }\n\n let orderFromAPI: DeltaOrderApiResponse;\n\n if (!shouldPreSignBatch) {\n // creating signing and POSTing the Order all together in one mutation\n orderFromAPI = await createOrderMut.mutateAsync(createOrderInput);\n } else {\n // prepare Order for pre-signing and POSTing:\n // 1. builds the order\n // 2. hashes the built order\n // 3. construct DeltaContract.setPreSignature(orderHash, true) tx calldata\n\n orderFromAPI = await preSignAndSubmitDeltaOrder({\n createDeltaOrderInput: createOrderInput,\n approval,\n preWrapETH,\n onTxSent,\n });\n }\n\n onLimitOrder?.({\n event: {\n name: \"LimitOrder:sent\",\n params: {\n price: limitPrice,\n order: orderFromAPI,\n },\n },\n });\n\n return {\n tradeFlowType: limitOrderFlowType,\n approve: {\n txHash: approveTxHash,\n receipt: approveTxReceipt,\n },\n limitOrder: {\n sentOrder: orderFromAPI,\n },\n limitPrice: limitPrice,\n account,\n receiverAddress,\n };\n } catch (error) {\n logger.error(\"Order submission error\", error);\n onLimitOrder?.({\n event: {\n name: \"LimitOrder:failed\",\n params: {\n price: limitPrice,\n error: error as Error,\n },\n },\n });\n throw error;\n }\n };\n\n const cancelLimitOrder = () => {\n assert(createOrderMut.data, \"No order to cancel\");\n cancelOrderMut.mutate({\n orderIds: [createOrderMut.data.id],\n });\n };\n\n const limitOrderMut = useMutation({\n mutationFn: submitLimitOrder,\n mutationKey: [LIMIT_ORDER_MUTATION_KEY],\n onSuccess: (data) => {\n logger.log(\"Order submission success\", data);\n },\n onError: (error) => {\n logger.error(\"Order submission error\", error);\n },\n onSettled: () => {\n logger.log(\"Order submission settled\");\n },\n });\n\n const runLimitOrderFlow = limitOrderMut.mutateAsync;\n\n const reset = () => {\n approveTxMut.reset();\n createOrderMut.reset();\n limitOrderMut.reset();\n cancelOrderMut.reset();\n resetPreSignAndSubmitDeltaOrder();\n };\n\n const retryFlow = (\n options?: RunLimitOrderOptions\n ): Promise<SubmitLimitOrderResult> => {\n reset();\n return runLimitOrderFlow(options);\n };\n\n /* 5. return result */\n return {\n tradeFlowType: limitOrderFlowType,\n chainId,\n runLimitOrderFlow,\n reset,\n cancelFlow,\n retryFlow,\n cancelLimitOrder,\n approval,\n limitOrderSubmission,\n limitOrderExecution,\n limitOrderCancelation,\n // deltaOrderMut includes all steps' queries and mutations and returns more precise errors (including cancellation)\n isPending: limitOrderMut.isPending,\n isSuccess: limitOrderSubmission.isSuccess, // approval is an optional step\n isError: limitOrderMut.isError,\n error: limitOrderMut.error,\n result: limitOrderMut.data,\n limitPrice,\n };\n}\n"],"names":["limitOrderFlowType","LIMIT_ORDER_MUTATION_KEY","useLimitOrderFlow","limitPrice","preWrapETH","logger","useLogger","chainId","useChainId","queryClient","useQueryClient","approval","approveTxMut","events","approveOrPermitEvents","useApproveOrPermit","srcToken","srcTokenAddress","srcAmount","spenderContractType","swapSide","tradeMode","address","account","useAccount","minClient","useMinViemClient","createOrderMut","useCreateDeltaOrder","client","mutationOptions","onSuccess","order","log","onError","error","limitOrderCreateAndSubmit","data","isCreatingOrder","isPending","isOrderSent","isSuccess","isError","deltaOrderPreSign","canBatchTxs","isConnectedToSafe","preSignAndSubmitDeltaOrder","reset","resetPreSignAndSubmitDeltaOrder","usePreSignAndSubmitDeltaOrder","viemClient","limitOrderSubmission","watchOrderExecution","useWatchDeltaAuction","orderId","id","onAuctionSuccess","onAuctionFailure","onUpdatedAuction","onTimeoutGettingOrder","orderStatus","getOverallOrderStatus","neverFetchedFinishedOrder","limitOrderExecution","sentOrder","lastOrderState","isOrderPending","isOrderExecuting","isOrderExecuted","isLoading","isRefetching","cancelOrderEvents","useCancelDeltaOrderEventCallbacks","orderChainId","forcedChainMatchesWalletChain","useChainMatches","mutateAsync","switchChain","useSwitchChainWithGuard","cancelOrderMut","useCancelDeltaOrders","onMutate","variables","assert","successResponse","vars","invalidateQueries","queryKey","deltaAuctionPollingQueryKey","limitOrderCancelation","isCancelingOrder","isOrderCanceled","success","ensureTxReceipt","useEnsureTxReceipt","currentAbortControllerRef","useRef","cancelFlow","current","abort","UserCancelledError","partner","usePartner","receiverAddress","useLimitReceiverAddressValue","deadline","useLimitDeadline","onLimitOrder","useWidgetEvents","submitLimitOrder","onTxSent","abortController","AbortController","signal","approveTxHash","approveTxReceipt","allowanceToSet","shouldDoApprovalTxOrPermit","shouldDoApprovalTx","shouldPreSignBatch","shouldApproveOrBatch","signPermit","isPermitSupported","isPermitReadyToSign","onApproveTx","request","approveAsync","allowanceData","sent","txHash","throwIfAborted","approveTxReceiptPromise","hash","onReplaced","action","transactionHash","receiptPromise","transactionSpecificData","approvedAmount","tokenAddress","token","spenderAddress","spender","confirmed","txReceipt","failed","event","name","params","price","bridgePrice","destChainId","bridge","destinationChainId","createOrderInput","type","orderInput","owner","beneficiary","destToken","destTokenAddress","destAmount","deltaPrice","protocolSelector","DEFAULT_DELTA_BRIDGE","protocolData","partnerFee","orderFromAPI","createDeltaOrderInput","tradeFlowType","approve","receipt","limitOrder","cancelLimitOrder","mutate","orderIds","limitOrderMut","useMutation","mutationFn","mutationKey","onSettled","runLimitOrderFlow","retryFlow","options","result"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAMA,kBAAAA,GAAqB,YAAA;AAiF3B,MAAMC,wBAAAA,GAA2B,mBAAA;AAE1B,SAASC,iBAAAA,CAAkB;AAAA,EAChCC,UAAAA;AAAAA,EACAC;AACsB,CAAA,EAA4B;AAClD,EAAA,MAAMC,MAAAA,GAASC,UAAU,gBAAgB,CAAA;AACzC,EAAA,MAAMC,UAAUC,UAAAA,EAAW;AAC3B,EAAA,MAAMC,cAAcC,cAAAA,EAAe;AASnC,EAAA,MAAM;AAAA,IACJC,QAAAA;AAAAA,IACAC,YAAAA;AAAAA,IACAC,MAAAA,EAAQC;AAAAA,MACNC,kBAAAA,CAAmB;AAAA,IACrBC,UAAUb,UAAAA,EAAYc,eAAAA;AAAAA,IACtBC,WAAWf,UAAAA,EAAYe,SAAAA;AAAAA,IACvBC,mBAAAA,EAAqB,eAAA;AAAA,IACrBC,QAAAA,EAAU,MAAA;AAAA,IACVC,SAAAA,EAAW;AAAA,GACZ,CAAA;AAID,EAAA,MAAM;AAAA,I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AAAA,KACoC;AACpCxI,IAAAA,KAAAA,EAAM;AACN,IAAA,OAAOsI,kBAAkBE,OAAO,CAAA;AAAA,EAClC,CAAA;AAGA,EAAA,OAAO;AAAA,IACLd,aAAAA,EAAezK,kBAAAA;AAAAA,IACfO,OAAAA;AAAAA,IACA8K,iBAAAA;AAAAA,IACAtI,KAAAA;AAAAA,IACAkD,UAAAA;AAAAA,IACAqF,SAAAA;AAAAA,IACAT,gBAAAA;AAAAA,IACAlK,QAAAA;AAAAA,IACAwC,oBAAAA;AAAAA,IACAY,mBAAAA;AAAAA,IACA0B,qBAAAA;AAAAA;AAAAA,IAEAlD,WAAWyI,aAAAA,CAAczI,SAAAA;AAAAA,IACzBE,WAAWU,oBAAAA,CAAqBV,SAAAA;AAAAA;AAAAA,IAChCC,SAASsI,aAAAA,CAActI,OAAAA;AAAAA,IACvBP,OAAO6I,aAAAA,CAAc7I,KAAAA;AAAAA,IACrBqJ,QAAQR,aAAAA,CAAc3I,IAAAA;AAAAA,IACtBlC;AAAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAwaitTx.d.ts","sourceRoot":"","sources":["../../../../src/hooks/txs/queries/useAwaitTx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAGL,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,EAC5C,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"useAwaitTx.d.ts","sourceRoot":"","sources":["../../../../src/hooks/txs/queries/useAwaitTx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAGL,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,EAC5C,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;AAIhD,MAAM,MAAM,oBAAoB,CAAC,UAAU,GAAG,sBAAsB,IAAI;IACtE,OAAO,EAAE,gBAAgB,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,sCAAsC,CAC5C,OAAO,WAAW,EAClB,gBAAgB,EAChB,UAAU,CACX,CAAC,OAAO,CAAC,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,CAChE,OAAO,WAAW,EAClB,gBAAgB,CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,UAAU,GAAG,sBAAsB,IAClE,sCAAsC,CACpC,OAAO,WAAW,EAClB,gBAAgB,EAChB,UAAU,CACX,CAAC;AAEJ,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAExD,wBAAgB,UAAU,CAAC,UAAU,GAAG,sBAAsB,EAAE,EAC9D,OAAO,EACP,aAAa,EACb,IAAI,EACJ,KAAK,GACN,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,oBAAoB,CAAC,UAAU,CAAC,CA2BrE;AAED,wBAAgB,kBAAkB,IAAI,iBAAiB,CAMtD"}
|
|
@@ -5,9 +5,10 @@ import 'wagmi/query';
|
|
|
5
5
|
import { useLogger } from '../../../core/logger.js';
|
|
6
6
|
import { ensureTxReceiptFactory } from '../../../transactions/queries/ensureTxReceipt.js';
|
|
7
7
|
import { useConnectedSafe } from '../../connectors/useIsConnectedSafe.js';
|
|
8
|
+
import { SAFE_CALLS_WAIT_TIMEOUT } from '../../../lib/constants/index.js';
|
|
8
9
|
|
|
9
10
|
function useAwaitTx(t0) {
|
|
10
|
-
const $ = distExports.c(
|
|
11
|
+
const $ = distExports.c(10);
|
|
11
12
|
const {
|
|
12
13
|
chainId,
|
|
13
14
|
confirmations,
|
|
@@ -15,6 +16,8 @@ function useAwaitTx(t0) {
|
|
|
15
16
|
query
|
|
16
17
|
} = t0;
|
|
17
18
|
const logger = useLogger("AwaitTx");
|
|
19
|
+
const isSafe = useConnectedSafe();
|
|
20
|
+
const timeout = isSafe ? SAFE_CALLS_WAIT_TIMEOUT : void 0;
|
|
18
21
|
let t1;
|
|
19
22
|
if ($[0] !== hash || $[1] !== logger) {
|
|
20
23
|
t1 = (data) => {
|
|
@@ -27,10 +30,11 @@ function useAwaitTx(t0) {
|
|
|
27
30
|
t1 = $[2];
|
|
28
31
|
}
|
|
29
32
|
let t2;
|
|
30
|
-
if ($[3] !== chainId || $[4] !== confirmations || $[5] !== hash || $[6] !== query || $[7] !== t1) {
|
|
33
|
+
if ($[3] !== chainId || $[4] !== confirmations || $[5] !== hash || $[6] !== query || $[7] !== t1 || $[8] !== timeout) {
|
|
31
34
|
t2 = {
|
|
32
35
|
chainId,
|
|
33
36
|
confirmations,
|
|
37
|
+
timeout,
|
|
34
38
|
hash,
|
|
35
39
|
query,
|
|
36
40
|
onReplaced: t1
|
|
@@ -40,9 +44,10 @@ function useAwaitTx(t0) {
|
|
|
40
44
|
$[5] = hash;
|
|
41
45
|
$[6] = query;
|
|
42
46
|
$[7] = t1;
|
|
43
|
-
$[8] =
|
|
47
|
+
$[8] = timeout;
|
|
48
|
+
$[9] = t2;
|
|
44
49
|
} else {
|
|
45
|
-
t2 = $[
|
|
50
|
+
t2 = $[9];
|
|
46
51
|
}
|
|
47
52
|
const queryResult = useWaitForTransactionReceipt(t2);
|
|
48
53
|
return queryResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAwaitTx.js","sources":["../../../../src/hooks/txs/queries/useAwaitTx.ts"],"sourcesContent":["import type { wagmiConfig } from \"@/lib/web3/wagmi/config\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n useConfig,\n useWaitForTransactionReceipt,\n type UseWaitForTransactionReceiptParameters,\n type UseWaitForTransactionReceiptReturnType,\n} from \"wagmi\";\nimport { type WaitForTransactionReceiptData } from \"wagmi/query\";\nimport { useLogger } from \"@/core/logger\";\nimport {\n ensureTxReceiptFactory,\n type EnsureTxReceiptFn,\n} from \"@/transactions/queries/ensureTxReceipt\";\nimport { useConnectedSafe } from \"@/hooks/connectors/useIsConnectedSafe\";\n\nexport type UseAwaitTxParameters<SelectData = DefaultTxReceiptSelect> = {\n chainId: SupportedChainId;\n confirmations?: number;\n hash?: `0x${string}`;\n query?: UseWaitForTransactionReceiptParameters<\n typeof wagmiConfig,\n SupportedChainId,\n SelectData\n >[\"query\"];\n};\n\nexport type DefaultTxReceiptSelect = WaitForTransactionReceiptData<\n typeof wagmiConfig,\n SupportedChainId\n>;\n\nexport type UseAwaitTxReturnType<SelectData = DefaultTxReceiptSelect> =\n UseWaitForTransactionReceiptReturnType<\n typeof wagmiConfig,\n SupportedChainId,\n SelectData\n >;\n\nexport type TxReceiptFromWagmi = DefaultTxReceiptSelect;\n\nexport function useAwaitTx<SelectData = DefaultTxReceiptSelect>({\n chainId,\n confirmations,\n hash,\n query,\n}: UseAwaitTxParameters<SelectData>): UseAwaitTxReturnType<SelectData> {\n const logger = useLogger(\"AwaitTx\");\n const queryResult = useWaitForTransactionReceipt<\n typeof wagmiConfig,\n SupportedChainId,\n SelectData\n >({\n chainId,\n confirmations,\n hash,\n query,\n onReplaced: (data) => {\n // @TODO connect to some atom if needed to detect cancelled/sped-up txs,\n // but sped-up txs may be detected correct internally and re-awaited with a new hash,\n // need to test\n // https://viem.sh/docs/actions/public/waitForTransactionReceipt.html#json-rpc-methods\n logger.log(\"onReplaced:tx\", hash, data);\n },\n });\n\n return queryResult;\n}\n\nexport function useEnsureTxReceipt(): EnsureTxReceiptFn {\n const queryClient = useQueryClient();\n const wagmiConfig = useConfig();\n const isSafe = useConnectedSafe();\n\n return ensureTxReceiptFactory({ queryClient, wagmiConfig, isSafe });\n}\n"],"names":["useAwaitTx","t0","$","_c","chainId","confirmations","hash","query","logger","useLogger","t1","data","log","t2","onReplaced","queryResult","useWaitForTransactionReceipt","useEnsureTxReceipt","queryClient","useQueryClient","wagmiConfig","useConfig","
|
|
1
|
+
{"version":3,"file":"useAwaitTx.js","sources":["../../../../src/hooks/txs/queries/useAwaitTx.ts"],"sourcesContent":["import type { wagmiConfig } from \"@/lib/web3/wagmi/config\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n useConfig,\n useWaitForTransactionReceipt,\n type UseWaitForTransactionReceiptParameters,\n type UseWaitForTransactionReceiptReturnType,\n} from \"wagmi\";\nimport { type WaitForTransactionReceiptData } from \"wagmi/query\";\nimport { useLogger } from \"@/core/logger\";\nimport {\n ensureTxReceiptFactory,\n type EnsureTxReceiptFn,\n} from \"@/transactions/queries/ensureTxReceipt\";\nimport { useConnectedSafe } from \"@/hooks/connectors/useIsConnectedSafe\";\nimport { SAFE_CALLS_WAIT_TIMEOUT } from \"@/lib/constants\";\n\nexport type UseAwaitTxParameters<SelectData = DefaultTxReceiptSelect> = {\n chainId: SupportedChainId;\n confirmations?: number;\n hash?: `0x${string}`;\n query?: UseWaitForTransactionReceiptParameters<\n typeof wagmiConfig,\n SupportedChainId,\n SelectData\n >[\"query\"];\n};\n\nexport type DefaultTxReceiptSelect = WaitForTransactionReceiptData<\n typeof wagmiConfig,\n SupportedChainId\n>;\n\nexport type UseAwaitTxReturnType<SelectData = DefaultTxReceiptSelect> =\n UseWaitForTransactionReceiptReturnType<\n typeof wagmiConfig,\n SupportedChainId,\n SelectData\n >;\n\nexport type TxReceiptFromWagmi = DefaultTxReceiptSelect;\n\nexport function useAwaitTx<SelectData = DefaultTxReceiptSelect>({\n chainId,\n confirmations,\n hash,\n query,\n}: UseAwaitTxParameters<SelectData>): UseAwaitTxReturnType<SelectData> {\n const logger = useLogger(\"AwaitTx\");\n\n const isSafe = useConnectedSafe();\n\n const timeout = isSafe ? SAFE_CALLS_WAIT_TIMEOUT : undefined;\n\n const queryResult = useWaitForTransactionReceipt<\n typeof wagmiConfig,\n SupportedChainId,\n SelectData\n >({\n chainId,\n confirmations,\n timeout,\n hash,\n query,\n onReplaced: (data) => {\n // @TODO connect to some atom if needed to detect cancelled/sped-up txs,\n // but sped-up txs may be detected correct internally and re-awaited with a new hash,\n // need to test\n // https://viem.sh/docs/actions/public/waitForTransactionReceipt.html#json-rpc-methods\n logger.log(\"onReplaced:tx\", hash, data);\n },\n });\n\n return queryResult;\n}\n\nexport function useEnsureTxReceipt(): EnsureTxReceiptFn {\n const queryClient = useQueryClient();\n const wagmiConfig = useConfig();\n const isSafe = useConnectedSafe();\n\n return ensureTxReceiptFactory({ queryClient, wagmiConfig, isSafe });\n}\n"],"names":["useAwaitTx","t0","$","_c","chainId","confirmations","hash","query","logger","useLogger","isSafe","useConnectedSafe","timeout","SAFE_CALLS_WAIT_TIMEOUT","undefined","t1","data","log","t2","onReplaced","queryResult","useWaitForTransactionReceipt","useEnsureTxReceipt","queryClient","useQueryClient","wagmiConfig","useConfig","ensureTxReceiptFactory"],"mappings":";;;;;;;;;AA2CO,SAAAA,WAAAC,EAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,EAAA,CAAA;AAAyD,EAAA,MAAA;AAAA,IAAAC,OAAAA;AAAAA,IAAAC,aAAAA;AAAAA,IAAAC,IAAAA;AAAAA,IAAAC;AAAAA,GAAA,GAAAN,EAAAA;AAM9D,EAAA,MAAAO,MAAAA,GAAeC,UAAU,SAAS,CAAA;AAElC,EAAA,MAAAC,SAAeC,gBAAA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,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAhB,EAAA,CAAA,CAAA;AAAA,EAAA;AAjBD,EAAA,MAAAkB,WAAAA,GAAoBC,6BAIlBH,EAaD,CAAA;AAAE,EAAA,OAEIE,WAAAA;AAAW;AAGb,SAAAE,kBAAAA,GAAA;AAAA,EAAA,MAAApB,CAAAA,GAAAC,cAAA,CAAA,CAAA;AACL,EAAA,MAAAoB,cAAoBC,cAAAA,EAAe;AACnC,EAAA,MAAAC,cAAoBC,SAAAA,EAAU;AAC9B,EAAA,MAAAhB,SAAeC,gBAAAA,EAAiB;AAAE,EAAA,IAAAV,EAAAA;AAAA,EAAA,IAAAC,CAAAA,CAAA,CAAA,CAAA,KAAAQ,MAAAA,IAAAR,CAAAA,QAAAqB,WAAAA,IAAArB,CAAAA,CAAA,CAAA,CAAA,KAAAuB,WAAAA,EAAA;AAE3BxB,IAAAA,EAAAA,GAAA0B,sBAAAA,CAAuB;AAAA,MAAAJ,WAAAA;AAAAA,MAAAE,WAAAA;AAAAA,MAAAf;AAAAA,KAAoC,CAAA;AAACR,IAAAA,CAAAA,MAAAQ,MAAAA;AAAAR,IAAAA,CAAAA,MAAAqB,WAAAA;AAAArB,IAAAA,CAAAA,MAAAuB,WAAAA;AAAAvB,IAAAA,CAAAA,MAAAD,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAC,EAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OAA5DD,EAAAA;AAA4D;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SupportedChainId } from '../lib/web3/wagmi/types';
|
|
2
|
+
export declare function useChainMatches(forcedChainId?: SupportedChainId): {
|
|
3
|
+
isConnected: boolean;
|
|
4
|
+
walletChainMatchesAppChain: boolean;
|
|
5
|
+
forcedChainMatchesWalletChain: boolean;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useChainMatches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChainMatches.d.ts","sourceRoot":"","sources":["../../src/hooks/useChainMatches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,wBAAgB,eAAe,CAAC,aAAa,CAAC,EAAE,gBAAgB;;;;EAkB/D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { d as distExports } from '../_virtual/index.js';
|
|
2
|
+
import { useChainId, useAccount } from 'wagmi';
|
|
3
|
+
|
|
4
|
+
function useChainMatches(forcedChainId) {
|
|
5
|
+
const $ = distExports.c(4);
|
|
6
|
+
const appChainId = useChainId();
|
|
7
|
+
const {
|
|
8
|
+
chainId: walletChainId,
|
|
9
|
+
isConnected
|
|
10
|
+
} = useAccount();
|
|
11
|
+
const walletChainMatchesAppChain = isConnected && !!walletChainId && appChainId === walletChainId;
|
|
12
|
+
const forcedChainMatchesWalletChain = isConnected && forcedChainId !== void 0 && walletChainId !== void 0 && forcedChainId === walletChainId;
|
|
13
|
+
let t0;
|
|
14
|
+
if ($[0] !== forcedChainMatchesWalletChain || $[1] !== isConnected || $[2] !== walletChainMatchesAppChain) {
|
|
15
|
+
t0 = {
|
|
16
|
+
isConnected,
|
|
17
|
+
walletChainMatchesAppChain,
|
|
18
|
+
forcedChainMatchesWalletChain
|
|
19
|
+
};
|
|
20
|
+
$[0] = forcedChainMatchesWalletChain;
|
|
21
|
+
$[1] = isConnected;
|
|
22
|
+
$[2] = walletChainMatchesAppChain;
|
|
23
|
+
$[3] = t0;
|
|
24
|
+
} else {
|
|
25
|
+
t0 = $[3];
|
|
26
|
+
}
|
|
27
|
+
return t0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { useChainMatches };
|
|
31
|
+
//# sourceMappingURL=useChainMatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChainMatches.js","sources":["../../src/hooks/useChainMatches.ts"],"sourcesContent":["import type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useAccount, useChainId } from \"wagmi\";\n\nexport function useChainMatches(forcedChainId?: SupportedChainId) {\n const appChainId = useChainId();\n const { chainId: walletChainId, isConnected } = useAccount();\n\n const walletChainMatchesAppChain =\n isConnected && !!walletChainId && appChainId === walletChainId;\n\n const forcedChainMatchesWalletChain =\n isConnected &&\n forcedChainId !== undefined &&\n walletChainId !== undefined &&\n forcedChainId === walletChainId;\n\n return {\n isConnected,\n walletChainMatchesAppChain,\n forcedChainMatchesWalletChain,\n };\n}\n"],"names":["useChainMatches","forcedChainId","$","_c","appChainId","useChainId","chainId","walletChainId","isConnected","useAccount","walletChainMatchesAppChain","forcedChainMatchesWalletChain","undefined","t0"],"mappings":";;;AAGO,SAAAA,gBAAAC,aAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,CAAA,CAAA;AACL,EAAA,MAAAC,aAAmBC,UAAAA,EAAW;AAC9B,EAAA,MAAA;AAAA,IAAAC,OAAAA,EAAAC,aAAAA;AAAAA,IAAAC;AAAAA,MAAgDC,UAAAA,EAAW;AAE3D,EAAA,MAAAC,0BAAAA,GACEF,WAAAA,IAAA,CAAgB,CAACD,iBAAiBH,UAAAA,KAAeG,aAAAA;AAEnD,EAAA,MAAAI,gCACEH,WAAAA,IACAP,aAAAA,KAAkBW,MAAAA,IAClBL,aAAAA,KAAkBK,UAClBX,aAAAA,KAAkBM,aAAAA;AAAc,EAAA,IAAAM,EAAAA;AAAA,EAAA,IAAAX,CAAAA,CAAA,CAAA,CAAA,KAAAS,6BAAAA,IAAAT,CAAAA,QAAAM,WAAAA,IAAAN,CAAAA,CAAA,CAAA,CAAA,KAAAQ,0BAAAA,EAAA;AAE3BG,IAAAA,EAAAA,GAAA;AAAA,MAAAL,WAAAA;AAAAA,MAAAE,0BAAAA;AAAAA,MAAAC;AAAAA,KAIP;AAACT,IAAAA,CAAAA,MAAAS,6BAAAA;AAAAT,IAAAA,CAAAA,MAAAM,WAAAA;AAAAN,IAAAA,CAAAA,MAAAQ,0BAAAA;AAAAR,IAAAA,CAAAA,MAAAW,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAX,EAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OAJMW,EAAAA;AAIN;;;;"}
|
|
@@ -12,5 +12,21 @@ type UseMinViemClientResult = {
|
|
|
12
12
|
isError: boolean;
|
|
13
13
|
};
|
|
14
14
|
export declare function useMinViemClient(options?: UseMinViemClientInput): UseMinViemClientResult;
|
|
15
|
+
/**
|
|
16
|
+
* Keep one subscriber to useConnectorClient query at all times
|
|
17
|
+
* to avoid async client creation on useMinViemClient mount
|
|
18
|
+
* and first useConnectorClient().data being undefined for a short time,
|
|
19
|
+
* which breaks Fill OTC flow which starts from Activities screen
|
|
20
|
+
*/
|
|
21
|
+
export declare function useCacheMinViemClient(): void;
|
|
22
|
+
type UseEnsureConnectorClientResult = {
|
|
23
|
+
ensureViemClient: (options: UseMinViemClientInput) => Promise<MinViemClient>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Returns a function that loads the connector client on demand via
|
|
27
|
+
* queryClient.ensureQueryData and getConnectorClientQueryOptions.
|
|
28
|
+
* Uses current account's chainId and connector when options are omitted.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useEnsureConnectorClient(): UseEnsureConnectorClientResult;
|
|
15
31
|
export {};
|
|
16
32
|
//# sourceMappingURL=useMinViemClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMinViemClient.d.ts","sourceRoot":"","sources":["../../src/hooks/useMinViemClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMinViemClient.d.ts","sourceRoot":"","sources":["../../src/hooks/useMinViemClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKrD,KAAK,qBAAqB,GAAG;IAC3B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAOF,wBAAgB,gBAAgB,CAC9B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,sBAAsB,CAwBxB;AAYD;;;;;GAKG;AACH,wBAAgB,qBAAqB,SAOpC;AAOD,KAAK,8BAA8B,GAAG;IACpC,gBAAgB,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CAC9E,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,8BAA8B,CAgBzE"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { d as distExports } from '../_virtual/index.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { useAccount, useChainId, useConnectorClient, useConfig } from 'wagmi';
|
|
4
5
|
import { signTypedData, writeContract, readContract } from 'viem/actions';
|
|
6
|
+
import { getConnectorClientQueryOptions } from 'wagmi/query';
|
|
5
7
|
|
|
6
8
|
function useMinViemClient(options) {
|
|
7
9
|
const $ = distExports.c(7);
|
|
@@ -19,11 +21,7 @@ function useMinViemClient(options) {
|
|
|
19
21
|
}
|
|
20
22
|
let t12;
|
|
21
23
|
if ($[0] !== connectorClient) {
|
|
22
|
-
t12 =
|
|
23
|
-
readContract: (params) => readContract(connectorClient, params),
|
|
24
|
-
writeContract: (params_0) => writeContract(connectorClient, params_0),
|
|
25
|
-
signTypedData: (params_1) => signTypedData(connectorClient, params_1)
|
|
26
|
-
};
|
|
24
|
+
t12 = constructMinViemClient(connectorClient);
|
|
27
25
|
$[0] = connectorClient;
|
|
28
26
|
$[1] = t12;
|
|
29
27
|
} else {
|
|
@@ -50,6 +48,63 @@ function useMinViemClient(options) {
|
|
|
50
48
|
}
|
|
51
49
|
return t1;
|
|
52
50
|
}
|
|
51
|
+
function constructMinViemClient(connectorClient) {
|
|
52
|
+
return {
|
|
53
|
+
readContract: (params) => readContract(connectorClient, params),
|
|
54
|
+
writeContract: (params) => writeContract(connectorClient, params),
|
|
55
|
+
signTypedData: (params) => signTypedData(connectorClient, params)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function useCacheMinViemClient() {
|
|
59
|
+
const $ = distExports.c(3);
|
|
60
|
+
const {
|
|
61
|
+
address: account
|
|
62
|
+
} = useAccount();
|
|
63
|
+
const chainId = useChainId();
|
|
64
|
+
let t0;
|
|
65
|
+
if ($[0] !== account || $[1] !== chainId) {
|
|
66
|
+
t0 = {
|
|
67
|
+
chainId,
|
|
68
|
+
account
|
|
69
|
+
};
|
|
70
|
+
$[0] = account;
|
|
71
|
+
$[1] = chainId;
|
|
72
|
+
$[2] = t0;
|
|
73
|
+
} else {
|
|
74
|
+
t0 = $[2];
|
|
75
|
+
}
|
|
76
|
+
useConnectorClient(t0);
|
|
77
|
+
}
|
|
78
|
+
function useEnsureConnectorClient() {
|
|
79
|
+
const $ = distExports.c(5);
|
|
80
|
+
const queryClient = useQueryClient();
|
|
81
|
+
const config = useConfig();
|
|
82
|
+
let t0;
|
|
83
|
+
if ($[0] !== config || $[1] !== queryClient) {
|
|
84
|
+
t0 = async (options) => {
|
|
85
|
+
const queryOptions = getConnectorClientQueryOptions(config, options);
|
|
86
|
+
const connectorClient = await queryClient.ensureQueryData(queryOptions);
|
|
87
|
+
return constructMinViemClient(connectorClient);
|
|
88
|
+
};
|
|
89
|
+
$[0] = config;
|
|
90
|
+
$[1] = queryClient;
|
|
91
|
+
$[2] = t0;
|
|
92
|
+
} else {
|
|
93
|
+
t0 = $[2];
|
|
94
|
+
}
|
|
95
|
+
const ensureViemClient = t0;
|
|
96
|
+
let t1;
|
|
97
|
+
if ($[3] !== ensureViemClient) {
|
|
98
|
+
t1 = {
|
|
99
|
+
ensureViemClient
|
|
100
|
+
};
|
|
101
|
+
$[3] = ensureViemClient;
|
|
102
|
+
$[4] = t1;
|
|
103
|
+
} else {
|
|
104
|
+
t1 = $[4];
|
|
105
|
+
}
|
|
106
|
+
return t1;
|
|
107
|
+
}
|
|
53
108
|
|
|
54
|
-
export { useMinViemClient };
|
|
109
|
+
export { useCacheMinViemClient, useEnsureConnectorClient, useMinViemClient };
|
|
55
110
|
//# sourceMappingURL=useMinViemClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMinViemClient.js","sources":["../../src/hooks/useMinViemClient.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useConnectorClient } from \"wagmi\";\nimport { readContract, signTypedData, writeContract } from \"viem/actions\";\nimport type { Address } from \"viem\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport type { MinViemClient } from \"@velora-dex/sdk\";\n\ntype UseMinViemClientInput = {\n chainId?: SupportedChainId;\n account?: Address;\n};\n\ntype UseMinViemClientResult = {\n minClient?: MinViemClient;\n isLoading: boolean;\n error: Error | null;\n isError: boolean;\n};\n\nexport function useMinViemClient(\n options?: UseMinViemClientInput\n): UseMinViemClientResult {\n const {\n data: connectorClient,\n isLoading,\n error,\n isError,\n } = useConnectorClient(options);\n\n const minClient = useMemo<MinViemClient | undefined>(() => {\n if (!connectorClient) return;\n\n // walletClient(useWalletClient) has writeContract and signTypedData,\n // publicClient(usePublicClient) has readContract\n // sdk requires all of them,\n // easier to compose connectorClient + viem actions (readContract, writeContract)\n return {\n
|
|
1
|
+
{"version":3,"file":"useMinViemClient.js","sources":["../../src/hooks/useMinViemClient.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useAccount, useChainId, useConfig, useConnectorClient } from \"wagmi\";\nimport { readContract, signTypedData, writeContract } from \"viem/actions\";\nimport type { Address } from \"viem\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport type { MinViemClient } from \"@velora-dex/sdk\";\nimport { getConnectorClientQueryOptions } from \"wagmi/query\";\nimport type { GetConnectorClientReturnType } from \"@wagmi/core\";\nimport type { wagmiConfig } from \"@/lib/web3/wagmi/config\";\n\ntype UseMinViemClientInput = {\n chainId?: SupportedChainId;\n account?: Address;\n};\n\ntype UseMinViemClientResult = {\n minClient?: MinViemClient;\n isLoading: boolean;\n error: Error | null;\n isError: boolean;\n};\n\ntype ConnectorClient = GetConnectorClientReturnType<\n typeof wagmiConfig,\n SupportedChainId\n>;\n\nexport function useMinViemClient(\n options?: UseMinViemClientInput\n): UseMinViemClientResult {\n const {\n data: connectorClient,\n isLoading,\n error,\n isError,\n } = useConnectorClient(options);\n\n const minClient = useMemo<MinViemClient | undefined>(() => {\n if (!connectorClient) return;\n\n // walletClient(useWalletClient) has writeContract and signTypedData,\n // publicClient(usePublicClient) has readContract\n // sdk requires all of them,\n // easier to compose connectorClient + viem actions (readContract, writeContract)\n return constructMinViemClient(connectorClient);\n }, [connectorClient]);\n\n return {\n minClient,\n isLoading,\n error,\n isError,\n };\n}\n\nfunction constructMinViemClient(\n connectorClient: ConnectorClient\n): MinViemClient {\n return {\n readContract: (params) => readContract(connectorClient, params),\n writeContract: (params) => writeContract(connectorClient, params),\n signTypedData: (params) => signTypedData(connectorClient, params),\n };\n}\n\n/**\n * Keep one subscriber to useConnectorClient query at all times\n * to avoid async client creation on useMinViemClient mount\n * and first useConnectorClient().data being undefined for a short time,\n * which breaks Fill OTC flow which starts from Activities screen\n */\nexport function useCacheMinViemClient() {\n const { address: account } = useAccount();\n const chainId = useChainId();\n useConnectorClient({\n chainId,\n account,\n });\n}\n\ntype EnsureMinViemClientOptions = {\n chainId?: SupportedChainId;\n connector?: ReturnType<typeof useAccount>[\"connector\"];\n};\n\ntype UseEnsureConnectorClientResult = {\n ensureViemClient: (options: UseMinViemClientInput) => Promise<MinViemClient>;\n};\n\n/**\n * Returns a function that loads the connector client on demand via\n * queryClient.ensureQueryData and getConnectorClientQueryOptions.\n * Uses current account's chainId and connector when options are omitted.\n */\nexport function useEnsureConnectorClient(): UseEnsureConnectorClientResult {\n const queryClient = useQueryClient();\n const config = useConfig();\n\n const ensureViemClient = useCallback(\n async (options: EnsureMinViemClientOptions): Promise<MinViemClient> => {\n const queryOptions = getConnectorClientQueryOptions(config, options);\n\n const connectorClient = await queryClient.ensureQueryData(queryOptions);\n\n return constructMinViemClient(connectorClient);\n },\n [queryClient, config]\n );\n\n return { ensureViemClient };\n}\n"],"names":["useMinViemClient","options","$","_c","data","connectorClient","isLoading","error","isError","useConnectorClient","t0","bb0","undefined","t1","constructMinViemClient","minClient","readContract","params","writeContract","signTypedData","useCacheMinViemClient","address","account","useAccount","chainId","useChainId","useEnsureConnectorClient","queryClient","useQueryClient","config","useConfig","queryOptions","getConnectorClientQueryOptions","ensureQueryData","ensureViemClient"],"mappings":";;;;;;;AA4BO,SAAAA,iBAAAC,OAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,CAAA,CAAA;AAGL,EAAA,MAAA;AAAA,IAAAC,IAAAA,EAAAC,eAAAA;AAAAA,IAAAC,SAAAA;AAAAA,IAAAC,KAAAA;AAAAA,IAAAC;AAAAA,GAAA,GAKIC,mBAAmBR,OAAO,CAAA;AAAE,EAAA,IAAAS,EAAAA;AAAAC,EAAAA,GAAAA,EAAA;AAG9B,IAAA,IAAI,CAACN,eAAAA,EAAe;AAAEK,MAAAA,EAAAA,GAAAE,MAAAA;AAAA,MAAA,MAAAD,GAAAA;AAAAA,IAAO;AAAA,IAAA,IAAAE,GAAAA;AAAA,IAA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AC,CAAA;AAC/CH,IAAAA,CAAAA,MAAA2B,MAAAA;AAAA3B,IAAAA,CAAAA,MAAAyB,WAAAA;AAAAzB,IAAAA,CAAAA,MAAAQ,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAR,EAAA,CAAA,CAAA;AAAA,EAAA;AAPH,EAAA,MAAAgC,gBAAAA,GAAyBxB,EAAAA;AASvB,EAAA,IAAAG,EAAAA;AAAA,EAAA,IAAAX,CAAAA,QAAAgC,gBAAAA,EAAA;AAEKrB,IAAAA,EAAAA,GAAA;AAAA,MAAAqB;AAAAA,KAAmB;AAAChC,IAAAA,CAAAA,MAAAgC,gBAAAA;AAAAhC,IAAAA,CAAAA,MAAAW,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAX,EAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OAApBW,EAAAA;AAAoB;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SupportedChainId } from '../lib/web3/wagmi/types';
|
|
2
|
+
import { UseMutationOptions } from '@tanstack/react-query';
|
|
3
|
+
type SwitchChainWithGuardInput = {
|
|
4
|
+
chainId: SupportedChainId;
|
|
5
|
+
};
|
|
6
|
+
type UseSwitchChainWithGuardMutationOption = Omit<UseMutationOptions<void, Error, SwitchChainWithGuardInput, void>, "mutationFn" | "mutationKey">;
|
|
7
|
+
type UseSwitchChainWithGuardInput = {
|
|
8
|
+
mutationOptions?: UseSwitchChainWithGuardMutationOption;
|
|
9
|
+
};
|
|
10
|
+
export declare function useSwitchChainWithGuard({ mutationOptions, }?: UseSwitchChainWithGuardInput): import('@tanstack/react-query').UseMutationResult<void, Error, SwitchChainWithGuardInput, void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=useSwitchChainWithGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwitchChainWithGuard.d.ts","sourceRoot":"","sources":["../../src/hooks/useSwitchChainWithGuard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,KAAK,qCAAqC,GAAG,IAAI,CAC/C,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAChE,YAAY,GAAG,aAAa,CAC7B,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,eAAe,CAAC,EAAE,qCAAqC,CAAC;CACzD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,EACtC,eAAe,GAChB,GAAE,4BAAiC,mGAkBnC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { d as distExports } from '../_virtual/index.js';
|
|
2
|
+
import { switchChain } from '../lib/web3/wagmi/switchChain.js';
|
|
3
|
+
import { useEnsureConnectorClient } from './useMinViemClient.js';
|
|
4
|
+
import { useAccount } from 'wagmi';
|
|
5
|
+
import { useMutation } from '@tanstack/react-query';
|
|
6
|
+
|
|
7
|
+
function useSwitchChainWithGuard(t0) {
|
|
8
|
+
const $ = distExports.c(9);
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] !== t0) {
|
|
11
|
+
t1 = {} ;
|
|
12
|
+
$[0] = t0;
|
|
13
|
+
$[1] = t1;
|
|
14
|
+
} else {
|
|
15
|
+
t1 = $[1];
|
|
16
|
+
}
|
|
17
|
+
const {
|
|
18
|
+
mutationOptions
|
|
19
|
+
} = t1;
|
|
20
|
+
const {
|
|
21
|
+
address: account
|
|
22
|
+
} = useAccount();
|
|
23
|
+
const {
|
|
24
|
+
ensureViemClient
|
|
25
|
+
} = useEnsureConnectorClient();
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
+
t2 = ["switchChainWithGuard"];
|
|
29
|
+
$[2] = t2;
|
|
30
|
+
} else {
|
|
31
|
+
t2 = $[2];
|
|
32
|
+
}
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[3] !== account || $[4] !== ensureViemClient) {
|
|
35
|
+
t3 = async (t42) => {
|
|
36
|
+
const {
|
|
37
|
+
chainId
|
|
38
|
+
} = t42;
|
|
39
|
+
await switchChain({
|
|
40
|
+
chainId
|
|
41
|
+
});
|
|
42
|
+
await ensureViemClient({
|
|
43
|
+
chainId,
|
|
44
|
+
account
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
$[3] = account;
|
|
48
|
+
$[4] = ensureViemClient;
|
|
49
|
+
$[5] = t3;
|
|
50
|
+
} else {
|
|
51
|
+
t3 = $[5];
|
|
52
|
+
}
|
|
53
|
+
let t4;
|
|
54
|
+
if ($[6] !== mutationOptions || $[7] !== t3) {
|
|
55
|
+
t4 = {
|
|
56
|
+
mutationKey: t2,
|
|
57
|
+
mutationFn: t3,
|
|
58
|
+
...mutationOptions
|
|
59
|
+
};
|
|
60
|
+
$[6] = mutationOptions;
|
|
61
|
+
$[7] = t3;
|
|
62
|
+
$[8] = t4;
|
|
63
|
+
} else {
|
|
64
|
+
t4 = $[8];
|
|
65
|
+
}
|
|
66
|
+
return useMutation(t4);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { useSwitchChainWithGuard };
|
|
70
|
+
//# sourceMappingURL=useSwitchChainWithGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwitchChainWithGuard.js","sources":["../../src/hooks/useSwitchChainWithGuard.ts"],"sourcesContent":["import { switchChain as switchChainUtil } from \"@/lib/web3/wagmi/switchChain\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useEnsureConnectorClient } from \"./useMinViemClient\";\nimport { useAccount } from \"wagmi\";\nimport { useMutation, type UseMutationOptions } from \"@tanstack/react-query\";\n\ntype SwitchChainWithGuardInput = {\n chainId: SupportedChainId;\n};\n\ntype UseSwitchChainWithGuardMutationOption = Omit<\n UseMutationOptions<void, Error, SwitchChainWithGuardInput, void>,\n \"mutationFn\" | \"mutationKey\"\n>;\n\ntype UseSwitchChainWithGuardInput = {\n mutationOptions?: UseSwitchChainWithGuardMutationOption;\n};\n\nexport function useSwitchChainWithGuard({\n mutationOptions,\n}: UseSwitchChainWithGuardInput = {}) {\n const { address: account } = useAccount();\n const { ensureViemClient } = useEnsureConnectorClient();\n\n return useMutation<void, Error, SwitchChainWithGuardInput, void>({\n mutationKey: [\"switchChainWithGuard\"],\n mutationFn: async ({ chainId }) => {\n await switchChainUtil({\n chainId,\n });\n // guard against using minClient with wrong chainId\n await ensureViemClient({\n chainId,\n account,\n });\n },\n ...mutationOptions,\n });\n}\n"],"names":["useSwitchChainWithGuard","t0","$","_c","t1","mutationOptions","address","account","useAccount","ensureViemClient","useEnsureConnectorClient","t2","Symbol","for","t3","t4","chainId","switchChainUtil","mutationKey","mutationFn","useMutation"],"mappings":";;;;;;AAmBO,SAAAA,wBAAAC,EAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,CAAA,CAAA;AAAA,EAAA,IAAAC,EAAAA;AAAA,EAAA,IAAAF,CAAAA,QAAAD,EAAAA,EAAA;AAAiCG,IAAAA,EAAAA,GAAA,EAEL,CAFKH;AAEJC,IAAAA,CAAAA,MAAAD,EAAAA;AAAAC,IAAAA,CAAAA,MAAAE,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAF,EAAA,CAAA,CAAA;AAAA,EAAA;AAFI,EAAA,MAAA;AAAA,IAAAG;AAAAA,GAAA,GAAAD,EAAAA;AAGtC,EAAA,MAAA;AAAA,IAAAE,OAAAA,EAAAC;AAAAA,MAA6BC,UAAAA,EAAW;AACxC,EAAA,MAAA;AAAA,IAAAC;AAAAA,MAA6BC,wBAAAA,EAAyB;A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AAAAA,IAAAA,EAAAA,GAAAb,EAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OAbMkB,YAA0DL,EAahE,CAAA;AAAC;;;;"}
|
|
@@ -5,7 +5,7 @@ import { unichain, sonic, bsc, gnosis, avalanche, arbitrum, base, polygon, optim
|
|
|
5
5
|
const rpcMap = {
|
|
6
6
|
[mainnet.id]: "https://ethereum-rpc.publicnode.com",
|
|
7
7
|
[optimism.id]: "https://optimism.drpc.org",
|
|
8
|
-
[polygon.id]: "https://
|
|
8
|
+
[polygon.id]: "https://1rpc.io/matic",
|
|
9
9
|
[base.id]: "https://base.publicnode.com",
|
|
10
10
|
[arbitrum.id]: "https://arb1.arbitrum.io/rpc",
|
|
11
11
|
[avalanche.id]: "https://api.avax.network/ext/bc/C/rpc",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.js","sources":["../../../../src/lib/web3/wagmi/transports.ts"],"sourcesContent":["import { fallback, http } from \"wagmi\";\n\nimport {\n mainnet,\n optimism,\n polygon,\n base,\n arbitrum,\n avalanche,\n gnosis,\n bsc,\n sonic,\n unichain,\n} from \"./supportedChains\";\nimport { supportedChainIds } from \"./constants\";\nimport type { SupportedChainId } from \"./types\";\nimport type { FallbackTransport, Transport } from \"viem\";\n\nconst rpcMap: Record<SupportedChainId, string> = {\n [mainnet.id]: \"https://ethereum-rpc.publicnode.com\",\n [optimism.id]: \"https://optimism.drpc.org\",\n [polygon.id]: \"https://
|
|
1
|
+
{"version":3,"file":"transports.js","sources":["../../../../src/lib/web3/wagmi/transports.ts"],"sourcesContent":["import { fallback, http } from \"wagmi\";\n\nimport {\n mainnet,\n optimism,\n polygon,\n base,\n arbitrum,\n avalanche,\n gnosis,\n bsc,\n sonic,\n unichain,\n} from \"./supportedChains\";\nimport { supportedChainIds } from \"./constants\";\nimport type { SupportedChainId } from \"./types\";\nimport type { FallbackTransport, Transport } from \"viem\";\n\nconst rpcMap: Record<SupportedChainId, string> = {\n [mainnet.id]: \"https://ethereum-rpc.publicnode.com\",\n [optimism.id]: \"https://optimism.drpc.org\",\n [polygon.id]: \"https://1rpc.io/matic\",\n [base.id]: \"https://base.publicnode.com\",\n [arbitrum.id]: \"https://arb1.arbitrum.io/rpc\",\n [avalanche.id]: \"https://api.avax.network/ext/bc/C/rpc\",\n [gnosis.id]: \"https://rpc.gnosischain.com\",\n [bsc.id]: \"https://binance.llamarpc.com\",\n [sonic.id]: \"https://rpc.soniclabs.com\",\n [unichain.id]: \"https://unichain.drpc.org\",\n};\n\nconst veloraRpcUrl = \"https://rpc.paraswap.io\";\n\nconst fallbackRpcMap = Object.fromEntries(\n supportedChainIds.map((chainId) => [chainId, `${veloraRpcUrl}/${chainId}`])\n) as Record<SupportedChainId, string>;\n\nexport const transports = Object.fromEntries(\n supportedChainIds.map((chainId) => [\n chainId,\n fallback([http(rpcMap[chainId]), http(fallbackRpcMap[chainId])]),\n ])\n) as Record<SupportedChainId, FallbackTransport<Transport[]>>;\n"],"names":["rpcMap","mainnet","id","optimism","polygon","base","arbitrum","avalanche","gnosis","bsc","sonic","unichain","veloraRpcUrl","fallbackRpcMap","Object","fromEntries","supportedChainIds","map","chainId","transports","fallback","http"],"mappings":";;;;AAkBA,MAAMA,MAAAA,GAA2C;AAAA,EAC/C,CAACC,OAAAA,CAAQC,EAAE,GAAG,qCAAA;AAAA,EACd,CAACC,QAAAA,CAASD,EAAE,GAAG,2BAAA;AAAA,EACf,CAACE,OAAAA,CAAQF,EAAE,GAAG,uBAAA;AAAA,EACd,CAACG,IAAAA,CAAKH,EAAE,GAAG,6BAAA;AAAA,EACX,CAACI,QAAAA,CAASJ,EAAE,GAAG,8BAAA;AAAA,EACf,CAACK,SAAAA,CAAUL,EAAE,GAAG,uCAAA;AAAA,EAChB,CAACM,MAAAA,CAAON,EAAE,GAAG,6BAAA;AAAA,EACb,CAACO,GAAAA,CAAIP,EAAE,GAAG,8BAAA;AAAA,EACV,CAACQ,KAAAA,CAAMR,EAAE,GAAG,2BAAA;AAAA,EACZ,CAACS,QAAAA,CAAST,EAAE,GAAG;AACjB,CAAA;AAEA,MAAMU,YAAAA,GAAe,yBAAA;AAErB,MAAMC,cAAAA,GAAiBC,MAAAA,CAAOC,WAAAA,CAC5BC,iBAAAA,CAAkBC,IAAKC,CAAAA,OAAAA,KAAY,CAACA,OAAAA,EAAS,CAAA,EAAGN,YAAY,CAAA,CAAA,EAAIM,OAAO,CAAA,CAAE,CAAC,CAC5E,CAAA;AAEO,MAAMC,UAAAA,GAAaL,OAAOC,WAAAA,CAC/BC,iBAAAA,CAAkBC,IAAKC,CAAAA,OAAAA,KAAY,CACjCA,OAAAA,EACAE,QAAAA,CAAS,CAACC,IAAAA,CAAKrB,OAAOkB,OAAO,CAAC,CAAA,EAAGG,IAAAA,CAAKR,cAAAA,CAAeK,OAAO,CAAC,CAAC,CAAC,CAAC,CACjE,CACH;;;;"}
|
|
@@ -3,7 +3,8 @@ import { wagmiConfig as _wagmiConfig } from '../../lib/web3/wagmi/config';
|
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { MarkRequired } from 'ts-essentials';
|
|
5
5
|
import { ReplacementReturnType, TransactionReceipt } from 'viem';
|
|
6
|
-
|
|
6
|
+
import { Chain } from 'wagmi/chains';
|
|
7
|
+
type OnReplacedCb = (data: ReplacementReturnType<Chain>) => void;
|
|
7
8
|
export type EnsureTxReceiptFn = (options: MarkRequired<Pick<UseAwaitTxParameters, "hash" | "chainId" | "confirmations">, "hash" | "chainId"> & {
|
|
8
9
|
onReplaced?: OnReplacedCb;
|
|
9
10
|
}) => Promise<TransactionReceipt>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureTxReceipt.d.ts","sourceRoot":"","sources":["../../../src/transactions/queries/ensureTxReceipt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ensureTxReceipt.d.ts","sourceRoot":"","sources":["../../../src/transactions/queries/ensureTxReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAI3E,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AAEjE,MAAM,MAAM,iBAAiB,GAAG,CAC9B,OAAO,EAAE,YAAY,CACnB,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,eAAe,CAAC,EAChE,MAAM,GAAG,SAAS,CACnB,GAAG;IACF,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B,KACE,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEjC,KAAK,sBAAsB,GAAG,CAAC,MAAM,CAAC,EAAE;IACtC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,YAAY,CAAC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,KAAK,iBAAiB,CAAC;AAExB,eAAO,MAAM,sBAAsB,EAAE,sBAsClC,CAAC"}
|