@velora-dex/widget 0.3.4-dev.1 → 0.3.5
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/web3/providers.d.ts.map +1 -1
- package/dist/components/web3/providers.js +7 -64
- package/dist/components/web3/providers.js.map +1 -1
- package/dist/configurator/Configurator.d.ts.map +1 -1
- package/dist/events/hooks/useOnWalletConnect.d.ts.map +1 -1
- package/dist/events/hooks/useOnWalletConnect.js +0 -4
- package/dist/events/hooks/useOnWalletConnect.js.map +1 -1
- package/dist/hooks/otc/mutations/useFillOrder.js +2 -3
- package/dist/hooks/otc/mutations/useFillOrder.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js.map +1 -1
- package/dist/hooks/swap/prices/usePricesParams.js +5 -0
- package/dist/hooks/swap/prices/usePricesParams.js.map +1 -1
- package/dist/hooks/txs/queries/useAwaitTx.d.ts.map +1 -1
- package/dist/hooks/txs/queries/useAwaitTx.js +19 -71
- package/dist/hooks/txs/queries/useAwaitTx.js.map +1 -1
- package/dist/lib/web3/privy/config.js +1 -1
- package/dist/lib/web3/wagmi/config.d.ts.map +1 -1
- package/dist/lib/web3/wagmi/config.js +7 -2
- package/dist/lib/web3/wagmi/config.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/transactions/state/effects/finalize.d.ts +1 -1
- package/dist/transactions/state/effects/finalize.js +2 -2
- package/dist/transactions/state/effects/finalize.js.map +1 -1
- package/dist/transactions/state/hooks/useActivateEffects.js +2 -2
- package/dist/transactions/state/hooks/useActivateEffects.js.map +1 -1
- package/dist/transactions/state/transactionsActionAtom.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../src/components/web3/providers.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../src/components/web3/providers.tsx"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,gBAAgB,GACjB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,2CASA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAIA;AAED,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAExE"}
|
|
@@ -5,80 +5,23 @@ import { wagmiConfig } from '../../lib/web3/wagmi/config.js';
|
|
|
5
5
|
import { WagmiProvider } from 'wagmi';
|
|
6
6
|
import { queryClient } from '../../lib/queryClient.js';
|
|
7
7
|
import { Provider, jotaiStore } from '../../core/store.js';
|
|
8
|
-
import { useEffect } from 'react';
|
|
9
8
|
|
|
10
9
|
function Web3Providers(t0) {
|
|
11
|
-
const $ = distExports.c(
|
|
10
|
+
const $ = distExports.c(3);
|
|
12
11
|
const {
|
|
13
12
|
children,
|
|
14
13
|
reconnectOnMount
|
|
15
14
|
} = t0;
|
|
16
15
|
let t1;
|
|
17
|
-
if ($[0]
|
|
18
|
-
t1 =
|
|
19
|
-
$[0] =
|
|
20
|
-
} else {
|
|
21
|
-
t1 = $[0];
|
|
22
|
-
}
|
|
23
|
-
useEffect(_temp2, t1);
|
|
24
|
-
let t2;
|
|
25
|
-
let t3;
|
|
26
|
-
if ($[1] !== reconnectOnMount) {
|
|
27
|
-
t2 = () => {
|
|
28
|
-
console.log("Web3Providers::reconnectOnMount", reconnectOnMount);
|
|
29
|
-
};
|
|
30
|
-
t3 = [reconnectOnMount];
|
|
16
|
+
if ($[0] !== children || $[1] !== reconnectOnMount) {
|
|
17
|
+
t1 = /* @__PURE__ */ jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount, children });
|
|
18
|
+
$[0] = children;
|
|
31
19
|
$[1] = reconnectOnMount;
|
|
32
|
-
$[2] =
|
|
33
|
-
$[3] = t3;
|
|
34
|
-
} else {
|
|
35
|
-
t2 = $[2];
|
|
36
|
-
t3 = $[3];
|
|
37
|
-
}
|
|
38
|
-
useEffect(t2, t3);
|
|
39
|
-
let t4;
|
|
40
|
-
let t5;
|
|
41
|
-
if ($[4] !== children) {
|
|
42
|
-
t4 = () => {
|
|
43
|
-
console.log("Web3Providers::children", children);
|
|
44
|
-
};
|
|
45
|
-
t5 = [children];
|
|
46
|
-
$[4] = children;
|
|
47
|
-
$[5] = t4;
|
|
48
|
-
$[6] = t5;
|
|
49
|
-
} else {
|
|
50
|
-
t4 = $[5];
|
|
51
|
-
t5 = $[6];
|
|
52
|
-
}
|
|
53
|
-
useEffect(t4, t5);
|
|
54
|
-
let t6;
|
|
55
|
-
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
56
|
-
t6 = [];
|
|
57
|
-
$[7] = t6;
|
|
20
|
+
$[2] = t1;
|
|
58
21
|
} else {
|
|
59
|
-
|
|
22
|
+
t1 = $[2];
|
|
60
23
|
}
|
|
61
|
-
|
|
62
|
-
let t7;
|
|
63
|
-
if ($[8] !== children || $[9] !== reconnectOnMount) {
|
|
64
|
-
t7 = /* @__PURE__ */ jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount, children });
|
|
65
|
-
$[8] = children;
|
|
66
|
-
$[9] = reconnectOnMount;
|
|
67
|
-
$[10] = t7;
|
|
68
|
-
} else {
|
|
69
|
-
t7 = $[10];
|
|
70
|
-
}
|
|
71
|
-
return t7;
|
|
72
|
-
}
|
|
73
|
-
function _temp3() {
|
|
74
|
-
console.log("Web3Providers::rerendered");
|
|
75
|
-
}
|
|
76
|
-
function _temp2() {
|
|
77
|
-
console.log("Web3Providers mounted");
|
|
78
|
-
return _temp;
|
|
79
|
-
}
|
|
80
|
-
function _temp() {
|
|
81
|
-
console.log("Web3Providers unmounted");
|
|
24
|
+
return t1;
|
|
82
25
|
}
|
|
83
26
|
function QueryClientProvider(t0) {
|
|
84
27
|
const $ = distExports.c(2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sources":["../../../src/components/web3/providers.tsx"],"sourcesContent":["import { QueryClientProvider as _QueryClientProvider } from \"@tanstack/react-query\";\nimport { wagmiConfig } from \"@/lib/web3/wagmi/config\";\nimport { WagmiProvider } from \"wagmi\";\nimport { queryClient } from \"@/lib/queryClient\";\nimport { jotaiStore, Provider } from \"@/core/store\";\
|
|
1
|
+
{"version":3,"file":"providers.js","sources":["../../../src/components/web3/providers.tsx"],"sourcesContent":["import { QueryClientProvider as _QueryClientProvider } from \"@tanstack/react-query\";\nimport { wagmiConfig } from \"@/lib/web3/wagmi/config\";\nimport { WagmiProvider } from \"wagmi\";\nimport { queryClient } from \"@/lib/queryClient\";\nimport { jotaiStore, Provider } from \"@/core/store\";\n\nexport function Web3Providers({\n children,\n reconnectOnMount,\n}: {\n children: React.ReactNode;\n reconnectOnMount?: boolean;\n}) {\n return (\n /* connect on mount (eager-connect) should be controlled by the App that uses the widget\n otherwise we can get different wallets connected between the App and the widget */\n <WagmiProvider config={wagmiConfig} reconnectOnMount={reconnectOnMount}>\n {/* @TODO: check if reconnectOnMount is necessary even with externalProvider in Dapp mode */}\n {children}\n </WagmiProvider>\n );\n}\n\nexport function QueryClientProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n return (\n <_QueryClientProvider client={queryClient}>{children}</_QueryClientProvider>\n );\n}\n\nexport function JotaiProvider({ children }: { children: React.ReactNode }) {\n return <Provider store={jotaiStore}>{children}</Provider>;\n}\n"],"names":["Web3Providers","t0","$","_c","children","reconnectOnMount","t1","wagmiConfig","QueryClientProvider","_QueryClientProvider","queryClient","JotaiProvider","jotaiStore"],"mappings":";;;;;;;;AAMO,SAAAA,cAAAC,EAAAA,EAAA;AAAA,EAAA,MA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K,EAAAA;AAAA,EAAA,IAAAJ,CAAAA,QAAAE,QAAAA,EAAA;AAChEE,IAAAA,EAAAA,mBAAA,GAAA,CAAC,QAAA,EAAA,EAAgBM,KAAAA,EAAAA,UAAAA,EAAaR,QAAAA,EAAS,CAAA;AAAWF,IAAAA,CAAAA,MAAAE,QAAAA;AAAAF,IAAAA,CAAAA,MAAAI,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAJ,EAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OAAlDI,EAAAA;AAAkD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configurator.d.ts","sourceRoot":"","sources":["../../src/configurator/Configurator.tsx"],"names":[],"mappings":"AAsPA,eAAO,MAAM,YAAY,+
|
|
1
|
+
{"version":3,"file":"Configurator.d.ts","sourceRoot":"","sources":["../../src/configurator/Configurator.tsx"],"names":[],"mappings":"AAsPA,eAAO,MAAM,YAAY,+CA8SxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnWalletConnect.d.ts","sourceRoot":"","sources":["../../../src/events/hooks/useOnWalletConnect.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useOnWalletConnect.d.ts","sourceRoot":"","sources":["../../../src/events/hooks/useOnWalletConnect.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,SAiCnC"}
|
|
@@ -19,10 +19,6 @@ function useOnWalletConnected() {
|
|
|
19
19
|
chainId,
|
|
20
20
|
isReconnected
|
|
21
21
|
} = t1;
|
|
22
|
-
if (!connector) {
|
|
23
|
-
debugger;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
22
|
const walletMetadata = await getWalletMetadata(connector);
|
|
27
23
|
const provider = await connector.getProvider();
|
|
28
24
|
const isEmbedded = connector.type === safe.type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnWalletConnect.js","sources":["../../../src/events/hooks/useOnWalletConnect.ts"],"sourcesContent":["import { getWalletMetadata } from \"@/components/web3/ConnectWallets/walletIcons\";\nimport { useWidgetEvents } from \"@/core/state/widgetEventsAtom\";\nimport { useAccountEffect } from \"wagmi\";\nimport { safe } from \"wagmi/connectors\";\n\nexport function useOnWalletConnected() {\n const { onConnectWallet } = useWidgetEvents();\n\n useAccountEffect({\n onConnect: async ({ address, connector, chainId, isReconnected }) => {\n
|
|
1
|
+
{"version":3,"file":"useOnWalletConnect.js","sources":["../../../src/events/hooks/useOnWalletConnect.ts"],"sourcesContent":["import { getWalletMetadata } from \"@/components/web3/ConnectWallets/walletIcons\";\nimport { useWidgetEvents } from \"@/core/state/widgetEventsAtom\";\nimport { useAccountEffect } from \"wagmi\";\nimport { safe } from \"wagmi/connectors\";\n\nexport function useOnWalletConnected() {\n const { onConnectWallet } = useWidgetEvents();\n\n useAccountEffect({\n onConnect: async ({ address, connector, chainId, isReconnected }) => {\n const walletMetadata = await getWalletMetadata(connector);\n const provider = await connector.getProvider();\n\n const isEmbedded = connector.type === safe.type;\n\n const connectorAction = isReconnected\n ? \"Eager\"\n : isEmbedded\n ? \"Embedded\"\n : \"Click\";\n\n onConnectWallet?.({\n event: {\n name: \"ConnectWallet:connect\",\n params: {\n connectorType: connector.type,\n connectorName: connector.name,\n connectorAction,\n provider,\n account: address,\n chainId,\n walletName: walletMetadata.name,\n walletIcon: walletMetadata.icon,\n },\n },\n });\n },\n });\n}\n"],"names":["useOnWalletConnected","$","_c","onConnectWallet","useWidgetEvents","t0","onConnect","t1","address","connector","chainId","isReconnected","walletMetadata","getWalletMetadata","provider","getProvider","isEmbedded","type","safe","connectorAction","event","name","params","connectorType","connectorName","account","walletName","walletIcon","icon","useAccountEffect"],"mappings":";;;;;;AAKO,SAAAA,oBAAAA,GAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,CAAA,CAAA;AACL,EAAA,MAAA;AAAA,IAAAC;AAAAA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AAAA,CAAiBxB,EA6BhB,CAAA;AAAC;;;;"}
|
|
@@ -4,12 +4,11 @@ import { useMutation } from '@tanstack/react-query';
|
|
|
4
4
|
import { assert } from 'ts-essentials';
|
|
5
5
|
import 'wagmi';
|
|
6
6
|
import 'wagmi/query';
|
|
7
|
-
import '../../../lib/queryClient.js';
|
|
8
7
|
import '../../../lib/web3/wagmi/config.js';
|
|
9
|
-
import 'viem';
|
|
10
|
-
import 'wagmi/chains';
|
|
11
8
|
import '@wagmi/core';
|
|
12
9
|
import 'wagmi/connectors';
|
|
10
|
+
import '../../../lib/queryClient.js';
|
|
11
|
+
import 'viem';
|
|
13
12
|
import 'react/jsx-runtime';
|
|
14
13
|
import 'clsx';
|
|
15
14
|
import 'tailwind-merge';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFillOrder.js","sources":["../../../../src/hooks/otc/mutations/useFillOrder.ts"],"sourcesContent":["import { useLimitOrdersSDK } from \"@/hooks/useSDK\";\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type {\n MinViemClient,\n TxSendOverrides,\n FillOrderDirectlyFunctions,\n} from \"@velora-dex/sdk\";\nimport { assert } from \"ts-essentials\";\nimport type { Address, TransactionReceipt } from \"viem\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useEnsureTxReceipt } from \"@/hooks/txs/queries/useAwaitTx\";\nimport { type TxSentObject } from \"@/lib/utils/transactionHandlers\";\nimport { limitOrdersQueryKey } from \"../queries/useLimitOrders\";\n\ntype FillOrderReturn = `0x${string}`;\ntype FillOrderAndWaitReturn = TransactionReceipt;\n\nexport type OrderFillData = Parameters<\n FillOrderDirectlyFunctions<FillOrderReturn>[\"fillOrderDirectly\"]\n>[0];\n\ntype FillOrderInput = {\n orderFillData: OrderFillData;\n overrides?: TxSendOverrides;\n signal?: AbortSignal; // since we have separate actions, we can abort in-between\n};\n\ntype FillOrderAndWaitInput = FillOrderInput & {\n onTxSent?: (txSent: TxSentObject) => void;\n};\n\ntype FillOrderMutationOptions = Omit<\n UseMutationOptions<FillOrderReturn, Error, FillOrderInput, void>,\n \"mutationFn\"\n>;\ntype FillOrderAndWaitMutationOptions = Omit<\n UseMutationOptions<FillOrderAndWaitReturn, Error, FillOrderInput, void>,\n \"mutationFn\"\n>;\n\ntype FillOrderMutInput = {\n mutationOptions?: FillOrderMutationOptions;\n chainId: SupportedChainId;\n account?: Address;\n client?: MinViemClient;\n};\n\ntype FillOrderAndWaitMutInput = {\n mutationOptions?: FillOrderAndWaitMutationOptions;\n chainId: SupportedChainId;\n account?: Address;\n client?: MinViemClient;\n};\n\nexport function useFillOrder({\n mutationOptions,\n chainId,\n account,\n client,\n}: FillOrderMutInput): UseMutationResult<\n FillOrderReturn,\n Error,\n FillOrderInput,\n void\n> {\n const { sdk } = useLimitOrdersSDK({ chainId, account, client });\n\n return useMutation<FillOrderReturn, Error, FillOrderInput, void>({\n mutationKey: [\"fillOrder\"],\n mutationFn: ({ orderFillData, overrides, signal }) => {\n // if aborted by this point, throw an error\n signal?.throwIfAborted();\n\n assert(\n \"fillOrderDirectly\" in sdk,\n \"fillOrderDirectly is not available on this SDK\"\n );\n // Note: This mutation requires the SDK to be initialized with account and client\n // to access fillOrderDirectly\n\n return sdk.fillOrderDirectly(orderFillData, overrides, { signal });\n },\n ...mutationOptions,\n });\n}\n\nexport function useFillOrderAndWait({\n mutationOptions,\n chainId,\n account,\n client,\n}: FillOrderAndWaitMutInput): UseMutationResult<\n FillOrderAndWaitReturn,\n Error,\n FillOrderAndWaitInput,\n void\n> & {\n fillTx: Omit<\n UseMutationResult<FillOrderReturn, Error, FillOrderInput, void>,\n \"mutate\" | \"mutateAsync\"\n >;\n} {\n const ensureTxReceipt = useEnsureTxReceipt();\n const { mutate, mutateAsync, ...fillTx } = useFillOrder({\n chainId,\n account,\n client,\n });\n const queryClient = useQueryClient();\n\n const mutationResult = useMutation<\n FillOrderAndWaitReturn,\n Error,\n FillOrderAndWaitInput,\n void\n >({\n mutationKey: [\"fillOrderAndWait\"],\n mutationFn: async ({ orderFillData, overrides, signal, onTxSent }) => {\n const txHash = await mutateAsync({ orderFillData, overrides, signal });\n\n const receiptPromise = ensureTxReceipt({ chainId, hash: txHash });\n\n onTxSent?.({\n chainId,\n transactionHash: txHash,\n action: \"fillOtcOrder\",\n receiptPromise,\n transactionSpecificData: {\n action: \"fillOtcOrder\",\n filledOrder: orderFillData.order,\n },\n });\n\n return receiptPromise;\n },\n ...mutationOptions,\n onSuccess: (data, variables, onMutationResult, context) => {\n queryClient.invalidateQueries({\n queryKey: limitOrdersQueryKey({ taker: account, type: \"P2P\" }, chainId),\n exact: false,\n });\n\n mutationOptions?.onSuccess?.(data, variables, onMutationResult, context);\n },\n });\n\n return { ...mutationResult, fillTx };\n}\n"],"names":["useFillOrder","t0","$","_c","mutationOptions","chainId","account","client","t1","sdk","useLimitOrdersSDK","t2","Symbol","for","t3","t4","orderFillData","overrides","signal","throwIfAborted","assert","fillOrderDirectly","mutationKey","mutationFn","useMutation"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFillOrder.js","sources":["../../../../src/hooks/otc/mutations/useFillOrder.ts"],"sourcesContent":["import { useLimitOrdersSDK } from \"@/hooks/useSDK\";\nimport {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\nimport type {\n MinViemClient,\n TxSendOverrides,\n FillOrderDirectlyFunctions,\n} from \"@velora-dex/sdk\";\nimport { assert } from \"ts-essentials\";\nimport type { Address, TransactionReceipt } from \"viem\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useEnsureTxReceipt } from \"@/hooks/txs/queries/useAwaitTx\";\nimport { type TxSentObject } from \"@/lib/utils/transactionHandlers\";\nimport { limitOrdersQueryKey } from \"../queries/useLimitOrders\";\n\ntype FillOrderReturn = `0x${string}`;\ntype FillOrderAndWaitReturn = TransactionReceipt;\n\nexport type OrderFillData = Parameters<\n FillOrderDirectlyFunctions<FillOrderReturn>[\"fillOrderDirectly\"]\n>[0];\n\ntype FillOrderInput = {\n orderFillData: OrderFillData;\n overrides?: TxSendOverrides;\n signal?: AbortSignal; // since we have separate actions, we can abort in-between\n};\n\ntype FillOrderAndWaitInput = FillOrderInput & {\n onTxSent?: (txSent: TxSentObject) => void;\n};\n\ntype FillOrderMutationOptions = Omit<\n UseMutationOptions<FillOrderReturn, Error, FillOrderInput, void>,\n \"mutationFn\"\n>;\ntype FillOrderAndWaitMutationOptions = Omit<\n UseMutationOptions<FillOrderAndWaitReturn, Error, FillOrderInput, void>,\n \"mutationFn\"\n>;\n\ntype FillOrderMutInput = {\n mutationOptions?: FillOrderMutationOptions;\n chainId: SupportedChainId;\n account?: Address;\n client?: MinViemClient;\n};\n\ntype FillOrderAndWaitMutInput = {\n mutationOptions?: FillOrderAndWaitMutationOptions;\n chainId: SupportedChainId;\n account?: Address;\n client?: MinViemClient;\n};\n\nexport function useFillOrder({\n mutationOptions,\n chainId,\n account,\n client,\n}: FillOrderMutInput): UseMutationResult<\n FillOrderReturn,\n Error,\n FillOrderInput,\n void\n> {\n const { sdk } = useLimitOrdersSDK({ chainId, account, client });\n\n return useMutation<FillOrderReturn, Error, FillOrderInput, void>({\n mutationKey: [\"fillOrder\"],\n mutationFn: ({ orderFillData, overrides, signal }) => {\n // if aborted by this point, throw an error\n signal?.throwIfAborted();\n\n assert(\n \"fillOrderDirectly\" in sdk,\n \"fillOrderDirectly is not available on this SDK\"\n );\n // Note: This mutation requires the SDK to be initialized with account and client\n // to access fillOrderDirectly\n\n return sdk.fillOrderDirectly(orderFillData, overrides, { signal });\n },\n ...mutationOptions,\n });\n}\n\nexport function useFillOrderAndWait({\n mutationOptions,\n chainId,\n account,\n client,\n}: FillOrderAndWaitMutInput): UseMutationResult<\n FillOrderAndWaitReturn,\n Error,\n FillOrderAndWaitInput,\n void\n> & {\n fillTx: Omit<\n UseMutationResult<FillOrderReturn, Error, FillOrderInput, void>,\n \"mutate\" | \"mutateAsync\"\n >;\n} {\n const ensureTxReceipt = useEnsureTxReceipt();\n const { mutate, mutateAsync, ...fillTx } = useFillOrder({\n chainId,\n account,\n client,\n });\n const queryClient = useQueryClient();\n\n const mutationResult = useMutation<\n FillOrderAndWaitReturn,\n Error,\n FillOrderAndWaitInput,\n void\n >({\n mutationKey: [\"fillOrderAndWait\"],\n mutationFn: async ({ orderFillData, overrides, signal, onTxSent }) => {\n const txHash = await mutateAsync({ orderFillData, overrides, signal });\n\n const receiptPromise = ensureTxReceipt({ chainId, hash: txHash });\n\n onTxSent?.({\n chainId,\n transactionHash: txHash,\n action: \"fillOtcOrder\",\n receiptPromise,\n transactionSpecificData: {\n action: \"fillOtcOrder\",\n filledOrder: orderFillData.order,\n },\n });\n\n return receiptPromise;\n },\n ...mutationOptions,\n onSuccess: (data, variables, onMutationResult, context) => {\n queryClient.invalidateQueries({\n queryKey: limitOrdersQueryKey({ taker: account, type: \"P2P\" }, chainId),\n exact: false,\n });\n\n mutationOptions?.onSuccess?.(data, variables, onMutationResult, context);\n },\n });\n\n return { ...mutationResult, fillTx };\n}\n"],"names":["useFillOrder","t0","$","_c","mutationOptions","chainId","account","client","t1","sdk","useLimitOrdersSDK","t2","Symbol","for","t3","t4","orderFillData","overrides","signal","throwIfAborted","assert","fillOrderDirectly","mutationKey","mutationFn","useMutation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2DO,SAAAA,aAAAC,EAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,EAAA,CAAA;AAAsB,EAAA,MAAA;AAAA,IAAAC,eAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC;AAAAA,GAAA,GAAAN,EAAAA;AAKT,EAAA,IAAAO,EAAAA;AAAA,EAAA,IAAAN,CAAAA,CAAA,CAAA,CAAA,KAAAI,OAAAA,IAAAJ,CAAAA,QAAAG,OAAAA,IAAAH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AAAAP,IAAAA,CAAAA,MAAAY,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAZ,EAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,IAAAa,EAAAA;AAAA,EAAA,IAAAb,EAAA,CAAA,CAAA,KAAAE,mBAAAF,CAAAA,QAAAY,EAAAA,EAAA;AAd8DC,IAAAA,EAAAA,GAAA;AAAA,MAAAO,WAAAA,EAClDX,EAAAA;AAAAA,MAAaY,UAAAA,EACdT,EAAAA;AAAAA,MAYX,GACEV;AAAAA,KACL;AAACF,IAAAA,CAAAA,MAAAE,eAAAA;AAAAF,IAAAA,CAAAA,MAAAY,EAAAA;AAAAZ,IAAAA,CAAAA,MAAAa,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAb,EAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OAhBMsB,YAA0DT,EAgBhE,CAAA;AAAC;;;;"}
|
|
@@ -108,7 +108,7 @@ function useDeltaPriceQuery(t0) {
|
|
|
108
108
|
return t6;
|
|
109
109
|
}
|
|
110
110
|
function isPriceParamsValid(priceParams) {
|
|
111
|
-
return !!priceParams.destToken &&
|
|
111
|
+
return !!priceParams.destToken && priceParams.destDecimals !== void 0 && Number(priceParams.amount) > 0;
|
|
112
112
|
}
|
|
113
113
|
function isDeltaPrice(price) {
|
|
114
114
|
return "bridge" in price;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeltaPriceQuery.js","sources":["../../../../../../src/hooks/swap/prices/delta/queries/useDeltaPriceQuery.ts"],"sourcesContent":["import { useDeltaSDK } from \"@/hooks/useSDK\";\nimport {\n Query,\n QueryClient,\n QueryObserver,\n useQuery,\n useQueryClient,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { useDebouncedValue } from \"@tanstack/react-pacer/debouncer\";\nimport type {\n DeltaPrice,\n BridgePrice,\n DeltaPriceParams as DParams,\n OptimalRate,\n} from \"@velora-dex/sdk\";\nimport { assert, type MarkOptional } from \"ts-essentials\";\nimport { useMemo } from \"react\";\n\n// overload is easier with input.destChainId\ntype RequiredDeltaPriceParams = Omit<DParams, \"destChainId\">;\ntype DeltaPriceParams = MarkOptional<\n RequiredDeltaPriceParams,\n \"destToken\" | \"destDecimals\" // destToken is not available in SwapForm initially\n>;\n\ntype DeltaQueryParams<TData = DeltaPrice | BridgePrice> = Omit<\n UseQueryOptions<DeltaPrice | BridgePrice, Error, TData, DeltaPriceQueryKey>,\n \"queryKey\" | \"queryFn\"\n>;\ntype DeltaQueryResult<TData = DeltaPrice> = UseQueryResult<TData, Error>;\n\ntype DeltaPriceQueryInput<TData = DeltaPrice> = {\n priceParams: DeltaPriceParams;\n query?: DeltaQueryParams<TData>;\n chainId: number;\n timeout?: number;\n};\n\nexport const DeltaPriceQueryKeyPrefix = \"swap/prices/delta\";\n\nexport type DeltaPriceQueryKey = readonly [\n base: typeof DeltaPriceQueryKeyPrefix,\n chainId: number,\n priceParams: DeltaPriceParams & {\n destChainId?: number;\n },\n];\n\n/**\n * 1. With destChainId: number -> returns BridgePrice\n * 2. With destChainId?: undefined -> returns DeltaPrice\n * 3. With destChainId?: number -> returns DeltaPrice | BridgePrice\n */\nexport function useDeltaPriceQuery<TData = BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: undefined;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams: _priceParams,\n query,\n chainId,\n timeout,\n destChainId,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n} {\n const { sdk } = useDeltaSDK({ chainId });\n\n const queryEnabled = query?.enabled ?? true;\n\n const { queryKey, sanitizedPriceParams } = useDeltaPriceQueryKey({\n priceParams: _priceParams,\n chainId,\n destChainId,\n });\n\n const result = useQuery<\n DeltaPrice | BridgePrice,\n Error,\n TData,\n DeltaPriceQueryKey\n >({\n queryKey,\n queryFn: ({ signal }) => {\n assert(isPriceParamsValid(sanitizedPriceParams), \"destToken is required\");\n const price = sdk.getDeltaPrice(sanitizedPriceParams, {\n signal,\n timeout,\n });\n return price;\n },\n ...query,\n enabled: queryEnabled && isPriceParamsValid(sanitizedPriceParams),\n });\n\n return { result, queryKey };\n}\n\nfunction isPriceParamsValid(\n priceParams: DeltaPriceParams\n): priceParams is RequiredDeltaPriceParams {\n return (\n !!priceParams.destToken &&\n !!priceParams.destDecimals &&\n Number(priceParams.amount) > 0\n );\n}\n\nexport function isDeltaPrice(\n price: OptimalRate | DeltaPrice\n): price is DeltaPrice {\n return \"bridge\" in price;\n}\n\nexport function isBridgePrice(\n price: DeltaPrice | BridgePrice\n): price is BridgePrice {\n return price.bridge.destinationChainId !== 0;\n}\n\ntype GetDeltaPriceQueryForPriceInput = {\n price: DeltaPrice | BridgePrice;\n chainId: number;\n};\n\ntype DeltaPriceQuery = Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n>;\n\ntype GetDeltaPriceQueryForPrice = (\n input: GetDeltaPriceQueryForPriceInput\n) =>\n | Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >\n | undefined;\n\n// get query for a given deltaPrice\nexport function useDeltaPriceQueryForPrice(): GetDeltaPriceQueryForPrice {\n const queryClient = useQueryClient();\n\n return ({ chainId, price }) => {\n const queryKey: [DeltaPriceQueryKey[0], DeltaPriceQueryKey[1]] = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n ];\n const queryCache = queryClient.getQueryCache();\n const query = queryCache.find<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice\n >({\n queryKey,\n exact: false,\n predicate: (query) => {\n return query.state.data === price;\n },\n });\n\n return query as DeltaPriceQuery | undefined;\n };\n}\n\ntype SubscribeToDeltaPriceInput = {\n queryKey: DeltaPriceQueryKey;\n onData?: (data: DeltaPrice | BridgePrice) => void;\n onError?: (error: Error) => void;\n};\n\ntype SubscribeToDeltaPriceResult = (\n input: SubscribeToDeltaPriceInput\n) => () => void;\n\n// independently subscribe to a price query\nexport function useSubscribeToDeltaPrice(): SubscribeToDeltaPriceResult {\n const queryClient = useQueryClient();\n\n return ({ queryKey, onData, onError }) => {\n const observer = new QueryObserver<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >(queryClient, {\n queryKey,\n // only receive updates from existing subscriptions\n enabled: false,\n });\n\n // return unsubscribe function\n return observer.subscribe((result) => {\n if (result.error) {\n onError?.(result.error);\n return;\n }\n if (result.data) {\n onData?.(result.data);\n }\n });\n };\n}\n\nfunction getLastDeltaPriceQuery(\n queryClient: QueryClient\n):\n | Query<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>\n | undefined {\n return queryClient\n .getQueryCache()\n .find<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>({\n queryKey: [DeltaPriceQueryKeyPrefix],\n exact: false,\n type: \"active\", // only the most recent query will be active\n });\n}\n\nexport function getLastDeltaPrice(\n queryClient: QueryClient\n): DeltaPrice | BridgePrice | undefined {\n const query = getLastDeltaPriceQuery(queryClient);\n\n return query?.state.data;\n}\n\nexport function isLastDeltaPriceQueryInError(\n queryClient: QueryClient\n): boolean {\n const query = getLastDeltaPriceQuery(queryClient);\n const error = query?.state.error;\n return !!error;\n}\n\nexport function isDataDeltaOrBridgePrice(\n price: unknown\n): price is DeltaPrice | BridgePrice {\n return (\n typeof price === \"object\" &&\n price !== null &&\n \"bridge\" in price &&\n \"srcToken\" in price &&\n \"destToken\" in price &&\n \"srcAmount\" in price &&\n \"destAmount\" in price\n );\n}\n\nexport function useDeltaPriceQueryKey({\n priceParams,\n chainId,\n destChainId,\n}: Pick<DeltaPriceQueryInput, \"priceParams\" | \"chainId\"> & {\n destChainId?: number;\n}) {\n \"use no memo\";\n\n // amount tends to change fast during input\n const [debouncedAmount] = useDebouncedValue(priceParams.amount, {\n wait: 500,\n });\n\n return useMemo(() => {\n // avoid passing unnecessary params to url?search and queryKey\n const sanitizedPriceParams: DeltaPriceParams & {\n destChainId?: number;\n } = {\n amount: debouncedAmount,\n srcToken: priceParams.srcToken,\n destToken: priceParams.destToken,\n srcDecimals: priceParams.srcDecimals,\n destDecimals: priceParams.destDecimals,\n userAddress: priceParams.userAddress,\n beneficiary: priceParams.beneficiary,\n partner: priceParams.partner,\n side: priceParams.side,\n includeAgents: priceParams.includeAgents,\n excludeAgents: priceParams.excludeAgents,\n includeBridges: priceParams.includeBridges,\n excludeBridges: priceParams.excludeBridges,\n allowBridgeAndSwap: priceParams.allowBridgeAndSwap,\n destChainId: destChainId,\n };\n\n const queryKey: DeltaPriceQueryKey = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n sanitizedPriceParams,\n ];\n\n return { queryKey, sanitizedPriceParams };\n }, [\n priceParams.beneficiary,\n priceParams.destDecimals,\n priceParams.destToken,\n priceParams.excludeAgents,\n priceParams.includeAgents,\n priceParams.includeBridges,\n priceParams.excludeBridges,\n priceParams.partner,\n priceParams.side,\n priceParams.srcDecimals,\n priceParams.srcToken,\n priceParams.userAddress,\n priceParams.allowBridgeAndSwap,\n chainId,\n debouncedAmount,\n destChainId,\n ]);\n}\n"],"names":["DeltaPriceQueryKeyPrefix","useDeltaPriceQuery","t0","$","_c","priceParams","_priceParams","query","chainId","timeout","destChainId","t1","sdk","useDeltaSDK","queryEnabled","enabled","t2","queryKey","sanitizedPriceParams","useDeltaPriceQueryKey","t3","t4","signal","assert","isPriceParamsValid","price","getDeltaPrice","t5","queryFn","result","useQuery","t6","destToken","destDecimals","Number","amount","isDeltaPrice","isBridgePrice","bridge","destinationChainId","useDeltaPriceQueryForPrice","queryClient","useQueryClient","queryCache","getQueryCache","query_0","find","exact","predicate","state","data","useSubscribeToDeltaPrice","onData","onError","observer","QueryObserver","subscribe","error","getLastDeltaPriceQuery","type","getLastDeltaPrice","isLastDeltaPriceQueryInError","isDataDeltaOrBridgePrice","debouncedAmount","useDebouncedValue","wait","useMemo","srcToken","srcDecimals","userAddress","beneficiary","partner","side","includeAgents","excludeAgents","includeBridges","excludeBridges","allowBridgeAndSwap"],"mappings":";;;;;;;AAwCO,MAAMA,wBAAAA,GAA2B;AAgDjC,SAAAC,mBAAAC,EAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,EAAA,CAAA;AAA8D,EAAA,MAAA;AAAA,IAAAC,WAAAA,EAAAC,YAAAA;AAAAA,IAAAC,KAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC;AAAAA,GAAA,GAAAR,EAAAA;AAQpE,EAAA,IAAAS,EAAAA;AAAA,EAAA,IAAAR,CAAAA,QAAAK,OAAAA,EAAA;AAI6BG,IAAAA,EAAAA,GAAA;AAAA,MAAAH;AAAAA,KAAU;AAACL,IAAAA,CAAAA,MAAAK,OAAAA;AAAAL,IAAAA,CAAAA,MAAAQ,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAR,EAAA,CAAA,CAAA;AAAA,EAAA;AAAvC,EAAA,MAAA;AAAA,IAAAS;AAAAA,GAAA,GAAgBC,YAAYF,EAAW,C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E,cAAAA,EACZtE,WAAAA,CAAYuE,cAAAA,EACZvE,WAAAA,CAAYkE,OAAAA,EACZlE,WAAAA,CAAYmE,IAAAA,EACZnE,WAAAA,CAAY+D,aACZ/D,WAAAA,CAAY8D,QAAAA,EACZ9D,WAAAA,CAAYgE,WAAAA,EACZhE,WAAAA,CAAYwE,kBAAAA,EACZrE,OAAAA,EACAuD,eAAAA,EACArD,WAAW,CACZ,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"useDeltaPriceQuery.js","sources":["../../../../../../src/hooks/swap/prices/delta/queries/useDeltaPriceQuery.ts"],"sourcesContent":["import { useDeltaSDK } from \"@/hooks/useSDK\";\nimport {\n Query,\n QueryClient,\n QueryObserver,\n useQuery,\n useQueryClient,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { useDebouncedValue } from \"@tanstack/react-pacer/debouncer\";\nimport type {\n DeltaPrice,\n BridgePrice,\n DeltaPriceParams as DParams,\n OptimalRate,\n} from \"@velora-dex/sdk\";\nimport { assert, type MarkOptional } from \"ts-essentials\";\nimport { useMemo } from \"react\";\n\n// overload is easier with input.destChainId\ntype RequiredDeltaPriceParams = Omit<DParams, \"destChainId\">;\ntype DeltaPriceParams = MarkOptional<\n RequiredDeltaPriceParams,\n \"destToken\" | \"destDecimals\" // destToken is not available in SwapForm initially\n>;\n\ntype DeltaQueryParams<TData = DeltaPrice | BridgePrice> = Omit<\n UseQueryOptions<DeltaPrice | BridgePrice, Error, TData, DeltaPriceQueryKey>,\n \"queryKey\" | \"queryFn\"\n>;\ntype DeltaQueryResult<TData = DeltaPrice> = UseQueryResult<TData, Error>;\n\ntype DeltaPriceQueryInput<TData = DeltaPrice> = {\n priceParams: DeltaPriceParams;\n query?: DeltaQueryParams<TData>;\n chainId: number;\n timeout?: number;\n};\n\nexport const DeltaPriceQueryKeyPrefix = \"swap/prices/delta\";\n\nexport type DeltaPriceQueryKey = readonly [\n base: typeof DeltaPriceQueryKeyPrefix,\n chainId: number,\n priceParams: DeltaPriceParams & {\n destChainId?: number;\n },\n];\n\n/**\n * 1. With destChainId: number -> returns BridgePrice\n * 2. With destChainId?: undefined -> returns DeltaPrice\n * 3. With destChainId?: number -> returns DeltaPrice | BridgePrice\n */\nexport function useDeltaPriceQuery<TData = BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: undefined;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams: _priceParams,\n query,\n chainId,\n timeout,\n destChainId,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n} {\n const { sdk } = useDeltaSDK({ chainId });\n\n const queryEnabled = query?.enabled ?? true;\n\n const { queryKey, sanitizedPriceParams } = useDeltaPriceQueryKey({\n priceParams: _priceParams,\n chainId,\n destChainId,\n });\n\n const result = useQuery<\n DeltaPrice | BridgePrice,\n Error,\n TData,\n DeltaPriceQueryKey\n >({\n queryKey,\n queryFn: ({ signal }) => {\n assert(isPriceParamsValid(sanitizedPriceParams), \"destToken is required\");\n const price = sdk.getDeltaPrice(sanitizedPriceParams, {\n signal,\n timeout,\n });\n return price;\n },\n ...query,\n enabled: queryEnabled && isPriceParamsValid(sanitizedPriceParams),\n });\n\n return { result, queryKey };\n}\n\nfunction isPriceParamsValid(\n priceParams: DeltaPriceParams\n): priceParams is RequiredDeltaPriceParams {\n return (\n !!priceParams.destToken &&\n priceParams.destDecimals !== undefined &&\n Number(priceParams.amount) > 0\n );\n}\n\nexport function isDeltaPrice(\n price: OptimalRate | DeltaPrice\n): price is DeltaPrice {\n return \"bridge\" in price;\n}\n\nexport function isBridgePrice(\n price: DeltaPrice | BridgePrice\n): price is BridgePrice {\n return price.bridge.destinationChainId !== 0;\n}\n\ntype GetDeltaPriceQueryForPriceInput = {\n price: DeltaPrice | BridgePrice;\n chainId: number;\n};\n\ntype DeltaPriceQuery = Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n>;\n\ntype GetDeltaPriceQueryForPrice = (\n input: GetDeltaPriceQueryForPriceInput\n) =>\n | Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >\n | undefined;\n\n// get query for a given deltaPrice\nexport function useDeltaPriceQueryForPrice(): GetDeltaPriceQueryForPrice {\n const queryClient = useQueryClient();\n\n return ({ chainId, price }) => {\n const queryKey: [DeltaPriceQueryKey[0], DeltaPriceQueryKey[1]] = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n ];\n const queryCache = queryClient.getQueryCache();\n const query = queryCache.find<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice\n >({\n queryKey,\n exact: false,\n predicate: (query) => {\n return query.state.data === price;\n },\n });\n\n return query as DeltaPriceQuery | undefined;\n };\n}\n\ntype SubscribeToDeltaPriceInput = {\n queryKey: DeltaPriceQueryKey;\n onData?: (data: DeltaPrice | BridgePrice) => void;\n onError?: (error: Error) => void;\n};\n\ntype SubscribeToDeltaPriceResult = (\n input: SubscribeToDeltaPriceInput\n) => () => void;\n\n// independently subscribe to a price query\nexport function useSubscribeToDeltaPrice(): SubscribeToDeltaPriceResult {\n const queryClient = useQueryClient();\n\n return ({ queryKey, onData, onError }) => {\n const observer = new QueryObserver<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >(queryClient, {\n queryKey,\n // only receive updates from existing subscriptions\n enabled: false,\n });\n\n // return unsubscribe function\n return observer.subscribe((result) => {\n if (result.error) {\n onError?.(result.error);\n return;\n }\n if (result.data) {\n onData?.(result.data);\n }\n });\n };\n}\n\nfunction getLastDeltaPriceQuery(\n queryClient: QueryClient\n):\n | Query<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>\n | undefined {\n return queryClient\n .getQueryCache()\n .find<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>({\n queryKey: [DeltaPriceQueryKeyPrefix],\n exact: false,\n type: \"active\", // only the most recent query will be active\n });\n}\n\nexport function getLastDeltaPrice(\n queryClient: QueryClient\n): DeltaPrice | BridgePrice | undefined {\n const query = getLastDeltaPriceQuery(queryClient);\n\n return query?.state.data;\n}\n\nexport function isLastDeltaPriceQueryInError(\n queryClient: QueryClient\n): boolean {\n const query = getLastDeltaPriceQuery(queryClient);\n const error = query?.state.error;\n return !!error;\n}\n\nexport function isDataDeltaOrBridgePrice(\n price: unknown\n): price is DeltaPrice | BridgePrice {\n return (\n typeof price === \"object\" &&\n price !== null &&\n \"bridge\" in price &&\n \"srcToken\" in price &&\n \"destToken\" in price &&\n \"srcAmount\" in price &&\n \"destAmount\" in price\n );\n}\n\nexport function useDeltaPriceQueryKey({\n priceParams,\n chainId,\n destChainId,\n}: Pick<DeltaPriceQueryInput, \"priceParams\" | \"chainId\"> & {\n destChainId?: number;\n}) {\n \"use no memo\";\n\n // amount tends to change fast during input\n const [debouncedAmount] = useDebouncedValue(priceParams.amount, {\n wait: 500,\n });\n\n return useMemo(() => {\n // avoid passing unnecessary params to url?search and queryKey\n const sanitizedPriceParams: DeltaPriceParams & {\n destChainId?: number;\n } = {\n amount: debouncedAmount,\n srcToken: priceParams.srcToken,\n destToken: priceParams.destToken,\n srcDecimals: priceParams.srcDecimals,\n destDecimals: priceParams.destDecimals,\n userAddress: priceParams.userAddress,\n beneficiary: priceParams.beneficiary,\n partner: priceParams.partner,\n side: priceParams.side,\n includeAgents: priceParams.includeAgents,\n excludeAgents: priceParams.excludeAgents,\n includeBridges: priceParams.includeBridges,\n excludeBridges: priceParams.excludeBridges,\n allowBridgeAndSwap: priceParams.allowBridgeAndSwap,\n destChainId: destChainId,\n };\n\n const queryKey: DeltaPriceQueryKey = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n sanitizedPriceParams,\n ];\n\n return { queryKey, sanitizedPriceParams };\n }, [\n priceParams.beneficiary,\n priceParams.destDecimals,\n priceParams.destToken,\n priceParams.excludeAgents,\n priceParams.includeAgents,\n priceParams.includeBridges,\n priceParams.excludeBridges,\n priceParams.partner,\n priceParams.side,\n priceParams.srcDecimals,\n priceParams.srcToken,\n priceParams.userAddress,\n priceParams.allowBridgeAndSwap,\n chainId,\n debouncedAmount,\n destChainId,\n ]);\n}\n"],"names":["DeltaPriceQueryKeyPrefix","useDeltaPriceQuery","t0","$","_c","priceParams","_priceParams","query","chainId","timeout","destChainId","t1","sdk","useDeltaSDK","queryEnabled","enabled","t2","queryKey","sanitizedPriceParams","useDeltaPriceQueryKey","t3","t4","signal","assert","isPriceParamsValid","price","getDeltaPrice","t5","queryFn","result","useQuery","t6","destToken","destDecimals","undefined","Number","amount","isDeltaPrice","isBridgePrice","bridge","destinationChainId","useDeltaPriceQueryForPrice","queryClient","useQueryClient","queryCache","getQueryCache","query_0","find","exact","predicate","state","data","useSubscribeToDeltaPrice","onData","onError","observer","QueryObserver","subscribe","error","getLastDeltaPriceQuery","type","getLastDeltaPrice","isLastDeltaPriceQueryInError","isDataDeltaOrBridgePrice","debouncedAmount","useDebouncedValue","wait","useMemo","srcToken","srcDecimals","userAddress","beneficiary","partner","side","includeAgents","excludeAgents","includeBridges","excludeBridges","allowBridgeAndSwap"],"mappings":";;;;;;;AAwCO,MAAMA,wBAAA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AAA;AAAAA,MAClBC,eAAerE,WAAAA,CAAYqE,aAAAA;AAAAA,MAC3BC,eAAetE,WAAAA,CAAYsE,aAAAA;AAAAA,MAC3BC,gBAAgBvE,WAAAA,CAAYuE,cAAAA;AAAAA,MAC5BC,gBAAgBxE,WAAAA,CAAYwE,cAAAA;AAAAA,MAC5BC,oBAAoBzE,WAAAA,CAAYyE,kBAAAA;AAAAA,MAChCpE;AAAAA,KACF;AAEA,IAAA,MAAMO,QAAAA,GAA+B,CACnCjB,wBAAAA,EACAQ,OAAAA,EACAU,oBAAoB,CAAA;AAGtB,IAAA,OAAO;AAAA,MAAED,QAAAA;AAAAA,MAAUC;AAAAA,KAAqB;AAAA,EAC1C,CAAA,EAAG,CACDb,WAAAA,CAAYkE,WAAAA,EACZlE,WAAAA,CAAY4B,YAAAA,EACZ5B,WAAAA,CAAY2B,SAAAA,EACZ3B,WAAAA,CAAYsE,aAAAA,EACZtE,WAAAA,CAAYqE,aAAAA,EACZrE,YAAYuE,cAAAA,EACZvE,WAAAA,CAAYwE,cAAAA,EACZxE,WAAAA,CAAYmE,OAAAA,EACZnE,WAAAA,CAAYoE,IAAAA,EACZpE,WAAAA,CAAYgE,aACZhE,WAAAA,CAAY+D,QAAAA,EACZ/D,WAAAA,CAAYiE,WAAAA,EACZjE,WAAAA,CAAYyE,kBAAAA,EACZtE,OAAAA,EACAwD,eAAAA,EACAtD,WAAW,CACZ,CAAA;AACH;;;;"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { d as distExports } from '../../../_virtual/index.js';
|
|
2
|
+
import '../../useSDK.js';
|
|
3
|
+
import '@tanstack/react-pacer/debouncer';
|
|
4
|
+
import '@tanstack/react-query';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'ts-essentials';
|
|
2
7
|
import { useAtomValue } from '../../../core/store.js';
|
|
3
8
|
import { useAccount } from 'wagmi';
|
|
4
9
|
import { useSwapSide } from '../../../components/widget/SwapModeSwitcher/state/swapSideAtom.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePricesParams.js","sources":["../../../../src/hooks/swap/prices/usePricesParams.ts"],"sourcesContent":["import { type RateParamsInput } from \"./market/queries/useMarketPriceQuery\";\n\nimport { useAtomValue } from \"@/core/store\";\nimport { useAccount } from \"wagmi\";\nimport type { MarkOptional, MarkRequired } from \"ts-essentials\";\nimport { useSwapSide } from \"@/components/widget/SwapModeSwitcher/state/swapSideAtom\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useTokenTaxFee } from \"@/hooks/tokens/useTokenTaxFee\";\nimport { usePartner } from \"@/hooks/usePartner\";\nimport type { TradeMode } from \"@/core/state/tradeModeAtom\";\nimport {\n tradeModeToPayAmountWeiAtom,\n tradeModeToReceiveAmountWeiAtom,\n tradeModeToTokenAtoms,\n} from \"@/core/inputs/state/common\";\nimport { useWidgetConfig } from \"@/core/state/configAtom\";\n\nexport type FetchPriceParams = MarkRequired<\n MarkOptional<\n Pick<\n RateParamsInput,\n | \"srcToken\"\n | \"destToken\"\n | \"amount\"\n | \"userAddress\"\n | \"side\"\n | \"srcDecimals\"\n | \"destDecimals\"\n | \"partner\"\n | \"ignoreBadUsdPrice\"\n | \"srcTokenDexTransferFee\"\n | \"destTokenDexTransferFee\"\n | \"otherExchangePrices\"\n >,\n \"destToken\"\n >,\n \"srcDecimals\" | \"side\"\n>;\n// @TODO add other params from options:\n// exclude* for Safe if still needed, or if we want to allow exluding DEXs like in UI\n\nexport function usePricesParams(tradeMode: TradeMode): {\n priceParams: FetchPriceParams;\n isCrossChain: boolean;\n chainId: SupportedChainId;\n destChainId?: SupportedChainId;\n} {\n const { tokenFromAtom, tokenToAtom } = tradeModeToTokenAtoms[tradeMode];\n const fromToken = useAtomValue(tokenFromAtom);\n const toToken = useAtomValue(tokenToAtom);\n\n const payAmountWeiAtom = tradeModeToPayAmountWeiAtom[tradeMode];\n const receiveAmountWeiAtom = tradeModeToReceiveAmountWeiAtom[tradeMode];\n\n const payAmountWei = useAtomValue(payAmountWeiAtom);\n const receiveAmountWei = useAtomValue(receiveAmountWeiAtom) ?? \"0\";\n\n const { data: fromTokenTaxFee } = useTokenTaxFee({\n tokenAddress: fromToken.address,\n chainId: fromToken.network,\n });\n\n const { data: toTokenTaxFee } = useTokenTaxFee({\n tokenAddress: toToken?.address,\n chainId: toToken?.network,\n });\n\n const srcTokenDexTransferFee = fromTokenTaxFee?.sellTax?.toString();\n const destTokenDexTransferFee = toTokenTaxFee?.buyTax?.toString();\n\n const { address } = useAccount();\n\n const widgetConfig = useWidgetConfig();\n const partner = usePartner();\n\n const isCrossChain = !!toToken && fromToken.network !== toToken.network;\n\n const swapSide = useSwapSide();\n const side = tradeMode === \"swap\" ? swapSide : \"SELL\";\n const amount = side === \"SELL\" ? payAmountWei : receiveAmountWei;\n\n const priceParams: FetchPriceParams = {\n srcToken: fromToken.address,\n destToken: toToken?.address,\n srcDecimals: fromToken.decimals,\n destDecimals: toToken?.decimals,\n side,\n amount,\n userAddress: address,\n partner,\n ignoreBadUsdPrice: widgetConfig.ignoreBadUsdPrice ?? true,\n srcTokenDexTransferFee,\n destTokenDexTransferFee,\n otherExchangePrices: true,\n };\n\n return {\n priceParams,\n isCrossChain,\n chainId: fromToken.network,\n destChainId: isCrossChain ? toToken?.network : undefined,\n };\n}\n"],"names":["usePricesParams","tradeMode","$","_c","tokenFromAtom","tokenToAtom","tradeModeToTokenAtoms","fromToken","useAtomValue","toToken","payAmountWeiAtom","tradeModeToPayAmountWeiAtom","receiveAmountWeiAtom","tradeModeToReceiveAmountWeiAtom","payAmountWei","receiveAmountWei","t0","address","network","tokenAddress","chainId","data","fromTokenTaxFee","useTokenTaxFee","t1","t2","t3","toTokenTaxFee","t4","sellTax","toString","srcTokenDexTransferFee","t5","buyTax","destTokenDexTransferFee","useAccount","widgetConfig","useWidgetConfig","partner","usePartner","isCrossChain","swapSide","useSwapSide","side","amount","t6","t7","decimals","t8","ignoreBadUsdPrice","t9","srcToken","destToken","srcDecimals","destDecimals","userAddress","otherExchangePrices","priceParams","t10","undefined","t11","destChainId"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePricesParams.js","sources":["../../../../src/hooks/swap/prices/usePricesParams.ts"],"sourcesContent":["import { type RateParamsInput } from \"./market/queries/useMarketPriceQuery\";\n\nimport { useAtomValue } from \"@/core/store\";\nimport { useAccount } from \"wagmi\";\nimport type { MarkOptional, MarkRequired } from \"ts-essentials\";\nimport { useSwapSide } from \"@/components/widget/SwapModeSwitcher/state/swapSideAtom\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useTokenTaxFee } from \"@/hooks/tokens/useTokenTaxFee\";\nimport { usePartner } from \"@/hooks/usePartner\";\nimport type { TradeMode } from \"@/core/state/tradeModeAtom\";\nimport {\n tradeModeToPayAmountWeiAtom,\n tradeModeToReceiveAmountWeiAtom,\n tradeModeToTokenAtoms,\n} from \"@/core/inputs/state/common\";\nimport { useWidgetConfig } from \"@/core/state/configAtom\";\n\nexport type FetchPriceParams = MarkRequired<\n MarkOptional<\n Pick<\n RateParamsInput,\n | \"srcToken\"\n | \"destToken\"\n | \"amount\"\n | \"userAddress\"\n | \"side\"\n | \"srcDecimals\"\n | \"destDecimals\"\n | \"partner\"\n | \"ignoreBadUsdPrice\"\n | \"srcTokenDexTransferFee\"\n | \"destTokenDexTransferFee\"\n | \"otherExchangePrices\"\n >,\n \"destToken\"\n >,\n \"srcDecimals\" | \"side\"\n>;\n// @TODO add other params from options:\n// exclude* for Safe if still needed, or if we want to allow exluding DEXs like in UI\n\nexport function usePricesParams(tradeMode: TradeMode): {\n priceParams: FetchPriceParams;\n isCrossChain: boolean;\n chainId: SupportedChainId;\n destChainId?: SupportedChainId;\n} {\n const { tokenFromAtom, tokenToAtom } = tradeModeToTokenAtoms[tradeMode];\n const fromToken = useAtomValue(tokenFromAtom);\n const toToken = useAtomValue(tokenToAtom);\n\n const payAmountWeiAtom = tradeModeToPayAmountWeiAtom[tradeMode];\n const receiveAmountWeiAtom = tradeModeToReceiveAmountWeiAtom[tradeMode];\n\n const payAmountWei = useAtomValue(payAmountWeiAtom);\n const receiveAmountWei = useAtomValue(receiveAmountWeiAtom) ?? \"0\";\n\n const { data: fromTokenTaxFee } = useTokenTaxFee({\n tokenAddress: fromToken.address,\n chainId: fromToken.network,\n });\n\n const { data: toTokenTaxFee } = useTokenTaxFee({\n tokenAddress: toToken?.address,\n chainId: toToken?.network,\n });\n\n const srcTokenDexTransferFee = fromTokenTaxFee?.sellTax?.toString();\n const destTokenDexTransferFee = toTokenTaxFee?.buyTax?.toString();\n\n const { address } = useAccount();\n\n const widgetConfig = useWidgetConfig();\n const partner = usePartner();\n\n const isCrossChain = !!toToken && fromToken.network !== toToken.network;\n\n const swapSide = useSwapSide();\n const side = tradeMode === \"swap\" ? swapSide : \"SELL\";\n const amount = side === \"SELL\" ? payAmountWei : receiveAmountWei;\n\n const priceParams: FetchPriceParams = {\n srcToken: fromToken.address,\n destToken: toToken?.address,\n srcDecimals: fromToken.decimals,\n destDecimals: toToken?.decimals,\n side,\n amount,\n userAddress: address,\n partner,\n ignoreBadUsdPrice: widgetConfig.ignoreBadUsdPrice ?? true,\n srcTokenDexTransferFee,\n destTokenDexTransferFee,\n otherExchangePrices: true,\n };\n\n return {\n priceParams,\n isCrossChain,\n chainId: fromToken.network,\n destChainId: isCrossChain ? toToken?.network : undefined,\n };\n}\n"],"names":["usePricesParams","tradeMode","$","_c","tokenFromAtom","tokenToAtom","tradeModeToTokenAtoms","fromToken","useAtomValue","toToken","payAmountWeiAtom","tradeModeToPayAmountWeiAtom","receiveAmountWeiAtom","tradeModeToReceiveAmountWeiAtom","payAmountWei","receiveAmountWei","t0","address","network","tokenAddress","chainId","data","fromTokenTaxFee","useTokenTaxFee","t1","t2","t3","toTokenTaxFee","t4","sellTax","toString","srcTokenDexTransferFee","t5","buyTax","destTokenDexTransferFee","useAccount","widgetConfig","useWidgetConfig","partner","usePartner","isCrossChain","swapSide","useSwapSide","side","amount","t6","t7","decimals","t8","ignoreBadUsdPrice","t9","srcToken","destToken","srcDecimals","destDecimals","userAddress","otherExchangePrices","priceParams","t10","undefined","t11","destChainId"],"mappings":";;;;;;;;;;;;;;AAyCO,SAAAA,gBAAAC,SAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,EAAA,CAAA;AAML,EAAA,MAAA;AAAA,IAAAC,aAAAA;AAAAA,IAAAC;AAAAA,GAAA,GAAuCC,sBAAsBL,SAAS,CAAA;AACtE,EAAA,MAAAM,SAAAA,GAAkBC,aAAaJ,aAAa,CAAA;AAC5C,EAAA,MAAAK,OAAAA,GAAgBD,aAAaH,WAAW,CAAA;AAExC,EAAA,MAAAK,gBAAAA,GAAyBC,4BAA4BV,SAAS,CAAA;AAC9D,EAAA,MAAAW,oBAAAA,GAA6BC,gCAAgCZ,SAAS,CAAA;AAEtE,EAAA,MAAAa,YAAAA,GAAqBN,aAAaE,gBAAgB,CAAA;AAClD,EAAA,MAAAK,gBAAAA,GAAyBP,YAAAA,CAAaI,oBAA2B,CAAA,IAAxC,GAAA;AAA0C,EAAA,IAAAI,EAAAA;AAAA,EAAA,IAAAd,CAAAA,CAAA,CAAA,CAAA,KAAAK,SAAAA,CAAAU,WAAAf,CAAAA,CAAA,CAAA,CAAA,KAAAK,SAAAA,CAAAW,OAAAA,EAAA;AAElBF,IAAAA,EAAAA,GAAA;AAAA,MAAAG,cACjCZ,SAAAA,CAASU,OAAAA;AAAAA,MAAQG,SACtBb,SAAAA,CAASW;AAAAA,KACpB;AAAChB,IAAAA,CAAAA,CAAA,CAAA,IAAAK,SAAAA,CAAAU,OAAAA;AAAAf,IAAAA,CAAAA,CAAA,CAAA,IAAAK,SAAAA,CAAAW,OAAAA;AAAAhB,IAAAA,CAAAA,MAAAc,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAd,EAAA,CAAA,CAAA;AAAA,EAAA;AAHD,EAAA,MAAA;AAAA,IA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AA,GAAe/B,OAAAA,EAAOS,OAAAA,GAAtByC,MAAAA;AAA2C,EAAA,IAAAC,GAAAA;AAAA,EAAA,IAAA1D,EAAA,EAAA,CAAA,KAAAK,SAAAA,CAAAW,OAAAA,IAAAhB,EAAA,EAAA,CAAA,KAAAsC,YAAAA,IAAAtC,CAAAA,CAAA,EAAA,CAAA,KAAAuD,WAAAA,IAAAvD,CAAAA,SAAAwD,GAAAA,EAAA;AAJnDE,IAAAA,GAAAA,GAAA;AAAA,MAAAH,WAAAA;AAAAA,MAAAjB,YAAAA;AAAAA,MAAApB,SAGIb,SAAAA,CAASW,OAAAA;AAAAA,MAAQ2C,WAAAA,EACbH;AAAAA,KACf;AAACxD,IAAAA,CAAAA,CAAA,EAAA,IAAAK,SAAAA,CAAAW,OAAAA;AAAAhB,IAAAA,CAAAA,OAAAsC,YAAAA;AAAAtC,IAAAA,CAAAA,OAAAuD,WAAAA;AAAAvD,IAAAA,CAAAA,OAAAwD,GAAAA;AAAAxD,IAAAA,CAAAA,OAAA0D,GAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,GAAAA,GAAA1D,EAAA,EAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OALM0D,GAAAA;AAKN;;;;"}
|
|
@@ -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,
|
|
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"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { d as distExports } from '../../../_virtual/index.js';
|
|
2
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
3
|
-
import {
|
|
3
|
+
import { useWaitForTransactionReceipt, useConfig } from 'wagmi';
|
|
4
4
|
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
8
|
import { SAFE_CALLS_WAIT_TIMEOUT } from '../../../lib/constants/index.js';
|
|
9
|
-
import { useIsSafeConnector } from '../../connectors/useIsGnosisSafeConnector.js';
|
|
10
|
-
import { assert } from 'ts-essentials';
|
|
11
9
|
|
|
12
10
|
function useAwaitTx(t0) {
|
|
13
|
-
const $ = distExports.c(
|
|
11
|
+
const $ = distExports.c(10);
|
|
14
12
|
const {
|
|
15
13
|
chainId,
|
|
16
14
|
confirmations,
|
|
@@ -19,89 +17,39 @@ function useAwaitTx(t0) {
|
|
|
19
17
|
} = t0;
|
|
20
18
|
const logger = useLogger("AwaitTx");
|
|
21
19
|
const isSafe = useConnectedSafe();
|
|
22
|
-
const isSafeConnector = useIsSafeConnector();
|
|
23
20
|
const timeout = isSafe ? SAFE_CALLS_WAIT_TIMEOUT : void 0;
|
|
24
|
-
const {
|
|
25
|
-
address: account
|
|
26
|
-
} = useAccount();
|
|
27
21
|
let t1;
|
|
28
|
-
if ($[0] !==
|
|
29
|
-
t1 = {
|
|
30
|
-
|
|
31
|
-
account
|
|
22
|
+
if ($[0] !== hash || $[1] !== logger) {
|
|
23
|
+
t1 = (data) => {
|
|
24
|
+
logger.log("onReplaced:tx", hash, data);
|
|
32
25
|
};
|
|
33
|
-
$[0] =
|
|
34
|
-
$[1] =
|
|
26
|
+
$[0] = hash;
|
|
27
|
+
$[1] = logger;
|
|
35
28
|
$[2] = t1;
|
|
36
29
|
} else {
|
|
37
30
|
t1 = $[2];
|
|
38
31
|
}
|
|
39
|
-
const {
|
|
40
|
-
data: connectorClient
|
|
41
|
-
} = useConnectorClient(t1);
|
|
42
|
-
const wagmiConfig = useConfig();
|
|
43
|
-
let config = wagmiConfig;
|
|
44
|
-
if (isSafeConnector && connectorClient) {
|
|
45
|
-
let t22;
|
|
46
|
-
if ($[3] !== chainId || $[4] !== connectorClient) {
|
|
47
|
-
t22 = (options) => {
|
|
48
|
-
assert(!options || options.chainId === chainId, "chainId mismatch");
|
|
49
|
-
return connectorClient;
|
|
50
|
-
};
|
|
51
|
-
$[3] = chainId;
|
|
52
|
-
$[4] = connectorClient;
|
|
53
|
-
$[5] = t22;
|
|
54
|
-
} else {
|
|
55
|
-
t22 = $[5];
|
|
56
|
-
}
|
|
57
|
-
let t32;
|
|
58
|
-
if ($[6] !== t22 || $[7] !== wagmiConfig) {
|
|
59
|
-
t32 = {
|
|
60
|
-
...wagmiConfig,
|
|
61
|
-
getClient: t22
|
|
62
|
-
};
|
|
63
|
-
$[6] = t22;
|
|
64
|
-
$[7] = wagmiConfig;
|
|
65
|
-
$[8] = t32;
|
|
66
|
-
} else {
|
|
67
|
-
t32 = $[8];
|
|
68
|
-
}
|
|
69
|
-
config = t32;
|
|
70
|
-
}
|
|
71
32
|
let t2;
|
|
72
|
-
if ($[
|
|
73
|
-
t2 =
|
|
74
|
-
logger.log("onReplaced:tx", hash, data);
|
|
75
|
-
};
|
|
76
|
-
$[9] = hash;
|
|
77
|
-
$[10] = logger;
|
|
78
|
-
$[11] = t2;
|
|
79
|
-
} else {
|
|
80
|
-
t2 = $[11];
|
|
81
|
-
}
|
|
82
|
-
let t3;
|
|
83
|
-
if ($[12] !== chainId || $[13] !== config || $[14] !== confirmations || $[15] !== hash || $[16] !== query || $[17] !== t2 || $[18] !== timeout) {
|
|
84
|
-
t3 = {
|
|
85
|
-
config,
|
|
33
|
+
if ($[3] !== chainId || $[4] !== confirmations || $[5] !== hash || $[6] !== query || $[7] !== t1 || $[8] !== timeout) {
|
|
34
|
+
t2 = {
|
|
86
35
|
chainId,
|
|
87
36
|
confirmations,
|
|
88
37
|
timeout,
|
|
89
38
|
hash,
|
|
90
39
|
query,
|
|
91
|
-
onReplaced:
|
|
40
|
+
onReplaced: t1
|
|
92
41
|
};
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
$[19] = t3;
|
|
42
|
+
$[3] = chainId;
|
|
43
|
+
$[4] = confirmations;
|
|
44
|
+
$[5] = hash;
|
|
45
|
+
$[6] = query;
|
|
46
|
+
$[7] = t1;
|
|
47
|
+
$[8] = timeout;
|
|
48
|
+
$[9] = t2;
|
|
101
49
|
} else {
|
|
102
|
-
|
|
50
|
+
t2 = $[9];
|
|
103
51
|
}
|
|
104
|
-
const queryResult = useWaitForTransactionReceipt(
|
|
52
|
+
const queryResult = useWaitForTransactionReceipt(t2);
|
|
105
53
|
return queryResult;
|
|
106
54
|
}
|
|
107
55
|
function useEnsureTxReceipt() {
|
|
@@ -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
|
|
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","ensureTxRe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AAAA,EAAA;AAAA,EAAA,OAA5DD,EAAAA;AAA4D;;;;"}
|
|
@@ -28,7 +28,7 @@ const privyConfig = {
|
|
|
28
28
|
},
|
|
29
29
|
// another option is to give an invalid ID,
|
|
30
30
|
// but then it retries indefinitely
|
|
31
|
-
walletConnectCloudProjectId: "
|
|
31
|
+
walletConnectCloudProjectId: "9796e40630a6bea7605ac281b0deb939",
|
|
32
32
|
// Privy doesn't accept const Chain[]
|
|
33
33
|
supportedChains: chains
|
|
34
34
|
// defaultChain: chains[0], @TODO set to App's selected chain
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/lib/web3/wagmi/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/lib/web3/wagmi/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAoC5E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAgB8yC,CAAC;;;;;;;;;;;;2BAAgrB,CAAC;+BAAgG,CAAC;;;;;;;;;;;;;;;;;;;;;;wBAAw5B,CAAC;gCAAyD,CAAC;;;0BAAuI,CAAC;oBAA+B,CAAC;;;;;;;;;;;;;;;;;;0BAA8xB,CAAC;iCAA0D,CAAC;mCAA4D,CAAC;uBAAgD,CAAC;uBAA6C,CAAC;;;gCAA2H,CAAC;4BAAqD,CA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BAAiL,CAAC;oBAA6C,CAAC;0BAAmD,CAAC;;;;;;;;;;;;;;;;;;;mCAA03B,CAAC;;;wBAAmH,CAAC;gCAAyD,CAAC;;;0BAAuI,CAAC;oBAA6C,CAAC;0BAAmD,CAAC;;;;;;;4BAAsR,CAAC;2BAAiD,CAAC;;;;;;;;;;oBAAsgB,CAAC;;;;;;;;;;;;;;;;;0JAP/tU,CAAC;AAEH,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,QAAQ;QAChB,MAAM,EAAE,OAAO,WAAW,CAAC;KAC5B;CACF"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { createConfig } from 'wagmi';
|
|
1
|
+
import { createConfig, createStorage } from 'wagmi';
|
|
2
2
|
import { walletConnect, injected, coinbaseWallet, safe } from 'wagmi/connectors';
|
|
3
3
|
import { chains } from './constants.js';
|
|
4
4
|
import { transports } from './transports.js';
|
|
5
5
|
import { isInIframe } from './isInsideSafeIframe.js';
|
|
6
|
+
import { LOCAL_STORAGE_PREFIX } from '../../constants/storage.js';
|
|
6
7
|
|
|
7
8
|
const connectors = [
|
|
8
9
|
walletConnect({
|
|
9
|
-
projectId: "
|
|
10
|
+
projectId: "9796e40630a6bea7605ac281b0deb939"
|
|
10
11
|
}),
|
|
11
12
|
injected(),
|
|
12
13
|
// metaMask() as CreateConnectorFn, // injected() detects metamask already
|
|
@@ -19,6 +20,10 @@ if (isInIframe) {
|
|
|
19
20
|
connectors.unshift(safe());
|
|
20
21
|
}
|
|
21
22
|
const wagmiConfig = createConfig({
|
|
23
|
+
storage: createStorage({
|
|
24
|
+
storage: typeof window !== "undefined" ? window.localStorage : void 0,
|
|
25
|
+
key: `${LOCAL_STORAGE_PREFIX}_wagmi`
|
|
26
|
+
}),
|
|
22
27
|
chains,
|
|
23
28
|
connectors,
|
|
24
29
|
transports,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../../src/lib/web3/wagmi/config.ts"],"sourcesContent":["import { createConfig, type CreateConnectorFn } from \"wagmi\";\nimport {\n injected,\n // metaMask,\n safe,\n walletConnect,\n coinbaseWallet,\n} from \"wagmi/connectors\";\nimport { chains } from \"./constants\";\nimport { transports } from \"./transports\";\nimport { isInIframe } from \"./isInsideSafeIframe\";\n\n// can add more connectors to cover wallets Privy doesn't support, but need to change UI to allow connection\nconst connectors = [\n walletConnect({\n projectId: import.meta.env.VITE_WALLET_CONNECT_ID,\n }) as CreateConnectorFn,\n injected() as CreateConnectorFn,\n // metaMask() as CreateConnectorFn, // injected() detects metamask already\n coinbaseWallet() as CreateConnectorFn,\n // raw returned types result in\n // The inferred type of 'config' cannot be named without a reference to '.pnpm/@safe-global+safe-apps-provider@0.18.6_typescript@5.8.3/node_modules/@safe-global/safe-apps-provider'. This is likely not portable. A type annotation is necessary.\n\n // getPrivyWalletConnector(), // only CorssApp Privy connector is available, not our use case\n];\n// @TODO see how we can implement Ledger connector, borrow it from rainbowkit?\n\nif (isInIframe) {\n // when widget is in an App inside iframe, chances are we are in Safe web app,\n // allow Safe connector to be used.\n // we can't know if we are inside specifically Safe iframe until we try to connect, though.\n // A check for that is in isInsideSafeIframe.ts\n connectors.unshift(safe());\n}\n\nexport const wagmiConfig = createConfig({\n chains,\n connectors,\n transports,\n syncConnectedChain: false,\n});\n\ndeclare module \"wagmi\" {\n interface Register {\n config: typeof wagmiConfig;\n }\n}\n"],"names":["connectors","walletConnect","projectId","import","injected","coinbaseWallet","isInIframe","unshift","safe","wagmiConfig","createConfig","chains","transports","syncConnectedChain"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../../src/lib/web3/wagmi/config.ts"],"sourcesContent":["import { createConfig, createStorage, type CreateConnectorFn } from \"wagmi\";\nimport {\n injected,\n // metaMask,\n safe,\n walletConnect,\n coinbaseWallet,\n} from \"wagmi/connectors\";\nimport { chains } from \"./constants\";\nimport { transports } from \"./transports\";\nimport { isInIframe } from \"./isInsideSafeIframe\";\nimport { LOCAL_STORAGE_PREFIX } from \"@/lib/constants/storage\";\n\n// can add more connectors to cover wallets Privy doesn't support, but need to change UI to allow connection\nconst connectors = [\n walletConnect({\n projectId: import.meta.env.VITE_WALLET_CONNECT_ID,\n }) as CreateConnectorFn,\n injected() as CreateConnectorFn,\n // metaMask() as CreateConnectorFn, // injected() detects metamask already\n coinbaseWallet() as CreateConnectorFn,\n // raw returned types result in\n // The inferred type of 'config' cannot be named without a reference to '.pnpm/@safe-global+safe-apps-provider@0.18.6_typescript@5.8.3/node_modules/@safe-global/safe-apps-provider'. This is likely not portable. A type annotation is necessary.\n\n // getPrivyWalletConnector(), // only CorssApp Privy connector is available, not our use case\n];\n// @TODO see how we can implement Ledger connector, borrow it from rainbowkit?\n\nif (isInIframe) {\n // when widget is in an App inside iframe, chances are we are in Safe web app,\n // allow Safe connector to be used.\n // we can't know if we are inside specifically Safe iframe until we try to connect, though.\n // A check for that is in isInsideSafeIframe.ts\n connectors.unshift(safe());\n}\n\nexport const wagmiConfig = createConfig({\n storage: createStorage({\n storage: typeof window !== \"undefined\" ? window.localStorage : undefined,\n key: `${LOCAL_STORAGE_PREFIX}_wagmi`,\n }),\n chains,\n connectors,\n transports,\n syncConnectedChain: false,\n});\n\ndeclare module \"wagmi\" {\n interface Register {\n config: typeof wagmiConfig;\n }\n}\n"],"names":["connectors","walletConnect","projectId","import","injected","coinbaseWallet","isInIframe","unshift","safe","wagmiConfig","createConfig","storage","createStorage","window","localStorage","undefined","key","LOCAL_STORAGE_PREFIX","chains","transports","syncConnectedChain"],"mappings":";;;;;;;AAcA,MAAMA,UAAAA,GAAa;AAAA,EACjBC,aAAAA,CAAc;AAAA,IACZC,SAAAA,EAAWC;AAAAA,GACZ,CAAA;AAAA,EACDC,QAAAA,EAAS;AAAA;AAAA,EAETC,cAAAA;AAAe;AAAA;AAAA;AAIf,CAAA;AAIF,IAAIC,UAAAA,EAAY;AAKdN,EAAAA,UAAAA,CAAWO,OAAAA,CAAQC,MAAM,CAAA;AAC3B;AAEO,MAAMC,cAAcC,YAAAA,CAAa;AAAA,EACtCC,SAASC,aAAAA,CAAc;AAAA,IACrBD,OAAAA,EAAS,OAAOE,MAAAA,KAAW,WAAA,GAAcA,OAAOC,YAAAA,GAAeC,MAAAA;AAAAA,IAC/DC,GAAAA,EAAK,GAAGC,oBAAoB,CAAA,MAAA;AAAA,GAC7B,CAAA;AAAA,EACDC,MAAAA;AAAAA,EACAlB,UAAAA;AAAAA,EACAmB,UAAAA;AAAAA,EACAC,kBAAAA,EAAoB;AACtB,CAAC;;;;"}
|
package/dist/styles.css
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
:root, :host {
|
|
74
74
|
--font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
75
75
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
76
76
|
--color-red-800: oklch(44.4% .177 26.899);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const finalizeStandoloneTxsEffect: import('jotai').Atom<void> & {
|
|
2
2
|
effect: import('jotai-effect').Effect;
|
|
3
3
|
};
|
|
4
4
|
export declare const finalizeBatchTxsEffect: import('jotai').Atom<void> & {
|
|
@@ -5,7 +5,7 @@ import { transactionLogger } from '../../logger.js';
|
|
|
5
5
|
import { accountAtom } from '../../../lib/web3/wagmi/external.js';
|
|
6
6
|
|
|
7
7
|
let hasRunStandaloneEffect = false;
|
|
8
|
-
const
|
|
8
|
+
const finalizeStandoloneTxsEffect = atomEffect((get, set) => {
|
|
9
9
|
if (hasRunStandaloneEffect) return;
|
|
10
10
|
hasRunStandaloneEffect = true;
|
|
11
11
|
const pendingStandaloneTxs = get(allPendingStandaloneTransactionItemsAtom);
|
|
@@ -24,5 +24,5 @@ const finalizeBatchTxsEffect = atomEffect((get, set) => {
|
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
export { finalizeBatchTxsEffect,
|
|
27
|
+
export { finalizeBatchTxsEffect, finalizeStandoloneTxsEffect };
|
|
28
28
|
//# sourceMappingURL=finalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finalize.js","sources":["../../../../src/transactions/state/effects/finalize.ts"],"sourcesContent":["import { atomEffect } from \"jotai-effect\";\nimport {\n allPendingBatchTransactionItemsAtom,\n allPendingStandaloneTransactionItemsAtom,\n} from \"../transactionsAtom\";\nimport {\n finalizeBatchTxAtom,\n finalizeStandaloneTxAtom,\n} from \"../transactionsActionAtom\";\n\nimport { transactionLogger } from \"../../logger\";\nimport { accountAtom } from \"@/lib/web3/wagmi/external\";\n\n// run only once on app load\nlet hasRunStandaloneEffect = false;\nexport const
|
|
1
|
+
{"version":3,"file":"finalize.js","sources":["../../../../src/transactions/state/effects/finalize.ts"],"sourcesContent":["import { atomEffect } from \"jotai-effect\";\nimport {\n allPendingBatchTransactionItemsAtom,\n allPendingStandaloneTransactionItemsAtom,\n} from \"../transactionsAtom\";\nimport {\n finalizeBatchTxAtom,\n finalizeStandaloneTxAtom,\n} from \"../transactionsActionAtom\";\n\nimport { transactionLogger } from \"../../logger\";\nimport { accountAtom } from \"@/lib/web3/wagmi/external\";\n\n// run only once on app load\nlet hasRunStandaloneEffect = false;\nexport const finalizeStandoloneTxsEffect = atomEffect((get, set) => {\n if (hasRunStandaloneEffect) return;\n hasRunStandaloneEffect = true;\n\n const pendingStandaloneTxs = get(allPendingStandaloneTransactionItemsAtom);\n transactionLogger.log(\"Effect::pendingStandaloneTxs\", pendingStandaloneTxs);\n pendingStandaloneTxs.forEach((tx) => set(finalizeStandaloneTxAtom, tx));\n});\n\n// run only once after account is connected and available in atom\n// because waitForCallsStatus requires wallet to be connected\nlet hasRunBatchEffect = false;\nexport const finalizeBatchTxsEffect = atomEffect((get, set) => {\n if (hasRunBatchEffect) return;\n\n const account = get(accountAtom);\n if (account) {\n hasRunBatchEffect = true;\n\n const pendingBatchTxs = get(allPendingBatchTransactionItemsAtom);\n transactionLogger.log(\"Effect::pendingBatchTxs\", pendingBatchTxs);\n pendingBatchTxs.forEach((tx) => set(finalizeBatchTxAtom, tx));\n }\n});\n"],"names":["hasRunStandaloneEffect","finalizeStandoloneTxsEffect","atomEffect","get","set","pendingStandaloneTxs","allPendingStandaloneTransactionItemsAtom","transactionLogger","log","forEach","tx","finalizeStandaloneTxAtom","hasRunBatchEffect","finalizeBatchTxsEffect","account","accountAtom","pendingBatchTxs","allPendingBatchTransactionItemsAtom","finalizeBatchTxAtom"],"mappings":";;;;;;AAcA,IAAIA,sBAAAA,GAAyB,KAAA;AACtB,MAAMC,2BAAAA,GAA8BC,UAAAA,CAAW,CAACC,GAAAA,EAAKC,GAAAA,KAAQ;AAClE,EAAA,IAAIJ,sBAAAA,EAAwB;AAC5BA,EAAAA,sBAAAA,GAAyB,IAAA;AAEzB,EAAA,MAAMK,oBAAAA,GAAuBF,IAAIG,wCAAwC,CAAA;AACzEC,EAAAA,iBAAAA,CAAkBC,GAAAA,CAAI,gCAAgCH,oBAAoB,CAAA;AAC1EA,EAAAA,oBAAAA,CAAqBI,OAAAA,CAASC,CAAAA,EAAAA,KAAON,GAAAA,CAAIO,wBAAAA,EAA0BD,EAAE,CAAC,CAAA;AACxE,CAAC;AAID,IAAIE,iBAAAA,GAAoB,KAAA;AACjB,MAAMC,sBAAAA,GAAyBX,UAAAA,CAAW,CAACC,GAAAA,EAAKC,GAAAA,KAAQ;AAC7D,EAAA,IAAIQ,iBAAAA,EAAmB;AAEvB,EAAA,MAAME,OAAAA,GAAUX,IAAIY,WAAW,CAAA;AAC/B,EAAA,IAAID,OAAAA,EAAS;AACXF,IAAAA,iBAAAA,GAAoB,IAAA;AAEpB,IAAA,MAAMI,eAAAA,GAAkBb,IAAIc,mCAAmC,CAAA;AAC/DV,IAAAA,iBAAAA,CAAkBC,GAAAA,CAAI,2BAA2BQ,eAAe,CAAA;AAChEA,IAAAA,eAAAA,CAAgBP,OAAAA,CAASC,CAAAA,EAAAA,KAAON,GAAAA,CAAIc,mBAAAA,EAAqBR,EAAE,CAAC,CAAA;AAAA,EAC9D;AACF,CAAC;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useAtom } from '../../../core/store.js';
|
|
2
|
-
import {
|
|
2
|
+
import { finalizeStandoloneTxsEffect, finalizeBatchTxsEffect } from '../effects/finalize.js';
|
|
3
3
|
|
|
4
4
|
function useActivateEffects() {
|
|
5
|
-
useAtom(
|
|
5
|
+
useAtom(finalizeStandoloneTxsEffect);
|
|
6
6
|
useAtom(finalizeBatchTxsEffect);
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActivateEffects.js","sources":["../../../../src/transactions/state/hooks/useActivateEffects.ts"],"sourcesContent":["import { useAtom } from \"@/core/store\";\nimport {\n finalizeBatchTxsEffect,\n
|
|
1
|
+
{"version":3,"file":"useActivateEffects.js","sources":["../../../../src/transactions/state/hooks/useActivateEffects.ts"],"sourcesContent":["import { useAtom } from \"@/core/store\";\nimport {\n finalizeBatchTxsEffect,\n finalizeStandoloneTxsEffect,\n} from \"@/transactions/state/effects/finalize\";\n\nexport function useActivateEffects() {\n // atomEffects must be rendered for subscriptions to activate\n useAtom(finalizeStandoloneTxsEffect);\n useAtom(finalizeBatchTxsEffect);\n}\n"],"names":["useActivateEffects","useAtom","finalizeStandoloneTxsEffect","finalizeBatchTxsEffect"],"mappings":";;;AAMO,SAAAA,kBAAAA,GAAA;AAELC,EAAAA,OAAAA,CAAQC,2BAA2B,CAAA;AACnCD,EAAAA,OAAAA,CAAQE,sBAAsB,CAAA;AAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionsActionAtom.js","sources":["../../../src/transactions/state/transactionsActionAtom.ts"],"sourcesContent":["import type {\n TransactionItem,\n StandaloneTransactionItem,\n BatchTransactionItem,\n MinTransactionItem,\n} from \"../types\";\nimport { atom } from \"jotai\";\nimport { jotaiStore } from \"@/core/store\";\n\nimport { ensureCallsStatusFactory } from \"../queries/ensureCallsStatus\";\nimport { ensureTxReceiptFactory } from \"../queries/ensureTxReceipt\";\nimport {\n WaitForCallsStatusTimeoutError,\n TransactionReceiptNotFoundError,\n WaitForTransactionReceiptTimeoutError,\n MethodNotSupportedRpcError,\n} from \"viem\";\nimport { transactionLogger } from \"../logger\";\nimport {\n transactionsAtom,\n type TransactionsMap,\n type TransactionsState,\n} from \"./transactionsAtom\";\nimport { isBatchTransactionItem, isStandaloneTransactionItem } from \"../utils\";\nimport { accountAtom } from \"@/lib/web3/wagmi/external\";\nimport { assert } from \"ts-essentials\";\n\nexport const addTxAtom = atom<null, [transaction: MinTransactionItem], void>(\n null,\n async (get, set, transaction) => {\n const account = get(accountAtom);\n assert(account, \"addTxAtom: account is required\");\n\n const txWithMeta = {\n ...transaction,\n account,\n timestamp: Date.now(),\n dropped: false,\n };\n set(transactionsAtom, (current) => assignTx(current, txWithMeta));\n\n if (isStandaloneTransactionItem(txWithMeta)) {\n await set(finalizeStandaloneTxAtom, txWithMeta);\n } else {\n await set(finalizeBatchTxAtom, txWithMeta);\n }\n }\n);\n\nexport const finalizeStandaloneTxAtom = atom<\n null,\n [StandaloneTransactionItem],\n Promise<void>\n>(null, async (_, set, transaction) => {\n const finalizedTx: StandaloneTransactionItem = { ...transaction };\n const ensureTxReceipt = ensureTxReceiptFactory()
|
|
1
|
+
{"version":3,"file":"transactionsActionAtom.js","sources":["../../../src/transactions/state/transactionsActionAtom.ts"],"sourcesContent":["import type {\n TransactionItem,\n StandaloneTransactionItem,\n BatchTransactionItem,\n MinTransactionItem,\n} from \"../types\";\nimport { atom } from \"jotai\";\nimport { jotaiStore } from \"@/core/store\";\n\nimport { ensureCallsStatusFactory } from \"../queries/ensureCallsStatus\";\nimport { ensureTxReceiptFactory } from \"../queries/ensureTxReceipt\";\nimport {\n WaitForCallsStatusTimeoutError,\n TransactionReceiptNotFoundError,\n WaitForTransactionReceiptTimeoutError,\n MethodNotSupportedRpcError,\n} from \"viem\";\nimport { transactionLogger } from \"../logger\";\nimport {\n transactionsAtom,\n type TransactionsMap,\n type TransactionsState,\n} from \"./transactionsAtom\";\nimport { isBatchTransactionItem, isStandaloneTransactionItem } from \"../utils\";\nimport { accountAtom } from \"@/lib/web3/wagmi/external\";\nimport { assert } from \"ts-essentials\";\n\nexport const addTxAtom = atom<null, [transaction: MinTransactionItem], void>(\n null,\n async (get, set, transaction) => {\n const account = get(accountAtom);\n assert(account, \"addTxAtom: account is required\");\n\n const txWithMeta = {\n ...transaction,\n account,\n timestamp: Date.now(),\n dropped: false,\n };\n set(transactionsAtom, (current) => assignTx(current, txWithMeta));\n\n if (isStandaloneTransactionItem(txWithMeta)) {\n await set(finalizeStandaloneTxAtom, txWithMeta);\n } else {\n await set(finalizeBatchTxAtom, txWithMeta);\n }\n }\n);\n\nexport const finalizeStandaloneTxAtom = atom<\n null,\n [StandaloneTransactionItem],\n Promise<void>\n>(null, async (_, set, transaction) => {\n const finalizedTx: StandaloneTransactionItem = { ...transaction };\n const ensureTxReceipt = ensureTxReceiptFactory();\n\n try {\n finalizedTx.receipt = await ensureTxReceipt({\n hash: transaction.transactionHash,\n chainId: transaction.chainId,\n });\n } catch (error) {\n if (\n error instanceof WaitForTransactionReceiptTimeoutError ||\n error instanceof TransactionReceiptNotFoundError\n ) {\n finalizedTx.dropped = true;\n transactionLogger.error(\n `finalizeStandaloneTxAtom::Transaction ${transaction.transactionHash} dropped with error: ${error.message}`\n );\n } else throw error;\n } finally {\n set(transactionsAtom, (current) => assignTx(current, finalizedTx));\n }\n});\n\nexport const finalizeBatchTxAtom = atom<\n null,\n [BatchTransactionItem],\n Promise<void>\n>(null, async (_, set, transaction) => {\n const finalizedTx: BatchTransactionItem = { ...transaction };\n const ensureCallsStatus = ensureCallsStatusFactory();\n\n try {\n const { receipts, status } = await ensureCallsStatus({\n id: transaction.callsId,\n });\n finalizedTx.callsStatus = status;\n finalizedTx.receipt = receipts?.[receipts.length - 1];\n } catch (error) {\n if (\n error instanceof WaitForCallsStatusTimeoutError ||\n error instanceof MethodNotSupportedRpcError\n ) {\n finalizedTx.dropped = true;\n transactionLogger.error(\n `finalizeBatchTxAtom::Batch transaction ${transaction.callsId} dropped with error: ${error.message}`\n );\n } else {\n finalizedTx.callsStatus = \"failure\";\n throw error;\n }\n } finally {\n set(transactionsAtom, (current) => assignTx(current, finalizedTx));\n }\n});\n\nexport const addTx = async (transaction: MinTransactionItem) => {\n return jotaiStore.set(addTxAtom, transaction);\n};\n\nfunction sanitizeTx(tx: TransactionItem): TransactionItem {\n if (isBatchTransactionItem(tx)) {\n return {\n action: tx.action,\n account: tx.account,\n chainId: tx.chainId,\n callsId: tx.callsId,\n callsStatus: tx.callsStatus,\n timestamp: tx.timestamp,\n dropped: tx.dropped,\n receipt: tx.receipt,\n transactionSpecificData: tx.transactionSpecificData,\n } as BatchTransactionItem;\n }\n\n return {\n action: tx.action,\n chainId: tx.chainId,\n account: tx.account,\n transactionHash: tx.transactionHash,\n timestamp: tx.timestamp,\n dropped: tx.dropped,\n receipt: tx.receipt,\n transactionSpecificData: tx.transactionSpecificData,\n } as StandaloneTransactionItem;\n}\n\nfunction assignTx(\n currentTransactions: TransactionsState,\n transaction: TransactionItem\n): TransactionsState {\n transactionLogger.log(\"assignTx\", {\n account: transaction.account,\n transaction,\n });\n\n const accountTransactions = currentTransactions[transaction.account] || {};\n const identifier = isStandaloneTransactionItem(transaction)\n ? transaction.transactionHash\n : transaction.callsId;\n\n const updatedAccountTransactions: TransactionsMap = {\n ...accountTransactions,\n [identifier]: sanitizeTx({\n ...accountTransactions[identifier],\n ...transaction,\n }),\n };\n\n return {\n ...currentTransactions,\n [transaction.account]: updatedAccountTransactions,\n };\n}\n"],"names":["addTxAtom","atom","get","set","transaction","account","accountAtom","assert","txWithMeta","timestamp","Date","now","dropped","transactionsAtom","current","assignTx","isStandaloneTransactionItem","finalizeStandaloneTxAtom","finalizeBatchTxAtom","_","finalizedTx","ensureTxReceipt","ensureTxReceiptFactory","receipt","hash","transactionHash","chainId","error","WaitForTransactionReceiptTimeoutError","TransactionReceiptNotFoundError","transactionLogger","message","ensureCallsStatus","ensureCallsStatusFactory","receipts","status","id","callsId","callsStatus","length","WaitForCallsStatusTimeoutError","MethodNotSupportedRpcError","addTx","jotaiStore","sanitizeTx","tx","isBatchTransactionItem","action","transactionSpecificData","currentTransactions","log","accountTransactions","identifier","updatedAccountTransactions"],"mappings":";;;;;;;;;;;AA2BO,MAAMA,YAAYC,IAAAA,CACvB,IAAA,EACA,OAAOC,GAAAA,EAAKC,KAAKC,WAAAA,KAAgB;AAC/B,EAAA,MAAMC,OAAAA,GAAUH,IAAII,WAAW,CAAA;AAC/BC,EAAAA,MAAAA,CAAOF,SAAS,gCAAgC,CAAA;AAEhD,EAAA,MAAMG,UAAAA,GAAa;AAAA,IACjB,GAAGJ,WAAAA;AAAAA,IACHC,OAAAA;AAAAA,IACAI,SAAAA,EAAWC,KAAKC,GAAAA,EAAI;AAAA,IACpBC,OAAAA,EAAS;AAAA,GACX;AACAT,EAAAA,GAAAA,CAAIU,gBAAAA,EAAmBC,CAAAA,OAAAA,KAAYC,QAAAA,CAASD,OAAAA,EAASN,UAAU,CAAC,CAAA;AAEhE,EAAA,IAAIQ,2BAAAA,CAA4BR,UAAU,CAAA,EAAG;AAC3C,IAAA,MAAML,GAAAA,CAAIc,0BAA0BT,UAAU,CAAA;AAAA,EAChD,CAAA,MAAO;AACL,IAAA,MAAML,GAAAA,CAAIe,qBAAqBV,UAAU,CAAA;AAAA,EAC3C;AACF,CACF;AAEO,MAAMS,2BAA2BhB,IAAAA,CAItC,IAAA,EAAM,OAAOkB,CAAAA,EAAGhB,KAAKC,WAAAA,KAAgB;AACrC,EAAA,MAAMgB,WAAAA,GAAyC;AAAA,IAAE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