@symmio/trading-react 4.3.0 → 4.5.0
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/account-layer/automatic-timelock-attempt.d.ts +11 -0
- package/dist/account-layer/automatic-timelock-attempt.d.ts.map +1 -0
- package/dist/account-layer/automatic-timelock-attempt.js +41 -0
- package/dist/account-layer/automatic-timelock-attempt.js.map +1 -0
- package/dist/account-layer/index.d.ts +9 -0
- package/dist/account-layer/index.d.ts.map +1 -1
- package/dist/account-layer/index.js +41 -32
- package/dist/account-layer/use-active-virtual-account-by-key.d.ts +33 -0
- package/dist/account-layer/use-active-virtual-account-by-key.d.ts.map +1 -0
- package/dist/account-layer/use-active-virtual-account-by-key.js +27 -0
- package/dist/account-layer/use-active-virtual-account-by-key.js.map +1 -0
- package/dist/account-layer/use-add-margin.d.ts +2 -2
- package/dist/account-layer/use-add-margin.d.ts.map +1 -1
- package/dist/account-layer/use-add-margin.js +28 -17
- package/dist/account-layer/use-add-margin.js.map +1 -1
- package/dist/account-layer/use-allocate.d.ts +2 -2
- package/dist/account-layer/use-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-allocate.js +28 -17
- package/dist/account-layer/use-allocate.js.map +1 -1
- package/dist/account-layer/use-automatic-timelock-recovery.d.ts +25 -0
- package/dist/account-layer/use-automatic-timelock-recovery.d.ts.map +1 -0
- package/dist/account-layer/use-automatic-timelock-recovery.js +26 -0
- package/dist/account-layer/use-automatic-timelock-recovery.js.map +1 -0
- package/dist/account-layer/use-automatic-timelock.d.ts +48 -0
- package/dist/account-layer/use-automatic-timelock.d.ts.map +1 -0
- package/dist/account-layer/use-automatic-timelock.js +189 -0
- package/dist/account-layer/use-automatic-timelock.js.map +1 -0
- package/dist/account-layer/use-create-sub-accounts.d.ts +9 -4
- package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
- package/dist/account-layer/use-create-sub-accounts.js +11 -13
- package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts +3 -3
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +32 -21
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
- package/dist/account-layer/use-deallocate.d.ts +6 -5
- package/dist/account-layer/use-deallocate.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate.js +33 -20
- package/dist/account-layer/use-deallocate.js.map +1 -1
- package/dist/account-layer/use-delete-sub-account.d.ts +2 -2
- package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
- package/dist/account-layer/use-delete-sub-account.js +30 -19
- package/dist/account-layer/use-delete-sub-account.js.map +1 -1
- package/dist/account-layer/use-execute-account-calls.d.ts +7 -0
- package/dist/account-layer/use-execute-account-calls.d.ts.map +1 -0
- package/dist/account-layer/use-execute-account-calls.js +54 -0
- package/dist/account-layer/use-execute-account-calls.js.map +1 -0
- package/dist/account-layer/use-protected-function.d.ts +22 -0
- package/dist/account-layer/use-protected-function.d.ts.map +1 -0
- package/dist/account-layer/use-protected-function.js +68 -0
- package/dist/account-layer/use-protected-function.js.map +1 -0
- package/dist/account-layer/use-remove-margin.d.ts +2 -2
- package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
- package/dist/account-layer/use-remove-margin.js +31 -20
- package/dist/account-layer/use-remove-margin.js.map +1 -1
- package/dist/account-layer/use-timelock-policy.d.ts +21 -0
- package/dist/account-layer/use-timelock-policy.d.ts.map +1 -0
- package/dist/account-layer/use-timelock-policy.js +112 -0
- package/dist/account-layer/use-timelock-policy.js.map +1 -0
- package/dist/account-layer/use-timelock-route.d.ts +75 -0
- package/dist/account-layer/use-timelock-route.d.ts.map +1 -0
- package/dist/account-layer/use-timelock-route.js +177 -0
- package/dist/account-layer/use-timelock-route.js.map +1 -0
- package/dist/account-layer/use-timelock.d.ts +102 -0
- package/dist/account-layer/use-timelock.d.ts.map +1 -0
- package/dist/account-layer/use-timelock.js +177 -0
- package/dist/account-layer/use-timelock.js.map +1 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts +24 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js +27 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js.map +1 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts +25 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts.map +1 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.js +27 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.js.map +1 -0
- package/dist/errors/normalize-protected-write-error.d.ts +5 -0
- package/dist/errors/normalize-protected-write-error.d.ts.map +1 -0
- package/dist/errors/normalize-protected-write-error.js +43 -0
- package/dist/errors/normalize-protected-write-error.js.map +1 -0
- package/dist/errors/normalize-symm-error.d.ts.map +1 -1
- package/dist/errors/normalize-symm-error.js +56 -43
- package/dist/errors/normalize-symm-error.js.map +1 -1
- package/dist/errors/symmio-request-error.d.ts +5 -0
- package/dist/errors/symmio-request-error.d.ts.map +1 -1
- package/dist/errors/symmio-request-error.js +2 -1
- package/dist/errors/symmio-request-error.js.map +1 -1
- package/dist/gasless/index.d.ts +1 -0
- package/dist/gasless/index.d.ts.map +1 -1
- package/dist/gasless/index.js +20 -19
- package/dist/gasless/invalidate-relay-reads.d.ts +3 -1
- package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -1
- package/dist/gasless/invalidate-relay-reads.js +115 -60
- package/dist/gasless/invalidate-relay-reads.js.map +1 -1
- package/dist/gasless/use-approve-operational-fee-allowance.d.ts +37 -0
- package/dist/gasless/use-approve-operational-fee-allowance.d.ts.map +1 -0
- package/dist/gasless/use-approve-operational-fee-allowance.js +48 -0
- package/dist/gasless/use-approve-operational-fee-allowance.js.map +1 -0
- package/dist/gasless/use-approve-operational-fee.d.ts +2 -2
- package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -1
- package/dist/gasless/use-approve-operational-fee.js +28 -17
- package/dist/gasless/use-approve-operational-fee.js.map +1 -1
- package/dist/gasless/use-relay-gasless-batch.d.ts +5 -4
- package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -1
- package/dist/gasless/use-relay-gasless-batch.js.map +1 -1
- package/dist/index.d.ts +13 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -256
- package/dist/instant-layer/index.d.ts +2 -0
- package/dist/instant-layer/index.d.ts.map +1 -1
- package/dist/instant-layer/index.js +25 -23
- package/dist/instant-layer/invalidate-delegation-grant.d.ts +17 -0
- package/dist/instant-layer/invalidate-delegation-grant.d.ts.map +1 -0
- package/dist/instant-layer/invalidate-delegation-grant.js +26 -0
- package/dist/instant-layer/invalidate-delegation-grant.js.map +1 -0
- package/dist/instant-layer/use-grant-delegation.d.ts +3 -1
- package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
- package/dist/instant-layer/use-grant-delegation.js +19 -28
- package/dist/instant-layer/use-grant-delegation.js.map +1 -1
- package/dist/instant-layer/use-grant-delegations.d.ts +44 -0
- package/dist/instant-layer/use-grant-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-grant-delegations.js +36 -0
- package/dist/instant-layer/use-grant-delegations.js.map +1 -0
- package/dist/instant-layer/use-instant-close-fees.js +8 -8
- package/dist/instant-layer/use-instant-open-inputs.d.ts +1 -0
- package/dist/instant-layer/use-instant-open-inputs.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-open-inputs.js +81 -80
- package/dist/instant-layer/use-instant-open-inputs.js.map +1 -1
- package/dist/instant-layer/use-prepare-instant-open-params.d.ts +6 -0
- package/dist/instant-layer/use-prepare-instant-open-params.d.ts.map +1 -1
- package/dist/instant-layer/use-prepare-instant-open-params.js +1 -0
- package/dist/instant-layer/use-prepare-instant-open-params.js.map +1 -1
- package/dist/instant-layer/use-session-key-selectors.d.ts +5 -2
- package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -1
- package/dist/instant-layer/use-session-key-selectors.js +9 -5
- package/dist/instant-layer/use-session-key-selectors.js.map +1 -1
- package/dist/instant-layer/use-simulate-grant-delegations.d.ts +25 -0
- package/dist/instant-layer/use-simulate-grant-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-simulate-grant-delegations.js +29 -0
- package/dist/instant-layer/use-simulate-grant-delegations.js.map +1 -0
- package/dist/price-service/use-enigma-prices.d.ts +4 -0
- package/dist/price-service/use-enigma-prices.d.ts.map +1 -1
- package/dist/price-service/use-enigma-prices.js +60 -24
- package/dist/price-service/use-enigma-prices.js.map +1 -1
- package/dist/provider/symmio-provider.d.ts +31 -4
- package/dist/provider/symmio-provider.d.ts.map +1 -1
- package/dist/provider/symmio-provider.js +12 -11
- package/dist/provider/symmio-provider.js.map +1 -1
- package/dist/solvers/timelock-capability-cache.d.ts +9 -0
- package/dist/solvers/timelock-capability-cache.d.ts.map +1 -0
- package/dist/solvers/timelock-capability-cache.js +79 -0
- package/dist/solvers/timelock-capability-cache.js.map +1 -0
- package/dist/solvers/use-solver-info.d.ts +5 -2
- package/dist/solvers/use-solver-info.d.ts.map +1 -1
- package/dist/solvers/use-solver-info.js +35 -11
- package/dist/solvers/use-solver-info.js.map +1 -1
- package/dist/transactions/write-types.d.ts +13 -1
- package/dist/transactions/write-types.d.ts.map +1 -1
- package/dist/withdraw/index.d.ts +3 -0
- package/dist/withdraw/index.d.ts.map +1 -1
- package/dist/withdraw/use-deallocate-debounce-time.d.ts +29 -0
- package/dist/withdraw/use-deallocate-debounce-time.d.ts.map +1 -0
- package/dist/withdraw/use-deallocate-debounce-time.js +27 -0
- package/dist/withdraw/use-deallocate-debounce-time.js.map +1 -0
- package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
- package/dist/withdraw/use-finalize-withdraw-request.js +13 -12
- package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
- package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.js +29 -17
- package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
- package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts +19 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts.map +1 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.js +27 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.js.map +1 -0
- package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.js +14 -13
- package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
- package/dist/withdraw/use-withdraw-cooldown-of.d.ts +33 -0
- package/dist/withdraw/use-withdraw-cooldown-of.d.ts.map +1 -0
- package/dist/withdraw/use-withdraw-cooldown-of.js +27 -0
- package/dist/withdraw/use-withdraw-cooldown-of.js.map +1 -0
- package/dist/withdraw/use-withdraw.d.ts +3 -3
- package/dist/withdraw/use-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-withdraw.js +57 -31
- package/dist/withdraw/use-withdraw.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,39 +6,75 @@ import { watchEnigmaPrices as r } from "@symmio/trading-core";
|
|
|
6
6
|
import { useEffect as i, useRef as a, useState as o } from "react";
|
|
7
7
|
//#region src/price-service/use-enigma-prices.ts
|
|
8
8
|
function s(s = {}) {
|
|
9
|
-
let { chainId:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
let { chainId: l, enabled: u = !0, onTick: d } = s, f = t(s), p = e(), m = l ?? p, [h, g] = o(() => c(f, m)), _ = h.config === f && h.chainId === m ? h : c(f, m);
|
|
10
|
+
_ !== h && g(_);
|
|
11
|
+
let v = a(d);
|
|
12
|
+
return v.current = d, i(() => {
|
|
13
|
+
let e = !0;
|
|
14
|
+
function t(t) {
|
|
15
|
+
e && g((e) => e.config === f && e.chainId === m ? t(e) : e);
|
|
16
|
+
}
|
|
17
|
+
if (!u) {
|
|
18
|
+
t((e) => ({
|
|
19
|
+
...e,
|
|
20
|
+
status: "closed"
|
|
21
|
+
}));
|
|
13
22
|
return;
|
|
14
23
|
}
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
t((e) => ({
|
|
25
|
+
...e,
|
|
26
|
+
error: null
|
|
27
|
+
}));
|
|
28
|
+
let i;
|
|
17
29
|
try {
|
|
18
|
-
|
|
19
|
-
chainId:
|
|
20
|
-
onPrices: (
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
for (let
|
|
24
|
-
return
|
|
25
|
-
|
|
30
|
+
i = r(f, {
|
|
31
|
+
chainId: m,
|
|
32
|
+
onPrices: (n) => {
|
|
33
|
+
e && (t((e) => {
|
|
34
|
+
let t = !1, r = { ...e.prices };
|
|
35
|
+
for (let e of n) r[e.name] !== e.markPrice && (r[e.name] = e.markPrice, t = !0);
|
|
36
|
+
return t ? {
|
|
37
|
+
...e,
|
|
38
|
+
prices: r
|
|
39
|
+
} : e;
|
|
40
|
+
}), v.current?.(n));
|
|
26
41
|
},
|
|
27
|
-
onStatusChange:
|
|
28
|
-
|
|
42
|
+
onStatusChange: (e) => t((t) => ({
|
|
43
|
+
...t,
|
|
44
|
+
status: e
|
|
45
|
+
})),
|
|
46
|
+
onError: (e) => t((t) => ({
|
|
47
|
+
...t,
|
|
48
|
+
error: n(e)
|
|
49
|
+
}))
|
|
29
50
|
});
|
|
30
51
|
} catch (e) {
|
|
31
|
-
|
|
52
|
+
t((t) => ({
|
|
53
|
+
...t,
|
|
54
|
+
error: n(e),
|
|
55
|
+
status: "closed"
|
|
56
|
+
}));
|
|
32
57
|
}
|
|
33
|
-
return () =>
|
|
58
|
+
return () => {
|
|
59
|
+
e = !1, i?.();
|
|
60
|
+
};
|
|
34
61
|
}, [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
62
|
+
u,
|
|
63
|
+
f,
|
|
64
|
+
m
|
|
38
65
|
]), {
|
|
39
|
-
prices:
|
|
40
|
-
status:
|
|
41
|
-
error:
|
|
66
|
+
prices: _.prices,
|
|
67
|
+
status: _.status,
|
|
68
|
+
error: _.error
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function c(e, t) {
|
|
72
|
+
return {
|
|
73
|
+
config: e,
|
|
74
|
+
chainId: t,
|
|
75
|
+
prices: {},
|
|
76
|
+
status: "closed",
|
|
77
|
+
error: null
|
|
42
78
|
};
|
|
43
79
|
}
|
|
44
80
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-enigma-prices.js","names":[],"sources":["../../src/price-service/use-enigma-prices.ts"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"use-enigma-prices.js","names":[],"sources":["../../src/price-service/use-enigma-prices.ts"],"sourcesContent":["\"use client\";\n\nimport {\n watchEnigmaPrices,\n type Config,\n type ConfigParameter,\n type EnigmaPriceTick,\n type SocketStatus,\n} from \"@symmio/trading-core\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/**\n * Parameters for {@link useEnigmaPrices}.\n */\nexport interface UseEnigmaPricesParameters extends ConfigParameter {\n /** Target chain id. Defaults to the SDK's active chain. */\n chainId?: number;\n /** Subscribe only when `true`. Default `true`. */\n enabled?: boolean;\n /** Imperative per-tick callback, invoked in addition to map updates. */\n onTick?: (ticks: EnigmaPriceTick[]) => void;\n}\n\n/**\n * Value returned by {@link useEnigmaPrices}.\n */\nexport interface UseEnigmaPricesReturnType {\n /** Latest mark price keyed by symbol name. */\n prices: Record<string, string>;\n /** Live socket status. */\n status: SocketStatus;\n /** Last transport/parse error, normalized, or `null`. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Subscribe to the chain's Enigma lowcap price-service WebSocket.\n *\n * Accumulates the latest `markPrice` per symbol name; updates whenever a new\n * tick arrives. Pass `onTick` to also react imperatively (e.g. push into a\n * non-stateful sink). The subscription is shared across hook instances via the\n * SDK socket pool — multiple `useEnigmaPrices()` mounts cost one connection.\n *\n * Prices, status and errors reset when the Config instance or resolved chain\n * changes. Reconnects and stopping/restarting the same target retain prices.\n * Callbacks from a disposed subscription are ignored.\n *\n * @example\n * ```tsx\n * const { prices, status } = useEnigmaPrices();\n * return <span>BTC: {prices[\"BTCUSDT\"] ?? \"—\"} ({status})</span>;\n * ```\n */\nexport function useEnigmaPrices(parameters: UseEnigmaPricesParameters = {}): UseEnigmaPricesReturnType {\n const { chainId, enabled = true, onTick } = parameters;\n const config = useSymmioConfig(parameters);\n const defaultChainId = useSymmioChainId();\n const resolvedChainId = chainId ?? defaultChainId;\n\n const [state, setState] = useState<PriceState>(() => emptyPriceState(config, resolvedChainId));\n // Reset during render so consumers never commit a previous deployment's prices.\n const current =\n state.config === config && state.chainId === resolvedChainId ? state : emptyPriceState(config, resolvedChainId);\n if (current !== state) setState(current);\n\n const onTickRef = useRef(onTick);\n onTickRef.current = onTick;\n\n useEffect(() => {\n let active = true;\n function update(updater: (previous: PriceState) => PriceState) {\n if (!active) return;\n setState((previous) =>\n previous.config === config && previous.chainId === resolvedChainId ? updater(previous) : previous,\n );\n }\n\n if (!enabled) {\n update((previous) => ({ ...previous, status: \"closed\" }));\n return;\n }\n\n update((previous) => ({ ...previous, error: null }));\n let unwatch: (() => void) | undefined;\n try {\n unwatch = watchEnigmaPrices(config, {\n chainId: resolvedChainId,\n onPrices: (ticks) => {\n if (!active) return;\n update((previous) => {\n let mutated = false;\n const prices = { ...previous.prices };\n for (const tick of ticks) {\n if (prices[tick.name] !== tick.markPrice) {\n prices[tick.name] = tick.markPrice;\n mutated = true;\n }\n }\n return mutated ? { ...previous, prices } : previous;\n });\n onTickRef.current?.(ticks);\n },\n onStatusChange: (status) => update((previous) => ({ ...previous, status })),\n onError: (error) => update((previous) => ({ ...previous, error: normalizeSymmError(error) })),\n });\n } catch (error) {\n update((previous) => ({ ...previous, error: normalizeSymmError(error), status: \"closed\" }));\n }\n\n return () => {\n active = false;\n unwatch?.();\n };\n }, [enabled, config, resolvedChainId]);\n\n return { prices: current.prices, status: current.status, error: current.error };\n}\n\ninterface PriceState extends UseEnigmaPricesReturnType {\n config: Config;\n chainId: number;\n}\n\nfunction emptyPriceState(config: Config, chainId: number): PriceState {\n return { config, chainId, prices: {}, status: \"closed\", error: null };\n}\n"],"mappings":";;;;;;;AAyDA,SAAgB,EAAgB,IAAwC,CAAC,GAA8B;CACrG,IAAM,EAAE,YAAS,aAAU,IAAM,cAAW,GACtC,IAAS,EAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAkB,KAAW,GAE7B,CAAC,GAAO,KAAY,QAA2B,EAAgB,GAAQ,CAAe,CAAC,GAEvF,IACJ,EAAM,WAAW,KAAU,EAAM,YAAY,IAAkB,IAAQ,EAAgB,GAAQ,CAAe;CAChH,AAAI,MAAY,KAAO,EAAS,CAAO;CAEvC,IAAM,IAAY,EAAO,CAAM;CAkD/B,OAjDA,EAAU,UAAU,GAEpB,QAAgB;EACd,IAAI,IAAS;EACb,SAAS,EAAO,GAA+C;GACxD,KACL,GAAU,MACR,EAAS,WAAW,KAAU,EAAS,YAAY,IAAkB,EAAQ,CAAQ,IAAI,CAC3F;EACF;EAEA,IAAI,CAAC,GAAS;GACZ,GAAQ,OAAc;IAAE,GAAG;IAAU,QAAQ;GAAS,EAAE;GACxD;EACF;EAEA,GAAQ,OAAc;GAAE,GAAG;GAAU,OAAO;EAAK,EAAE;EACnD,IAAI;EACJ,IAAI;GACF,IAAU,EAAkB,GAAQ;IAClC,SAAS;IACT,WAAW,MAAU;KACd,MACL,GAAQ,MAAa;MACnB,IAAI,IAAU,IACR,IAAS,EAAE,GAAG,EAAS,OAAO;MACpC,KAAK,IAAM,KAAQ,GACjB,AAAI,EAAO,EAAK,UAAU,EAAK,cAC7B,EAAO,EAAK,QAAQ,EAAK,WACzB,IAAU;MAGd,OAAO,IAAU;OAAE,GAAG;OAAU;MAAO,IAAI;KAC7C,CAAC,GACD,EAAU,UAAU,CAAK;IAC3B;IACA,iBAAiB,MAAW,GAAQ,OAAc;KAAE,GAAG;KAAU;IAAO,EAAE;IAC1E,UAAU,MAAU,GAAQ,OAAc;KAAE,GAAG;KAAU,OAAO,EAAmB,CAAK;IAAE,EAAE;GAC9F,CAAC;EACH,SAAS,GAAO;GACd,GAAQ,OAAc;IAAE,GAAG;IAAU,OAAO,EAAmB,CAAK;IAAG,QAAQ;GAAS,EAAE;EAC5F;EAEA,aAAa;GAEX,AADA,IAAS,IACT,IAAU;EACZ;CACF,GAAG;EAAC;EAAS;EAAQ;CAAe,CAAC,GAE9B;EAAE,QAAQ,EAAQ;EAAQ,QAAQ,EAAQ;EAAQ,OAAO,EAAQ;CAAM;AAChF;AAOA,SAAS,EAAgB,GAAgB,GAA6B;CACpE,OAAO;EAAE;EAAQ;EAAS,QAAQ,CAAC;EAAG,QAAQ;EAAU,OAAO;CAAK;AACtE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateConfigParameters, GetWalletClientFn } from '@symmio/trading-core';
|
|
1
|
+
import { CreateConfigParameters, GetClientFn, GetWalletClientFn } from '@symmio/trading-core';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Props for {@link SymmioProvider}.
|
|
@@ -28,6 +28,32 @@ export interface SymmioProviderProps {
|
|
|
28
28
|
* chain. Defaults to the SDK's first supported chain.
|
|
29
29
|
*/
|
|
30
30
|
defaultChainId?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Custom read-client resolver. Receives `{ chainId? }` from the SDK and
|
|
33
|
+
* returns the viem `PublicClient` that every on-chain SDK read — and every
|
|
34
|
+
* write's dry-run and receipt wait — runs on. Use it when the app reads
|
|
35
|
+
* through its own client (a dedicated RPC URL, request batching, an
|
|
36
|
+
* instrumented transport) rather than wagmi's transport for that chain.
|
|
37
|
+
*
|
|
38
|
+
* Return a client bound to the requested `chainId`, or throw for a chain the
|
|
39
|
+
* app does not serve — never a client for another chain, which would read
|
|
40
|
+
* the wrong contracts without any error.
|
|
41
|
+
*
|
|
42
|
+
* When omitted, the provider reads through wagmi's public client for the
|
|
43
|
+
* requested chain. Memoize the resolver: a new function identity rebuilds
|
|
44
|
+
* the SDK config, which resets every per-config cache (nonce locks, relay
|
|
45
|
+
* request registry, stream connections).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* const getClient = useCallback(() => appPublicClient, []);
|
|
50
|
+
*
|
|
51
|
+
* <SymmioProvider symmioConfig={symmioConfig} getClient={getClient}>
|
|
52
|
+
* {children}
|
|
53
|
+
* </SymmioProvider>;
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
getClient?: GetClientFn;
|
|
31
57
|
/**
|
|
32
58
|
* Custom wallet-client resolver. Receives `{ chainId, from? }` from the SDK
|
|
33
59
|
* and returns the wallet client to sign with. Use this to plug in
|
|
@@ -45,8 +71,9 @@ export interface SymmioProviderProps {
|
|
|
45
71
|
}
|
|
46
72
|
/**
|
|
47
73
|
* Provides the SYMMIO {@link Config} to descendant hooks. The config's viem
|
|
48
|
-
* clients are resolved from the host's wagmi config
|
|
49
|
-
* the
|
|
74
|
+
* clients are resolved from the host's wagmi config unless the host passes its
|
|
75
|
+
* own `getClient` / `getWalletClient` resolver, so this is the only place the
|
|
76
|
+
* SDK touches wagmi.
|
|
50
77
|
*
|
|
51
78
|
* **Mount order matters**: this reads wagmi context and (transitively) the
|
|
52
79
|
* host's `@tanstack/react-query` `QueryClient`. Both must be mounted **outside**
|
|
@@ -65,5 +92,5 @@ export interface SymmioProviderProps {
|
|
|
65
92
|
* The SDK never mounts wagmi or a `QueryClient` for the host — those (which
|
|
66
93
|
* connectors, which RPC URLs, which shared `QueryClient`) belong to the host.
|
|
67
94
|
*/
|
|
68
|
-
export declare function SymmioProvider({ children, symmioConfig, defaultChainId, getWalletClient: getWalletClientProp, }: SymmioProviderProps): import("react").JSX.Element;
|
|
95
|
+
export declare function SymmioProvider({ children, symmioConfig, defaultChainId, getClient: getClientProp, getWalletClient: getWalletClientProp, }: SymmioProviderProps): import("react").JSX.Element;
|
|
69
96
|
//# sourceMappingURL=symmio-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symmio-provider.d.ts","sourceRoot":"","sources":["../../src/provider/symmio-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACrD;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED
|
|
1
|
+
{"version":3,"file":"symmio-provider.d.ts","sourceRoot":"","sources":["../../src/provider/symmio-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACrD;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,SAAS,EAAE,aAAa,EACxB,eAAe,EAAE,mBAAmB,GACrC,EAAE,mBAAmB,+BAwErB"}
|
|
@@ -6,19 +6,19 @@ import { useMemo as o } from "react";
|
|
|
6
6
|
import { useChainId as s, useConfig as c } from "wagmi";
|
|
7
7
|
import { jsx as l } from "react/jsx-runtime";
|
|
8
8
|
//#region src/provider/symmio-provider.tsx
|
|
9
|
-
function u({ children: u, symmioConfig: d, defaultChainId: f,
|
|
10
|
-
let
|
|
9
|
+
function u({ children: u, symmioConfig: d, defaultChainId: f, getClient: p, getWalletClient: m }) {
|
|
10
|
+
let h = c(), g = s(), _ = r().some((e) => e === g) ? g : f, v = o(() => n({
|
|
11
11
|
symmioConfig: d,
|
|
12
|
-
defaultChainId:
|
|
13
|
-
getClient: ({ chainId: e } = {}) => {
|
|
14
|
-
let n = i(
|
|
12
|
+
defaultChainId: _,
|
|
13
|
+
getClient: p ?? (({ chainId: e } = {}) => {
|
|
14
|
+
let n = i(h, { chainId: e });
|
|
15
15
|
if (!n) throw new t("config", "NO_PUBLIC_CLIENT", `No public client available for chain ${e ?? "(default)"}.`);
|
|
16
16
|
return n;
|
|
17
|
-
},
|
|
18
|
-
getWalletClient:
|
|
17
|
+
}),
|
|
18
|
+
getWalletClient: m ?? (async ({ chainId: e, from: n }) => {
|
|
19
19
|
let r;
|
|
20
20
|
try {
|
|
21
|
-
r = await a(
|
|
21
|
+
r = await a(h, { chainId: e });
|
|
22
22
|
} catch (e) {
|
|
23
23
|
throw new t("config", "NO_WALLET_CONNECTED", "No connected wallet. Connect a wallet before sending transactions.", { cause: e instanceof Error ? e : void 0 });
|
|
24
24
|
}
|
|
@@ -27,12 +27,13 @@ function u({ children: u, symmioConfig: d, defaultChainId: f, getWalletClient: p
|
|
|
27
27
|
})
|
|
28
28
|
}), [
|
|
29
29
|
d,
|
|
30
|
-
|
|
30
|
+
_,
|
|
31
31
|
p,
|
|
32
|
-
m
|
|
32
|
+
m,
|
|
33
|
+
h
|
|
33
34
|
]);
|
|
34
35
|
return /* @__PURE__ */ l(e.Provider, {
|
|
35
|
-
value:
|
|
36
|
+
value: v,
|
|
36
37
|
children: u
|
|
37
38
|
});
|
|
38
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symmio-provider.js","names":[],"sources":["../../src/provider/symmio-provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createConfig,\n listSupportedChains,\n SymmError,\n type Config,\n type CreateConfigParameters,\n type GetWalletClientFn,\n type SymmioWalletClient,\n} from \"@symmio/trading-core\";\nimport { useMemo, type ReactNode } from \"react\";\nimport type { PublicClient } from \"viem\";\nimport { useChainId, useConfig } from \"wagmi\";\nimport { getPublicClient, getWalletClient } from \"wagmi/actions\";\nimport { SymmioConfigContext } from \"./symmio-config-context\";\n\n/**\n * Props for {@link SymmioProvider}.\n */\nexport interface SymmioProviderProps {\n /** React subtree that may use SYMMIO SDK hooks. */\n children: ReactNode;\n /**\n * Per-chain SYMMIO configuration, keyed by chain id — deep-merged onto the\n * SDK's built-in defaults (addresses, subgraphs, solver, …).\n *\n * **Required.** Every supported chain must set a non-zero\n * `addresses.affiliatesAddress` — your frontend's on-chain affiliate (your\n * identity in SYMMIO on that chain), attached to every quote so the protocol\n * attributes the trade to you and routes your fee share. Affiliate addresses\n * are per chain (a registration on one chain is not valid on another). The\n * provider throws `AFFILIATE_ADDRESS_REQUIRED` (via `createConfig`) for any\n * supported chain missing it, so trades can never silently fall back to the\n * built-in default affiliate and lose attribution.\n */\n symmioConfig: CreateConfigParameters[\"symmioConfig\"];\n /**\n * Fallback chain used when a hook or action omits `chainId` **and** the\n * connected wallet is not on a supported SYMMIO chain (or is disconnected).\n * When the wallet *is* on a supported chain, that chain becomes the default\n * instead — so a no-arg `config.getChainConfig()` always follows the active\n * chain. Defaults to the SDK's first supported chain.\n */\n defaultChainId?: number;\n /**\n * Custom wallet-client resolver. Receives `{ chainId, from? }` from the SDK\n * and returns the wallet client to sign with. Use this to plug in\n * session-key, multi-signer, or any non-wagmi flow — the resolver decides.\n * {@link createSessionKeyWalletClientResolver} builds the session-key one.\n *\n * When omitted, the provider signs with wagmi's connected wallet. That default\n * can only honor a `from` that *is* the connected account: any other `from`\n * (a session key, another signer) throws `SESSION_SIGNER_UNAVAILABLE` rather\n * than silently prompting the connected wallet instead — the owner is also\n * authorized on-chain, so such a write would otherwise succeed with the wrong\n * signer and no way to notice.\n */\n getWalletClient?: GetWalletClientFn;\n}\n\n/**\n * Provides the SYMMIO {@link Config} to descendant hooks. The config's viem\n * clients are resolved from the host's wagmi config, so this is the only place\n *
|
|
1
|
+
{"version":3,"file":"symmio-provider.js","names":[],"sources":["../../src/provider/symmio-provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createConfig,\n listSupportedChains,\n SymmError,\n type Config,\n type CreateConfigParameters,\n type GetClientFn,\n type GetWalletClientFn,\n type SymmioWalletClient,\n} from \"@symmio/trading-core\";\nimport { useMemo, type ReactNode } from \"react\";\nimport type { PublicClient } from \"viem\";\nimport { useChainId, useConfig } from \"wagmi\";\nimport { getPublicClient, getWalletClient } from \"wagmi/actions\";\nimport { SymmioConfigContext } from \"./symmio-config-context\";\n\n/**\n * Props for {@link SymmioProvider}.\n */\nexport interface SymmioProviderProps {\n /** React subtree that may use SYMMIO SDK hooks. */\n children: ReactNode;\n /**\n * Per-chain SYMMIO configuration, keyed by chain id — deep-merged onto the\n * SDK's built-in defaults (addresses, subgraphs, solver, …).\n *\n * **Required.** Every supported chain must set a non-zero\n * `addresses.affiliatesAddress` — your frontend's on-chain affiliate (your\n * identity in SYMMIO on that chain), attached to every quote so the protocol\n * attributes the trade to you and routes your fee share. Affiliate addresses\n * are per chain (a registration on one chain is not valid on another). The\n * provider throws `AFFILIATE_ADDRESS_REQUIRED` (via `createConfig`) for any\n * supported chain missing it, so trades can never silently fall back to the\n * built-in default affiliate and lose attribution.\n */\n symmioConfig: CreateConfigParameters[\"symmioConfig\"];\n /**\n * Fallback chain used when a hook or action omits `chainId` **and** the\n * connected wallet is not on a supported SYMMIO chain (or is disconnected).\n * When the wallet *is* on a supported chain, that chain becomes the default\n * instead — so a no-arg `config.getChainConfig()` always follows the active\n * chain. Defaults to the SDK's first supported chain.\n */\n defaultChainId?: number;\n /**\n * Custom read-client resolver. Receives `{ chainId? }` from the SDK and\n * returns the viem `PublicClient` that every on-chain SDK read — and every\n * write's dry-run and receipt wait — runs on. Use it when the app reads\n * through its own client (a dedicated RPC URL, request batching, an\n * instrumented transport) rather than wagmi's transport for that chain.\n *\n * Return a client bound to the requested `chainId`, or throw for a chain the\n * app does not serve — never a client for another chain, which would read\n * the wrong contracts without any error.\n *\n * When omitted, the provider reads through wagmi's public client for the\n * requested chain. Memoize the resolver: a new function identity rebuilds\n * the SDK config, which resets every per-config cache (nonce locks, relay\n * request registry, stream connections).\n *\n * @example\n * ```tsx\n * const getClient = useCallback(() => appPublicClient, []);\n *\n * <SymmioProvider symmioConfig={symmioConfig} getClient={getClient}>\n * {children}\n * </SymmioProvider>;\n * ```\n */\n getClient?: GetClientFn;\n /**\n * Custom wallet-client resolver. Receives `{ chainId, from? }` from the SDK\n * and returns the wallet client to sign with. Use this to plug in\n * session-key, multi-signer, or any non-wagmi flow — the resolver decides.\n * {@link createSessionKeyWalletClientResolver} builds the session-key one.\n *\n * When omitted, the provider signs with wagmi's connected wallet. That default\n * can only honor a `from` that *is* the connected account: any other `from`\n * (a session key, another signer) throws `SESSION_SIGNER_UNAVAILABLE` rather\n * than silently prompting the connected wallet instead — the owner is also\n * authorized on-chain, so such a write would otherwise succeed with the wrong\n * signer and no way to notice.\n */\n getWalletClient?: GetWalletClientFn;\n}\n\n/**\n * Provides the SYMMIO {@link Config} to descendant hooks. The config's viem\n * clients are resolved from the host's wagmi config unless the host passes its\n * own `getClient` / `getWalletClient` resolver, so this is the only place the\n * SDK touches wagmi.\n *\n * **Mount order matters**: this reads wagmi context and (transitively) the\n * host's `@tanstack/react-query` `QueryClient`. Both must be mounted **outside**\n * `SymmioProvider`:\n *\n * ```tsx\n * <WagmiProvider config={wagmiConfig}>\n * <QueryClientProvider client={queryClient}>\n * <SymmioProvider symmioConfig={{ [SymmioSupportedChainId.ARBITRUM]: { addresses: { affiliatesAddress: \"0x…\" } } }}>\n * <App />\n * </SymmioProvider>\n * </QueryClientProvider>\n * </WagmiProvider>\n * ```\n *\n * The SDK never mounts wagmi or a `QueryClient` for the host — those (which\n * connectors, which RPC URLs, which shared `QueryClient`) belong to the host.\n */\nexport function SymmioProvider({\n children,\n symmioConfig,\n defaultChainId,\n getClient: getClientProp,\n getWalletClient: getWalletClientProp,\n}: SymmioProviderProps) {\n const wagmiConfig = useConfig();\n const connectedChainId = useChainId();\n\n // Track the connected wallet's chain as the config default whenever it is a\n // supported SYMMIO chain, so a no-arg `config.getChainConfig()` — and any hook\n // that omits `chainId` — resolves to the ACTIVE chain rather than a hardcoded\n // first chain. Single fix for the whole class of \"reads the wrong chain's\n // addresses after switching\". Falls back to the explicit `defaultChainId` prop\n // (then the SDK's first supported chain) when the wallet is on an unsupported\n // chain or disconnected.\n const effectiveDefaultChainId = listSupportedChains().some((id) => id === connectedChainId)\n ? connectedChainId\n : defaultChainId;\n\n const config = useMemo<Config>(\n () =>\n createConfig({\n symmioConfig,\n defaultChainId: effectiveDefaultChainId,\n getClient:\n getClientProp ??\n (({ chainId } = {}): PublicClient => {\n const client = getPublicClient(wagmiConfig, { chainId });\n\n if (!client)\n throw new SymmError(\n \"config\",\n \"NO_PUBLIC_CLIENT\",\n `No public client available for chain ${chainId ?? \"(default)\"}.`,\n );\n return client;\n }),\n getWalletClient:\n getWalletClientProp ??\n (async ({ chainId, from }) => {\n let walletClient: SymmioWalletClient;\n\n try {\n walletClient = await getWalletClient(wagmiConfig, { chainId });\n } catch (err) {\n throw new SymmError(\n \"config\",\n \"NO_WALLET_CONNECTED\",\n \"No connected wallet. Connect a wallet before sending transactions.\",\n { cause: err instanceof Error ? err : undefined },\n );\n }\n\n /**\n * `from` is never forwarded to wagmi as `account` — a session key is\n * not a wagmi-connected account, so wagmi would reject it or\n * mis-resolve it. Instead the resolved signer is checked against the\n * request. Dropping a `from` it cannot honor would be silent: the\n * account owner is authorized on-chain for the same calls, so the\n * write succeeds after an unexpected wallet prompt and nothing looks\n * broken.\n */\n if (from && from.toLowerCase() !== walletClient.account.address.toLowerCase())\n throw new SymmError(\n \"config\",\n \"SESSION_SIGNER_UNAVAILABLE\",\n `This action asked to sign as ${from}, but the default wallet-client resolver can only sign with the wagmi-connected wallet (${walletClient.account.address}). Pass SymmioProvider a \\`getWalletClient\\` built by \\`createSessionKeyWalletClientResolver\\` to route session-key signers.`,\n );\n\n return walletClient;\n }),\n }),\n [symmioConfig, effectiveDefaultChainId, getClientProp, getWalletClientProp, wagmiConfig],\n );\n\n return <SymmioConfigContext.Provider value={config}>{children}</SymmioConfigContext.Provider>;\n}\n"],"mappings":";;;;;;;;AA+GA,SAAgB,EAAe,EAC7B,aACA,iBACA,mBACA,WAAW,GACX,iBAAiB,KACK;CACtB,IAAM,IAAc,EAAU,GACxB,IAAmB,EAAW,GAS9B,IAA0B,EAAoB,EAAE,MAAM,MAAO,MAAO,CAAgB,IACtF,IACA,GAEE,IAAS,QAEX,EAAa;EACX;EACA,gBAAgB;EAChB,WACE,OACE,EAAE,eAAY,CAAC,MAAoB;GACnC,IAAM,IAAS,EAAgB,GAAa,EAAE,WAAQ,CAAC;GAEvD,IAAI,CAAC,GACH,MAAM,IAAI,EACR,UACA,oBACA,wCAAwC,KAAW,YAAY,EACjE;GACF,OAAO;EACT;EACF,iBACE,MACC,OAAO,EAAE,YAAS,cAAW;GAC5B,IAAI;GAEJ,IAAI;IACF,IAAe,MAAM,EAAgB,GAAa,EAAE,WAAQ,CAAC;GAC/D,SAAS,GAAK;IACZ,MAAM,IAAI,EACR,UACA,uBACA,sEACA,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;GACF;GAWA,IAAI,KAAQ,EAAK,YAAY,MAAM,EAAa,QAAQ,QAAQ,YAAY,GAC1E,MAAM,IAAI,EACR,UACA,8BACA,gCAAgC,EAAK,0FAA0F,EAAa,QAAQ,QAAQ,6HAC9J;GAEF,OAAO;EACT;CACJ,CAAC,GACH;EAAC;EAAc;EAAyB;EAAe;EAAqB;CAAW,CACzF;CAEA,OAAO,kBAAC,EAAoB,UAArB;EAA8B,OAAO;EAAS;CAAuC,CAAA;AAC9F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Config, SolverId, TimelockApprovalCapability } from '@symmio/trading-core';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
/** Keep positive discovery scoped to one solver deployment and QueryClient. */
|
|
4
|
+
export declare function timelockCapabilityKey(config: Config, chainId: number, solverId?: SolverId): readonly ["symmio", "known-timelock-capability", number, string, "enigma" | "rasa", string];
|
|
5
|
+
export declare function rememberTimelockCapability(client: QueryClient, key: ReturnType<typeof timelockCapabilityKey>, capability: TimelockApprovalCapability | undefined): void;
|
|
6
|
+
/** Recheck availability after a transport outage without retrying the approval request. */
|
|
7
|
+
export declare function refreshTimelockInfoAfterUnavailable(client: QueryClient, config: Config, chainId: number, solverId: SolverId, error: unknown): Promise<void>;
|
|
8
|
+
export declare function useKnownTimelockCapability(config: Config, chainId: number, solverId?: SolverId): TimelockApprovalCapability | undefined;
|
|
9
|
+
//# sourceMappingURL=timelock-capability-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timelock-capability-cache.d.ts","sourceRoot":"","sources":["../../src/solvers/timelock-capability-cache.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIzE,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,+FAWzF;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAC7C,UAAU,EAAE,0BAA0B,GAAG,SAAS,QAKnD;AAED,2FAA2F;AAC3F,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,OAAO,iBAqCf;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,0CA2B9F"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { normalizeSymmError as e } from "../errors/normalize-symm-error.js";
|
|
3
|
+
import { TimelockApprovalHttpError as t, getSolverInfoQueryOptions as n } from "@symmio/trading-core";
|
|
4
|
+
import { useCallback as r, useMemo as i, useSyncExternalStore as a } from "react";
|
|
5
|
+
import { useQueryClient as o } from "@tanstack/react-query";
|
|
6
|
+
//#region src/solvers/timelock-capability-cache.ts
|
|
7
|
+
function s(e, t, n) {
|
|
8
|
+
let r = e.getChainConfig(t), i = e.getSolver({
|
|
9
|
+
chainId: t,
|
|
10
|
+
solverId: n
|
|
11
|
+
});
|
|
12
|
+
return [
|
|
13
|
+
"symmio",
|
|
14
|
+
"known-timelock-capability",
|
|
15
|
+
t,
|
|
16
|
+
r.addresses.accountLayerAddress.toLowerCase(),
|
|
17
|
+
i.id,
|
|
18
|
+
i.url
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
function c(e, t, n) {
|
|
22
|
+
n && (e.setQueryDefaults(t, {
|
|
23
|
+
gcTime: Infinity,
|
|
24
|
+
staleTime: Infinity
|
|
25
|
+
}), e.setQueryData(t, n));
|
|
26
|
+
}
|
|
27
|
+
async function l(r, i, a, o, l) {
|
|
28
|
+
if (!(!(l instanceof t) || l.status !== 0 && l.status < 500)) try {
|
|
29
|
+
if (i.getSolver({
|
|
30
|
+
chainId: a,
|
|
31
|
+
solverId: o
|
|
32
|
+
}).id !== "enigma") return;
|
|
33
|
+
let t = s(i, a, o), l = n(i, {
|
|
34
|
+
chainId: a,
|
|
35
|
+
solverId: o
|
|
36
|
+
}), u = i.getSolver({ chainId: a }).id === o ? [l, n(i, { chainId: a })] : [l], d, f = async () => {
|
|
37
|
+
try {
|
|
38
|
+
if (!d) {
|
|
39
|
+
let e = l.queryFn();
|
|
40
|
+
d = e, e.then(() => {
|
|
41
|
+
d === e && (d = void 0);
|
|
42
|
+
}, () => {
|
|
43
|
+
d === e && (d = void 0);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
let e = await d;
|
|
47
|
+
return c(r, t, e.timelockApproval), e;
|
|
48
|
+
} catch (t) {
|
|
49
|
+
throw e(t);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
await Promise.allSettled(u.map((e) => r.fetchQuery({
|
|
53
|
+
...e,
|
|
54
|
+
retry: !1,
|
|
55
|
+
staleTime: 0,
|
|
56
|
+
queryFn: f
|
|
57
|
+
})));
|
|
58
|
+
} catch {}
|
|
59
|
+
}
|
|
60
|
+
function u(e, t, n) {
|
|
61
|
+
let c = o(), l = i(() => {
|
|
62
|
+
try {
|
|
63
|
+
return s(e, t, n);
|
|
64
|
+
} catch {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}, [
|
|
68
|
+
e,
|
|
69
|
+
t,
|
|
70
|
+
n
|
|
71
|
+
]);
|
|
72
|
+
return a(r((e) => c.getQueryCache().subscribe((t) => {
|
|
73
|
+
l && t.query.queryKey.length === l.length && l.every((e, n) => t.query.queryKey[n] === e) && e();
|
|
74
|
+
}), [c, l]), r(() => l ? c.getQueryData(l) : void 0, [c, l]), () => void 0);
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { l as refreshTimelockInfoAfterUnavailable, c as rememberTimelockCapability, s as timelockCapabilityKey, u as useKnownTimelockCapability };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=timelock-capability-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timelock-capability-cache.js","names":[],"sources":["../../src/solvers/timelock-capability-cache.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverInfoQueryOptions,\n TimelockApprovalHttpError,\n type Config,\n type SolverId,\n type TimelockApprovalCapability,\n} from \"@symmio/trading-core\";\nimport { useQueryClient, type QueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\n\n/** Keep positive discovery scoped to one solver deployment and QueryClient. */\nexport function timelockCapabilityKey(config: Config, chainId: number, solverId?: SolverId) {\n const chain = config.getChainConfig(chainId);\n const solver = config.getSolver({ chainId, solverId });\n return [\n \"symmio\",\n \"known-timelock-capability\",\n chainId,\n chain.addresses.accountLayerAddress.toLowerCase(),\n solver.id,\n solver.url,\n ] as const;\n}\n\nexport function rememberTimelockCapability(\n client: QueryClient,\n key: ReturnType<typeof timelockCapabilityKey>,\n capability: TimelockApprovalCapability | undefined,\n) {\n if (!capability) return;\n client.setQueryDefaults(key, { gcTime: Infinity, staleTime: Infinity });\n client.setQueryData(key, capability);\n}\n\n/** Recheck availability after a transport outage without retrying the approval request. */\nexport async function refreshTimelockInfoAfterUnavailable(\n client: QueryClient,\n config: Config,\n chainId: number,\n solverId: SolverId,\n error: unknown,\n) {\n if (!(error instanceof TimelockApprovalHttpError) || (error.status !== 0 && error.status < 500)) return;\n try {\n if (config.getSolver({ chainId, solverId }).id !== \"enigma\") return;\n const key = timelockCapabilityKey(config, chainId, solverId);\n const options = getSolverInfoQueryOptions(config, { chainId, solverId });\n const isDefault = config.getSolver({ chainId }).id === solverId;\n const queries = isDefault ? [options, getSolverInfoQueryOptions(config, { chainId })] : [options];\n let shared: ReturnType<typeof options.queryFn> | undefined;\n const queryFn = async () => {\n try {\n if (!shared) {\n const pending = options.queryFn();\n shared = pending;\n void pending.then(\n () => {\n if (shared === pending) shared = undefined;\n },\n () => {\n if (shared === pending) shared = undefined;\n },\n );\n }\n const info = await shared;\n rememberTimelockCapability(client, key, info.timelockApproval);\n return info;\n } catch (failure) {\n throw normalizeSymmError(failure);\n }\n };\n await Promise.allSettled(\n queries.map((query) => client.fetchQuery({ ...query, retry: false, staleTime: 0, queryFn })),\n );\n } catch {\n // Preserve the original approval error and previously confirmed capability.\n }\n}\n\nexport function useKnownTimelockCapability(config: Config, chainId: number, solverId?: SolverId) {\n const client = useQueryClient();\n const key = useMemo(() => {\n try {\n return timelockCapabilityKey(config, chainId, solverId);\n } catch {\n // Disabled and invalid queries must retain the normal query error behavior.\n return undefined;\n }\n }, [config, chainId, solverId]);\n const subscribe = useCallback(\n (callback: () => void) =>\n client.getQueryCache().subscribe((event) => {\n if (\n key &&\n event.query.queryKey.length === key.length &&\n key.every((part, index) => event.query.queryKey[index] === part)\n )\n callback();\n }),\n [client, key],\n );\n const snapshot = useCallback(\n () => (key ? client.getQueryData<TimelockApprovalCapability>(key) : undefined),\n [client, key],\n );\n return useSyncExternalStore(subscribe, snapshot, () => undefined);\n}\n"],"mappings":";;;;;;AAcA,SAAgB,EAAsB,GAAgB,GAAiB,GAAqB;CAC1F,IAAM,IAAQ,EAAO,eAAe,CAAO,GACrC,IAAS,EAAO,UAAU;EAAE;EAAS;CAAS,CAAC;CACrD,OAAO;EACL;EACA;EACA;EACA,EAAM,UAAU,oBAAoB,YAAY;EAChD,EAAO;EACP,EAAO;CACT;AACF;AAEA,SAAgB,EACd,GACA,GACA,GACA;CACK,MACL,EAAO,iBAAiB,GAAK;EAAE,QAAQ;EAAU,WAAW;CAAS,CAAC,GACtE,EAAO,aAAa,GAAK,CAAU;AACrC;AAGA,eAAsB,EACpB,GACA,GACA,GACA,GACA,GACA;CACI,QAAE,aAAiB,MAA+B,EAAM,WAAW,KAAK,EAAM,SAAS,MAC3F,IAAI;EACF,IAAI,EAAO,UAAU;GAAE;GAAS;EAAS,CAAC,EAAE,OAAO,UAAU;EAC7D,IAAM,IAAM,EAAsB,GAAQ,GAAS,CAAQ,GACrD,IAAU,EAA0B,GAAQ;GAAE;GAAS;EAAS,CAAC,GAEjE,IADY,EAAO,UAAU,EAAE,WAAQ,CAAC,EAAE,OAAO,IAC3B,CAAC,GAAS,EAA0B,GAAQ,EAAE,WAAQ,CAAC,CAAC,IAAI,CAAC,CAAO,GAC5F,GACE,IAAU,YAAY;GAC1B,IAAI;IACF,IAAI,CAAC,GAAQ;KACX,IAAM,IAAU,EAAQ,QAAQ;KAEhC,AADA,IAAS,GACT,EAAa,WACL;MACJ,AAAI,MAAW,MAAS,IAAS,KAAA;KACnC,SACM;MACJ,AAAI,MAAW,MAAS,IAAS,KAAA;KACnC,CACF;IACF;IACA,IAAM,IAAO,MAAM;IAEnB,OADA,EAA2B,GAAQ,GAAK,EAAK,gBAAgB,GACtD;GACT,SAAS,GAAS;IAChB,MAAM,EAAmB,CAAO;GAClC;EACF;EACA,MAAM,QAAQ,WACZ,EAAQ,KAAK,MAAU,EAAO,WAAW;GAAE,GAAG;GAAO,OAAO;GAAO,WAAW;GAAG;EAAQ,CAAC,CAAC,CAC7F;CACF,QAAQ,CAER;AACF;AAEA,SAAgB,EAA2B,GAAgB,GAAiB,GAAqB;CAC/F,IAAM,IAAS,EAAe,GACxB,IAAM,QAAc;EACxB,IAAI;GACF,OAAO,EAAsB,GAAQ,GAAS,CAAQ;EACxD,QAAQ;GAEN;EACF;CACF,GAAG;EAAC;EAAQ;EAAS;CAAQ,CAAC;CAiB9B,OAAO,EAhBW,GACf,MACC,EAAO,cAAc,EAAE,WAAW,MAAU;EAC1C,AACE,KACA,EAAM,MAAM,SAAS,WAAW,EAAI,UACpC,EAAI,OAAO,GAAM,MAAU,EAAM,MAAM,SAAS,OAAW,CAAI,KAE/D,EAAS;CACb,CAAC,GACH,CAAC,GAAQ,CAAG,CAMc,GAJX,QACR,IAAM,EAAO,aAAyC,CAAG,IAAI,KAAA,GACpE,CAAC,GAAQ,CAAG,CAEyB,SAAgB,KAAA,CAAS;AAClE"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { ConfigParameter, GetSolverInfoData, GetSolverInfoOptions } from '@symmio/trading-core';
|
|
1
|
+
import { ConfigParameter, GetSolverInfoData, GetSolverInfoOptions, TimelockApprovalCapability } from '@symmio/trading-core';
|
|
2
2
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/** Parameters for {@link useSolverInfo}. */
|
|
5
5
|
export type UseSolverInfoParameters = GetSolverInfoOptions & ConfigParameter;
|
|
6
6
|
/** Return type of {@link useSolverInfo}. */
|
|
7
|
-
export type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError
|
|
7
|
+
export type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError> & {
|
|
8
|
+
/** Last validated positive timelock capability observed for this deployment in this QueryClient. */
|
|
9
|
+
knownTimelockApproval?: TimelockApprovalCapability;
|
|
10
|
+
};
|
|
8
11
|
/**
|
|
9
12
|
* Read the solver's static fee configuration via the Enigma-only `/info`
|
|
10
13
|
* endpoint. Fails with `UNSUPPORTED_BY_SOLVER` when the resolved solver is not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-solver-info.d.ts","sourceRoot":"","sources":["../../src/solvers/use-solver-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"use-solver-info.d.ts","sourceRoot":"","sources":["../../src/solvers/use-solver-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AASzE,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAE7E,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG;IAC5F,oGAAoG;IACpG,qBAAqB,CAAC,EAAE,0BAA0B,CAAC;CACpD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,GAAE,uBAA4B,GAAG,uBAAuB,CAsC/F"}
|
|
@@ -2,26 +2,50 @@
|
|
|
2
2
|
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
3
|
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
4
|
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { rememberTimelockCapability as r, timelockCapabilityKey as i, useKnownTimelockCapability as a } from "./timelock-capability-cache.js";
|
|
6
|
+
import { getSolverInfoQueryOptions as o } from "@symmio/trading-core";
|
|
7
|
+
import { useEffect as s, useMemo as c } from "react";
|
|
8
|
+
import { useQuery as l, useQueryClient as u } from "@tanstack/react-query";
|
|
7
9
|
//#region src/solvers/use-solver-info.ts
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function d(d = {}) {
|
|
11
|
+
let f = t(d), p = e(), m = d.chainId ?? p, h = u(), g = c(() => {
|
|
12
|
+
try {
|
|
13
|
+
return i(f, m, d.solverId);
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}, [
|
|
18
|
+
f,
|
|
19
|
+
m,
|
|
20
|
+
d.solverId
|
|
21
|
+
]), _ = a(f, m, d.solverId), v = o(f, {
|
|
22
|
+
...d,
|
|
23
|
+
chainId: m
|
|
24
|
+
}), y = l({
|
|
25
|
+
...v,
|
|
15
26
|
queryFn: async () => {
|
|
16
27
|
try {
|
|
17
|
-
|
|
28
|
+
let e = await v.queryFn();
|
|
29
|
+
return g && r(h, g, e.timelockApproval), e;
|
|
18
30
|
} catch (e) {
|
|
19
31
|
throw n(e);
|
|
20
32
|
}
|
|
21
33
|
}
|
|
22
34
|
});
|
|
35
|
+
return s(() => {
|
|
36
|
+
g && !y.isPlaceholderData && y.data?.timelockApproval && !_ && r(h, g, y.data.timelockApproval);
|
|
37
|
+
}, [
|
|
38
|
+
h,
|
|
39
|
+
g,
|
|
40
|
+
_,
|
|
41
|
+
y.isPlaceholderData,
|
|
42
|
+
y.data?.timelockApproval
|
|
43
|
+
]), {
|
|
44
|
+
...y,
|
|
45
|
+
knownTimelockApproval: _ ?? (y.isPlaceholderData ? void 0 : y.data?.timelockApproval)
|
|
46
|
+
};
|
|
23
47
|
}
|
|
24
48
|
//#endregion
|
|
25
|
-
export {
|
|
49
|
+
export { d as useSolverInfo };
|
|
26
50
|
|
|
27
51
|
//# sourceMappingURL=use-solver-info.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-solver-info.js","names":[],"sources":["../../src/solvers/use-solver-info.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverInfoQueryOptions,\n type ConfigParameter,\n type GetSolverInfoData,\n type GetSolverInfoOptions,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useSolverInfo}. */\nexport type UseSolverInfoParameters = GetSolverInfoOptions & ConfigParameter;\n\n/** Return type of {@link useSolverInfo}. */\nexport type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError
|
|
1
|
+
{"version":3,"file":"use-solver-info.js","names":[],"sources":["../../src/solvers/use-solver-info.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverInfoQueryOptions,\n type ConfigParameter,\n type GetSolverInfoData,\n type GetSolverInfoOptions,\n type TimelockApprovalCapability,\n} from \"@symmio/trading-core\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useEffect, useMemo } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport {\n rememberTimelockCapability,\n timelockCapabilityKey,\n useKnownTimelockCapability,\n} from \"./timelock-capability-cache\";\n\n/** Parameters for {@link useSolverInfo}. */\nexport type UseSolverInfoParameters = GetSolverInfoOptions & ConfigParameter;\n\n/** Return type of {@link useSolverInfo}. */\nexport type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError> & {\n /** Last validated positive timelock capability observed for this deployment in this QueryClient. */\n knownTimelockApproval?: TimelockApprovalCapability;\n};\n\n/**\n * Read the solver's static fee configuration via the Enigma-only `/info`\n * endpoint. Fails with `UNSUPPORTED_BY_SOLVER` when the resolved solver is not\n * an `enigma` solver.\n */\nexport function useSolverInfo(parameters: UseSolverInfoParameters = {}): UseSolverInfoReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const resolvedChainId = parameters.chainId ?? chainId;\n const queryClient = useQueryClient();\n const key = useMemo(() => {\n try {\n return timelockCapabilityKey(config, resolvedChainId, parameters.solverId);\n } catch {\n return undefined;\n }\n }, [config, resolvedChainId, parameters.solverId]);\n const known = useKnownTimelockCapability(config, resolvedChainId, parameters.solverId);\n const options = getSolverInfoQueryOptions(config, {\n ...parameters,\n chainId: resolvedChainId,\n });\n\n const result = useQuery({\n ...options,\n queryFn: async () => {\n try {\n const data = await options.queryFn();\n if (key) rememberTimelockCapability(queryClient, key, data.timelockApproval);\n return data;\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<GetSolverInfoData, SymmioRequestError>;\n useEffect(() => {\n if (key && !result.isPlaceholderData && result.data?.timelockApproval && !known)\n rememberTimelockCapability(queryClient, key, result.data.timelockApproval);\n }, [queryClient, key, known, result.isPlaceholderData, result.data?.timelockApproval]);\n return {\n ...result,\n knownTimelockApproval: known ?? (result.isPlaceholderData ? undefined : result.data?.timelockApproval),\n };\n}\n"],"mappings":";;;;;;;;;AAmCA,SAAgB,EAAc,IAAsC,CAAC,GAA4B;CAC/F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAkB,EAAW,WAAW,GACxC,IAAc,EAAe,GAC7B,IAAM,QAAc;EACxB,IAAI;GACF,OAAO,EAAsB,GAAQ,GAAiB,EAAW,QAAQ;EAC3E,QAAQ;GACN;EACF;CACF,GAAG;EAAC;EAAQ;EAAiB,EAAW;CAAQ,CAAC,GAC3C,IAAQ,EAA2B,GAAQ,GAAiB,EAAW,QAAQ,GAC/E,IAAU,EAA0B,GAAQ;EAChD,GAAG;EACH,SAAS;CACX,CAAC,GAEK,IAAS,EAAS;EACtB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,IAAM,IAAO,MAAM,EAAQ,QAAQ;IAEnC,OADI,KAAK,EAA2B,GAAa,GAAK,EAAK,gBAAgB,GACpE;GACT,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAKD,OAJA,QAAgB;EACd,AAAI,KAAO,CAAC,EAAO,qBAAqB,EAAO,MAAM,oBAAoB,CAAC,KACxE,EAA2B,GAAa,GAAK,EAAO,KAAK,gBAAgB;CAC7E,GAAG;EAAC;EAAa;EAAK;EAAO,EAAO;EAAmB,EAAO,MAAM;CAAgB,CAAC,GAC9E;EACL,GAAG;EACH,uBAAuB,MAAU,EAAO,oBAAoB,KAAA,IAAY,EAAO,MAAM;CACvF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigParameter } from '@symmio/trading-core';
|
|
1
|
+
import { ConfigParameter, TimelockApprovalCapability, TimelockApprovalProvider, ValidatedTimelockApproval } from '@symmio/trading-core';
|
|
2
2
|
import { Hash, TransactionReceipt } from 'viem';
|
|
3
3
|
/**
|
|
4
4
|
* Parameters shared by every write hook — those that submit a transaction and
|
|
@@ -15,6 +15,18 @@ export interface WriteParameters extends ConfigParameter {
|
|
|
15
15
|
/** Confirmations to wait for when `waitForReceipt` is true. Defaults to `1`. */
|
|
16
16
|
confirmations?: number;
|
|
17
17
|
}
|
|
18
|
+
/** Write-hook options for operations that can automatically request a timelock approval. */
|
|
19
|
+
export interface AutomaticTimelockWriteParameters extends WriteParameters {
|
|
20
|
+
/** Set false for app-owned routing, or provide metadata and transport for a custom provider. Defaults to true. Keep the provider object stable while an operation is active. */
|
|
21
|
+
automaticTimelock?: boolean | {
|
|
22
|
+
capability: TimelockApprovalCapability;
|
|
23
|
+
provider: TimelockApprovalProvider;
|
|
24
|
+
/** Unix-seconds request deadline; defaults to chain time plus five minutes. */
|
|
25
|
+
deadline?: bigint;
|
|
26
|
+
/** Persist issued approvals before submission when recovery must survive reload. */
|
|
27
|
+
onApproval?: (approval: ValidatedTimelockApproval) => void | Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
18
30
|
/**
|
|
19
31
|
* Result shared by every write hook: the submitted transaction hash, plus the
|
|
20
32
|
* mined receipt when `waitForReceipt` is enabled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-types.d.ts","sourceRoot":"","sources":["../../src/transactions/write-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"write-types.d.ts","sourceRoot":"","sources":["../../src/transactions/write-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,4FAA4F;AAC5F,MAAM,WAAW,gCAAiC,SAAQ,eAAe;IACvE,gLAAgL;IAChL,iBAAiB,CAAC,EACd,OAAO,GACP;QACE,UAAU,EAAE,0BAA0B,CAAC;QACvC,QAAQ,EAAE,wBAAwB,CAAC;QACnC,+EAA+E;QAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,oFAAoF;QACpF,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,yBAAyB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5E,CAAC;CACP;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,mEAAmE;IACnE,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE;QACR,uDAAuD;QACvD,SAAS,EAAE,MAAM,CAAC;QAClB,sEAAsE;QACtE,aAAa,EAAE,IAAI,CAAC;KACrB,CAAC;CACH"}
|
package/dist/withdraw/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
export * from './use-deallocate-debounce-time.js';
|
|
1
2
|
export * from './use-finalize-withdraw-request.js';
|
|
2
3
|
export * from './use-initiate-withdraw.js';
|
|
3
4
|
export * from './use-last-withdraw-request-id.js';
|
|
4
5
|
export * from './use-pending-withdraw-requests.js';
|
|
6
|
+
export * from './use-pending-withdraw-requests-batch.js';
|
|
5
7
|
export * from './use-request-cancel-withdraw.js';
|
|
6
8
|
export * from './use-simulate-finalize-withdraw-request.js';
|
|
7
9
|
export * from './use-simulate-initiate-withdraw.js';
|
|
8
10
|
export * from './use-simulate-request-cancel-withdraw.js';
|
|
9
11
|
export * from './use-withdraw.js';
|
|
12
|
+
export * from './use-withdraw-cooldown-of.js';
|
|
10
13
|
export * from './use-withdraw-requests.js';
|
|
11
14
|
export * from './use-withdrawable-time.js';
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withdraw/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withdraw/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ConfigParameter, GetDeallocateDebounceTimeOptions, GetDeallocateDebounceTimeReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for {@link useDeallocateDebounceTime}: the core query options
|
|
6
|
+
* (optional chain id, TanStack `query` overrides) plus an optional `config`.
|
|
7
|
+
*/
|
|
8
|
+
export type UseDeallocateDebounceTimeParameters = GetDeallocateDebounceTimeOptions & ConfigParameter;
|
|
9
|
+
/** Return type of {@link useDeallocateDebounceTime}. */
|
|
10
|
+
export type UseDeallocateDebounceTimeReturnType = UseQueryResult<GetDeallocateDebounceTimeReturnType, SymmioRequestError>;
|
|
11
|
+
/**
|
|
12
|
+
* Read the protocol's deallocate debounce, in seconds: the minimum gap the
|
|
13
|
+
* SYMMIO core enforces between two deallocations of the same account. A
|
|
14
|
+
* deallocation reverts until `withdrawCooldownOf(account) + debounce` has
|
|
15
|
+
* passed (see {@link useWithdrawCooldownOf}); `0n` means no gap.
|
|
16
|
+
*
|
|
17
|
+
* It is a deployment-wide setting, the same for every account, so it rarely
|
|
18
|
+
* changes. `chainId` defaults to the connected chain.
|
|
19
|
+
*
|
|
20
|
+
* @param parameters - Optional chain id, query overrides and config.
|
|
21
|
+
* @returns The TanStack query result; `data` is the debounce in seconds.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const { data: debounceSeconds } = useDeallocateDebounceTime();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useDeallocateDebounceTime(parameters?: UseDeallocateDebounceTimeParameters): UseDeallocateDebounceTimeReturnType;
|
|
29
|
+
//# sourceMappingURL=use-deallocate-debounce-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-deallocate-debounce-time.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-deallocate-debounce-time.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gCAAgC,EACrC,KAAK,mCAAmC,EACzC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;;GAGG;AACH,MAAM,MAAM,mCAAmC,GAAG,gCAAgC,GAAG,eAAe,CAAC;AAErG,wDAAwD;AACxD,MAAM,MAAM,mCAAmC,GAAG,cAAc,CAC9D,mCAAmC,EACnC,kBAAkB,CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,GAAE,mCAAwC,GACnD,mCAAmC,CAkBrC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
|
+
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
|
+
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
+
import { getDeallocateDebounceTimeQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/withdraw/use-deallocate-debounce-time.ts
|
|
8
|
+
function a(a = {}) {
|
|
9
|
+
let o = t(a), s = e(), c = r(o, {
|
|
10
|
+
...a,
|
|
11
|
+
chainId: a.chainId ?? s
|
|
12
|
+
});
|
|
13
|
+
return i({
|
|
14
|
+
...c,
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
try {
|
|
17
|
+
return await c.queryFn();
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw n(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { a as useDeallocateDebounceTime };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-deallocate-debounce-time.js.map
|