@chipi-stack/chipi-react 11.3.0 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hooks.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { CreateWalletParams, CreateWalletResponse, GetWalletParams, WalletData, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, RecordSendTransactionParams, Transaction } from '@chipi-stack/types';
1
+ import { CreateWalletParams, CreateWalletResponse, GetWalletParams, GetWalletResponse, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, RecordSendTransactionParams, Transaction, GetTokenBalanceParams, GetTokenBalanceResponse } from '@chipi-stack/types';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
3
+ import { UseQueryOptions } from '@tanstack/react-query';
2
4
 
3
5
  type CreateWalletInput = {
4
6
  params: CreateWalletParams;
@@ -18,15 +20,223 @@ declare function useCreateWallet(): {
18
20
  reset: () => void;
19
21
  };
20
22
 
21
- declare function useGetWallet(): {
22
- getWallet: (params: GetWalletParams) => void;
23
- getWalletAsync: (params: GetWalletParams) => Promise<WalletData>;
24
- data: WalletData | undefined;
23
+ type GetWalletInput = {
24
+ params?: GetWalletParams;
25
+ getBearerToken?: () => Promise<string | null | undefined>;
26
+ queryOptions?: Omit<UseQueryOptions<(GetWalletResponse & {
27
+ normalizedPublicKey: string;
28
+ }) | null, Error>, "queryKey" | "queryFn">;
29
+ };
30
+ declare function useGetWallet(input?: GetWalletInput): {
31
+ fetchWallet: (newInput: GetWalletInput) => Promise<(GetWalletResponse & {
32
+ normalizedPublicKey: string;
33
+ }) | null>;
34
+ data: (GetWalletResponse & {
35
+ normalizedPublicKey: string;
36
+ }) | null;
37
+ error: Error;
38
+ isError: true;
39
+ isPending: false;
40
+ isLoading: false;
41
+ isLoadingError: false;
42
+ isRefetchError: true;
43
+ isSuccess: false;
44
+ isPlaceholderData: false;
45
+ status: "error";
46
+ dataUpdatedAt: number;
47
+ errorUpdatedAt: number;
48
+ failureCount: number;
49
+ failureReason: Error | null;
50
+ errorUpdateCount: number;
51
+ isFetched: boolean;
52
+ isFetchedAfterMount: boolean;
53
+ isFetching: boolean;
54
+ isInitialLoading: boolean;
55
+ isPaused: boolean;
56
+ isRefetching: boolean;
57
+ isStale: boolean;
58
+ isEnabled: boolean;
59
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<(GetWalletResponse & {
60
+ normalizedPublicKey: string;
61
+ }) | null, Error>>;
62
+ fetchStatus: _tanstack_react_query.FetchStatus;
63
+ promise: Promise<(GetWalletResponse & {
64
+ normalizedPublicKey: string;
65
+ }) | null>;
66
+ } | {
67
+ fetchWallet: (newInput: GetWalletInput) => Promise<(GetWalletResponse & {
68
+ normalizedPublicKey: string;
69
+ }) | null>;
70
+ data: (GetWalletResponse & {
71
+ normalizedPublicKey: string;
72
+ }) | null;
73
+ error: null;
74
+ isError: false;
75
+ isPending: false;
76
+ isLoading: false;
77
+ isLoadingError: false;
78
+ isRefetchError: false;
79
+ isSuccess: true;
80
+ isPlaceholderData: false;
81
+ status: "success";
82
+ dataUpdatedAt: number;
83
+ errorUpdatedAt: number;
84
+ failureCount: number;
85
+ failureReason: Error | null;
86
+ errorUpdateCount: number;
87
+ isFetched: boolean;
88
+ isFetchedAfterMount: boolean;
89
+ isFetching: boolean;
90
+ isInitialLoading: boolean;
91
+ isPaused: boolean;
92
+ isRefetching: boolean;
93
+ isStale: boolean;
94
+ isEnabled: boolean;
95
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<(GetWalletResponse & {
96
+ normalizedPublicKey: string;
97
+ }) | null, Error>>;
98
+ fetchStatus: _tanstack_react_query.FetchStatus;
99
+ promise: Promise<(GetWalletResponse & {
100
+ normalizedPublicKey: string;
101
+ }) | null>;
102
+ } | {
103
+ fetchWallet: (newInput: GetWalletInput) => Promise<(GetWalletResponse & {
104
+ normalizedPublicKey: string;
105
+ }) | null>;
106
+ data: undefined;
107
+ error: Error;
108
+ isError: true;
109
+ isPending: false;
110
+ isLoading: false;
111
+ isLoadingError: true;
112
+ isRefetchError: false;
113
+ isSuccess: false;
114
+ isPlaceholderData: false;
115
+ status: "error";
116
+ dataUpdatedAt: number;
117
+ errorUpdatedAt: number;
118
+ failureCount: number;
119
+ failureReason: Error | null;
120
+ errorUpdateCount: number;
121
+ isFetched: boolean;
122
+ isFetchedAfterMount: boolean;
123
+ isFetching: boolean;
124
+ isInitialLoading: boolean;
125
+ isPaused: boolean;
126
+ isRefetching: boolean;
127
+ isStale: boolean;
128
+ isEnabled: boolean;
129
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<(GetWalletResponse & {
130
+ normalizedPublicKey: string;
131
+ }) | null, Error>>;
132
+ fetchStatus: _tanstack_react_query.FetchStatus;
133
+ promise: Promise<(GetWalletResponse & {
134
+ normalizedPublicKey: string;
135
+ }) | null>;
136
+ } | {
137
+ fetchWallet: (newInput: GetWalletInput) => Promise<(GetWalletResponse & {
138
+ normalizedPublicKey: string;
139
+ }) | null>;
140
+ data: undefined;
141
+ error: null;
142
+ isError: false;
143
+ isPending: true;
144
+ isLoading: true;
145
+ isLoadingError: false;
146
+ isRefetchError: false;
147
+ isSuccess: false;
148
+ isPlaceholderData: false;
149
+ status: "pending";
150
+ dataUpdatedAt: number;
151
+ errorUpdatedAt: number;
152
+ failureCount: number;
153
+ failureReason: Error | null;
154
+ errorUpdateCount: number;
155
+ isFetched: boolean;
156
+ isFetchedAfterMount: boolean;
157
+ isFetching: boolean;
158
+ isInitialLoading: boolean;
159
+ isPaused: boolean;
160
+ isRefetching: boolean;
161
+ isStale: boolean;
162
+ isEnabled: boolean;
163
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<(GetWalletResponse & {
164
+ normalizedPublicKey: string;
165
+ }) | null, Error>>;
166
+ fetchStatus: _tanstack_react_query.FetchStatus;
167
+ promise: Promise<(GetWalletResponse & {
168
+ normalizedPublicKey: string;
169
+ }) | null>;
170
+ } | {
171
+ fetchWallet: (newInput: GetWalletInput) => Promise<(GetWalletResponse & {
172
+ normalizedPublicKey: string;
173
+ }) | null>;
174
+ data: undefined;
175
+ error: null;
176
+ isError: false;
177
+ isPending: true;
178
+ isLoadingError: false;
179
+ isRefetchError: false;
180
+ isSuccess: false;
181
+ isPlaceholderData: false;
182
+ status: "pending";
183
+ dataUpdatedAt: number;
184
+ errorUpdatedAt: number;
185
+ failureCount: number;
186
+ failureReason: Error | null;
187
+ errorUpdateCount: number;
188
+ isFetched: boolean;
189
+ isFetchedAfterMount: boolean;
190
+ isFetching: boolean;
25
191
  isLoading: boolean;
26
- isError: boolean;
27
- error: Error | null;
28
- isSuccess: boolean;
29
- refetch: () => void;
192
+ isInitialLoading: boolean;
193
+ isPaused: boolean;
194
+ isRefetching: boolean;
195
+ isStale: boolean;
196
+ isEnabled: boolean;
197
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<(GetWalletResponse & {
198
+ normalizedPublicKey: string;
199
+ }) | null, Error>>;
200
+ fetchStatus: _tanstack_react_query.FetchStatus;
201
+ promise: Promise<(GetWalletResponse & {
202
+ normalizedPublicKey: string;
203
+ }) | null>;
204
+ } | {
205
+ fetchWallet: (newInput: GetWalletInput) => Promise<(GetWalletResponse & {
206
+ normalizedPublicKey: string;
207
+ }) | null>;
208
+ data: (GetWalletResponse & {
209
+ normalizedPublicKey: string;
210
+ }) | null;
211
+ isError: false;
212
+ error: null;
213
+ isPending: false;
214
+ isLoading: false;
215
+ isLoadingError: false;
216
+ isRefetchError: false;
217
+ isSuccess: true;
218
+ isPlaceholderData: true;
219
+ status: "success";
220
+ dataUpdatedAt: number;
221
+ errorUpdatedAt: number;
222
+ failureCount: number;
223
+ failureReason: Error | null;
224
+ errorUpdateCount: number;
225
+ isFetched: boolean;
226
+ isFetchedAfterMount: boolean;
227
+ isFetching: boolean;
228
+ isInitialLoading: boolean;
229
+ isPaused: boolean;
230
+ isRefetching: boolean;
231
+ isStale: boolean;
232
+ isEnabled: boolean;
233
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<(GetWalletResponse & {
234
+ normalizedPublicKey: string;
235
+ }) | null, Error>>;
236
+ fetchStatus: _tanstack_react_query.FetchStatus;
237
+ promise: Promise<(GetWalletResponse & {
238
+ normalizedPublicKey: string;
239
+ }) | null>;
30
240
  };
31
241
 
32
242
  type TransferInput = {
@@ -134,4 +344,179 @@ declare function useRecordSendTransaction(): {
134
344
  reset: () => void;
135
345
  };
136
346
 
137
- export { useApprove, useCallAnyContract, useCreateWallet, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
347
+ type GetTokenBalanceInput = {
348
+ params?: GetTokenBalanceParams;
349
+ getBearerToken?: () => Promise<string | null | undefined>;
350
+ queryOptions?: Omit<UseQueryOptions<GetTokenBalanceResponse, Error>, 'queryKey' | 'queryFn'>;
351
+ };
352
+ declare function useGetTokenBalance(input?: GetTokenBalanceInput): {
353
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
354
+ data: GetTokenBalanceResponse;
355
+ error: Error;
356
+ isError: true;
357
+ isPending: false;
358
+ isLoading: false;
359
+ isLoadingError: false;
360
+ isRefetchError: true;
361
+ isSuccess: false;
362
+ isPlaceholderData: false;
363
+ status: "error";
364
+ dataUpdatedAt: number;
365
+ errorUpdatedAt: number;
366
+ failureCount: number;
367
+ failureReason: Error | null;
368
+ errorUpdateCount: number;
369
+ isFetched: boolean;
370
+ isFetchedAfterMount: boolean;
371
+ isFetching: boolean;
372
+ isInitialLoading: boolean;
373
+ isPaused: boolean;
374
+ isRefetching: boolean;
375
+ isStale: boolean;
376
+ isEnabled: boolean;
377
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
378
+ fetchStatus: _tanstack_react_query.FetchStatus;
379
+ promise: Promise<GetTokenBalanceResponse>;
380
+ } | {
381
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
382
+ data: GetTokenBalanceResponse;
383
+ error: null;
384
+ isError: false;
385
+ isPending: false;
386
+ isLoading: false;
387
+ isLoadingError: false;
388
+ isRefetchError: false;
389
+ isSuccess: true;
390
+ isPlaceholderData: false;
391
+ status: "success";
392
+ dataUpdatedAt: number;
393
+ errorUpdatedAt: number;
394
+ failureCount: number;
395
+ failureReason: Error | null;
396
+ errorUpdateCount: number;
397
+ isFetched: boolean;
398
+ isFetchedAfterMount: boolean;
399
+ isFetching: boolean;
400
+ isInitialLoading: boolean;
401
+ isPaused: boolean;
402
+ isRefetching: boolean;
403
+ isStale: boolean;
404
+ isEnabled: boolean;
405
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
406
+ fetchStatus: _tanstack_react_query.FetchStatus;
407
+ promise: Promise<GetTokenBalanceResponse>;
408
+ } | {
409
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
410
+ data: undefined;
411
+ error: Error;
412
+ isError: true;
413
+ isPending: false;
414
+ isLoading: false;
415
+ isLoadingError: true;
416
+ isRefetchError: false;
417
+ isSuccess: false;
418
+ isPlaceholderData: false;
419
+ status: "error";
420
+ dataUpdatedAt: number;
421
+ errorUpdatedAt: number;
422
+ failureCount: number;
423
+ failureReason: Error | null;
424
+ errorUpdateCount: number;
425
+ isFetched: boolean;
426
+ isFetchedAfterMount: boolean;
427
+ isFetching: boolean;
428
+ isInitialLoading: boolean;
429
+ isPaused: boolean;
430
+ isRefetching: boolean;
431
+ isStale: boolean;
432
+ isEnabled: boolean;
433
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
434
+ fetchStatus: _tanstack_react_query.FetchStatus;
435
+ promise: Promise<GetTokenBalanceResponse>;
436
+ } | {
437
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
438
+ data: undefined;
439
+ error: null;
440
+ isError: false;
441
+ isPending: true;
442
+ isLoading: true;
443
+ isLoadingError: false;
444
+ isRefetchError: false;
445
+ isSuccess: false;
446
+ isPlaceholderData: false;
447
+ status: "pending";
448
+ dataUpdatedAt: number;
449
+ errorUpdatedAt: number;
450
+ failureCount: number;
451
+ failureReason: Error | null;
452
+ errorUpdateCount: number;
453
+ isFetched: boolean;
454
+ isFetchedAfterMount: boolean;
455
+ isFetching: boolean;
456
+ isInitialLoading: boolean;
457
+ isPaused: boolean;
458
+ isRefetching: boolean;
459
+ isStale: boolean;
460
+ isEnabled: boolean;
461
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
462
+ fetchStatus: _tanstack_react_query.FetchStatus;
463
+ promise: Promise<GetTokenBalanceResponse>;
464
+ } | {
465
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
466
+ data: undefined;
467
+ error: null;
468
+ isError: false;
469
+ isPending: true;
470
+ isLoadingError: false;
471
+ isRefetchError: false;
472
+ isSuccess: false;
473
+ isPlaceholderData: false;
474
+ status: "pending";
475
+ dataUpdatedAt: number;
476
+ errorUpdatedAt: number;
477
+ failureCount: number;
478
+ failureReason: Error | null;
479
+ errorUpdateCount: number;
480
+ isFetched: boolean;
481
+ isFetchedAfterMount: boolean;
482
+ isFetching: boolean;
483
+ isLoading: boolean;
484
+ isInitialLoading: boolean;
485
+ isPaused: boolean;
486
+ isRefetching: boolean;
487
+ isStale: boolean;
488
+ isEnabled: boolean;
489
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
490
+ fetchStatus: _tanstack_react_query.FetchStatus;
491
+ promise: Promise<GetTokenBalanceResponse>;
492
+ } | {
493
+ fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
494
+ data: GetTokenBalanceResponse;
495
+ isError: false;
496
+ error: null;
497
+ isPending: false;
498
+ isLoading: false;
499
+ isLoadingError: false;
500
+ isRefetchError: false;
501
+ isSuccess: true;
502
+ isPlaceholderData: true;
503
+ status: "success";
504
+ dataUpdatedAt: number;
505
+ errorUpdatedAt: number;
506
+ failureCount: number;
507
+ failureReason: Error | null;
508
+ errorUpdateCount: number;
509
+ isFetched: boolean;
510
+ isFetchedAfterMount: boolean;
511
+ isFetching: boolean;
512
+ isInitialLoading: boolean;
513
+ isPaused: boolean;
514
+ isRefetching: boolean;
515
+ isStale: boolean;
516
+ isEnabled: boolean;
517
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<GetTokenBalanceResponse, Error>>;
518
+ fetchStatus: _tanstack_react_query.FetchStatus;
519
+ promise: Promise<GetTokenBalanceResponse>;
520
+ };
521
+
522
+ export { useApprove, useCallAnyContract, useCreateWallet, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
package/dist/hooks.js CHANGED
@@ -35,45 +35,38 @@ function useCreateWallet() {
35
35
  reset: mutation.reset
36
36
  };
37
37
  }
38
- var walletKey = (externalUserId) => ["wallet", externalUserId];
39
- function useGetWallet() {
38
+ function useGetWallet(input) {
40
39
  const { chipiSDK } = useChipiContext();
41
40
  const queryClient = reactQuery.useQueryClient();
42
- const [params, setParams] = react.useState(null);
43
41
  const query = reactQuery.useQuery({
44
- queryKey: walletKey(params?.externalUserId || ""),
45
- queryFn: () => {
46
- if (!params) throw new Error("No wallet params provided");
47
- return chipiSDK.getWallet(params);
42
+ queryKey: ["wallet", input?.params?.externalUserId],
43
+ queryFn: async () => {
44
+ if (!input || !input.params || !input.getBearerToken)
45
+ throw new Error("Input is required");
46
+ const bearerToken = await input.getBearerToken();
47
+ if (!bearerToken) throw new Error("Bearer token is required");
48
+ return chipiSDK.getWallet(input.params, bearerToken);
48
49
  },
49
- enabled: !!params,
50
- staleTime: Infinity,
51
- gcTime: Infinity,
52
- refetchOnWindowFocus: false,
53
- refetchOnMount: false
50
+ enabled: Boolean(
51
+ input?.params?.externalUserId && input?.getBearerToken && input.params.externalUserId.trim() !== ""
52
+ ),
53
+ ...input?.queryOptions
54
54
  });
55
- const getWallet = (walletParams) => {
56
- setParams(walletParams);
57
- };
58
- const getWalletAsync = (walletParams) => {
55
+ const fetchWallet = async (newInput) => {
59
56
  return queryClient.fetchQuery({
60
- queryKey: walletKey(walletParams.externalUserId),
61
- queryFn: () => chipiSDK.getWallet(walletParams),
62
- staleTime: Infinity,
63
- gcTime: Infinity
57
+ queryKey: ["wallet", newInput?.params?.externalUserId],
58
+ queryFn: async () => {
59
+ if (!newInput || !newInput.getBearerToken || !newInput.params)
60
+ throw new Error("Input is required");
61
+ const bearerToken = await newInput.getBearerToken();
62
+ if (!bearerToken) throw new Error("Bearer token is required");
63
+ return chipiSDK.getWallet(newInput.params, bearerToken);
64
+ }
64
65
  });
65
66
  };
66
67
  return {
67
- getWallet,
68
- getWalletAsync,
69
- data: query.data,
70
- isLoading: query.isLoading,
71
- isError: query.isError,
72
- error: query.error ?? null,
73
- isSuccess: query.isSuccess,
74
- refetch: () => {
75
- if (params) void query.refetch();
76
- }
68
+ ...query,
69
+ fetchWallet
77
70
  };
78
71
  }
79
72
  function useTransfer() {
@@ -180,10 +173,41 @@ function useRecordSendTransaction() {
180
173
  reset: mutation.reset
181
174
  };
182
175
  }
176
+ function useGetTokenBalance(input) {
177
+ const { chipiSDK } = useChipiContext();
178
+ const queryClient = reactQuery.useQueryClient();
179
+ const query = reactQuery.useQuery({
180
+ queryKey: ["chain-token-balance", input?.params?.chainToken, input?.params?.chain, input?.params?.walletPublicKey, input?.params?.externalUserId],
181
+ queryFn: async () => {
182
+ if (!input || !input.params || !input.getBearerToken) throw new Error("Input is required");
183
+ const bearerToken = await input.getBearerToken();
184
+ if (!bearerToken) throw new Error("Bearer token is required");
185
+ return chipiSDK.getTokenBalance(input.params, bearerToken);
186
+ },
187
+ enabled: Boolean(input?.params && input?.getBearerToken),
188
+ ...input?.queryOptions
189
+ });
190
+ const fetchTokenBalance = async (newInput) => {
191
+ return queryClient.fetchQuery({
192
+ queryKey: ["chain-token-balance", newInput?.params?.chainToken, newInput?.params?.chain, newInput?.params?.walletPublicKey, newInput?.params?.externalUserId],
193
+ queryFn: async () => {
194
+ if (!newInput || !newInput.getBearerToken || !newInput.params) throw new Error("Input is required");
195
+ const bearerToken = await newInput.getBearerToken();
196
+ if (!bearerToken) throw new Error("Bearer token is required");
197
+ return chipiSDK.getTokenBalance(newInput.params, bearerToken);
198
+ }
199
+ });
200
+ };
201
+ return {
202
+ ...query,
203
+ fetchTokenBalance
204
+ };
205
+ }
183
206
 
184
207
  exports.useApprove = useApprove;
185
208
  exports.useCallAnyContract = useCallAnyContract;
186
209
  exports.useCreateWallet = useCreateWallet;
210
+ exports.useGetTokenBalance = useGetTokenBalance;
187
211
  exports.useGetWallet = useGetWallet;
188
212
  exports.useRecordSendTransaction = useRecordSendTransaction;
189
213
  exports.useStakeVesuUsdc = useStakeVesuUsdc;
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context/ChipiProvider.tsx","../src/hooks/useCreateWallet.ts","../src/hooks/useGetWallet.ts","../src/hooks/useTransfer.ts","../src/hooks/useApprove.ts","../src/hooks/useStakeVesuUsdc.ts","../src/hooks/useWithdrawVesuUsdc.ts","../src/hooks/useCallAnyContract.ts","../src/hooks/useRecordSendTransaction.ts"],"names":["createContext","useContext","useMutation","useQueryClient","useState","useQuery"],"mappings":";;;;;;;;AAUA,IA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WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,OAAO,QAAA,CAAS;AAAA,GAClB;AACF;AC5BO,SAAS,wBAAA,GAWd;AACA,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,eAAA,EAAgB;AAErC,EAAA,MAAM,WAIFA,sBAAAA,CAAY;AAAA,IACd,UAAA,EAAY,CAAC,KAAA,KACX,QAAA,CAAS,qBAAA,CAAsB;AAAA,MAC7B,QAAQ,KAAA,CAAM,MAAA;AAAA,MACd,aAAa,KAAA,CAAM;AAAA,KACpB;AAAA,GACJ,CAAA;AAED,EAAA,OAAO;AAAA,IACL,uBAAuB,QAAA,CAAS,MAAA;AAAA,IAChC,4BAA4B,QAAA,CAAS,WAAA;AAAA,IACrC,MAAM,QAAA,CAAS,IAAA;AAAA,IACf,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,SAAS,QAAA,CAAS,OAAA;AAAA,IAClB,OAAO,QAAA,CAAS,KAAA;AAAA,IAChB,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,OAAO,QAAA,CAAS;AAAA,GAClB;AACF","file":"hooks.js","sourcesContent":["import React, { createContext, useContext, ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { ChipiSDK } from \"@chipi-stack/backend\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\ninterface ChipiContextValue {\n chipiSDK: ChipiSDK;\n config: ChipiSDKConfig;\n}\n\nconst ChipiContext = createContext<ChipiContextValue | null>(null);\n\ninterface ChipiProviderProps {\n children: ReactNode;\n config: ChipiSDKConfig;\n}\n\n// Default QueryClient configuration\nconst createDefaultQueryClient = () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000, // 1 minute\n gcTime: 10 * 60 * 1000, // 10 minutes (formerly cacheTime)\n retry: (failureCount, error: any) => {\n // Don't retry on 4xx errors\n if (error?.status >= 400 && error?.status < 500) {\n return false;\n }\n return failureCount < 3;\n },\n },\n mutations: {\n retry: false,\n },\n },\n });\n\n/**\n * Provider component that wraps your app and provides Chipi SDK context with QueryClient\n */\nexport function ChipiProvider({ children, config }: ChipiProviderProps) {\n // Create QueryClient\n const queryClient = React.useMemo(() => createDefaultQueryClient(), []);\n\n const chipiSDK = React.useMemo(() => new ChipiSDK(config), [config]);\n\n const value = React.useMemo(\n () => ({\n chipiSDK,\n config,\n }),\n [chipiSDK, config]\n );\n\n return (\n <QueryClientProvider client={queryClient}>\n <ChipiContext.Provider value={value}>{children}</ChipiContext.Provider>\n </QueryClientProvider>\n );\n}\n\n/**\n * Hook to access Chipi SDK context\n */\nexport function useChipiContext(): ChipiContextValue {\n const context = useContext(ChipiContext);\n\n if (!context) {\n throw new Error(\"useChipiContext must be used within a ChipiProvider\");\n }\n\n return context;\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type {\n CreateWalletParams,\n CreateWalletResponse,\n} from \"@chipi-stack/types\";\n\ntype CreateWalletInput = {\n params: CreateWalletParams;\n bearerToken: string;\n};\n\n/**\n * Hook for creating a new wallet\n */\nexport function useCreateWallet(): {\n createWallet: (input: CreateWalletInput) => void;\n createWalletAsync: (\n input: CreateWalletInput\n ) => Promise<CreateWalletResponse>;\n data: CreateWalletResponse | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<\n CreateWalletResponse,\n Error,\n CreateWalletInput\n > = useMutation({\n mutationFn: (input: CreateWalletInput) =>\n chipiSDK.createWallet({\n params: input.params,\n bearerToken: input.bearerToken,\n }),\n });\n\n return {\n createWallet: mutation.mutate,\n createWalletAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","\"use client\";\n\nimport { useState } from \"react\";\nimport {\n useQuery,\n useQueryClient,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { GetWalletParams, WalletData } from \"@chipi-stack/types\";\nimport { useChipiContext } from \"../context\";\n\nconst walletKey = (externalUserId: string) =>\n [\"wallet\", externalUserId] as const;\n\nexport function useGetWallet(): {\n getWallet: (params: GetWalletParams) => void;\n getWalletAsync: (params: GetWalletParams) => Promise<WalletData>;\n data: WalletData | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n refetch: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n const queryClient = useQueryClient();\n\n const [params, setParams] = useState<GetWalletParams | null>(null);\n\n const query: UseQueryResult<WalletData, Error> = useQuery({\n queryKey: walletKey(params?.externalUserId || \"\"),\n queryFn: () => {\n if (!params) throw new Error(\"No wallet params provided\");\n return chipiSDK.getWallet(params);\n },\n enabled: !!params,\n staleTime: Infinity,\n gcTime: Infinity,\n refetchOnWindowFocus: false,\n refetchOnMount: false,\n });\n\n const getWallet = (walletParams: GetWalletParams) => {\n setParams(walletParams);\n };\n\n const getWalletAsync = (\n walletParams: GetWalletParams\n ): Promise<WalletData> => {\n return queryClient.fetchQuery({\n queryKey: walletKey(walletParams.externalUserId),\n queryFn: () => chipiSDK.getWallet(walletParams),\n staleTime: Infinity,\n gcTime: Infinity,\n });\n };\n\n return {\n getWallet,\n getWalletAsync,\n data: query.data,\n isLoading: query.isLoading,\n isError: query.isError,\n error: query.error ?? null,\n isSuccess: query.isSuccess,\n refetch: () => {\n if (params) void query.refetch();\n },\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { TransferParams } from \"@chipi-stack/types\";\n\ntype TransferInput = { params: TransferParams; bearerToken: string };\n\n/**\n * Hook for transferring tokens\n */\nexport function useTransfer(): {\n transfer: (input: TransferInput) => void;\n transferAsync: (input: TransferInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, TransferInput> = useMutation(\n {\n mutationFn: (input: TransferInput) =>\n chipiSDK.transfer({\n params: input.params,\n bearerToken: input.bearerToken,\n }),\n }\n );\n\n return {\n transfer: mutation.mutate,\n transferAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { ApproveParams } from \"@chipi-stack/types\";\n\ntype ApproveInput = {\n params: ApproveParams;\n bearerToken: string;\n};\n\n/**\n * Hook for approving token spending\n */\nexport function useApprove(): {\n approve: (params: ApproveInput) => void;\n approveAsync: (params: ApproveInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, ApproveInput> = useMutation({\n mutationFn: (params: ApproveInput) => chipiSDK.approve(params),\n });\n\n return {\n approve: mutation.mutate,\n approveAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { StakeVesuUsdcParams } from \"@chipi-stack/types\";\n\ntype StakeVesuUsdcInput = {\n params: StakeVesuUsdcParams;\n bearerToken: string;\n};\n\n/**\n * Hook for staking USDC in Vesu protocol\n */\nexport function useStakeVesuUsdc(): {\n stakeVesuUsdc: (params: StakeVesuUsdcInput) => void;\n stakeVesuUsdcAsync: (params: StakeVesuUsdcInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, StakeVesuUsdcInput> =\n useMutation({\n mutationFn: (params: StakeVesuUsdcInput) =>\n chipiSDK.stakeVesuUsdc(params),\n });\n\n return {\n stakeVesuUsdc: mutation.mutate,\n stakeVesuUsdcAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { WithdrawVesuUsdcParams } from \"@chipi-stack/types\";\n\ntype WithdrawVesuUsdcInput = {\n params: WithdrawVesuUsdcParams;\n bearerToken: string;\n};\n\n/**\n * Hook for withdrawing USDC from Vesu protocol\n */\nexport function useWithdrawVesuUsdc(): {\n withdrawVesuUsdc: (params: WithdrawVesuUsdcInput) => void;\n withdrawVesuUsdcAsync: (params: WithdrawVesuUsdcInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, WithdrawVesuUsdcInput> =\n useMutation({\n mutationFn: (params: WithdrawVesuUsdcInput) =>\n chipiSDK.withdrawVesuUsdc(params),\n });\n\n return {\n withdrawVesuUsdc: mutation.mutate,\n withdrawVesuUsdcAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { CallAnyContractParams } from \"@chipi-stack/types\";\n\ntype CallAnyContractInput = {\n params: CallAnyContractParams;\n bearerToken: string;\n};\n\n/**\n * Hook for calling any contract method\n */\nexport function useCallAnyContract(): {\n callAnyContract: (params: CallAnyContractInput) => void;\n callAnyContractAsync: (params: CallAnyContractInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, CallAnyContractInput> =\n useMutation({\n mutationFn: (params: CallAnyContractInput) =>\n chipiSDK.callAnyContract(params),\n });\n\n return {\n callAnyContract: mutation.mutate,\n callAnyContractAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type {\n RecordSendTransactionParams,\n Transaction,\n} from \"@chipi-stack/types\";\n\ntype RecordSendTransactionInput = {\n params: RecordSendTransactionParams;\n bearerToken: string;\n};\n\nexport function useRecordSendTransaction(): {\n recordSendTransaction: (input: RecordSendTransactionInput) => void;\n recordSendTransactionAsync: (\n input: RecordSendTransactionInput\n ) => Promise<Transaction>;\n data: Transaction | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<\n Transaction,\n Error,\n RecordSendTransactionInput\n > = useMutation({\n mutationFn: (input: RecordSendTransactionInput) =>\n chipiSDK.recordSendTransaction({\n params: input.params,\n bearerToken: input.bearerToken,\n }),\n });\n\n return {\n recordSendTransaction: mutation.mutate,\n recordSendTransactionAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/context/ChipiProvider.tsx","../src/hooks/useCreateWallet.ts","../src/hooks/useGetWallet.ts","../src/hooks/useTransfer.ts","../src/hooks/useApprove.ts","../src/hooks/useStakeVesuUsdc.ts","../src/hooks/useWithdrawVesuUsdc.ts","../src/hooks/useCallAnyContract.ts","../src/hooks/useRecordSendTransaction.ts","../src/hooks/useGetTokenBalance.ts"],"names":["createContext","useContext","useMutation","useQueryClient","useQuery"],"mappings":";;;;;;;;AAUA,IAAM,YAAA,GAAeA,oBAAwC,IAAI,CAAA;AAuD1D,SAAS,eAAA,GAAqC;AACnD,EAAA,MAAM,OAAA,GAAUC,iBAAW,YAAY,CAAA;AAEvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AAEA,EAAA,OAAO,OAAA;AACT;;;AC1DO,SAAS,eAAA,GAWd;AACA,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,eAAA,EAAgB;AAErC,EAAA,MAAM,WAIFC,sBAAA,CAAY;AAAA,IACd,UAAA,EAAY,CAAC,KAAA,KACX,QAAA,CAAS,YAAA,CAAa;AAAA,MACpB,QAAQ,KAAA,CAAM,MAAA;AAAA,MACd,aAAa,KAAA,CAAM;AAAA,KACpB;AAAA,GACJ,CAAA;AAED,EAAA,OAAO;AAAA,IACL,cAAc,QAAA,CAAS,MAAA;AAAA,IACvB,mBAAmB,QAAA,CAAS,WAAA;AAAA,IAC5B,MAAM,QAAA,CAAS,IAAA;AAAA,IACf,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,SAAS,QAAA,CAAS,OAAA;AAAA,IAClB,OAAO,QAAA,CAAS,KAAA;AAAA,IAChB,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,OAAO,QAAA,CAAS;AAAA,GAClB;AACF;AC7BO,SAAS,aAAa,KAAA,EAAwB;AACnD,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,eAAA,EAAgB;AACrC,EAAA,MAAM,cAAcC,yBAAA,EAAe;AAEnC,EAAA,MAAM,QAAQC,mBAAA,CAGZ;AAAA,IACA,QAA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AAO;AAAA,IACL,GAAG,KAAA;AAAA,IACH;AAAA,GACF;AACF","file":"hooks.js","sourcesContent":["import React, { createContext, useContext, ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { ChipiSDK } from \"@chipi-stack/backend\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\ninterface ChipiContextValue {\n chipiSDK: ChipiSDK;\n config: ChipiSDKConfig;\n}\n\nconst ChipiContext = createContext<ChipiContextValue | null>(null);\n\ninterface ChipiProviderProps {\n children: ReactNode;\n config: ChipiSDKConfig;\n}\n\n// Default QueryClient configuration\nconst createDefaultQueryClient = () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000, // 1 minute\n gcTime: 10 * 60 * 1000, // 10 minutes (formerly cacheTime)\n retry: (failureCount, error: any) => {\n // Don't retry on 4xx errors\n if (error?.status >= 400 && error?.status < 500) {\n return false;\n }\n return failureCount < 3;\n },\n },\n mutations: {\n retry: false,\n },\n },\n });\n\n/**\n * Provider component that wraps your app and provides Chipi SDK context with QueryClient\n */\nexport function ChipiProvider({ children, config }: ChipiProviderProps) {\n // Create QueryClient\n const queryClient = React.useMemo(() => createDefaultQueryClient(), []);\n\n const chipiSDK = React.useMemo(() => new ChipiSDK(config), [config]);\n\n const value = React.useMemo(\n () => ({\n chipiSDK,\n config,\n }),\n [chipiSDK, config]\n );\n\n return (\n <QueryClientProvider client={queryClient}>\n <ChipiContext.Provider value={value}>{children}</ChipiContext.Provider>\n </QueryClientProvider>\n );\n}\n\n/**\n * Hook to access Chipi SDK context\n */\nexport function useChipiContext(): ChipiContextValue {\n const context = useContext(ChipiContext);\n\n if (!context) {\n throw new Error(\"useChipiContext must be used within a ChipiProvider\");\n }\n\n return context;\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type {\n CreateWalletParams,\n CreateWalletResponse,\n} from \"@chipi-stack/types\";\n\ntype CreateWalletInput = {\n params: CreateWalletParams;\n bearerToken: string;\n};\n\n/**\n * Hook for creating a new wallet\n */\nexport function useCreateWallet(): {\n createWallet: (input: CreateWalletInput) => void;\n createWalletAsync: (\n input: CreateWalletInput\n ) => Promise<CreateWalletResponse>;\n data: CreateWalletResponse | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<\n CreateWalletResponse,\n Error,\n CreateWalletInput\n > = useMutation({\n mutationFn: (input: CreateWalletInput) =>\n chipiSDK.createWallet({\n params: input.params,\n bearerToken: input.bearerToken,\n }),\n });\n\n return {\n createWallet: mutation.mutate,\n createWalletAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","\"use client\";\n\nimport {\n useQuery,\n useQueryClient,\n type UseQueryOptions,\n} from \"@tanstack/react-query\";\nimport {\n GetWalletParams,\n GetWalletResponse,\n} from \"@chipi-stack/types\";\nimport { useChipiContext } from \"../context\";\n\ntype GetWalletInput = {\n params?: GetWalletParams;\n getBearerToken?: () => Promise<string | null | undefined>;\n queryOptions?: Omit<\n UseQueryOptions<(GetWalletResponse & { normalizedPublicKey: string }) | null, Error>,\n \"queryKey\" | \"queryFn\"\n >;\n};\n\nexport function useGetWallet(input?: GetWalletInput) {\n const { chipiSDK } = useChipiContext();\n const queryClient = useQueryClient();\n\n const query = useQuery<\n (GetWalletResponse & { normalizedPublicKey: string }) | null,\n Error\n >({\n queryKey: [\"wallet\", input?.params?.externalUserId],\n queryFn: async () => {\n if (!input || !input.params || !input.getBearerToken)\n throw new Error(\"Input is required\");\n const bearerToken = await input.getBearerToken();\n if (!bearerToken) throw new Error(\"Bearer token is required\");\n return chipiSDK.getWallet(input.params, bearerToken);\n },\n enabled: Boolean(\n input?.params?.externalUserId && \n input?.getBearerToken &&\n input.params.externalUserId.trim() !== \"\"\n ),\n ...input?.queryOptions,\n });\n\n const fetchWallet = async (newInput: GetWalletInput): Promise<(GetWalletResponse & { normalizedPublicKey: string }) | null> => {\n return queryClient.fetchQuery({\n queryKey: [\"wallet\", newInput?.params?.externalUserId],\n queryFn: async () => {\n if (!newInput || !newInput.getBearerToken || !newInput.params)\n throw new Error(\"Input is required\");\n const bearerToken = await newInput.getBearerToken();\n if (!bearerToken) throw new Error(\"Bearer token is required\");\n return chipiSDK.getWallet(newInput.params, bearerToken);\n },\n });\n };\n\n return {\n ...query,\n fetchWallet,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { TransferParams } from \"@chipi-stack/types\";\n\ntype TransferInput = { params: TransferParams; bearerToken: string };\n\n/**\n * Hook for transferring tokens\n */\nexport function useTransfer(): {\n transfer: (input: TransferInput) => void;\n transferAsync: (input: TransferInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, TransferInput> = useMutation(\n {\n mutationFn: (input: TransferInput) =>\n chipiSDK.transfer({\n params: input.params,\n bearerToken: input.bearerToken,\n }),\n }\n );\n\n return {\n transfer: mutation.mutate,\n transferAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { ApproveParams } from \"@chipi-stack/types\";\n\ntype ApproveInput = {\n params: ApproveParams;\n bearerToken: string;\n};\n\n/**\n * Hook for approving token spending\n */\nexport function useApprove(): {\n approve: (params: ApproveInput) => void;\n approveAsync: (params: ApproveInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, ApproveInput> = useMutation({\n mutationFn: (params: ApproveInput) => chipiSDK.approve(params),\n });\n\n return {\n approve: mutation.mutate,\n approveAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { StakeVesuUsdcParams } from \"@chipi-stack/types\";\n\ntype StakeVesuUsdcInput = {\n params: StakeVesuUsdcParams;\n bearerToken: string;\n};\n\n/**\n * Hook for staking USDC in Vesu protocol\n */\nexport function useStakeVesuUsdc(): {\n stakeVesuUsdc: (params: StakeVesuUsdcInput) => void;\n stakeVesuUsdcAsync: (params: StakeVesuUsdcInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, StakeVesuUsdcInput> =\n useMutation({\n mutationFn: (params: StakeVesuUsdcInput) =>\n chipiSDK.stakeVesuUsdc(params),\n });\n\n return {\n stakeVesuUsdc: mutation.mutate,\n stakeVesuUsdcAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { WithdrawVesuUsdcParams } from \"@chipi-stack/types\";\n\ntype WithdrawVesuUsdcInput = {\n params: WithdrawVesuUsdcParams;\n bearerToken: string;\n};\n\n/**\n * Hook for withdrawing USDC from Vesu protocol\n */\nexport function useWithdrawVesuUsdc(): {\n withdrawVesuUsdc: (params: WithdrawVesuUsdcInput) => void;\n withdrawVesuUsdcAsync: (params: WithdrawVesuUsdcInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, WithdrawVesuUsdcInput> =\n useMutation({\n mutationFn: (params: WithdrawVesuUsdcInput) =>\n chipiSDK.withdrawVesuUsdc(params),\n });\n\n return {\n withdrawVesuUsdc: mutation.mutate,\n withdrawVesuUsdcAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type { CallAnyContractParams } from \"@chipi-stack/types\";\n\ntype CallAnyContractInput = {\n params: CallAnyContractParams;\n bearerToken: string;\n};\n\n/**\n * Hook for calling any contract method\n */\nexport function useCallAnyContract(): {\n callAnyContract: (params: CallAnyContractInput) => void;\n callAnyContractAsync: (params: CallAnyContractInput) => Promise<string>;\n data: string | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<string, Error, CallAnyContractInput> =\n useMutation({\n mutationFn: (params: CallAnyContractInput) =>\n chipiSDK.callAnyContract(params),\n });\n\n return {\n callAnyContract: mutation.mutate,\n callAnyContractAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","import { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useChipiContext } from \"../context\";\nimport type {\n RecordSendTransactionParams,\n Transaction,\n} from \"@chipi-stack/types\";\n\ntype RecordSendTransactionInput = {\n params: RecordSendTransactionParams;\n bearerToken: string;\n};\n\nexport function useRecordSendTransaction(): {\n recordSendTransaction: (input: RecordSendTransactionInput) => void;\n recordSendTransactionAsync: (\n input: RecordSendTransactionInput\n ) => Promise<Transaction>;\n data: Transaction | undefined;\n isLoading: boolean;\n isError: boolean;\n error: Error | null;\n isSuccess: boolean;\n reset: () => void;\n} {\n const { chipiSDK } = useChipiContext();\n\n const mutation: UseMutationResult<\n Transaction,\n Error,\n RecordSendTransactionInput\n > = useMutation({\n mutationFn: (input: RecordSendTransactionInput) =>\n chipiSDK.recordSendTransaction({\n params: input.params,\n bearerToken: input.bearerToken,\n }),\n });\n\n return {\n recordSendTransaction: mutation.mutate,\n recordSendTransactionAsync: mutation.mutateAsync,\n data: mutation.data,\n isLoading: mutation.isPending,\n isError: mutation.isError,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n };\n}\n","\"use client\";\n\nimport { useQuery, useQueryClient, type UseQueryOptions } from \"@tanstack/react-query\";\nimport {\n GetTokenBalanceParams,\n GetTokenBalanceResponse,\n} from \"@chipi-stack/types\";\nimport { useChipiContext } from \"../context\";\n\ntype GetTokenBalanceInput = {\n params?: GetTokenBalanceParams;\n getBearerToken?: () => Promise<string | null | undefined>;\n queryOptions?: Omit<UseQueryOptions<GetTokenBalanceResponse, Error>, 'queryKey' | 'queryFn'>;\n};\n\nexport function useGetTokenBalance(input?: GetTokenBalanceInput) {\n const { chipiSDK } = useChipiContext();\n const queryClient = useQueryClient();\n \n const query = useQuery<GetTokenBalanceResponse, Error>({\n queryKey: [\"chain-token-balance\", input?.params?.chainToken, input?.params?.chain, input?.params?.walletPublicKey, input?.params?.externalUserId],\n queryFn: async () => {\n if (!input || !input.params || !input.getBearerToken) throw new Error(\"Input is required\");\n const bearerToken = await input.getBearerToken();\n if (!bearerToken) throw new Error(\"Bearer token is required\");\n return chipiSDK.getTokenBalance(input.params, bearerToken);\n },\n enabled: Boolean(input?.params && input?.getBearerToken),\n ...input?.queryOptions\n });\n\n const fetchTokenBalance = async (newInput: GetTokenBalanceInput) => {\n return queryClient.fetchQuery({\n queryKey: [\"chain-token-balance\", newInput?.params?.chainToken, newInput?.params?.chain, newInput?.params?.walletPublicKey, newInput?.params?.externalUserId],\n queryFn: async () => {\n if (!newInput || !newInput.getBearerToken || !newInput.params) throw new Error(\"Input is required\");\n const bearerToken = await newInput.getBearerToken();\n if (!bearerToken) throw new Error(\"Bearer token is required\");\n return chipiSDK.getTokenBalance(newInput.params, bearerToken);\n },\n });\n };\n\n return {\n ...query,\n fetchTokenBalance,\n };\n}\n"]}