@symmio/trading-react 3.0.0 → 3.1.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/use-account-balance-of.d.ts +5 -4
- package/dist/account-layer/use-account-balance-of.d.ts.map +1 -1
- package/dist/account-layer/use-account-balance-of.js.map +1 -1
- package/dist/account-layer/use-add-margin.d.ts.map +1 -1
- package/dist/account-layer/use-add-margin.js +1 -3
- package/dist/account-layer/use-add-margin.js.map +1 -1
- package/dist/account-layer/use-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-allocate.js +1 -3
- package/dist/account-layer/use-allocate.js.map +1 -1
- package/dist/account-layer/use-cancel-registration.d.ts.map +1 -1
- package/dist/account-layer/use-cancel-registration.js +1 -2
- package/dist/account-layer/use-cancel-registration.js.map +1 -1
- package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
- package/dist/account-layer/use-create-sub-accounts.js +1 -3
- package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +1 -6
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
- package/dist/account-layer/use-deallocate.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate.js +1 -3
- package/dist/account-layer/use-deallocate.js.map +1 -1
- package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
- package/dist/account-layer/use-delete-sub-account.js +1 -2
- package/dist/account-layer/use-delete-sub-account.js.map +1 -1
- package/dist/account-layer/use-deposit-and-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-deposit-and-allocate.js +1 -3
- package/dist/account-layer/use-deposit-and-allocate.js.map +1 -1
- package/dist/account-layer/use-deposit.d.ts.map +1 -1
- package/dist/account-layer/use-deposit.js +1 -3
- package/dist/account-layer/use-deposit.js.map +1 -1
- package/dist/account-layer/use-edit-account-name.d.ts.map +1 -1
- package/dist/account-layer/use-edit-account-name.js +1 -3
- package/dist/account-layer/use-edit-account-name.js.map +1 -1
- package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
- package/dist/account-layer/use-remove-margin.js +1 -3
- package/dist/account-layer/use-remove-margin.js.map +1 -1
- package/dist/account-layer/use-request-to-register-affiliate.d.ts.map +1 -1
- package/dist/account-layer/use-request-to-register-affiliate.js +1 -2
- package/dist/account-layer/use-request-to-register-affiliate.js.map +1 -1
- package/dist/collateral/use-approve-collateral.d.ts.map +1 -1
- package/dist/collateral/use-approve-collateral.js +1 -2
- package/dist/collateral/use-approve-collateral.js.map +1 -1
- package/dist/errors/normalize-symm-error.d.ts.map +1 -1
- package/dist/errors/normalize-symm-error.js +1 -0
- package/dist/errors/normalize-symm-error.js.map +1 -1
- package/dist/errors/symmio-request-error.d.ts +19 -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/gasless-relay-types.d.ts +115 -0
- package/dist/gasless/gasless-relay-types.d.ts.map +1 -0
- package/dist/gasless/gasless-relay-types.js +9 -0
- package/dist/gasless/gasless-relay-types.js.map +1 -0
- package/dist/gasless/index.d.ts +21 -0
- package/dist/gasless/index.d.ts.map +1 -0
- package/dist/gasless/index.js +21 -0
- package/dist/gasless/invalidate-relay-reads.d.ts +96 -0
- package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -0
- package/dist/gasless/invalidate-relay-reads.js +107 -0
- package/dist/gasless/invalidate-relay-reads.js.map +1 -0
- package/dist/gasless/use-approve-operational-fee.d.ts +38 -0
- package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -0
- package/dist/gasless/use-approve-operational-fee.js +37 -0
- package/dist/gasless/use-approve-operational-fee.js.map +1 -0
- package/dist/gasless/use-debounced-batch.d.ts +22 -0
- package/dist/gasless/use-debounced-batch.d.ts.map +1 -0
- package/dist/gasless/use-debounced-batch.js +27 -0
- package/dist/gasless/use-debounced-batch.js.map +1 -0
- package/dist/gasless/use-gasless-batch-fee-quote.d.ts +48 -0
- package/dist/gasless/use-gasless-batch-fee-quote.d.ts.map +1 -0
- package/dist/gasless/use-gasless-batch-fee-quote.js +33 -0
- package/dist/gasless/use-gasless-batch-fee-quote.js.map +1 -0
- package/dist/gasless/use-gasless-deposit-policy.d.ts +28 -0
- package/dist/gasless/use-gasless-deposit-policy.d.ts.map +1 -0
- package/dist/gasless/use-gasless-deposit-policy.js +27 -0
- package/dist/gasless/use-gasless-deposit-policy.js.map +1 -0
- package/dist/gasless/use-gasless-fee-quote.d.ts +25 -0
- package/dist/gasless/use-gasless-fee-quote.d.ts.map +1 -0
- package/dist/gasless/use-gasless-fee-quote.js +27 -0
- package/dist/gasless/use-gasless-fee-quote.js.map +1 -0
- package/dist/gasless/use-gasless-relay-confirmation.d.ts +72 -0
- package/dist/gasless/use-gasless-relay-confirmation.d.ts.map +1 -0
- package/dist/gasless/use-gasless-relay-confirmation.js +148 -0
- package/dist/gasless/use-gasless-relay-confirmation.js.map +1 -0
- package/dist/gasless/use-gasless-request-stream.d.ts +34 -0
- package/dist/gasless/use-gasless-request-stream.d.ts.map +1 -0
- package/dist/gasless/use-gasless-request-stream.js +86 -0
- package/dist/gasless/use-gasless-request-stream.js.map +1 -0
- package/dist/gasless/use-gasless-request-transactions.d.ts +42 -0
- package/dist/gasless/use-gasless-request-transactions.d.ts.map +1 -0
- package/dist/gasless/use-gasless-request-transactions.js +28 -0
- package/dist/gasless/use-gasless-request-transactions.js.map +1 -0
- package/dist/gasless/use-gasless-request.d.ts +56 -0
- package/dist/gasless/use-gasless-request.d.ts.map +1 -0
- package/dist/gasless/use-gasless-request.js +51 -0
- package/dist/gasless/use-gasless-request.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-address.d.ts +24 -0
- package/dist/gasless/use-gasless-wallet-address.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-address.js +27 -0
- package/dist/gasless/use-gasless-wallet-address.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.d.ts +29 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.js +27 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts +44 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.js +19 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute.d.ts +51 -0
- package/dist/gasless/use-gasless-wallet-execute.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute.js +44 -0
- package/dist/gasless/use-gasless-wallet-execute.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-nonce.d.ts +27 -0
- package/dist/gasless/use-gasless-wallet-nonce.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-nonce.js +27 -0
- package/dist/gasless/use-gasless-wallet-nonce.js.map +1 -0
- package/dist/gasless/use-operational-fee-allowance.d.ts +23 -0
- package/dist/gasless/use-operational-fee-allowance.d.ts.map +1 -0
- package/dist/gasless/use-operational-fee-allowance.js +27 -0
- package/dist/gasless/use-operational-fee-allowance.js.map +1 -0
- package/dist/gasless/use-relay-gasless-batch.d.ts +48 -0
- package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -0
- package/dist/gasless/use-relay-gasless-batch.js +44 -0
- package/dist/gasless/use-relay-gasless-batch.js.map +1 -0
- package/dist/gasless/use-relay-instant-operations.d.ts +43 -0
- package/dist/gasless/use-relay-instant-operations.d.ts.map +1 -0
- package/dist/gasless/use-relay-instant-operations.js +44 -0
- package/dist/gasless/use-relay-instant-operations.js.map +1 -0
- package/dist/gasless/use-resubmit-gasless-request.d.ts +39 -0
- package/dist/gasless/use-resubmit-gasless-request.d.ts.map +1 -0
- package/dist/gasless/use-resubmit-gasless-request.js +56 -0
- package/dist/gasless/use-resubmit-gasless-request.js.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts +41 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.js +47 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.js.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts +48 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.js +48 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.js.map +1 -0
- package/dist/gasless/use-supports-gasless-service.d.ts +22 -0
- package/dist/gasless/use-supports-gasless-service.d.ts.map +1 -0
- package/dist/gasless/use-supports-gasless-service.js +13 -0
- package/dist/gasless/use-supports-gasless-service.js.map +1 -0
- package/dist/index.d.ts +29 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +251 -221
- package/dist/instant-layer/index.d.ts +7 -0
- package/dist/instant-layer/index.d.ts.map +1 -1
- package/dist/instant-layer/index.js +26 -19
- package/dist/instant-layer/use-active-delegations.d.ts +31 -0
- package/dist/instant-layer/use-active-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-active-delegations.js +23 -0
- package/dist/instant-layer/use-active-delegations.js.map +1 -0
- package/dist/instant-layer/use-are-delegations-active.d.ts +100 -0
- package/dist/instant-layer/use-are-delegations-active.d.ts.map +1 -0
- package/dist/instant-layer/use-are-delegations-active.js +60 -0
- package/dist/instant-layer/use-are-delegations-active.js.map +1 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.d.ts +32 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.d.ts.map +1 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.js +45 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.js.map +1 -0
- package/dist/instant-layer/use-grant-delegation.d.ts +12 -2
- package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
- package/dist/instant-layer/use-grant-delegation.js +27 -20
- package/dist/instant-layer/use-grant-delegation.js.map +1 -1
- package/dist/instant-layer/use-initiate-revoke-delegation.d.ts +32 -0
- package/dist/instant-layer/use-initiate-revoke-delegation.d.ts.map +1 -0
- package/dist/instant-layer/use-initiate-revoke-delegation.js +45 -0
- package/dist/instant-layer/use-initiate-revoke-delegation.js.map +1 -0
- package/dist/instant-layer/use-pending-revocation.d.ts +119 -0
- package/dist/instant-layer/use-pending-revocation.d.ts.map +1 -0
- package/dist/instant-layer/use-pending-revocation.js +73 -0
- package/dist/instant-layer/use-pending-revocation.js.map +1 -0
- package/dist/instant-layer/use-revocation-cooldown.d.ts +24 -0
- package/dist/instant-layer/use-revocation-cooldown.d.ts.map +1 -0
- package/dist/instant-layer/use-revocation-cooldown.js +23 -0
- package/dist/instant-layer/use-revocation-cooldown.js.map +1 -0
- package/dist/instant-layer/use-session-key-selectors.d.ts +53 -0
- package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -0
- package/dist/instant-layer/use-session-key-selectors.js +25 -0
- package/dist/instant-layer/use-session-key-selectors.js.map +1 -0
- package/dist/margin/use-available-instant-open-margin.js +8 -8
- package/dist/markets/index.d.ts +1 -0
- package/dist/markets/index.d.ts.map +1 -1
- package/dist/markets/index.js +3 -2
- package/dist/markets/use-funding-fees-of-party-b.d.ts +47 -0
- package/dist/markets/use-funding-fees-of-party-b.d.ts.map +1 -0
- package/dist/markets/use-funding-fees-of-party-b.js +27 -0
- package/dist/markets/use-funding-fees-of-party-b.js.map +1 -0
- package/dist/provider/create-session-key-wallet-client-resolver.d.ts +68 -0
- package/dist/provider/create-session-key-wallet-client-resolver.d.ts.map +1 -0
- package/dist/provider/create-session-key-wallet-client-resolver.js +51 -0
- package/dist/provider/create-session-key-wallet-client-resolver.js.map +1 -0
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +5 -4
- package/dist/provider/symmio-provider.d.ts +7 -2
- package/dist/provider/symmio-provider.d.ts.map +1 -1
- package/dist/provider/symmio-provider.js +10 -7
- package/dist/provider/symmio-provider.js.map +1 -1
- package/dist/quotes/index.d.ts +2 -0
- package/dist/quotes/index.d.ts.map +1 -1
- package/dist/quotes/use-account-upnl.js +9 -9
- package/dist/quotes/use-close-quote-group.js +13 -13
- package/dist/quotes/use-force-cancel-close-request.d.ts.map +1 -1
- package/dist/quotes/use-force-cancel-close-request.js +1 -4
- package/dist/quotes/use-force-cancel-close-request.js.map +1 -1
- package/dist/quotes/use-force-cancel-quote.d.ts.map +1 -1
- package/dist/quotes/use-force-cancel-quote.js +1 -4
- package/dist/quotes/use-force-cancel-quote.js.map +1 -1
- package/dist/quotes/use-force-close.d.ts +2 -1
- package/dist/quotes/use-force-close.d.ts.map +1 -1
- package/dist/quotes/use-force-close.js +14 -12
- package/dist/quotes/use-force-close.js.map +1 -1
- package/dist/quotes/use-limit-orders.js +9 -9
- package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
- package/dist/quotes/use-managed-quotes.js +103 -103
- package/dist/quotes/use-managed-quotes.js.map +1 -1
- package/dist/quotes/use-party-a-open-positions.js +5 -5
- package/dist/quotes/use-quote-group-funding-history.d.ts +10 -7
- package/dist/quotes/use-quote-group-funding-history.d.ts.map +1 -1
- package/dist/quotes/use-quote-group-funding-history.js.map +1 -1
- package/dist/quotes/use-quote-group-funding.d.ts +4 -2
- package/dist/quotes/use-quote-group-funding.d.ts.map +1 -1
- package/dist/quotes/use-quote-group-funding.js.map +1 -1
- package/dist/quotes/use-quote-pending-funding.d.ts +62 -0
- package/dist/quotes/use-quote-pending-funding.d.ts.map +1 -0
- package/dist/quotes/use-quote-pending-funding.js +31 -0
- package/dist/quotes/use-quote-pending-funding.js.map +1 -0
- package/dist/quotes/use-quotes-funding.d.ts +4 -2
- package/dist/quotes/use-quotes-funding.d.ts.map +1 -1
- package/dist/quotes/use-quotes-funding.js.map +1 -1
- package/dist/quotes/use-quotes-pending-funding.d.ts +92 -0
- package/dist/quotes/use-quotes-pending-funding.d.ts.map +1 -0
- package/dist/quotes/use-quotes-pending-funding.js +94 -0
- package/dist/quotes/use-quotes-pending-funding.js.map +1 -0
- package/dist/quotes/use-request-to-cancel-close-request.d.ts.map +1 -1
- package/dist/quotes/use-request-to-cancel-close-request.js +1 -4
- package/dist/quotes/use-request-to-cancel-close-request.js.map +1 -1
- package/dist/quotes/use-request-to-cancel-quote.d.ts.map +1 -1
- package/dist/quotes/use-request-to-cancel-quote.js +1 -4
- package/dist/quotes/use-request-to-cancel-quote.js.map +1 -1
- package/dist/transactions/index.js +3 -3
- package/dist/transactions/resolve-write-result.d.ts +53 -2
- package/dist/transactions/resolve-write-result.d.ts.map +1 -1
- package/dist/transactions/resolve-write-result.js +52 -9
- package/dist/transactions/resolve-write-result.js.map +1 -1
- package/dist/transactions/write-types.d.ts +19 -1
- package/dist/transactions/write-types.d.ts.map +1 -1
- package/dist/utils/predicate-match.d.ts +7 -4
- package/dist/utils/predicate-match.d.ts.map +1 -1
- package/dist/utils/predicate-match.js +5 -5
- package/dist/utils/predicate-match.js.map +1 -1
- package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
- package/dist/withdraw/use-finalize-withdraw-request.js +1 -3
- package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.js +1 -5
- package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.js +1 -3
- package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
- package/dist/withdraw/use-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-withdraw.js +2 -1
- package/dist/withdraw/use-withdraw.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { normalizeSymmError as e } from "../errors/normalize-symm-error.js";
|
|
3
|
+
import { IDLE_RELAY_PROGRESS as t } from "./gasless-relay-types.js";
|
|
4
|
+
import { GaslessRequestStatus as n, confirmGaslessRequest as r, getGaslessRequestQueryKey as i, isNewerGaslessRequest as a } from "@symmio/trading-core";
|
|
5
|
+
import { useCallback as o, useEffect as s, useRef as c, useState as l } from "react";
|
|
6
|
+
import { useQueryClient as u } from "@tanstack/react-query";
|
|
7
|
+
//#region src/gasless/use-gasless-relay-confirmation.ts
|
|
8
|
+
var d = new Set(["GASLESS_TERMINAL_TIMEOUT", "GASLESS_BROADCAST_TIMEOUT"]);
|
|
9
|
+
function f(e) {
|
|
10
|
+
return e.walletIds ? e.walletIds : e.walletId === void 0 ? [] : [e.walletId];
|
|
11
|
+
}
|
|
12
|
+
function p(p, g) {
|
|
13
|
+
let _ = u(), [v, y] = l(t), b = c(void 0), x = c(!0), S = c(p.abortOnUnmount ?? !0);
|
|
14
|
+
S.current = p.abortOnUnmount ?? !0, s(() => (x.current = !0, () => {
|
|
15
|
+
x.current = !1, S.current && b.current?.abort();
|
|
16
|
+
}), []);
|
|
17
|
+
let C = o((e) => {
|
|
18
|
+
x.current && y(e);
|
|
19
|
+
}, []);
|
|
20
|
+
return {
|
|
21
|
+
progress: v,
|
|
22
|
+
reset: o(() => {
|
|
23
|
+
b.current?.abort(), b.current = void 0, C(t);
|
|
24
|
+
}, [C]),
|
|
25
|
+
submit: o(async (e) => {
|
|
26
|
+
C({
|
|
27
|
+
phase: "submitting",
|
|
28
|
+
degraded: !1
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
return await e();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
throw C({
|
|
34
|
+
phase: "error",
|
|
35
|
+
degraded: !1
|
|
36
|
+
}), e;
|
|
37
|
+
}
|
|
38
|
+
}, [C]),
|
|
39
|
+
confirm: o(async (t, o) => {
|
|
40
|
+
let { chainId: s, service: c, invalidate: l } = o, { confirmation: u = "receipt" } = p;
|
|
41
|
+
try {
|
|
42
|
+
p.onAccepted?.({
|
|
43
|
+
requestId: t.requestId,
|
|
44
|
+
service: c ?? "operations",
|
|
45
|
+
chainId: s,
|
|
46
|
+
protocolInstance: t.protocolInstance,
|
|
47
|
+
idempotencyKey: t.idempotencyKey,
|
|
48
|
+
operationType: o.operationType ?? null,
|
|
49
|
+
owner: t.owner,
|
|
50
|
+
walletIds: f(t)
|
|
51
|
+
});
|
|
52
|
+
} catch {}
|
|
53
|
+
let v = !1, y, x = (e) => {
|
|
54
|
+
C({
|
|
55
|
+
...e,
|
|
56
|
+
idempotencyKey: t.idempotencyKey,
|
|
57
|
+
degraded: v,
|
|
58
|
+
issue: y
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
if (x({
|
|
62
|
+
phase: "queued",
|
|
63
|
+
requestId: t.requestId,
|
|
64
|
+
status: n.QUEUED
|
|
65
|
+
}), u === "none") return;
|
|
66
|
+
b.current?.abort();
|
|
67
|
+
let S = new AbortController();
|
|
68
|
+
b.current = S;
|
|
69
|
+
let w = !1, T, E = null, D = g.getChainConfigKey(s), O = () => b.current === S, k = (e) => {
|
|
70
|
+
e.status === n.SUCCEEDED && (w = !0), T = e.status, E = e.txHash, v = !1, y = void 0, _.setQueryData(i({
|
|
71
|
+
chainId: s,
|
|
72
|
+
requestId: t.requestId,
|
|
73
|
+
service: c,
|
|
74
|
+
configKey: D
|
|
75
|
+
}), (t) => a(t, e) ? e : t), O() && x({
|
|
76
|
+
phase: e.status === n.SUBMITTED ? "submitted" : "queued",
|
|
77
|
+
requestId: e.requestId,
|
|
78
|
+
status: e.status,
|
|
79
|
+
txHash: e.txHash ?? void 0
|
|
80
|
+
}), p.onProgress?.(e);
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
let i = await r(g, {
|
|
84
|
+
chainId: s,
|
|
85
|
+
requestId: t.requestId,
|
|
86
|
+
service: c ?? "operations",
|
|
87
|
+
until: u,
|
|
88
|
+
receiptConfirmations: p.receiptConfirmations,
|
|
89
|
+
timeoutMs: p.timeoutMs,
|
|
90
|
+
receiptTimeoutMs: p.receiptTimeoutMs,
|
|
91
|
+
signal: S.signal,
|
|
92
|
+
onTransportIssue: (r) => {
|
|
93
|
+
v = !0, y = e(r), O() && x({
|
|
94
|
+
phase: T === n.SUBMITTED ? "submitted" : "queued",
|
|
95
|
+
requestId: t.requestId,
|
|
96
|
+
status: T,
|
|
97
|
+
txHash: E ?? void 0
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
onUpdate: (e) => {
|
|
101
|
+
k(e), e.status === n.SUCCEEDED && u === "receipt" && O() && x({
|
|
102
|
+
phase: "awaiting-receipt",
|
|
103
|
+
requestId: e.requestId,
|
|
104
|
+
status: e.status,
|
|
105
|
+
txHash: e.txHash ?? void 0
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return O() && x({
|
|
110
|
+
phase: "confirmed",
|
|
111
|
+
requestId: i.request.requestId,
|
|
112
|
+
status: i.request.status,
|
|
113
|
+
txHash: i.txHash
|
|
114
|
+
}), i;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
if (O()) {
|
|
117
|
+
let n = d.has(m(e)) ? "unconfirmed" : "error";
|
|
118
|
+
x({
|
|
119
|
+
phase: n,
|
|
120
|
+
requestId: t.requestId,
|
|
121
|
+
status: h(e) ?? (n === "unconfirmed" ? T : void 0),
|
|
122
|
+
txHash: E ?? void 0
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
throw e;
|
|
126
|
+
} finally {
|
|
127
|
+
w && l(_), b.current === S && (b.current = void 0);
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
g,
|
|
131
|
+
p,
|
|
132
|
+
C,
|
|
133
|
+
_
|
|
134
|
+
])
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function m(e) {
|
|
138
|
+
let t = e?.code;
|
|
139
|
+
return typeof t == "string" ? t : "";
|
|
140
|
+
}
|
|
141
|
+
function h(e) {
|
|
142
|
+
let t = e?.responseData?.status;
|
|
143
|
+
return typeof t == "string" && Object.values(n).includes(t) ? t : void 0;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { p as useGaslessRelayConfirmation };
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=use-gasless-relay-confirmation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-relay-confirmation.js","names":[],"sources":["../../src/gasless/use-gasless-relay-confirmation.ts"],"sourcesContent":["\"use client\";\n\nimport {\n confirmGaslessRequest,\n GaslessRequestStatus,\n getGaslessRequestQueryKey,\n isNewerGaslessRequest,\n type Config,\n type GaslessAcceptedRequest,\n type GaslessConfirmedRequest,\n type GaslessRequest,\n type GaslessService,\n} from \"@symmio/trading-core\";\nimport { useQueryClient, type QueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { Address } from \"viem\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport { IDLE_RELAY_PROGRESS, type GaslessRelayParameters, type GaslessRelayProgress } from \"./gasless-relay-types\";\n\n/**\n * The acceptance fields a confirmation needs. Every gasless submit receipt\n * satisfies it: an operations receipt carries `walletIds`, a deposit settlement\n * carries the single `walletId` it settled.\n *\n * @internal\n */\nexport interface GaslessRelayAcceptance {\n requestId: string;\n idempotencyKey: string;\n protocolInstance: string | null;\n owner: Address;\n walletIds?: readonly bigint[];\n walletId?: bigint;\n}\n\n/** What the relay hook tells the confirmation about the request it just submitted. @internal */\nexport interface GaslessRelayConfirmOptions {\n /** The chain the relay was accepted on. */\n chainId: number;\n /** Which sub-service stores the request. Defaults to `\"operations\"`. */\n service?: GaslessService;\n /** The workflow label the submit carried, for the persisted row. */\n operationType?: string;\n /** Invalidate the reads a `succeeded` relay changed. */\n invalidate: (queryClient: QueryClient) => void;\n}\n\n/** What {@link useGaslessRelayConfirmation} hands back to a relay hook. */\nexport interface GaslessRelayConfirmationController {\n /** Current progress, to merge onto the mutation result as `relay`. */\n progress: GaslessRelayProgress;\n /** Reset progress and abort any in-flight wait. Call from the hook's `reset`. */\n reset: () => void;\n /**\n * Run the submit half of a relay through the progress state.\n *\n * Publishes `submitting` for the window between the user's click and the\n * service's `202` — signing and the POST — which is the one stretch\n * {@link confirm} cannot see, and publishes `error` if that window fails.\n * Nothing is accepted yet, so neither phase carries a request id.\n */\n submit: <result>(send: () => Promise<result>) => Promise<result>;\n /**\n * Follow an accepted request to the configured depth.\n *\n * Returns the confirmation, or `undefined` for `confirmation: \"none\"`.\n * `invalidate` runs whenever a `succeeded` terminal was observed — including\n * when the wait was later aborted — because the point of waiting is the\n * invalidation, and the query client outlives the component.\n */\n confirm: (\n accepted: GaslessRelayAcceptance,\n options: GaslessRelayConfirmOptions,\n ) => Promise<GaslessConfirmedRequest | undefined>;\n}\n\n/** The wait budget ran out: the outcome is unknown, not failed. */\nconst TIMEOUT_CODES: ReadonlySet<string> = new Set([\"GASLESS_TERMINAL_TIMEOUT\", \"GASLESS_BROADCAST_TIMEOUT\"]);\n\n/** The ids a relay selected, whichever shape its acceptance reports them in. */\nfunction acceptedWalletIds(accepted: GaslessRelayAcceptance): readonly bigint[] {\n if (accepted.walletIds) return accepted.walletIds;\n return accepted.walletId === undefined ? [] : [accepted.walletId];\n}\n\n/**\n * The confirmation half of every explicit relay hook.\n *\n * Owns the four things a relay mutation needs and a plain `useMutation` cannot\n * give it: an `AbortController` tied to the component's life, progress state\n * that survives a 120-second wait, the `onAccepted` hand-off that lets a\n * consumer persist the request id before anything can go wrong, and the\n * guarantee that a `succeeded` relay invalidates its reads even if nobody is\n * left watching.\n *\n * @param parameters - The hook's confirmation options.\n * @param config - The SDK config, for the confirm call and the cache seed.\n *\n * @internal\n */\nexport function useGaslessRelayConfirmation(\n parameters: GaslessRelayParameters,\n config: Config,\n): GaslessRelayConfirmationController {\n const queryClient = useQueryClient();\n const [progress, setProgress] = useState<GaslessRelayProgress>(IDLE_RELAY_PROGRESS);\n\n const abortRef = useRef<AbortController>(undefined);\n const mountedRef = useRef(true);\n\n /**\n * Held in a ref, and the effect has no dependencies, so the cleanup runs on\n * unmount only. Depending on the value would re-run the cleanup whenever a\n * caller flipped the flag — aborting a live confirmation, and doing so on\n * exactly the `true -> false` transition that asks for the opposite.\n */\n const abortOnUnmountRef = useRef(parameters.abortOnUnmount ?? true);\n abortOnUnmountRef.current = parameters.abortOnUnmount ?? true;\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n if (abortOnUnmountRef.current) abortRef.current?.abort();\n };\n }, []);\n\n /** Progress is cosmetic — never let a late setState warn after unmount. */\n const publish = useCallback((next: GaslessRelayProgress) => {\n if (mountedRef.current) setProgress(next);\n }, []);\n\n const reset = useCallback(() => {\n abortRef.current?.abort();\n abortRef.current = undefined;\n publish(IDLE_RELAY_PROGRESS);\n }, [publish]);\n\n const submit = useCallback(\n async <result>(send: () => Promise<result>): Promise<result> => {\n publish({ phase: \"submitting\", degraded: false });\n try {\n return await send();\n } catch (err) {\n /**\n * The service never accepted anything, so there is no id to report and\n * no workflow to keep watching: unlike a failed confirmation, this one\n * is safe to retry from the wallet.\n */\n publish({ phase: \"error\", degraded: false });\n throw err;\n }\n },\n [publish],\n );\n\n const confirm = useCallback(\n async (accepted: GaslessRelayAcceptance, options: GaslessRelayConfirmOptions) => {\n const { chainId, service, invalidate } = options;\n const { confirmation = \"receipt\" } = parameters;\n\n /**\n * Before anything can fail: the request exists server-side from this\n * point on, and its id is the only handle on it.\n */\n try {\n parameters.onAccepted?.({\n requestId: accepted.requestId,\n service: service ?? \"operations\",\n chainId,\n protocolInstance: accepted.protocolInstance,\n idempotencyKey: accepted.idempotencyKey,\n operationType: options.operationType ?? null,\n owner: accepted.owner,\n walletIds: acceptedWalletIds(accepted),\n } satisfies GaslessAcceptedRequest);\n } catch {\n /** An observer must never fail a relay the service has already accepted. */\n }\n\n /** Reported on every publish, so a transient blind spot never reads as a failure. */\n let degraded = false;\n let issue: GaslessRelayProgress[\"issue\"];\n\n const publishPhase = (next: Omit<GaslessRelayProgress, \"degraded\" | \"issue\" | \"idempotencyKey\">) => {\n publish({ ...next, idempotencyKey: accepted.idempotencyKey, degraded, issue });\n };\n\n publishPhase({\n phase: \"queued\",\n requestId: accepted.requestId,\n status: GaslessRequestStatus.QUEUED,\n });\n if (confirmation === \"none\") return undefined;\n\n /** A second submit supersedes the first: stop watching the old one. */\n abortRef.current?.abort();\n const controller = new AbortController();\n abortRef.current = controller;\n\n let sawSuccess = false;\n let lastStatus: GaslessRequestStatus | undefined;\n let lastTxHash: GaslessRequest[\"txHash\"] = null;\n const configKey = config.getChainConfigKey(chainId);\n\n /** A superseded or aborted wait must not paint over the live one. */\n const isCurrent = () => abortRef.current === controller;\n\n const onUpdate = (request: GaslessRequest) => {\n if (request.status === GaslessRequestStatus.SUCCEEDED) sawSuccess = true;\n lastStatus = request.status;\n lastTxHash = request.txHash;\n /** A read landed: whatever was unreadable a moment ago is readable again. */\n degraded = false;\n issue = undefined;\n /**\n * Seed the record so a separately mounted `useGaslessRequest` on the\n * same id sees terminal immediately instead of running its own poll —\n * but only when it is genuinely newer, or a slow `queued` response\n * would repaint a finished workflow as pending.\n */\n queryClient.setQueryData<GaslessRequest>(\n getGaslessRequestQueryKey({ chainId, requestId: accepted.requestId, service, configKey }),\n (previous) => (isNewerGaslessRequest(previous, request) ? request : previous),\n );\n if (isCurrent()) {\n publishPhase({\n phase: request.status === GaslessRequestStatus.SUBMITTED ? \"submitted\" : \"queued\",\n requestId: request.requestId,\n status: request.status,\n txHash: request.txHash ?? undefined,\n });\n }\n parameters.onProgress?.(request);\n };\n\n try {\n const confirmed = await confirmGaslessRequest(config, {\n chainId,\n requestId: accepted.requestId,\n service: service ?? \"operations\",\n until: confirmation,\n receiptConfirmations: parameters.receiptConfirmations,\n timeoutMs: parameters.timeoutMs,\n receiptTimeoutMs: parameters.receiptTimeoutMs,\n signal: controller.signal,\n onTransportIssue: (error) => {\n degraded = true;\n issue = normalizeSymmError(error);\n if (isCurrent()) {\n publishPhase({\n phase: lastStatus === GaslessRequestStatus.SUBMITTED ? \"submitted\" : \"queued\",\n requestId: accepted.requestId,\n status: lastStatus,\n txHash: lastTxHash ?? undefined,\n });\n }\n },\n onUpdate: (request) => {\n onUpdate(request);\n if (request.status === GaslessRequestStatus.SUCCEEDED && confirmation === \"receipt\" && isCurrent()) {\n publishPhase({\n phase: \"awaiting-receipt\",\n requestId: request.requestId,\n status: request.status,\n txHash: request.txHash ?? undefined,\n });\n }\n },\n });\n if (isCurrent()) {\n publishPhase({\n phase: \"confirmed\",\n requestId: confirmed.request.requestId,\n status: confirmed.request.status,\n txHash: confirmed.txHash,\n });\n }\n return confirmed;\n } catch (err) {\n if (isCurrent()) {\n /**\n * A budget that ran out is not a verdict: the relay is still running\n * and its id is still good. The mutation rejects either way — it has\n * no result to report — but the phase must not tell the user their\n * action failed, which is what makes them submit it a second time.\n */\n const phase = TIMEOUT_CODES.has(readErrorCode(err)) ? \"unconfirmed\" : \"error\";\n publishPhase({\n phase,\n requestId: accepted.requestId,\n status: progressStatus(err) ?? (phase === \"unconfirmed\" ? lastStatus : undefined),\n txHash: lastTxHash ?? undefined,\n });\n }\n throw err;\n } finally {\n /**\n * Gated on the observed terminal, not on how the wait ended: an abort\n * after `succeeded` still leaves the cache stale for everyone else.\n */\n if (sawSuccess) invalidate(queryClient);\n if (abortRef.current === controller) abortRef.current = undefined;\n }\n },\n [config, parameters, publish, queryClient],\n );\n\n return { progress, reset, submit, confirm };\n}\n\n/** The SDK error code an error carries, read structurally across the error layers. */\nfunction readErrorCode(err: unknown): string {\n const code = (err as { code?: unknown } | undefined)?.code;\n return typeof code === \"string\" ? code : \"\";\n}\n\n/** Best-effort status for the error phase; absent when the failure was transport-level. */\nfunction progressStatus(err: unknown): GaslessRequestStatus | undefined {\n const data = (err as { responseData?: { status?: unknown } } | undefined)?.responseData;\n const status = data?.status;\n return typeof status === \"string\" && (Object.values(GaslessRequestStatus) as string[]).includes(status)\n ? (status as GaslessRequestStatus)\n : undefined;\n}\n"],"mappings":";;;;;;;AA6EA,IAAM,IAAqC,IAAI,IAAI,CAAC,4BAA4B,2BAA2B,CAAC;AAG5G,SAAS,EAAkB,GAAqD;CAE9E,OADI,EAAS,YAAkB,EAAS,YACjC,EAAS,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC,EAAS,QAAQ;AAClE;AAiBA,SAAgB,EACd,GACA,GACoC;CACpC,IAAM,IAAc,EAAe,GAC7B,CAAC,GAAU,KAAe,EAA+B,CAAmB,GAE5E,IAAW,EAAwB,KAAA,CAAS,GAC5C,IAAa,EAAO,EAAI,GAQxB,IAAoB,EAAO,EAAW,kBAAkB,EAAI;CAGlE,AAFA,EAAkB,UAAU,EAAW,kBAAkB,IAEzD,SACE,EAAW,UAAU,UACR;EAEX,AADA,EAAW,UAAU,IACjB,EAAkB,WAAS,EAAS,SAAS,MAAM;CACzD,IACC,CAAC,CAAC;CAGL,IAAM,IAAU,GAAa,MAA+B;EAC1D,AAAI,EAAW,WAAS,EAAY,CAAI;CAC1C,GAAG,CAAC,CAAC;CAkLL,OAAO;EAAE;EAAU,OAhLL,QAAkB;GAG9B,AAFA,EAAS,SAAS,MAAM,GACxB,EAAS,UAAU,KAAA,GACnB,EAAQ,CAAmB;EAC7B,GAAG,CAAC,CAAO,CA4KQ;EAAO,QA1KX,EACb,OAAe,MAAiD;GAC9D,EAAQ;IAAE,OAAO;IAAc,UAAU;GAAM,CAAC;GAChD,IAAI;IACF,OAAO,MAAM,EAAK;GACpB,SAAS,GAAK;IAOZ,MADA,EAAQ;KAAE,OAAO;KAAS,UAAU;IAAM,CAAC,GACrC;GACR;EACF,GACA,CAAC,CAAO,CA2JgB;EAAQ,SAxJlB,EACd,OAAO,GAAkC,MAAwC;GAC/E,IAAM,EAAE,YAAS,YAAS,kBAAe,GACnC,EAAE,kBAAe,cAAc;GAMrC,IAAI;IACF,EAAW,aAAa;KACtB,WAAW,EAAS;KACpB,SAAS,KAAW;KACpB;KACA,kBAAkB,EAAS;KAC3B,gBAAgB,EAAS;KACzB,eAAe,EAAQ,iBAAiB;KACxC,OAAO,EAAS;KAChB,WAAW,EAAkB,CAAQ;IACvC,CAAkC;GACpC,QAAQ,CAER;GAGA,IAAI,IAAW,IACX,GAEE,KAAgB,MAA8E;IAClG,EAAQ;KAAE,GAAG;KAAM,gBAAgB,EAAS;KAAgB;KAAU;IAAM,CAAC;GAC/E;GAOA,IALA,EAAa;IACX,OAAO;IACP,WAAW,EAAS;IACpB,QAAQ,EAAqB;GAC/B,CAAC,GACG,MAAiB,QAAQ;GAG7B,EAAS,SAAS,MAAM;GACxB,IAAM,IAAa,IAAI,gBAAgB;GACvC,EAAS,UAAU;GAEnB,IAAI,IAAa,IACb,GACA,IAAuC,MACrC,IAAY,EAAO,kBAAkB,CAAO,GAG5C,UAAkB,EAAS,YAAY,GAEvC,KAAY,MAA4B;IAyB5C,AAxBI,EAAQ,WAAW,EAAqB,cAAW,IAAa,KACpE,IAAa,EAAQ,QACrB,IAAa,EAAQ,QAErB,IAAW,IACX,IAAQ,KAAA,GAOR,EAAY,aACV,EAA0B;KAAE;KAAS,WAAW,EAAS;KAAW;KAAS;IAAU,CAAC,IACvF,MAAc,EAAsB,GAAU,CAAO,IAAI,IAAU,CACtE,GACI,EAAU,KACZ,EAAa;KACX,OAAO,EAAQ,WAAW,EAAqB,YAAY,cAAc;KACzE,WAAW,EAAQ;KACnB,QAAQ,EAAQ;KAChB,QAAQ,EAAQ,UAAU,KAAA;IAC5B,CAAC,GAEH,EAAW,aAAa,CAAO;GACjC;GAEA,IAAI;IACF,IAAM,IAAY,MAAM,EAAsB,GAAQ;KACpD;KACA,WAAW,EAAS;KACpB,SAAS,KAAW;KACpB,OAAO;KACP,sBAAsB,EAAW;KACjC,WAAW,EAAW;KACtB,kBAAkB,EAAW;KAC7B,QAAQ,EAAW;KACnB,mBAAmB,MAAU;MAG3B,AAFA,IAAW,IACX,IAAQ,EAAmB,CAAK,GAC5B,EAAU,KACZ,EAAa;OACX,OAAO,MAAe,EAAqB,YAAY,cAAc;OACrE,WAAW,EAAS;OACpB,QAAQ;OACR,QAAQ,KAAc,KAAA;MACxB,CAAC;KAEL;KACA,WAAW,MAAY;MAErB,AADA,EAAS,CAAO,GACZ,EAAQ,WAAW,EAAqB,aAAa,MAAiB,aAAa,EAAU,KAC/F,EAAa;OACX,OAAO;OACP,WAAW,EAAQ;OACnB,QAAQ,EAAQ;OAChB,QAAQ,EAAQ,UAAU,KAAA;MAC5B,CAAC;KAEL;IACF,CAAC;IASD,OARI,EAAU,KACZ,EAAa;KACX,OAAO;KACP,WAAW,EAAU,QAAQ;KAC7B,QAAQ,EAAU,QAAQ;KAC1B,QAAQ,EAAU;IACpB,CAAC,GAEI;GACT,SAAS,GAAK;IACZ,IAAI,EAAU,GAAG;KAOf,IAAM,IAAQ,EAAc,IAAI,EAAc,CAAG,CAAC,IAAI,gBAAgB;KACtE,EAAa;MACX;MACA,WAAW,EAAS;MACpB,QAAQ,EAAe,CAAG,MAAM,MAAU,gBAAgB,IAAa,KAAA;MACvE,QAAQ,KAAc,KAAA;KACxB,CAAC;IACH;IACA,MAAM;GACR,UAAU;IAMR,AADI,KAAY,EAAW,CAAW,GAClC,EAAS,YAAY,MAAY,EAAS,UAAU,KAAA;GAC1D;EACF,GACA;GAAC;GAAQ;GAAY;GAAS;EAAW,CAGT;CAAQ;AAC5C;AAGA,SAAS,EAAc,GAAsB;CAC3C,IAAM,IAAQ,GAAwC;CACtD,OAAO,OAAO,KAAS,WAAW,IAAO;AAC3C;AAGA,SAAS,EAAe,GAAgD;CAEtE,IAAM,IADQ,GAA6D,cACtD;CACrB,OAAO,OAAO,KAAW,YAAa,OAAO,OAAO,CAAoB,EAAe,SAAS,CAAM,IACjG,IACD,KAAA;AACN"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Config, GaslessService, GaslessStatusTransport, GaslessStreamStatus, GaslessStreamStatusDetail } from '@symmio/trading-core';
|
|
2
|
+
/** What {@link useGaslessRequestStream} reports about the live transport. */
|
|
3
|
+
export interface GaslessStreamState {
|
|
4
|
+
/** Stream health; anything but `"live"` means the caller should keep polling. */
|
|
5
|
+
status: GaslessStreamStatus;
|
|
6
|
+
/** Why, when the status alone does not say. */
|
|
7
|
+
detail: GaslessStreamStatusDetail | null;
|
|
8
|
+
/** Convenience for gating a poll: `status === "live"`. */
|
|
9
|
+
live: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe one workflow to the gateway's status stream and push its records
|
|
13
|
+
* into the query cache.
|
|
14
|
+
*
|
|
15
|
+
* The hook owns no data of its own: every delivery is written to the same cache
|
|
16
|
+
* entries the HTTP reads use, so components keep reading through
|
|
17
|
+
* `useGaslessRequest` / `useGaslessRequestTransactions` and never learn which
|
|
18
|
+
* transport produced a record. It returns only the stream's health, which the
|
|
19
|
+
* caller uses to pause or resume its poll — the pattern `usePrices` uses for the
|
|
20
|
+
* price feed.
|
|
21
|
+
*
|
|
22
|
+
* A deployment without a stream, or a disabled one, simply stays `"idle"`.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function useGaslessRequestStream(parameters: {
|
|
27
|
+
config: Config;
|
|
28
|
+
chainId: number;
|
|
29
|
+
requestId: string;
|
|
30
|
+
service?: GaslessService;
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
transport?: GaslessStatusTransport;
|
|
33
|
+
}): GaslessStreamState;
|
|
34
|
+
//# sourceMappingURL=use-gasless-request-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-request-stream.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-request-stream.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,MAAM,EAEX,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC/B,MAAM,sBAAsB,CAAC;AAI9B,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,MAAM,EAAE,mBAAmB,CAAC;IAC5B,+CAA+C;IAC/C,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACzC,0DAA0D;IAC1D,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC,GAAG,kBAAkB,CA8DrB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getGaslessRequestQueryKey as e, getGaslessRequestTransactionsQueryKey as t, isGaslessRequestTerminal as n, supportsGaslessStatusStream as r, watchGaslessRequest as i } from "@symmio/trading-core";
|
|
3
|
+
import { useEffect as a, useState as o } from "react";
|
|
4
|
+
import { useQueryClient as s } from "@tanstack/react-query";
|
|
5
|
+
//#region src/gasless/use-gasless-request-stream.ts
|
|
6
|
+
function c(n) {
|
|
7
|
+
let { config: c, chainId: u, requestId: d, service: f = "operations", enabled: p, transport: m = "auto" } = n, h = s(), [g, _] = o({
|
|
8
|
+
status: "idle",
|
|
9
|
+
detail: null,
|
|
10
|
+
live: !1
|
|
11
|
+
}), v = p && d.length > 0 && m !== "poll" && r(c, {
|
|
12
|
+
chainId: u,
|
|
13
|
+
service: f
|
|
14
|
+
});
|
|
15
|
+
return a(() => {
|
|
16
|
+
if (!v) {
|
|
17
|
+
_({
|
|
18
|
+
status: "idle",
|
|
19
|
+
detail: null,
|
|
20
|
+
live: !1
|
|
21
|
+
});
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let n = c.getChainConfigKey(u), r = e({
|
|
25
|
+
chainId: u,
|
|
26
|
+
requestId: d,
|
|
27
|
+
service: f,
|
|
28
|
+
configKey: n
|
|
29
|
+
}), a = t({
|
|
30
|
+
chainId: u,
|
|
31
|
+
requestId: d,
|
|
32
|
+
service: f,
|
|
33
|
+
configKey: n
|
|
34
|
+
}), o;
|
|
35
|
+
try {
|
|
36
|
+
o = i(c, {
|
|
37
|
+
chainId: u,
|
|
38
|
+
requestId: d,
|
|
39
|
+
service: f,
|
|
40
|
+
onUpdate: ({ request: e, transactions: t }) => {
|
|
41
|
+
e && (h.cancelQueries({
|
|
42
|
+
queryKey: r,
|
|
43
|
+
exact: !0
|
|
44
|
+
}), h.setQueryData(r, (t) => t && l(t, e) ? t : e)), t.length > 0 && (h.cancelQueries({
|
|
45
|
+
queryKey: a,
|
|
46
|
+
exact: !0
|
|
47
|
+
}), h.setQueryData(a, t));
|
|
48
|
+
},
|
|
49
|
+
onStatusChange: (e, t) => _({
|
|
50
|
+
status: e,
|
|
51
|
+
detail: t,
|
|
52
|
+
live: e === "live"
|
|
53
|
+
}),
|
|
54
|
+
onError: () => {}
|
|
55
|
+
});
|
|
56
|
+
} catch {
|
|
57
|
+
_({
|
|
58
|
+
status: "idle",
|
|
59
|
+
detail: null,
|
|
60
|
+
live: !1
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
return () => {
|
|
65
|
+
o?.(), _({
|
|
66
|
+
status: "idle",
|
|
67
|
+
detail: null,
|
|
68
|
+
live: !1
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}, [
|
|
72
|
+
v,
|
|
73
|
+
c,
|
|
74
|
+
u,
|
|
75
|
+
d,
|
|
76
|
+
f,
|
|
77
|
+
h
|
|
78
|
+
]), g;
|
|
79
|
+
}
|
|
80
|
+
function l(e, t) {
|
|
81
|
+
return n(e.status) && !n(t.status) ? !0 : e.updatedAt && t.updatedAt ? e.updatedAt > t.updatedAt : !1;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { c as useGaslessRequestStream };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=use-gasless-request-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-request-stream.js","names":[],"sources":["../../src/gasless/use-gasless-request-stream.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getGaslessRequestQueryKey,\n getGaslessRequestTransactionsQueryKey,\n isGaslessRequestTerminal,\n supportsGaslessStatusStream,\n watchGaslessRequest,\n type Config,\n type GaslessRequest,\n type GaslessService,\n type GaslessStatusTransport,\n type GaslessStreamStatus,\n type GaslessStreamStatusDetail,\n} from \"@symmio/trading-core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useEffect, useState } from \"react\";\n\n/** What {@link useGaslessRequestStream} reports about the live transport. */\nexport interface GaslessStreamState {\n /** Stream health; anything but `\"live\"` means the caller should keep polling. */\n status: GaslessStreamStatus;\n /** Why, when the status alone does not say. */\n detail: GaslessStreamStatusDetail | null;\n /** Convenience for gating a poll: `status === \"live\"`. */\n live: boolean;\n}\n\n/**\n * Subscribe one workflow to the gateway's status stream and push its records\n * into the query cache.\n *\n * The hook owns no data of its own: every delivery is written to the same cache\n * entries the HTTP reads use, so components keep reading through\n * `useGaslessRequest` / `useGaslessRequestTransactions` and never learn which\n * transport produced a record. It returns only the stream's health, which the\n * caller uses to pause or resume its poll — the pattern `usePrices` uses for the\n * price feed.\n *\n * A deployment without a stream, or a disabled one, simply stays `\"idle\"`.\n *\n * @internal\n */\nexport function useGaslessRequestStream(parameters: {\n config: Config;\n chainId: number;\n requestId: string;\n service?: GaslessService;\n enabled: boolean;\n transport?: GaslessStatusTransport;\n}): GaslessStreamState {\n const { config, chainId, requestId, service = \"operations\", enabled, transport = \"auto\" } = parameters;\n const queryClient = useQueryClient();\n const [state, setState] = useState<GaslessStreamState>({ status: \"idle\", detail: null, live: false });\n\n const active =\n enabled &&\n requestId.length > 0 &&\n transport !== \"poll\" &&\n supportsGaslessStatusStream(config, { chainId, service });\n\n useEffect(() => {\n if (!active) {\n setState({ status: \"idle\", detail: null, live: false });\n return;\n }\n\n /** The same keys the query factories build, `service` and `configKey` included. */\n const configKey = config.getChainConfigKey(chainId);\n const requestKey = getGaslessRequestQueryKey({ chainId, requestId, service, configKey });\n const transactionsKey = getGaslessRequestTransactionsQueryKey({ chainId, requestId, service, configKey });\n let unwatch: (() => void) | undefined;\n\n try {\n unwatch = watchGaslessRequest(config, {\n chainId,\n requestId,\n service,\n onUpdate: ({ request, transactions }) => {\n if (request) {\n /**\n * Cancel the poll in flight before seeding: a response that started\n * earlier must not land on top of this fresher record.\n */\n void queryClient.cancelQueries({ queryKey: requestKey, exact: true });\n queryClient.setQueryData(requestKey, (previous: GaslessRequest | undefined) =>\n previous && isNewer(previous, request) ? previous : request,\n );\n }\n if (transactions.length > 0) {\n void queryClient.cancelQueries({ queryKey: transactionsKey, exact: true });\n queryClient.setQueryData(transactionsKey, transactions);\n }\n },\n onStatusChange: (status, detail) => setState({ status, detail, live: status === \"live\" }),\n onError: () => {\n /** Stream trouble is reported through the status; the poll covers the data. */\n },\n });\n } catch {\n /** An unconfigured stream is not an error here: the caller keeps polling. */\n setState({ status: \"idle\", detail: null, live: false });\n return;\n }\n\n return () => {\n unwatch?.();\n setState({ status: \"idle\", detail: null, live: false });\n };\n }, [active, config, chainId, requestId, service, queryClient]);\n\n return state;\n}\n\n/**\n * Whether the record already in the cache is newer than an incoming one.\n *\n * A terminal status is sticky — nothing may regress it — and otherwise the\n * later `updatedAt` wins. Without this, a poll that started before a stream\n * snapshot could overwrite it with staler state.\n */\nfunction isNewer(previous: GaslessRequest, next: GaslessRequest): boolean {\n if (isGaslessRequestTerminal(previous.status) && !isGaslessRequestTerminal(next.status)) return true;\n if (previous.updatedAt && next.updatedAt) return previous.updatedAt > next.updatedAt;\n return false;\n}\n"],"mappings":";;;;;AA2CA,SAAgB,EAAwB,GAOjB;CACrB,IAAM,EAAE,WAAQ,YAAS,cAAW,aAAU,cAAc,YAAS,eAAY,WAAW,GACtF,IAAc,EAAe,GAC7B,CAAC,GAAO,KAAY,EAA6B;EAAE,QAAQ;EAAQ,QAAQ;EAAM,MAAM;CAAM,CAAC,GAE9F,IACJ,KACA,EAAU,SAAS,KACnB,MAAc,UACd,EAA4B,GAAQ;EAAE;EAAS;CAAQ,CAAC;CAoD1D,OAlDA,QAAgB;EACd,IAAI,CAAC,GAAQ;GACX,EAAS;IAAE,QAAQ;IAAQ,QAAQ;IAAM,MAAM;GAAM,CAAC;GACtD;EACF;EAGA,IAAM,IAAY,EAAO,kBAAkB,CAAO,GAC5C,IAAa,EAA0B;GAAE;GAAS;GAAW;GAAS;EAAU,CAAC,GACjF,IAAkB,EAAsC;GAAE;GAAS;GAAW;GAAS;EAAU,CAAC,GACpG;EAEJ,IAAI;GACF,IAAU,EAAoB,GAAQ;IACpC;IACA;IACA;IACA,WAAW,EAAE,YAAS,sBAAmB;KAWvC,AAVI,MAKF,EAAiB,cAAc;MAAE,UAAU;MAAY,OAAO;KAAK,CAAC,GACpE,EAAY,aAAa,IAAa,MACpC,KAAY,EAAQ,GAAU,CAAO,IAAI,IAAW,CACtD,IAEE,EAAa,SAAS,MACxB,EAAiB,cAAc;MAAE,UAAU;MAAiB,OAAO;KAAK,CAAC,GACzE,EAAY,aAAa,GAAiB,CAAY;IAE1D;IACA,iBAAiB,GAAQ,MAAW,EAAS;KAAE;KAAQ;KAAQ,MAAM,MAAW;IAAO,CAAC;IACxF,eAAe,CAEf;GACF,CAAC;EACH,QAAQ;GAEN,EAAS;IAAE,QAAQ;IAAQ,QAAQ;IAAM,MAAM;GAAM,CAAC;GACtD;EACF;EAEA,aAAa;GAEX,AADA,IAAU,GACV,EAAS;IAAE,QAAQ;IAAQ,QAAQ;IAAM,MAAM;GAAM,CAAC;EACxD;CACF,GAAG;EAAC;EAAQ;EAAQ;EAAS;EAAW;EAAS;CAAW,CAAC,GAEtD;AACT;AASA,SAAS,EAAQ,GAA0B,GAA+B;CAGxE,OAFI,EAAyB,EAAS,MAAM,KAAK,CAAC,EAAyB,EAAK,MAAM,IAAU,KAC5F,EAAS,aAAa,EAAK,YAAkB,EAAS,YAAY,EAAK,YACpE;AACT"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ConfigParameter, GetGaslessRequestTransactionsOptions, GetGaslessRequestTransactionsReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useGaslessRequestTransactions}. */
|
|
5
|
+
export type UseGaslessRequestTransactionsParameters = GetGaslessRequestTransactionsOptions & ConfigParameter;
|
|
6
|
+
/** Return type of {@link useGaslessRequestTransactions}. */
|
|
7
|
+
export type UseGaslessRequestTransactionsReturnType = UseQueryResult<GetGaslessRequestTransactionsReturnType, SymmioRequestError>;
|
|
8
|
+
/**
|
|
9
|
+
* List the EVM broadcast attempts stored for one GaslessQ request.
|
|
10
|
+
*
|
|
11
|
+
* The companion to {@link useGaslessRequest}: the record says what the workflow
|
|
12
|
+
* is doing, this says which transactions it tried. That distinction is
|
|
13
|
+
* load-bearing — the relayer replaces a stuck transaction, so a request has one
|
|
14
|
+
* id and possibly several hashes, and an attempt that `reverted` or `failed`
|
|
15
|
+
* does not mean the request did. Read the outcome from the record; read the
|
|
16
|
+
* attempts to link to an explorer or to explain a failure.
|
|
17
|
+
*
|
|
18
|
+
* **Polls only when you pass the record's `status`.** The attempts list has no
|
|
19
|
+
* terminal of its own to stop on, so a self-driven poll would outlive the
|
|
20
|
+
* workflow. Hand it the status you are already reading from `useGaslessRequest`
|
|
21
|
+
* and it follows the same jittered cadence and stops when the record does;
|
|
22
|
+
* leave it out and it fetches once, with `query.refetchInterval` yours to set.
|
|
23
|
+
*
|
|
24
|
+
* Enabled only while `requestId` is non-empty, so the hook can mount before a
|
|
25
|
+
* submit has happened.
|
|
26
|
+
*
|
|
27
|
+
* @param parameters - Request id, the optional cadence `status`, optional service and chain id, TanStack overrides.
|
|
28
|
+
* @returns The stored attempts, oldest first as the service returns them.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* const request = useGaslessRequest({ requestId: requestId ?? "", query: { enabled: Boolean(requestId) } });
|
|
33
|
+
* const attempts = useGaslessRequestTransactions({
|
|
34
|
+
* requestId: requestId ?? "",
|
|
35
|
+
* status: request.data?.status,
|
|
36
|
+
* query: { enabled: Boolean(requestId) },
|
|
37
|
+
* });
|
|
38
|
+
* const latest = attempts.data?.at(-1);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function useGaslessRequestTransactions(parameters: UseGaslessRequestTransactionsParameters): UseGaslessRequestTransactionsReturnType;
|
|
42
|
+
//# sourceMappingURL=use-gasless-request-transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-request-transactions.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-request-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oCAAoC,EACzC,KAAK,uCAAuC,EAC7C,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,4DAA4D;AAC5D,MAAM,MAAM,uCAAuC,GAAG,oCAAoC,GAAG,eAAe,CAAC;AAE7G,4DAA4D;AAC5D,MAAM,MAAM,uCAAuC,GAAG,cAAc,CAClE,uCAAuC,EACvC,kBAAkB,CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,uCAAuC,GAClD,uCAAuC,CAoBzC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { getGaslessRequestTransactionsQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/gasless/use-gasless-request-transactions.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
|
+
enabled: (a.query?.enabled ?? !0) && a.requestId.length > 0,
|
|
16
|
+
queryFn: async (e) => {
|
|
17
|
+
try {
|
|
18
|
+
return await c.queryFn(e);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw n(e);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { a as useGaslessRequestTransactions };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=use-gasless-request-transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-request-transactions.js","names":[],"sources":["../../src/gasless/use-gasless-request-transactions.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getGaslessRequestTransactionsQueryOptions,\n type ConfigParameter,\n type GetGaslessRequestTransactionsOptions,\n type GetGaslessRequestTransactionsReturnType,\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 useGaslessRequestTransactions}. */\nexport type UseGaslessRequestTransactionsParameters = GetGaslessRequestTransactionsOptions & ConfigParameter;\n\n/** Return type of {@link useGaslessRequestTransactions}. */\nexport type UseGaslessRequestTransactionsReturnType = UseQueryResult<\n GetGaslessRequestTransactionsReturnType,\n SymmioRequestError\n>;\n\n/**\n * List the EVM broadcast attempts stored for one GaslessQ request.\n *\n * The companion to {@link useGaslessRequest}: the record says what the workflow\n * is doing, this says which transactions it tried. That distinction is\n * load-bearing — the relayer replaces a stuck transaction, so a request has one\n * id and possibly several hashes, and an attempt that `reverted` or `failed`\n * does not mean the request did. Read the outcome from the record; read the\n * attempts to link to an explorer or to explain a failure.\n *\n * **Polls only when you pass the record's `status`.** The attempts list has no\n * terminal of its own to stop on, so a self-driven poll would outlive the\n * workflow. Hand it the status you are already reading from `useGaslessRequest`\n * and it follows the same jittered cadence and stops when the record does;\n * leave it out and it fetches once, with `query.refetchInterval` yours to set.\n *\n * Enabled only while `requestId` is non-empty, so the hook can mount before a\n * submit has happened.\n *\n * @param parameters - Request id, the optional cadence `status`, optional service and chain id, TanStack overrides.\n * @returns The stored attempts, oldest first as the service returns them.\n *\n * @example\n * ```tsx\n * const request = useGaslessRequest({ requestId: requestId ?? \"\", query: { enabled: Boolean(requestId) } });\n * const attempts = useGaslessRequestTransactions({\n * requestId: requestId ?? \"\",\n * status: request.data?.status,\n * query: { enabled: Boolean(requestId) },\n * });\n * const latest = attempts.data?.at(-1);\n * ```\n */\nexport function useGaslessRequestTransactions(\n parameters: UseGaslessRequestTransactionsParameters,\n): UseGaslessRequestTransactionsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n const options = getGaslessRequestTransactionsQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n enabled: (parameters.query?.enabled ?? true) && parameters.requestId.length > 0,\n queryFn: async (context) => {\n try {\n return await options.queryFn(context);\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseGaslessRequestTransactionsReturnType;\n}\n"],"mappings":";;;;;;;AAwDA,SAAgB,EACd,GACyC;CACzC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAE3B,IAAU,EAA0C,GAAQ;EAChE,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,UAAU,EAAW,OAAO,WAAW,OAAS,EAAW,UAAU,SAAS;EAC9E,SAAS,OAAO,MAAY;GAC1B,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ,CAAO;GACtC,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ConfigParameter, GaslessStatusTransport, GetGaslessRequestOptions, GetGaslessRequestReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { GaslessStreamState } from './use-gasless-request-stream.js';
|
|
5
|
+
/** Parameters for {@link useGaslessRequest}. */
|
|
6
|
+
export type UseGaslessRequestParameters = GetGaslessRequestOptions & ConfigParameter & {
|
|
7
|
+
/**
|
|
8
|
+
* Invalidate account-balance reads once the request transitions to
|
|
9
|
+
* `succeeded` (a relayed operation moved collateral: the action itself
|
|
10
|
+
* and/or its operational fee). Default `true`. Flow-specific reads are the
|
|
11
|
+
* submitting hook's job — this covers the balance staleness every gasless
|
|
12
|
+
* success implies.
|
|
13
|
+
*/
|
|
14
|
+
invalidateOnSuccess?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* How to follow the workflow. `"auto"` (default) subscribes to the
|
|
17
|
+
* gateway's status stream where the deployment enables it and polls only
|
|
18
|
+
* while the stream is not delivering; `"poll"` forces HTTP polling.
|
|
19
|
+
*/
|
|
20
|
+
transport?: GaslessStatusTransport;
|
|
21
|
+
};
|
|
22
|
+
/** Return type of {@link useGaslessRequest}. */
|
|
23
|
+
export type UseGaslessRequestReturnType = UseQueryResult<GetGaslessRequestReturnType, SymmioRequestError> & {
|
|
24
|
+
/**
|
|
25
|
+
* The live transport's health. `stream.live` means the record is arriving
|
|
26
|
+
* over the WebSocket and this hook has stopped polling; anything else means
|
|
27
|
+
* it is polling, which is also the whole behavior on a deployment without a
|
|
28
|
+
* status stream.
|
|
29
|
+
*/
|
|
30
|
+
stream: GaslessStreamState;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Poll one GaslessQ relayer request.
|
|
34
|
+
*
|
|
35
|
+
* **Polls on its own.** The query factory ships the service-recommended cadence
|
|
36
|
+
* — a jittered 1–2 s while `queued`, 3–5 s after `submitted`, stopping at a
|
|
37
|
+
* terminal status — tolerates the brief post-`202` `404` while the record
|
|
38
|
+
* becomes readable, and absorbs transient transport failures (`429`, `503`, a
|
|
39
|
+
* dropped connection) with the gateway's `Retry-After` when it sent one. A
|
|
40
|
+
* failed read is not a failed request, so none of that surfaces as an error.
|
|
41
|
+
* Pass `query.refetchInterval` only to override the cadence.
|
|
42
|
+
*
|
|
43
|
+
* Enabled only while `requestId` is non-empty, so the hook can mount before a
|
|
44
|
+
* submit has happened. `submitted` is **not** success; only `succeeded` is.
|
|
45
|
+
*
|
|
46
|
+
* On a `succeeded` terminal it invalidates account balances (every relayed
|
|
47
|
+
* action moves collateral); pass `invalidateOnSuccess: false` to opt out. Reads
|
|
48
|
+
* specific to the action belong to the hook that submitted it.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* const request = useGaslessRequest({ requestId: requestId ?? "", query: { enabled: Boolean(requestId) } });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function useGaslessRequest(parameters: UseGaslessRequestParameters): UseGaslessRequestReturnType;
|
|
56
|
+
//# sourceMappingURL=use-gasless-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-request.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEhG,gDAAgD;AAChD,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAChE,eAAe,GAAG;IAChB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC,CAAC;AAEJ,gDAAgD;AAChD,MAAM,MAAM,2BAA2B,GAAG,cAAc,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,GAAG;IAC1G;;;;;OAKG;IACH,MAAM,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,2BAA2B,GAAG,2BAA2B,CA+DtG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { invalidateAccountBalances as r } from "../utils/invalidate-account-balances.js";
|
|
6
|
+
import { useGaslessRequestStream as i } from "./use-gasless-request-stream.js";
|
|
7
|
+
import { GaslessRequestStatus as a, getGaslessRequestQueryOptions as o } from "@symmio/trading-core";
|
|
8
|
+
import { useEffect as s, useRef as c } from "react";
|
|
9
|
+
import { useQuery as l, useQueryClient as u } from "@tanstack/react-query";
|
|
10
|
+
//#region src/gasless/use-gasless-request.ts
|
|
11
|
+
function d(d) {
|
|
12
|
+
let f = t(d), p = e(), m = u(), h = d.chainId ?? p, { invalidateOnSuccess: g = !0, transport: _ = "auto", ...v } = d, y = i({
|
|
13
|
+
config: f,
|
|
14
|
+
chainId: h,
|
|
15
|
+
requestId: d.requestId,
|
|
16
|
+
service: d.service,
|
|
17
|
+
enabled: (d.query?.enabled ?? !0) && d.requestId.length > 0,
|
|
18
|
+
transport: _
|
|
19
|
+
}), b = o(f, {
|
|
20
|
+
...v,
|
|
21
|
+
chainId: h
|
|
22
|
+
}), x = l({
|
|
23
|
+
...b,
|
|
24
|
+
enabled: (d.query?.enabled ?? !0) && d.requestId.length > 0,
|
|
25
|
+
refetchInterval: d.query?.refetchInterval ?? (y.live ? !1 : b.refetchInterval),
|
|
26
|
+
queryFn: async (e) => {
|
|
27
|
+
try {
|
|
28
|
+
return await b.queryFn(e);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
throw n(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}), S = c(null), C = x.data?.status;
|
|
34
|
+
return s(() => {
|
|
35
|
+
!g || C !== a.SUCCEEDED || S.current !== d.requestId && (S.current = d.requestId, r(m, { configKey: f.getChainConfigKey(h) }));
|
|
36
|
+
}, [
|
|
37
|
+
g,
|
|
38
|
+
C,
|
|
39
|
+
d.requestId,
|
|
40
|
+
m,
|
|
41
|
+
f,
|
|
42
|
+
h
|
|
43
|
+
]), {
|
|
44
|
+
...x,
|
|
45
|
+
stream: y
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { d as useGaslessRequest };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=use-gasless-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-request.js","names":[],"sources":["../../src/gasless/use-gasless-request.ts"],"sourcesContent":["\"use client\";\n\nimport {\n GaslessRequestStatus,\n getGaslessRequestQueryOptions,\n type ConfigParameter,\n type GaslessStatusTransport,\n type GetGaslessRequestOptions,\n type GetGaslessRequestReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useEffect, useRef } 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 { invalidateAccountBalances } from \"../utils/invalidate-account-balances\";\nimport { useGaslessRequestStream, type GaslessStreamState } from \"./use-gasless-request-stream\";\n\n/** Parameters for {@link useGaslessRequest}. */\nexport type UseGaslessRequestParameters = GetGaslessRequestOptions &\n ConfigParameter & {\n /**\n * Invalidate account-balance reads once the request transitions to\n * `succeeded` (a relayed operation moved collateral: the action itself\n * and/or its operational fee). Default `true`. Flow-specific reads are the\n * submitting hook's job — this covers the balance staleness every gasless\n * success implies.\n */\n invalidateOnSuccess?: boolean;\n /**\n * How to follow the workflow. `\"auto\"` (default) subscribes to the\n * gateway's status stream where the deployment enables it and polls only\n * while the stream is not delivering; `\"poll\"` forces HTTP polling.\n */\n transport?: GaslessStatusTransport;\n };\n\n/** Return type of {@link useGaslessRequest}. */\nexport type UseGaslessRequestReturnType = UseQueryResult<GetGaslessRequestReturnType, SymmioRequestError> & {\n /**\n * The live transport's health. `stream.live` means the record is arriving\n * over the WebSocket and this hook has stopped polling; anything else means\n * it is polling, which is also the whole behavior on a deployment without a\n * status stream.\n */\n stream: GaslessStreamState;\n};\n\n/**\n * Poll one GaslessQ relayer request.\n *\n * **Polls on its own.** The query factory ships the service-recommended cadence\n * — a jittered 1–2 s while `queued`, 3–5 s after `submitted`, stopping at a\n * terminal status — tolerates the brief post-`202` `404` while the record\n * becomes readable, and absorbs transient transport failures (`429`, `503`, a\n * dropped connection) with the gateway's `Retry-After` when it sent one. A\n * failed read is not a failed request, so none of that surfaces as an error.\n * Pass `query.refetchInterval` only to override the cadence.\n *\n * Enabled only while `requestId` is non-empty, so the hook can mount before a\n * submit has happened. `submitted` is **not** success; only `succeeded` is.\n *\n * On a `succeeded` terminal it invalidates account balances (every relayed\n * action moves collateral); pass `invalidateOnSuccess: false` to opt out. Reads\n * specific to the action belong to the hook that submitted it.\n *\n * @example\n * ```tsx\n * const request = useGaslessRequest({ requestId: requestId ?? \"\", query: { enabled: Boolean(requestId) } });\n * ```\n */\nexport function useGaslessRequest(parameters: UseGaslessRequestParameters): UseGaslessRequestReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const resolvedChainId = parameters.chainId ?? chainId;\n /**\n * Strip the hook-only control flag before forwarding: the key factory hashes\n * whatever it is handed, so leaving it in would make two callers watching the\n * same request with different flags key on separate cache entries and poll\n * the record twice.\n */\n const { invalidateOnSuccess = true, transport = \"auto\", ...queryParameters } = parameters;\n\n /**\n * The stream writes straight into this hook's cache entry, so the query below\n * only has to stop polling while it is live.\n */\n const stream = useGaslessRequestStream({\n config,\n chainId: resolvedChainId,\n requestId: parameters.requestId,\n service: parameters.service,\n enabled: (parameters.query?.enabled ?? true) && parameters.requestId.length > 0,\n transport,\n });\n\n const options = getGaslessRequestQueryOptions(config, {\n ...queryParameters,\n chainId: resolvedChainId,\n });\n\n const result = useQuery({\n ...options,\n enabled: (parameters.query?.enabled ?? true) && parameters.requestId.length > 0,\n /**\n * While the stream delivers, polling stands down; an explicit\n * `query.refetchInterval` still wins, and a degraded stream resumes it.\n */\n refetchInterval: parameters.query?.refetchInterval ?? (stream.live ? false : options.refetchInterval),\n queryFn: async (context) => {\n try {\n /** Forwards TanStack's abort signal, so an unmounted poll stops in flight. */\n return await options.queryFn(context);\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseGaslessRequestReturnType;\n\n /**\n * Invalidate balances exactly once per request id on the transition into\n * `succeeded` — after on-chain reality, per the invalidation timing rule.\n */\n const invalidatedForRef = useRef<string | null>(null);\n const status = result.data?.status;\n useEffect(() => {\n if (!invalidateOnSuccess || status !== GaslessRequestStatus.SUCCEEDED) return;\n if (invalidatedForRef.current === parameters.requestId) return;\n invalidatedForRef.current = parameters.requestId;\n invalidateAccountBalances(queryClient, { configKey: config.getChainConfigKey(resolvedChainId) });\n }, [invalidateOnSuccess, status, parameters.requestId, queryClient, config, resolvedChainId]);\n\n return { ...result, stream } as UseGaslessRequestReturnType;\n}\n"],"mappings":";;;;;;;;;;AAwEA,SAAgB,EAAkB,GAAsE;CACtG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAkB,EAAW,WAAW,GAOxC,EAAE,yBAAsB,IAAM,eAAY,QAAQ,GAAG,MAAoB,GAMzE,IAAS,EAAwB;EACrC;EACA,SAAS;EACT,WAAW,EAAW;EACtB,SAAS,EAAW;EACpB,UAAU,EAAW,OAAO,WAAW,OAAS,EAAW,UAAU,SAAS;EAC9E;CACF,CAAC,GAEK,IAAU,EAA8B,GAAQ;EACpD,GAAG;EACH,SAAS;CACX,CAAC,GAEK,IAAS,EAAS;EACtB,GAAG;EACH,UAAU,EAAW,OAAO,WAAW,OAAS,EAAW,UAAU,SAAS;EAK9E,iBAAiB,EAAW,OAAO,oBAAoB,EAAO,OAAO,KAAQ,EAAQ;EACrF,SAAS,OAAO,MAAY;GAC1B,IAAI;IAEF,OAAO,MAAM,EAAQ,QAAQ,CAAO;GACtC,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC,GAMK,IAAoB,EAAsB,IAAI,GAC9C,IAAS,EAAO,MAAM;CAQ5B,OAPA,QAAgB;EACV,CAAC,KAAuB,MAAW,EAAqB,aACxD,EAAkB,YAAY,EAAW,cAC7C,EAAkB,UAAU,EAAW,WACvC,EAA0B,GAAa,EAAE,WAAW,EAAO,kBAAkB,CAAe,EAAE,CAAC;CACjG,GAAG;EAAC;EAAqB;EAAQ,EAAW;EAAW;EAAa;EAAQ;CAAe,CAAC,GAErF;EAAE,GAAG;EAAQ;CAAO;AAC7B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ConfigParameter, GetGaslessWalletAddressOptions, GetGaslessWalletAddressReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useGaslessWalletAddress}. */
|
|
5
|
+
export type UseGaslessWalletAddressParameters = GetGaslessWalletAddressOptions & ConfigParameter;
|
|
6
|
+
/** Return type of {@link useGaslessWalletAddress}. */
|
|
7
|
+
export type UseGaslessWalletAddressReturnType = UseQueryResult<GetGaslessWalletAddressReturnType, SymmioRequestError>;
|
|
8
|
+
/**
|
|
9
|
+
* Read the deterministic address of one of an owner's GaslessWallets (a pure
|
|
10
|
+
* CREATE2 view on the GaslessLayer) - the deposit address for gasless
|
|
11
|
+
* onboarding and the target of gasless-wallet operations. A wallet is
|
|
12
|
+
* identified by `(owner, walletId)`; `walletId` defaults to `0n`, the original
|
|
13
|
+
* wallet, and each positive id has its own address.
|
|
14
|
+
*
|
|
15
|
+
* @param parameters - Owner, optional `walletId` (default `0n`), optional chain id, config and query overrides.
|
|
16
|
+
* @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const query = useGaslessWalletAddress({ owner, walletId: 1n });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function useGaslessWalletAddress(parameters: UseGaslessWalletAddressParameters): UseGaslessWalletAddressReturnType;
|
|
24
|
+
//# sourceMappingURL=use-gasless-wallet-address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-wallet-address.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-wallet-address.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,8BAA8B,EACnC,KAAK,iCAAiC,EACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,sDAAsD;AACtD,MAAM,MAAM,iCAAiC,GAAG,8BAA8B,GAAG,eAAe,CAAC;AAEjG,sDAAsD;AACtD,MAAM,MAAM,iCAAiC,GAAG,cAAc,CAAC,iCAAiC,EAAE,kBAAkB,CAAC,CAAC;AAEtH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iCAAiC,GAC5C,iCAAiC,CAmBnC"}
|
|
@@ -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 { getGaslessWalletAddressQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/gasless/use-gasless-wallet-address.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 useGaslessWalletAddress };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-gasless-wallet-address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-wallet-address.js","names":[],"sources":["../../src/gasless/use-gasless-wallet-address.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getGaslessWalletAddressQueryOptions,\n type ConfigParameter,\n type GetGaslessWalletAddressOptions,\n type GetGaslessWalletAddressReturnType,\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 useGaslessWalletAddress}. */\nexport type UseGaslessWalletAddressParameters = GetGaslessWalletAddressOptions & ConfigParameter;\n\n/** Return type of {@link useGaslessWalletAddress}. */\nexport type UseGaslessWalletAddressReturnType = UseQueryResult<GetGaslessWalletAddressReturnType, SymmioRequestError>;\n\n/**\n * Read the deterministic address of one of an owner's GaslessWallets (a pure\n * CREATE2 view on the GaslessLayer) - the deposit address for gasless\n * onboarding and the target of gasless-wallet operations. A wallet is\n * identified by `(owner, walletId)`; `walletId` defaults to `0n`, the original\n * wallet, and each positive id has its own address.\n *\n * @param parameters - Owner, optional `walletId` (default `0n`), optional chain id, config and query overrides.\n * @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const query = useGaslessWalletAddress({ owner, walletId: 1n });\n * ```\n */\nexport function useGaslessWalletAddress(\n parameters: UseGaslessWalletAddressParameters,\n): UseGaslessWalletAddressReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n const options = getGaslessWalletAddressQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseGaslessWalletAddressReturnType;\n}\n"],"mappings":";;;;;;;AAmCA,SAAgB,EACd,GACmC;CACnC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAE3B,IAAU,EAAoC,GAAQ;EAC1D,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ConfigParameter, GetGaslessWalletCreationFeeOptions, GetGaslessWalletCreationFeeReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useGaslessWalletCreationFee}. */
|
|
5
|
+
export type UseGaslessWalletCreationFeeParameters = GetGaslessWalletCreationFeeOptions & ConfigParameter;
|
|
6
|
+
/** Return type of {@link useGaslessWalletCreationFee}. */
|
|
7
|
+
export type UseGaslessWalletCreationFeeReturnType = UseQueryResult<GetGaslessWalletCreationFeeReturnType, SymmioRequestError>;
|
|
8
|
+
/**
|
|
9
|
+
* Read the one-time fee for deploying one of an owner's GaslessWallets
|
|
10
|
+
* (`getWalletCreationFee(owner, walletId)` on the GaslessLayer), in collateral
|
|
11
|
+
* token units. It is the configured fee while the wallet has no code, for any
|
|
12
|
+
* wallet id including `0`, and `0n` once the wallet is deployed. A deposit
|
|
13
|
+
* settlement deducts it from the swept balance; a relayed wallet operation
|
|
14
|
+
* charges it to the payer's SYMMIO balance.
|
|
15
|
+
*
|
|
16
|
+
* The relay hooks invalidate it after a wallet execute or a deposit settlement,
|
|
17
|
+
* since either may deploy the wallet.
|
|
18
|
+
*
|
|
19
|
+
* @param parameters - Owner, optional `walletId` (default `0n`), optional chain id, config and query overrides.
|
|
20
|
+
* @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const creationFee = useGaslessWalletCreationFee({ owner, walletId: 1n });
|
|
25
|
+
* const chargesFirstUse = (creationFee.data ?? 0n) > 0n;
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useGaslessWalletCreationFee(parameters: UseGaslessWalletCreationFeeParameters): UseGaslessWalletCreationFeeReturnType;
|
|
29
|
+
//# sourceMappingURL=use-gasless-wallet-creation-fee.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-wallet-creation-fee.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-wallet-creation-fee.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kCAAkC,EACvC,KAAK,qCAAqC,EAC3C,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,0DAA0D;AAC1D,MAAM,MAAM,qCAAqC,GAAG,kCAAkC,GAAG,eAAe,CAAC;AAEzG,0DAA0D;AAC1D,MAAM,MAAM,qCAAqC,GAAG,cAAc,CAChE,qCAAqC,EACrC,kBAAkB,CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,qCAAqC,GAChD,qCAAqC,CAmBvC"}
|