@funkit/connect 10.6.0 → 11.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/CHANGELOG.md +46 -0
- package/dist/clients/{chunk-F6P4CN27.js → chunk-2QYQNTOI.js} +161 -18
- package/dist/clients/chunk-5MY7WMEJ.js +20 -0
- package/dist/clients/chunk-63XTVHO3.js +19 -0
- package/dist/clients/chunk-6T6URLBM.js +33 -0
- package/dist/clients/chunk-A44M6EAG.js +160 -0
- package/dist/clients/chunk-A6OXZWCN.js +40 -0
- package/dist/clients/chunk-BPDLF2R6.js +31 -0
- package/dist/clients/chunk-C53FRCUM.js +190 -0
- package/dist/clients/{chunk-6PIIYPQK.js → chunk-EJKHMZW3.js} +4 -327
- package/dist/clients/chunk-FAYBQQNB.js +15 -0
- package/dist/clients/{chunk-3LJQTM37.js → chunk-FNB7OPJI.js} +12 -198
- package/dist/clients/{chunk-2NBYHUIW.js → chunk-HZP4DXIZ.js} +1 -0
- package/dist/clients/chunk-NAVU6W7V.js +89 -0
- package/dist/clients/{chunk-BNMZM23Q.js → chunk-OJZNF6EM.js} +2 -2
- package/dist/clients/{chunk-FJ6GCMJ4.js → chunk-OODIKHYE.js} +3 -1
- package/dist/clients/chunk-PENJ5JGH.js +331 -0
- package/dist/clients/{chunk-TG2AACP2.js → chunk-QIMCURVA.js} +10 -10
- package/dist/clients/{chunk-YFHTV7DT.js → chunk-SH3MHRHX.js} +1 -1
- package/dist/clients/chunk-SO756ELD.js +35 -0
- package/dist/clients/chunk-SYFHMTUO.js +106 -0
- package/dist/clients/chunk-WVM4ZJD2.js +61 -0
- package/dist/clients/{chunk-L2KSNS7H.js → chunk-WZRW6WUM.js} +1 -1
- package/dist/clients/chunk-YMGRBJAS.js +302 -0
- package/dist/clients/chunk-YZSO4EMO.js +44 -0
- package/dist/clients/{chunk-2YWQL3AO.js → chunk-Z7HTQFEO.js} +26 -3
- package/dist/clients/fanatics.js +6 -6
- package/dist/clients/internal/nado/encoding.d.ts +5 -2
- package/dist/clients/internal/nado/encoding.js +4 -25
- package/dist/clients/internal/nado/errors.d.ts +14 -1
- package/dist/clients/internal/nado/errors.js +7 -3
- package/dist/clients/internal/nado/fetch.js +2 -2
- package/dist/clients/internal/nado/gateway.d.ts +19 -41
- package/dist/clients/internal/nado/gateway.js +3 -9
- package/dist/clients/internal/nado/hooks.d.ts +8 -160
- package/dist/clients/internal/nado/hooks.js +13 -124
- package/dist/clients/internal/nado/indexer.js +3 -3
- package/dist/clients/internal/nado/typedData.js +4 -37
- package/dist/clients/internal/nado/withdrawalCallback.d.ts +20 -0
- package/dist/clients/internal/nado/withdrawalCallback.js +20 -0
- package/dist/clients/internal/nado/withdrawalConfig.d.ts +8 -3
- package/dist/clients/internal/nado/withdrawalConfig.js +8 -14
- package/dist/clients/internal/nado/withdrawalErrors.d.ts +14 -0
- package/dist/clients/internal/nado/withdrawalErrors.js +11 -0
- package/dist/clients/internal/nado/withdrawalForm.css +17529 -0
- package/dist/clients/internal/nado/withdrawalForm.d.ts +40 -0
- package/dist/clients/internal/nado/withdrawalForm.js +262 -0
- package/dist/clients/internal/nado/withdrawalStatus.d.ts +41 -0
- package/dist/clients/internal/nado/withdrawalStatus.js +231 -0
- package/dist/clients/internal/nado/withdrawalTypes.d.ts +28 -9
- package/dist/clients/lighter.css +18 -18
- package/dist/clients/lighter.d.ts +29 -1
- package/dist/clients/lighter.js +109 -100
- package/dist/clients/mallard.js +27 -5
- package/dist/clients/nado.d.ts +67 -0
- package/dist/clients/nado.js +73 -0
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +60 -60
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +11 -5
- package/dist/clients/polymarket/createPolymarketDepositConfig.js +3 -2
- package/dist/clients/polymarket/index.css +60 -60
- package/dist/clients/polymarket/index.js +11 -5
- package/dist/clients/polymarket/polymarket.js +2 -1
- package/dist/consts/customers.d.ts +1 -1
- package/dist/domains/swapped.d.ts +1 -10
- package/dist/hooks/track/analytics/events.d.ts +57 -0
- package/dist/hooks/track/analytics/mappers.d.ts +6 -0
- package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +20 -0
- package/dist/hooks/track/useTrack.d.ts +2 -1
- package/dist/hooks/useTokenAndChainDropdown.d.ts +8 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3647 -2728
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +20 -31
- package/dist/modals/WithdrawalModal/NadoWithdrawalSuccess.d.ts +20 -0
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +5 -9
- package/dist/providers/FunkitCheckoutContext/types.d.ts +61 -5
- package/dist/providers/GeneralWalletProvider.d.ts +1 -0
- package/dist/utils/customer.d.ts +349 -0
- package/dist/utils/withdrawal.d.ts +13 -6
- package/dist/wagmi/actions.d.ts +1 -1
- package/dist/wallets/Wallet.d.ts +21 -1
- package/dist/wallets/walletConnectors/index.js +43 -43
- package/package.json +4 -4
- package/dist/clients/chunk-A4WQS6QG.js +0 -207
- package/dist/clients/chunk-OZ3KD24N.js +0 -107
- package/dist/clients/internal/nado/products.d.ts +0 -36
- package/dist/clients/internal/nado/products.js +0 -19
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* React-query hooks over the Nado gateway/indexer. Poll cadences are budgeted
|
|
3
3
|
* against Nado's IP rate limit (2400 query-weight/min): an open modal spends
|
|
4
|
-
* ~
|
|
4
|
+
* ~10 weight/min on the selected product's max; the indexer poll runs only
|
|
5
|
+
* while a settlement is pending.
|
|
5
6
|
*
|
|
6
7
|
* @see {@link https://docs.nado.xyz/developer-resources/api/rate-limits | Nado rate limits}
|
|
7
8
|
*/
|
|
@@ -13,170 +14,17 @@ import type { Hex } from 'viem';
|
|
|
13
14
|
* next scheduled poll is the retry).
|
|
14
15
|
*/
|
|
15
16
|
export declare function shouldRetryNadoQuery(failureCount: number, error: unknown): boolean;
|
|
16
|
-
/** Live product list; falls back to the static list while loading or on gateway failure. */
|
|
17
|
-
export declare function useNadoProducts(): {
|
|
18
|
-
data: import("./products").NadoProduct[];
|
|
19
|
-
error: unknown;
|
|
20
|
-
isError: true;
|
|
21
|
-
isPending: false;
|
|
22
|
-
isLoading: false;
|
|
23
|
-
isLoadingError: false;
|
|
24
|
-
isRefetchError: true;
|
|
25
|
-
isSuccess: false;
|
|
26
|
-
isPlaceholderData: false;
|
|
27
|
-
status: "error";
|
|
28
|
-
dataUpdatedAt: number;
|
|
29
|
-
errorUpdatedAt: number;
|
|
30
|
-
failureCount: number;
|
|
31
|
-
failureReason: unknown;
|
|
32
|
-
errorUpdateCount: number;
|
|
33
|
-
isFetched: boolean;
|
|
34
|
-
isFetchedAfterMount: boolean;
|
|
35
|
-
isFetching: boolean;
|
|
36
|
-
isInitialLoading: boolean;
|
|
37
|
-
isPaused: boolean;
|
|
38
|
-
isRefetching: boolean;
|
|
39
|
-
isStale: boolean;
|
|
40
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
|
|
41
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
42
|
-
promise: Promise<import("./products").NadoProduct[]>;
|
|
43
|
-
} | {
|
|
44
|
-
data: import("./products").NadoProduct[];
|
|
45
|
-
error: null;
|
|
46
|
-
isError: false;
|
|
47
|
-
isPending: false;
|
|
48
|
-
isLoading: false;
|
|
49
|
-
isLoadingError: false;
|
|
50
|
-
isRefetchError: false;
|
|
51
|
-
isSuccess: true;
|
|
52
|
-
isPlaceholderData: false;
|
|
53
|
-
status: "success";
|
|
54
|
-
dataUpdatedAt: number;
|
|
55
|
-
errorUpdatedAt: number;
|
|
56
|
-
failureCount: number;
|
|
57
|
-
failureReason: unknown;
|
|
58
|
-
errorUpdateCount: number;
|
|
59
|
-
isFetched: boolean;
|
|
60
|
-
isFetchedAfterMount: boolean;
|
|
61
|
-
isFetching: boolean;
|
|
62
|
-
isInitialLoading: boolean;
|
|
63
|
-
isPaused: boolean;
|
|
64
|
-
isRefetching: boolean;
|
|
65
|
-
isStale: boolean;
|
|
66
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
|
|
67
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
68
|
-
promise: Promise<import("./products").NadoProduct[]>;
|
|
69
|
-
} | {
|
|
70
|
-
data: import("./products").NadoProduct[];
|
|
71
|
-
error: unknown;
|
|
72
|
-
isError: true;
|
|
73
|
-
isPending: false;
|
|
74
|
-
isLoading: false;
|
|
75
|
-
isLoadingError: true;
|
|
76
|
-
isRefetchError: false;
|
|
77
|
-
isSuccess: false;
|
|
78
|
-
isPlaceholderData: false;
|
|
79
|
-
status: "error";
|
|
80
|
-
dataUpdatedAt: number;
|
|
81
|
-
errorUpdatedAt: number;
|
|
82
|
-
failureCount: number;
|
|
83
|
-
failureReason: unknown;
|
|
84
|
-
errorUpdateCount: number;
|
|
85
|
-
isFetched: boolean;
|
|
86
|
-
isFetchedAfterMount: boolean;
|
|
87
|
-
isFetching: boolean;
|
|
88
|
-
isInitialLoading: boolean;
|
|
89
|
-
isPaused: boolean;
|
|
90
|
-
isRefetching: boolean;
|
|
91
|
-
isStale: boolean;
|
|
92
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
|
|
93
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
94
|
-
promise: Promise<import("./products").NadoProduct[]>;
|
|
95
|
-
} | {
|
|
96
|
-
data: import("./products").NadoProduct[];
|
|
97
|
-
error: null;
|
|
98
|
-
isError: false;
|
|
99
|
-
isPending: true;
|
|
100
|
-
isLoading: true;
|
|
101
|
-
isLoadingError: false;
|
|
102
|
-
isRefetchError: false;
|
|
103
|
-
isSuccess: false;
|
|
104
|
-
isPlaceholderData: false;
|
|
105
|
-
status: "pending";
|
|
106
|
-
dataUpdatedAt: number;
|
|
107
|
-
errorUpdatedAt: number;
|
|
108
|
-
failureCount: number;
|
|
109
|
-
failureReason: unknown;
|
|
110
|
-
errorUpdateCount: number;
|
|
111
|
-
isFetched: boolean;
|
|
112
|
-
isFetchedAfterMount: boolean;
|
|
113
|
-
isFetching: boolean;
|
|
114
|
-
isInitialLoading: boolean;
|
|
115
|
-
isPaused: boolean;
|
|
116
|
-
isRefetching: boolean;
|
|
117
|
-
isStale: boolean;
|
|
118
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
|
|
119
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
120
|
-
promise: Promise<import("./products").NadoProduct[]>;
|
|
121
|
-
} | {
|
|
122
|
-
data: import("./products").NadoProduct[];
|
|
123
|
-
error: null;
|
|
124
|
-
isError: false;
|
|
125
|
-
isPending: true;
|
|
126
|
-
isLoadingError: false;
|
|
127
|
-
isRefetchError: false;
|
|
128
|
-
isSuccess: false;
|
|
129
|
-
isPlaceholderData: false;
|
|
130
|
-
status: "pending";
|
|
131
|
-
dataUpdatedAt: number;
|
|
132
|
-
errorUpdatedAt: number;
|
|
133
|
-
failureCount: number;
|
|
134
|
-
failureReason: unknown;
|
|
135
|
-
errorUpdateCount: number;
|
|
136
|
-
isFetched: boolean;
|
|
137
|
-
isFetchedAfterMount: boolean;
|
|
138
|
-
isFetching: boolean;
|
|
139
|
-
isLoading: boolean;
|
|
140
|
-
isInitialLoading: boolean;
|
|
141
|
-
isPaused: boolean;
|
|
142
|
-
isRefetching: boolean;
|
|
143
|
-
isStale: boolean;
|
|
144
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
|
|
145
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
146
|
-
promise: Promise<import("./products").NadoProduct[]>;
|
|
147
|
-
} | {
|
|
148
|
-
data: import("./products").NadoProduct[];
|
|
149
|
-
isError: false;
|
|
150
|
-
error: null;
|
|
151
|
-
isPending: false;
|
|
152
|
-
isLoading: false;
|
|
153
|
-
isLoadingError: false;
|
|
154
|
-
isRefetchError: false;
|
|
155
|
-
isSuccess: true;
|
|
156
|
-
isPlaceholderData: true;
|
|
157
|
-
status: "success";
|
|
158
|
-
dataUpdatedAt: number;
|
|
159
|
-
errorUpdatedAt: number;
|
|
160
|
-
failureCount: number;
|
|
161
|
-
failureReason: unknown;
|
|
162
|
-
errorUpdateCount: number;
|
|
163
|
-
isFetched: boolean;
|
|
164
|
-
isFetchedAfterMount: boolean;
|
|
165
|
-
isFetching: boolean;
|
|
166
|
-
isInitialLoading: boolean;
|
|
167
|
-
isPaused: boolean;
|
|
168
|
-
isRefetching: boolean;
|
|
169
|
-
isStale: boolean;
|
|
170
|
-
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
|
|
171
|
-
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
172
|
-
promise: Promise<import("./products").NadoProduct[]>;
|
|
173
|
-
};
|
|
174
|
-
export declare function useNadoSubaccountBalances(subaccount: Hex | undefined): import("@tanstack/react-query").UseQueryResult<import("./gateway").NadoSubaccountInfo, unknown>;
|
|
175
17
|
export declare function useNadoMaxWithdrawable(params: {
|
|
176
18
|
productId: number | undefined;
|
|
177
19
|
sender: Hex | undefined;
|
|
178
20
|
spotLeverage: boolean;
|
|
179
21
|
}): import("@tanstack/react-query").UseQueryResult<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Drops every cached max — prefix match, since each product and borrow state
|
|
24
|
+
* holds its own entry — so a follow-up withdrawal sees the debited balance
|
|
25
|
+
* rather than waiting out the refetch interval.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useInvalidateNadoMaxWithdrawable(): () => void;
|
|
180
28
|
export declare function useNadoFeeRates(sender: Hex | undefined): import("@tanstack/react-query").UseQueryResult<import("./gateway").NadoFeeRates, unknown>;
|
|
181
29
|
export interface NadoSettlementStatus {
|
|
182
30
|
/** True once the sequencer has recorded the withdrawal we signed. */
|
|
@@ -1,132 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
findSettlementForNonce,
|
|
13
|
-
getNadoWithdrawalEvents
|
|
14
|
-
} from "../../chunk-BNMZM23Q.js";
|
|
3
|
+
shouldRetryNadoQuery,
|
|
4
|
+
useInvalidateNadoMaxWithdrawable,
|
|
5
|
+
useNadoFeeRates,
|
|
6
|
+
useNadoMaxWithdrawable,
|
|
7
|
+
useNadoSettlementStatus
|
|
8
|
+
} from "../../chunk-SYFHMTUO.js";
|
|
9
|
+
import "../../chunk-OJZNF6EM.js";
|
|
10
|
+
import "../../chunk-A44M6EAG.js";
|
|
15
11
|
import "../../chunk-II5CZTBC.js";
|
|
16
|
-
import "../../chunk-
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
} from "../../chunk-2YWQL3AO.js";
|
|
20
|
-
import "../../chunk-FJ6GCMJ4.js";
|
|
21
|
-
import {
|
|
22
|
-
useConfig
|
|
23
|
-
} from "../../chunk-UPZNKPYU.js";
|
|
24
|
-
import {
|
|
25
|
-
logger
|
|
26
|
-
} from "../../chunk-AHYOV7AV.js";
|
|
27
|
-
|
|
28
|
-
// src/clients/internal/nado/hooks.ts
|
|
29
|
-
import { skipToken, useQuery } from "@tanstack/react-query";
|
|
30
|
-
import { useEffect, useReducer } from "react";
|
|
31
|
-
var BALANCES_REFETCH_MS = 3e4;
|
|
32
|
-
var MAX_WITHDRAWABLE_REFETCH_MS = 3e4;
|
|
33
|
-
var FEE_RATES_STALE_MS = 5 * 6e4;
|
|
34
|
-
var SETTLEMENT_POLL_MS = 1e4;
|
|
35
|
-
var SETTLEMENT_TIMEOUT_MS = 10 * 6e4;
|
|
36
|
-
function shouldRetryNadoQuery(failureCount, error) {
|
|
37
|
-
if (error instanceof NadoGatewayError && (error.kind === "api" || error.kind === "timeout" || error.httpStatus === 429)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return failureCount < 2;
|
|
41
|
-
}
|
|
42
|
-
function useNadoProducts() {
|
|
43
|
-
const wagmiConfig = useConfig();
|
|
44
|
-
const query = useQuery({
|
|
45
|
-
queryKey: ["nadoProducts"],
|
|
46
|
-
queryFn: ({ signal }) => fetchNadoProducts(wagmiConfig, signal),
|
|
47
|
-
staleTime: Number.POSITIVE_INFINITY,
|
|
48
|
-
gcTime: Number.POSITIVE_INFINITY,
|
|
49
|
-
retry: shouldRetryNadoQuery
|
|
50
|
-
});
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (query.isError) {
|
|
53
|
-
logger.warn("nado:products_fallback", {
|
|
54
|
-
message: "gateway_error",
|
|
55
|
-
errorMessage: query.error instanceof Error ? query.error.message : String(query.error)
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}, [query.isError, query.error]);
|
|
59
|
-
return { ...query, data: query.data ?? NADO_SUPPORTED_PRODUCTS };
|
|
60
|
-
}
|
|
61
|
-
function useNadoSubaccountBalances(subaccount) {
|
|
62
|
-
return useQuery({
|
|
63
|
-
queryKey: ["nadoSubaccountInfo", subaccount],
|
|
64
|
-
queryFn: subaccount ? ({ signal }) => getNadoSubaccountInfo(subaccount, signal) : skipToken,
|
|
65
|
-
refetchInterval: BALANCES_REFETCH_MS,
|
|
66
|
-
retry: shouldRetryNadoQuery
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function useNadoMaxWithdrawable(params) {
|
|
70
|
-
const { productId, sender, spotLeverage } = params;
|
|
71
|
-
return useQuery({
|
|
72
|
-
queryKey: ["nadoMaxWithdrawable", sender, productId, spotLeverage],
|
|
73
|
-
queryFn: productId !== void 0 && sender ? ({ signal }) => getNadoMaxWithdrawable({ productId, sender, spotLeverage }, signal) : skipToken,
|
|
74
|
-
refetchInterval: MAX_WITHDRAWABLE_REFETCH_MS,
|
|
75
|
-
retry: shouldRetryNadoQuery
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
function useNadoFeeRates(sender) {
|
|
79
|
-
return useQuery({
|
|
80
|
-
queryKey: ["nadoFeeRates", sender],
|
|
81
|
-
queryFn: sender ? ({ signal }) => getNadoFeeRates(sender, signal) : skipToken,
|
|
82
|
-
staleTime: FEE_RATES_STALE_MS,
|
|
83
|
-
retry: shouldRetryNadoQuery
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function useNadoSettlementStatus(params) {
|
|
87
|
-
const { subaccount, nonce, submittedAtMs, enabled } = params;
|
|
88
|
-
const isPastTimeout = () => submittedAtMs !== void 0 && Date.now() - submittedAtMs >= SETTLEMENT_TIMEOUT_MS;
|
|
89
|
-
const query = useQuery({
|
|
90
|
-
queryKey: ["nadoSettlementStatus", subaccount, nonce?.toString()],
|
|
91
|
-
queryFn: subaccount && nonce !== void 0 ? async ({ signal }) => {
|
|
92
|
-
const { txs } = await getNadoWithdrawalEvents(
|
|
93
|
-
{ subaccount, limit: 3 },
|
|
94
|
-
signal
|
|
95
|
-
);
|
|
96
|
-
const settlement = findSettlementForNonce(txs, nonce);
|
|
97
|
-
return {
|
|
98
|
-
isSequenced: settlement !== void 0,
|
|
99
|
-
sequencedAt: settlement ? Number(settlement.timestamp) : void 0
|
|
100
|
-
};
|
|
101
|
-
} : skipToken,
|
|
102
|
-
enabled: enabled && submittedAtMs !== void 0,
|
|
103
|
-
// Only the 10s interval drives fetches — a sequenced result is final, so
|
|
104
|
-
// focus/remount refetches would re-ask an answered question
|
|
105
|
-
staleTime: Number.POSITIVE_INFINITY,
|
|
106
|
-
// No retry — the next 10s poll is the retry
|
|
107
|
-
retry: false,
|
|
108
|
-
refetchInterval: (query2) => query2.state.data?.isSequenced || isPastTimeout() ? false : SETTLEMENT_POLL_MS
|
|
109
|
-
});
|
|
110
|
-
const [, rerenderAtTimeout] = useReducer((n) => n + 1, 0);
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (submittedAtMs === void 0 || !enabled) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const remainingMs = submittedAtMs + SETTLEMENT_TIMEOUT_MS - Date.now();
|
|
116
|
-
if (remainingMs <= 0) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const id = setTimeout(rerenderAtTimeout, remainingMs);
|
|
120
|
-
return () => clearTimeout(id);
|
|
121
|
-
}, [submittedAtMs, enabled]);
|
|
122
|
-
const isTimedOut = isPastTimeout() && query.data?.isSequenced !== true;
|
|
123
|
-
return { ...query, isTimedOut };
|
|
124
|
-
}
|
|
12
|
+
import "../../chunk-WZRW6WUM.js";
|
|
13
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
14
|
+
import "../../chunk-AHYOV7AV.js";
|
|
125
15
|
export {
|
|
126
16
|
shouldRetryNadoQuery,
|
|
17
|
+
useInvalidateNadoMaxWithdrawable,
|
|
127
18
|
useNadoFeeRates,
|
|
128
19
|
useNadoMaxWithdrawable,
|
|
129
|
-
|
|
130
|
-
useNadoSettlementStatus,
|
|
131
|
-
useNadoSubaccountBalances
|
|
20
|
+
useNadoSettlementStatus
|
|
132
21
|
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
findSettlementForNonce,
|
|
4
4
|
getNadoWithdrawalEvents
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-OJZNF6EM.js";
|
|
6
6
|
import "../../chunk-II5CZTBC.js";
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-WZRW6WUM.js";
|
|
8
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
9
9
|
import "../../chunk-AHYOV7AV.js";
|
|
10
10
|
export {
|
|
11
11
|
findSettlementForNonce,
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
|
|
7
|
-
// src/clients/internal/nado/typedData.ts
|
|
8
|
-
var WITHDRAW_COLLATERAL_V2_TYPES = {
|
|
9
|
-
WithdrawCollateralV2: [
|
|
10
|
-
{ name: "sender", type: "bytes32" },
|
|
11
|
-
{ name: "productId", type: "uint32" },
|
|
12
|
-
{ name: "amount", type: "uint128" },
|
|
13
|
-
{ name: "nonce", type: "uint64" },
|
|
14
|
-
{ name: "sendTo", type: "address" },
|
|
15
|
-
// Reserved by Nado — must be signed as 0
|
|
16
|
-
{ name: "appendix", type: "uint128" }
|
|
17
|
-
]
|
|
18
|
-
};
|
|
19
|
-
function buildWithdrawCollateralV2TypedData(params) {
|
|
20
|
-
return {
|
|
21
|
-
domain: {
|
|
22
|
-
name: "Nado",
|
|
23
|
-
version: "0.0.1",
|
|
24
|
-
chainId: INK_CHAIN_ID,
|
|
25
|
-
verifyingContract: NADO_EIP712_VERIFYING_CONTRACT_ADDRESS
|
|
26
|
-
},
|
|
27
|
-
types: WITHDRAW_COLLATERAL_V2_TYPES,
|
|
28
|
-
primaryType: "WithdrawCollateralV2",
|
|
29
|
-
message: {
|
|
30
|
-
sender: params.sender,
|
|
31
|
-
productId: params.productId,
|
|
32
|
-
amount: params.amount,
|
|
33
|
-
nonce: params.nonce,
|
|
34
|
-
sendTo: params.sendTo,
|
|
35
|
-
appendix: 0n
|
|
36
|
-
// set to 0, Nado reserved
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
3
|
+
WITHDRAW_COLLATERAL_V2_TYPES,
|
|
4
|
+
buildWithdrawCollateralV2TypedData
|
|
5
|
+
} from "../../chunk-YZSO4EMO.js";
|
|
6
|
+
import "../../chunk-II5CZTBC.js";
|
|
40
7
|
export {
|
|
41
8
|
WITHDRAW_COLLATERAL_V2_TYPES,
|
|
42
9
|
buildWithdrawCollateralV2TypedData
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Nado withdrawal money path: generate a Fun deposit address, sign Nado's
|
|
3
|
+
* gasless `withdraw_collateral_v2` with `sendTo` pointing at it, and submit.
|
|
4
|
+
*
|
|
5
|
+
* - Nado's signed `amount` is what lands at `sendTo`; the sequencer fee is a
|
|
6
|
+
* separate subaccount debit, so we sign the net the screen already quoted.
|
|
7
|
+
* - Re-submitting belongs to the gateway, which reuses the signed nonce. A
|
|
8
|
+
* retry from here would mint a fresh one and withdraw twice.
|
|
9
|
+
*/
|
|
10
|
+
import type { Address, Hex } from 'viem';
|
|
11
|
+
import type { WithdrawalParam } from '../../../providers/FunkitCheckoutContext/types';
|
|
12
|
+
import type { Config } from '../../../wagmi/hooks';
|
|
13
|
+
export interface NadoWithdrawalCallbackContext {
|
|
14
|
+
/** Connected wallet — Nado rejects linked signers on withdrawals. */
|
|
15
|
+
walletAddress: Address;
|
|
16
|
+
/** Packed id of the subaccount being debited. */
|
|
17
|
+
subaccount: Hex;
|
|
18
|
+
wagmiConfig: Config;
|
|
19
|
+
}
|
|
20
|
+
export declare function createNadoWithdrawalCallback({ walletAddress, subaccount, wagmiConfig, }: NadoWithdrawalCallbackContext): (param: WithdrawalParam) => Promise<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
createNadoWithdrawalCallback
|
|
4
|
+
} from "../../chunk-YMGRBJAS.js";
|
|
5
|
+
import "../../chunk-YZSO4EMO.js";
|
|
6
|
+
import "../../chunk-WVM4ZJD2.js";
|
|
7
|
+
import "../../chunk-63XTVHO3.js";
|
|
8
|
+
import "../../chunk-SO756ELD.js";
|
|
9
|
+
import "../../chunk-6T6URLBM.js";
|
|
10
|
+
import "../../chunk-A44M6EAG.js";
|
|
11
|
+
import "../../chunk-II5CZTBC.js";
|
|
12
|
+
import "../../chunk-WZRW6WUM.js";
|
|
13
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
14
|
+
import "../../chunk-OODIKHYE.js";
|
|
15
|
+
import "../../chunk-2QYQNTOI.js";
|
|
16
|
+
import "../../chunk-PENJ5JGH.js";
|
|
17
|
+
import "../../chunk-AHYOV7AV.js";
|
|
18
|
+
export {
|
|
19
|
+
createNadoWithdrawalCallback
|
|
20
|
+
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Nado withdrawal config type
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Nado withdrawal config: its type, its guard, and the subaccount id the
|
|
3
|
+
* config is built around. All SDK-private (the `clients/internal/*` exports map
|
|
4
|
+
* blocks consumer imports) except the config type, which reaches integrators
|
|
5
|
+
* via the `clients/nado` re-export.
|
|
5
6
|
*/
|
|
7
|
+
import type { Address, Hex } from 'viem';
|
|
6
8
|
import type { CustomWithdrawalConfig, FunkitWithdrawalConfig } from '../../../providers/FunkitCheckoutContext';
|
|
7
9
|
import type { NadoWithdrawalCustomerConfig } from './withdrawalTypes';
|
|
8
10
|
export interface NadoWithdrawalConfig extends CustomWithdrawalConfig {
|
|
9
11
|
customerConfig: NadoWithdrawalCustomerConfig;
|
|
10
12
|
}
|
|
11
13
|
export declare function isNadoWithdrawalConfig(config: FunkitWithdrawalConfig | null | undefined): config is NadoWithdrawalConfig;
|
|
14
|
+
/** Packed subaccount id, or undefined when one can't be built — the caller
|
|
15
|
+
* disables the config rather than crashing the render. */
|
|
16
|
+
export declare function resolveNadoSubaccount(walletAddress: Address | undefined, subaccountName: string | undefined): Hex | undefined;
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isNadoWithdrawalConfig,
|
|
4
|
+
resolveNadoSubaccount
|
|
5
|
+
} from "../../chunk-A6OXZWCN.js";
|
|
6
|
+
import "../../chunk-SO756ELD.js";
|
|
7
|
+
import "../../chunk-6T6URLBM.js";
|
|
2
8
|
import "../../chunk-AHYOV7AV.js";
|
|
3
|
-
|
|
4
|
-
// src/utils/withdrawal.ts
|
|
5
|
-
import { isEVMAddressEquivalent, isTokenEquivalent } from "@funkit/utils";
|
|
6
|
-
import * as dnum from "dnum";
|
|
7
|
-
import { parseUnits } from "viem";
|
|
8
|
-
function isCustomWithdrawalConfig(config) {
|
|
9
|
-
return "withdrawCallback" in config;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// src/clients/internal/nado/withdrawalConfig.ts
|
|
13
|
-
function isNadoWithdrawalConfig(config) {
|
|
14
|
-
return !!config && isCustomWithdrawalConfig(config) && config.customerConfig?.customerName === "nado";
|
|
15
|
-
}
|
|
16
9
|
export {
|
|
17
|
-
isNadoWithdrawalConfig
|
|
10
|
+
isNadoWithdrawalConfig,
|
|
11
|
+
resolveNadoSubaccount
|
|
18
12
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nado gateway failure → user-facing withdrawal message.
|
|
3
|
+
*
|
|
4
|
+
* - Lives apart from `errors.ts`, which stays flow-agnostic (the codes are
|
|
5
|
+
* shared across every Nado execute and query).
|
|
6
|
+
* - Messages are surfaced verbatim by `useWithdrawal`'s custom-callback path,
|
|
7
|
+
* so unmapped codes get the generic line and the raw Nado string is logged.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Whether the failure is one we have specific copy for. Shares the code set with
|
|
11
|
+
* {@link toNadoWithdrawalErrorMessage} so severity and messaging can't drift.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isExpectedNadoWithdrawalFailure(error: unknown): boolean;
|
|
14
|
+
export declare function toNadoWithdrawalErrorMessage(error: unknown): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isExpectedNadoWithdrawalFailure,
|
|
4
|
+
toNadoWithdrawalErrorMessage
|
|
5
|
+
} from "../../chunk-WVM4ZJD2.js";
|
|
6
|
+
import "../../chunk-Z7HTQFEO.js";
|
|
7
|
+
import "../../chunk-2QYQNTOI.js";
|
|
8
|
+
export {
|
|
9
|
+
isExpectedNadoWithdrawalFailure,
|
|
10
|
+
toNadoWithdrawalErrorMessage
|
|
11
|
+
};
|