@chipi-stack/chipi-react 9.0.0 → 11.0.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/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Chipi SDK
2
+
3
+ Chipi SDK is the easiest way to integrate USDC staking and withdrawal functionality into your React/Next.js application. Add secure wallet management, token staking, and withdrawals to your application in minutes. All transactions are sponsored thanks to Avnu's paymaster.
4
+
5
+ ## Prerequisites
6
+
7
+ - React 18 or later
8
+ - Node.js >=18.17.0 or later
9
+ - A Chipi account. [Create your account for free](https://dashboard.chipipay.com)
10
+
11
+ ## Installation
12
+
13
+ The fastest way to get started with Chipi SDK is by following our [Quickstart Guide](https://docs.chipipay.com/gasless/quickstart).
14
+
15
+ ```bash
16
+ npm install @chipi-stack/chipi-react
17
+ # or
18
+ yarn add @chipi-stack/chipi-react
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ For detailed information, guides, and examples visit our [documentation](https://docs.chipipay.com).
24
+
25
+ ## Support
26
+
27
+ You can get in touch with us in any of the following ways:
28
+
29
+ - Join our [Telegram community](https://t.me/chipi_pay)
30
+ - Visit our [YouTube channel](https://www.youtube.com/@chipipay) for tutorials
31
+ - Email us at support@chipi.com
32
+
33
+ ## Contributing
34
+
35
+ We're open to all community contributions! If you'd like to contribute in any way, please read our contribution guidelines and code of conduct.
36
+
37
+ ## Security
38
+
39
+ @chipi-stack/chipi-react follows best practices for security, but 100% security cannot be assured.
40
+
41
+ @chipi-stack/chipi-react is provided "as is" without any warranty. Use at your own risk.
42
+
43
+ For more information and to report security issues, please refer to our [security documentation](https://docs.chipipay.com).
package/dist/hooks.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { CreateWalletParams, CreateWalletResponse, GetWalletParams, WalletDataResponse, TransferParams, ApproveParams, ExecuteTransactionParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, RecordSendTransactionParams, Transaction } from '@chipi-stack/types';
1
+ import { CreateWalletParams, CreateWalletResponse, GetWalletParams, WalletData, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, RecordSendTransactionParams, Transaction } from '@chipi-stack/types';
2
2
 
3
3
  type CreateWalletInput = {
4
- params: Omit<CreateWalletParams, "nodeUrl">;
4
+ params: CreateWalletParams;
5
5
  bearerToken: string;
6
6
  };
7
7
  /**
@@ -20,8 +20,8 @@ declare function useCreateWallet(): {
20
20
 
21
21
  declare function useGetWallet(): {
22
22
  getWallet: (params: GetWalletParams) => void;
23
- getWalletAsync: (params: GetWalletParams) => Promise<WalletDataResponse>;
24
- data: WalletDataResponse | undefined;
23
+ getWalletAsync: (params: GetWalletParams) => Promise<WalletData>;
24
+ data: WalletData | undefined;
25
25
  isLoading: boolean;
26
26
  isError: boolean;
27
27
  error: Error | null;
@@ -47,7 +47,10 @@ declare function useTransfer(): {
47
47
  reset: () => void;
48
48
  };
49
49
 
50
- type ApproveInput = Omit<ApproveParams, 'apiPublicKey'>;
50
+ type ApproveInput = {
51
+ params: ApproveParams;
52
+ bearerToken: string;
53
+ };
51
54
  /**
52
55
  * Hook for approving token spending
53
56
  */
@@ -62,22 +65,10 @@ declare function useApprove(): {
62
65
  reset: () => void;
63
66
  };
64
67
 
65
- type ExecuteTransactionInput = Omit<ExecuteTransactionParams, 'apiPublicKey'>;
66
- /**
67
- * Hook for executing gasless transactions
68
- */
69
- declare function useExecuteTransaction(): {
70
- executeTransaction: (params: ExecuteTransactionInput) => void;
71
- executeTransactionAsync: (params: ExecuteTransactionInput) => Promise<string>;
72
- data: string | undefined;
73
- isLoading: boolean;
74
- isError: boolean;
75
- error: Error | null;
76
- isSuccess: boolean;
77
- reset: () => void;
68
+ type StakeVesuUsdcInput = {
69
+ params: StakeVesuUsdcParams;
70
+ bearerToken: string;
78
71
  };
79
-
80
- type StakeVesuUsdcInput = Omit<StakeVesuUsdcParams, 'apiPublicKey'>;
81
72
  /**
82
73
  * Hook for staking USDC in Vesu protocol
83
74
  */
@@ -92,7 +83,10 @@ declare function useStakeVesuUsdc(): {
92
83
  reset: () => void;
93
84
  };
94
85
 
95
- type WithdrawVesuUsdcInput = Omit<WithdrawVesuUsdcParams, 'apiPublicKey'>;
86
+ type WithdrawVesuUsdcInput = {
87
+ params: WithdrawVesuUsdcParams;
88
+ bearerToken: string;
89
+ };
96
90
  /**
97
91
  * Hook for withdrawing USDC from Vesu protocol
98
92
  */
@@ -107,7 +101,10 @@ declare function useWithdrawVesuUsdc(): {
107
101
  reset: () => void;
108
102
  };
109
103
 
110
- type CallAnyContractInput = Omit<CallAnyContractParams, 'apiPublicKey'>;
104
+ type CallAnyContractInput = {
105
+ params: CallAnyContractParams;
106
+ bearerToken: string;
107
+ };
111
108
  /**
112
109
  * Hook for calling any contract method
113
110
  */
@@ -137,4 +134,4 @@ declare function useRecordSendTransaction(): {
137
134
  reset: () => void;
138
135
  };
139
136
 
140
- export { useApprove, useCallAnyContract, useCreateWallet, useExecuteTransaction, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
137
+ export { useApprove, useCallAnyContract, useCreateWallet, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
package/dist/hooks.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { CreateWalletParams, CreateWalletResponse, GetWalletParams, WalletDataResponse, TransferParams, ApproveParams, ExecuteTransactionParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, RecordSendTransactionParams, Transaction } from '@chipi-stack/types';
1
+ import { CreateWalletParams, CreateWalletResponse, GetWalletParams, WalletData, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, RecordSendTransactionParams, Transaction } from '@chipi-stack/types';
2
2
 
3
3
  type CreateWalletInput = {
4
- params: Omit<CreateWalletParams, "nodeUrl">;
4
+ params: CreateWalletParams;
5
5
  bearerToken: string;
6
6
  };
7
7
  /**
@@ -20,8 +20,8 @@ declare function useCreateWallet(): {
20
20
 
21
21
  declare function useGetWallet(): {
22
22
  getWallet: (params: GetWalletParams) => void;
23
- getWalletAsync: (params: GetWalletParams) => Promise<WalletDataResponse>;
24
- data: WalletDataResponse | undefined;
23
+ getWalletAsync: (params: GetWalletParams) => Promise<WalletData>;
24
+ data: WalletData | undefined;
25
25
  isLoading: boolean;
26
26
  isError: boolean;
27
27
  error: Error | null;
@@ -47,7 +47,10 @@ declare function useTransfer(): {
47
47
  reset: () => void;
48
48
  };
49
49
 
50
- type ApproveInput = Omit<ApproveParams, 'apiPublicKey'>;
50
+ type ApproveInput = {
51
+ params: ApproveParams;
52
+ bearerToken: string;
53
+ };
51
54
  /**
52
55
  * Hook for approving token spending
53
56
  */
@@ -62,22 +65,10 @@ declare function useApprove(): {
62
65
  reset: () => void;
63
66
  };
64
67
 
65
- type ExecuteTransactionInput = Omit<ExecuteTransactionParams, 'apiPublicKey'>;
66
- /**
67
- * Hook for executing gasless transactions
68
- */
69
- declare function useExecuteTransaction(): {
70
- executeTransaction: (params: ExecuteTransactionInput) => void;
71
- executeTransactionAsync: (params: ExecuteTransactionInput) => Promise<string>;
72
- data: string | undefined;
73
- isLoading: boolean;
74
- isError: boolean;
75
- error: Error | null;
76
- isSuccess: boolean;
77
- reset: () => void;
68
+ type StakeVesuUsdcInput = {
69
+ params: StakeVesuUsdcParams;
70
+ bearerToken: string;
78
71
  };
79
-
80
- type StakeVesuUsdcInput = Omit<StakeVesuUsdcParams, 'apiPublicKey'>;
81
72
  /**
82
73
  * Hook for staking USDC in Vesu protocol
83
74
  */
@@ -92,7 +83,10 @@ declare function useStakeVesuUsdc(): {
92
83
  reset: () => void;
93
84
  };
94
85
 
95
- type WithdrawVesuUsdcInput = Omit<WithdrawVesuUsdcParams, 'apiPublicKey'>;
86
+ type WithdrawVesuUsdcInput = {
87
+ params: WithdrawVesuUsdcParams;
88
+ bearerToken: string;
89
+ };
96
90
  /**
97
91
  * Hook for withdrawing USDC from Vesu protocol
98
92
  */
@@ -107,7 +101,10 @@ declare function useWithdrawVesuUsdc(): {
107
101
  reset: () => void;
108
102
  };
109
103
 
110
- type CallAnyContractInput = Omit<CallAnyContractParams, 'apiPublicKey'>;
104
+ type CallAnyContractInput = {
105
+ params: CallAnyContractParams;
106
+ bearerToken: string;
107
+ };
111
108
  /**
112
109
  * Hook for calling any contract method
113
110
  */
@@ -137,4 +134,4 @@ declare function useRecordSendTransaction(): {
137
134
  reset: () => void;
138
135
  };
139
136
 
140
- export { useApprove, useCallAnyContract, useCreateWallet, useExecuteTransaction, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
137
+ export { useApprove, useCallAnyContract, useCreateWallet, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
package/dist/hooks.js CHANGED
@@ -113,22 +113,6 @@ function useApprove() {
113
113
  reset: mutation.reset
114
114
  };
115
115
  }
116
- function useExecuteTransaction() {
117
- const { chipiSDK } = useChipiContext();
118
- const mutation = reactQuery.useMutation({
119
- mutationFn: (params) => chipiSDK.executeTransaction(params)
120
- });
121
- return {
122
- executeTransaction: mutation.mutate,
123
- executeTransactionAsync: mutation.mutateAsync,
124
- data: mutation.data,
125
- isLoading: mutation.isPending,
126
- isError: mutation.isError,
127
- error: mutation.error,
128
- isSuccess: mutation.isSuccess,
129
- reset: mutation.reset
130
- };
131
- }
132
116
  function useStakeVesuUsdc() {
133
117
  const { chipiSDK } = useChipiContext();
134
118
  const mutation = reactQuery.useMutation({
@@ -200,7 +184,6 @@ function useRecordSendTransaction() {
200
184
  exports.useApprove = useApprove;
201
185
  exports.useCallAnyContract = useCallAnyContract;
202
186
  exports.useCreateWallet = useCreateWallet;
203
- exports.useExecuteTransaction = useExecuteTransaction;
204
187
  exports.useGetWallet = useGetWallet;
205
188
  exports.useRecordSendTransaction = useRecordSendTransaction;
206
189
  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/useExecuteTransaction.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":";;;;;;;;AASA,IAAM,YAAA,GAAeA,oBAAwC,IAAI,CAAA;AA6B1D,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;;;AC/BO,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;ACzCA,IAAM,SAAA,GAAY,CAAC,cAAA,KAA2B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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 { 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/**\n * Provider component that wraps your app and provides Chipi SDK context\n */\nexport function ChipiProvider({ children, config }: ChipiProviderProps) {\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 <ChipiContext.Provider value={value}>{children}</ChipiContext.Provider>\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: Omit<CreateWalletParams, \"nodeUrl\">;\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","\n\"use client\";\n\nimport { useState } from \"react\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { GetWalletParams, WalletDataResponse } from \"@chipi-stack/types\";\nimport { useChipiContext } from \"../context\";\n\n\n\nconst walletKey = (externalUserId: string) => [\"wallet\", externalUserId] as const;\n\nexport function useGetWallet(): {\n getWallet: (params: GetWalletParams) => void;\n getWalletAsync: (params: GetWalletParams) => Promise<WalletDataResponse>;\n data: WalletDataResponse | 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\n const [params, setParams] = useState<GetWalletParams | null>(null);\n\n const query: UseQueryResult<WalletDataResponse, 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\n const getWalletAsync = (walletParams: GetWalletParams): Promise<WalletDataResponse> => {\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: () => { if (params) void query.refetch(); },\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 = Omit<ApproveParams, 'apiPublicKey'>;\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 { ExecuteTransactionParams } from '@chipi-stack/types';\n\ntype ExecuteTransactionInput = Omit<ExecuteTransactionParams, 'apiPublicKey'>;\n\n/**\n * Hook for executing gasless transactions\n */\nexport function useExecuteTransaction(): {\n executeTransaction: (params: ExecuteTransactionInput) => void;\n executeTransactionAsync: (params: ExecuteTransactionInput) => 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, ExecuteTransactionInput> = useMutation({\n mutationFn: (params: ExecuteTransactionInput) => chipiSDK.executeTransaction(params),\n });\n\n return {\n executeTransaction: mutation.mutate,\n executeTransactionAsync: 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 = Omit<StakeVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: StakeVesuUsdcInput) => 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 = Omit<WithdrawVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: WithdrawVesuUsdcInput) => 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 = Omit<CallAnyContractParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: CallAnyContractInput) => 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"],"names":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CAAS,OAAA;AAAA,IAClB,OAAO,QAAA,CAAS,KAAA;AAAA,IAChB,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"]}
package/dist/hooks.mjs CHANGED
@@ -111,22 +111,6 @@ function useApprove() {
111
111
  reset: mutation.reset
112
112
  };
113
113
  }
114
- function useExecuteTransaction() {
115
- const { chipiSDK } = useChipiContext();
116
- const mutation = useMutation({
117
- mutationFn: (params) => chipiSDK.executeTransaction(params)
118
- });
119
- return {
120
- executeTransaction: mutation.mutate,
121
- executeTransactionAsync: mutation.mutateAsync,
122
- data: mutation.data,
123
- isLoading: mutation.isPending,
124
- isError: mutation.isError,
125
- error: mutation.error,
126
- isSuccess: mutation.isSuccess,
127
- reset: mutation.reset
128
- };
129
- }
130
114
  function useStakeVesuUsdc() {
131
115
  const { chipiSDK } = useChipiContext();
132
116
  const mutation = useMutation({
@@ -195,6 +179,6 @@ function useRecordSendTransaction() {
195
179
  };
196
180
  }
197
181
 
198
- export { useApprove, useCallAnyContract, useCreateWallet, useExecuteTransaction, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
182
+ export { useApprove, useCallAnyContract, useCreateWallet, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
199
183
  //# sourceMappingURL=hooks.mjs.map
200
184
  //# sourceMappingURL=hooks.mjs.map
@@ -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/useExecuteTransaction.ts","../src/hooks/useStakeVesuUsdc.ts","../src/hooks/useWithdrawVesuUsdc.ts","../src/hooks/useCallAnyContract.ts","../src/hooks/useRecordSendTransaction.ts"],"names":["useMutation"],"mappings":";;;;;;AASA,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AA6B1D,SAAS,eAAA,GAAqC;AACnD,EAAA,MAAM,OAAA,GAAU,WAAW,YAAY,CAAA;AAEvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AAEA,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Y,CAAC,MAAA,KAAiC,QAAA,CAAS,gBAAgB,MAAM;AAAA,GAC9E,CAAA;AAED,EAAA,OAAO;AAAA,IACL,iBAAiB,QAAA,CAAS,MAAA;AAAA,IAC1B,sBAAsB,QAAA,CAAS,WAAA;AAAA,IAC/B,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;ACvBO,SAAS,wBAAA,GAWd;AACA,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,eAAA,EAAgB;AAErC,EAAA,MAAM,WAIFA,WAAAA,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.mjs","sourcesContent":["import React, { createContext, useContext, ReactNode } from \"react\";\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/**\n * Provider component that wraps your app and provides Chipi SDK context\n */\nexport function ChipiProvider({ children, config }: ChipiProviderProps) {\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 <ChipiContext.Provider value={value}>{children}</ChipiContext.Provider>\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: Omit<CreateWalletParams, \"nodeUrl\">;\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","\n\"use client\";\n\nimport { useState } from \"react\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { GetWalletParams, WalletDataResponse } from \"@chipi-stack/types\";\nimport { useChipiContext } from \"../context\";\n\n\n\nconst walletKey = (externalUserId: string) => [\"wallet\", externalUserId] as const;\n\nexport function useGetWallet(): {\n getWallet: (params: GetWalletParams) => void;\n getWalletAsync: (params: GetWalletParams) => Promise<WalletDataResponse>;\n data: WalletDataResponse | 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\n const [params, setParams] = useState<GetWalletParams | null>(null);\n\n const query: UseQueryResult<WalletDataResponse, 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\n const getWalletAsync = (walletParams: GetWalletParams): Promise<WalletDataResponse> => {\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: () => { if (params) void query.refetch(); },\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 = Omit<ApproveParams, 'apiPublicKey'>;\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 { ExecuteTransactionParams } from '@chipi-stack/types';\n\ntype ExecuteTransactionInput = Omit<ExecuteTransactionParams, 'apiPublicKey'>;\n\n/**\n * Hook for executing gasless transactions\n */\nexport function useExecuteTransaction(): {\n executeTransaction: (params: ExecuteTransactionInput) => void;\n executeTransactionAsync: (params: ExecuteTransactionInput) => 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, ExecuteTransactionInput> = useMutation({\n mutationFn: (params: ExecuteTransactionInput) => chipiSDK.executeTransaction(params),\n });\n\n return {\n executeTransaction: mutation.mutate,\n executeTransactionAsync: 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 = Omit<StakeVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: StakeVesuUsdcInput) => 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 = Omit<WithdrawVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: WithdrawVesuUsdcInput) => 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 = Omit<CallAnyContractParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: CallAnyContractInput) => 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"],"names":["useMutation"],"mappings":";;;;;;AAUA,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AAuD1D,SAAS,eAAA,GAAqC;AACnD,EAAA,MAAM,OAAA,GAAU,WAAW,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,WAIF,WAAA,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,C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QAAA,CAAS,KAAA;AAAA,IAChB,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,OAAO,QAAA,CAAS;AAAA,GAClB;AACF","file":"hooks.mjs","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"]}
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
3
3
  import { ChipiSDK } from '@chipi-stack/backend';
4
4
  import { ChipiSDKConfig } from '@chipi-stack/types';
5
5
  export * from '@chipi-stack/types';
6
- export { useApprove, useCallAnyContract, useCreateWallet, useExecuteTransaction, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from './hooks.mjs';
6
+ export { useApprove, useCallAnyContract, useCreateWallet, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from './hooks.mjs';
7
7
 
8
8
  interface ChipiContextValue {
9
9
  chipiSDK: ChipiSDK;
@@ -14,7 +14,7 @@ interface ChipiProviderProps {
14
14
  config: ChipiSDKConfig;
15
15
  }
16
16
  /**
17
- * Provider component that wraps your app and provides Chipi SDK context
17
+ * Provider component that wraps your app and provides Chipi SDK context with QueryClient
18
18
  */
19
19
  declare function ChipiProvider({ children, config }: ChipiProviderProps): react_jsx_runtime.JSX.Element;
20
20
  /**
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
3
3
  import { ChipiSDK } from '@chipi-stack/backend';
4
4
  import { ChipiSDKConfig } from '@chipi-stack/types';
5
5
  export * from '@chipi-stack/types';
6
- export { useApprove, useCallAnyContract, useCreateWallet, useExecuteTransaction, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from './hooks.js';
6
+ export { useApprove, useCallAnyContract, useCreateWallet, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from './hooks.js';
7
7
 
8
8
  interface ChipiContextValue {
9
9
  chipiSDK: ChipiSDK;
@@ -14,7 +14,7 @@ interface ChipiProviderProps {
14
14
  config: ChipiSDKConfig;
15
15
  }
16
16
  /**
17
- * Provider component that wraps your app and provides Chipi SDK context
17
+ * Provider component that wraps your app and provides Chipi SDK context with QueryClient
18
18
  */
19
19
  declare function ChipiProvider({ children, config }: ChipiProviderProps): react_jsx_runtime.JSX.Element;
20
20
  /**
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var reactQuery = require('@tanstack/react-query');
4
5
  var backend = require('@chipi-stack/backend');
5
6
  var jsxRuntime = require('react/jsx-runtime');
6
- var reactQuery = require('@tanstack/react-query');
7
7
 
8
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
 
@@ -11,7 +11,27 @@ var React__default = /*#__PURE__*/_interopDefault(React);
11
11
 
12
12
  // src/context/ChipiProvider.tsx
13
13
  var ChipiContext = React.createContext(null);
14
+ var createDefaultQueryClient = () => new reactQuery.QueryClient({
15
+ defaultOptions: {
16
+ queries: {
17
+ staleTime: 60 * 1e3,
18
+ // 1 minute
19
+ gcTime: 10 * 60 * 1e3,
20
+ // 10 minutes (formerly cacheTime)
21
+ retry: (failureCount, error) => {
22
+ if (error?.status >= 400 && error?.status < 500) {
23
+ return false;
24
+ }
25
+ return failureCount < 3;
26
+ }
27
+ },
28
+ mutations: {
29
+ retry: false
30
+ }
31
+ }
32
+ });
14
33
  function ChipiProvider({ children, config }) {
34
+ const queryClient = React__default.default.useMemo(() => createDefaultQueryClient(), []);
15
35
  const chipiSDK = React__default.default.useMemo(() => new backend.ChipiSDK(config), [config]);
16
36
  const value = React__default.default.useMemo(
17
37
  () => ({
@@ -20,7 +40,7 @@ function ChipiProvider({ children, config }) {
20
40
  }),
21
41
  [chipiSDK, config]
22
42
  );
23
- return /* @__PURE__ */ jsxRuntime.jsx(ChipiContext.Provider, { value, children });
43
+ return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsxRuntime.jsx(ChipiContext.Provider, { value, children }) });
24
44
  }
25
45
  function useChipiContext() {
26
46
  const context = React.useContext(ChipiContext);
@@ -126,22 +146,6 @@ function useApprove() {
126
146
  reset: mutation.reset
127
147
  };
128
148
  }
129
- function useExecuteTransaction() {
130
- const { chipiSDK } = useChipiContext();
131
- const mutation = reactQuery.useMutation({
132
- mutationFn: (params) => chipiSDK.executeTransaction(params)
133
- });
134
- return {
135
- executeTransaction: mutation.mutate,
136
- executeTransactionAsync: mutation.mutateAsync,
137
- data: mutation.data,
138
- isLoading: mutation.isPending,
139
- isError: mutation.isError,
140
- error: mutation.error,
141
- isSuccess: mutation.isSuccess,
142
- reset: mutation.reset
143
- };
144
- }
145
149
  function useStakeVesuUsdc() {
146
150
  const { chipiSDK } = useChipiContext();
147
151
  const mutation = reactQuery.useMutation({
@@ -215,7 +219,6 @@ exports.useApprove = useApprove;
215
219
  exports.useCallAnyContract = useCallAnyContract;
216
220
  exports.useChipiContext = useChipiContext;
217
221
  exports.useCreateWallet = useCreateWallet;
218
- exports.useExecuteTransaction = useExecuteTransaction;
219
222
  exports.useGetWallet = useGetWallet;
220
223
  exports.useRecordSendTransaction = useRecordSendTransaction;
221
224
  exports.useStakeVesuUsdc = useStakeVesuUsdc;
package/dist/index.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/useExecuteTransaction.ts","../src/hooks/useStakeVesuUsdc.ts","../src/hooks/useWithdrawVesuUsdc.ts","../src/hooks/useCallAnyContract.ts","../src/hooks/useRecordSendTransaction.ts"],"names":["createContext","React","ChipiSDK","jsx","useContext","useMutation","useQueryClient","useState","useQuery"],"mappings":";;;;;;;;;;;;AASA,IAAM,YAAA,GAAeA,oBAAwC,IAAI,CAAA;AAU1D,SAAS,aAAA,CAAc,EAAE,QAAA,EAAU,MAAA,EAAO,EAAuB;AACtE,EAAA,MAAM,QAAA,GAAWC,sBAAA,CAAM,OAAA,CAAQ,MAAM,IAAIC,iBAAS,MAAM,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEnE,EAAA,MAAM,QAAQD,sBAAA,CAAM,OAAA;AAAA,IAClB,OAAO;AAAA,MACL,QAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,UAAU,MAAM;AAAA,GACnB;AAEA,EAAA,uBACEE,cAAA,CAAC,YAAA,CAAa,QAAA,EAAb,EAAsB,OAAe,QAAA,EAAS,CAAA;AAEnD;AAKO,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;AC/BO,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,MA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S,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;ACvBO,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":"index.js","sourcesContent":["import React, { createContext, useContext, ReactNode } from \"react\";\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/**\n * Provider component that wraps your app and provides Chipi SDK context\n */\nexport function ChipiProvider({ children, config }: ChipiProviderProps) {\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 <ChipiContext.Provider value={value}>{children}</ChipiContext.Provider>\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: Omit<CreateWalletParams, \"nodeUrl\">;\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","\n\"use client\";\n\nimport { useState } from \"react\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { GetWalletParams, WalletDataResponse } from \"@chipi-stack/types\";\nimport { useChipiContext } from \"../context\";\n\n\n\nconst walletKey = (externalUserId: string) => [\"wallet\", externalUserId] as const;\n\nexport function useGetWallet(): {\n getWallet: (params: GetWalletParams) => void;\n getWalletAsync: (params: GetWalletParams) => Promise<WalletDataResponse>;\n data: WalletDataResponse | 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\n const [params, setParams] = useState<GetWalletParams | null>(null);\n\n const query: UseQueryResult<WalletDataResponse, 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\n const getWalletAsync = (walletParams: GetWalletParams): Promise<WalletDataResponse> => {\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: () => { if (params) void query.refetch(); },\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 = Omit<ApproveParams, 'apiPublicKey'>;\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 { ExecuteTransactionParams } from '@chipi-stack/types';\n\ntype ExecuteTransactionInput = Omit<ExecuteTransactionParams, 'apiPublicKey'>;\n\n/**\n * Hook for executing gasless transactions\n */\nexport function useExecuteTransaction(): {\n executeTransaction: (params: ExecuteTransactionInput) => void;\n executeTransactionAsync: (params: ExecuteTransactionInput) => 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, ExecuteTransactionInput> = useMutation({\n mutationFn: (params: ExecuteTransactionInput) => chipiSDK.executeTransaction(params),\n });\n\n return {\n executeTransaction: mutation.mutate,\n executeTransactionAsync: 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 = Omit<StakeVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: StakeVesuUsdcInput) => 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 = Omit<WithdrawVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: WithdrawVesuUsdcInput) => 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 = Omit<CallAnyContractParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: CallAnyContractInput) => 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"],"names":["createContext","QueryClient","React","ChipiSDK","jsx","QueryClientProvider","useContext","useMutation","useQueryClient","useState","useQuery"],"mappings":";;;;;;;;;;;;AAUA,IAAM,YAAA,GAAeA,oBAAwC,IAAI,CAAA;AAQjE,IAAM,wBAAA,GAA2B,MAC/B,IAAIC,sBAAA,CAAY;AAAA,EACd,cAAA,EAAgB;AAAA,IACd,OAAA,EAAS;AAAA,MACP,WAAW,EAAA,GAAK,GAAA;AAAA;AAAA,MAChB,MAAA,EAAQ,KAAK,EAAA,GAAK,GAAA;AAAA;AAAA,MAClB,KAAA,EAAO,CAAC,YAAA,EAAc,KAAA,KAAe;AAEnC,QAAA,IAAI,KAAA,EAAO,MAAA,IAAU,GAAA,IAAO,KAAA,EAAO,SAAS,GAAA,EAAK;AAC/C,UAAA,OAAO,KAAA;AAAA,QACT;AACA,QAAA,OAAO,YAAA,GAAe,CAAA;AAAA,MACxB;AAAA,KACF;AAAA,IACA,SAAA,EAAW;AAAA,MACT,KAAA,EAAO;AAAA;AACT;AAEJ,CAAC,CAAA;AAKI,SAAS,aAAA,CAAc,EAAE,QAAA,EAAU,MAAA,EAAO,EAAuB;AAEtE,EAAA,MAAM,cAAcC,sBAAA,CAAM,OAAA,CAAQ,MAAM,wBAAA,EAAyB,EAAG,EAAE,CAAA;AAEtE,EAAA,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,GAAI,eAAA,EAAgB;AAErC,EAAA,MAAM,WACJA,sBAAAA,CAAY;AAAA,IACV,UAAA,EAAY,CAAC,MAAA,KACX,QAAA,CAAS,gBAAgB,MAAM;AAAA,GAClC,CAAA;AAEH,EAAA,OAAO;AAAA,IACL,iBAAiB,QAAA,CAAS,MAAA;AAAA,IAC1B,sBAAsB,QAAA,CAAS,WAAA;AAAA,IAC/B,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;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":"index.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"]}
package/dist/index.mjs CHANGED
@@ -1,11 +1,31 @@
1
1
  import React, { createContext, useContext, useState } from 'react';
2
+ import { QueryClient, QueryClientProvider, useMutation, useQueryClient, useQuery } from '@tanstack/react-query';
2
3
  import { ChipiSDK } from '@chipi-stack/backend';
3
4
  import { jsx } from 'react/jsx-runtime';
4
- import { useMutation, useQueryClient, useQuery } from '@tanstack/react-query';
5
5
 
6
6
  // src/context/ChipiProvider.tsx
7
7
  var ChipiContext = createContext(null);
8
+ var createDefaultQueryClient = () => new QueryClient({
9
+ defaultOptions: {
10
+ queries: {
11
+ staleTime: 60 * 1e3,
12
+ // 1 minute
13
+ gcTime: 10 * 60 * 1e3,
14
+ // 10 minutes (formerly cacheTime)
15
+ retry: (failureCount, error) => {
16
+ if (error?.status >= 400 && error?.status < 500) {
17
+ return false;
18
+ }
19
+ return failureCount < 3;
20
+ }
21
+ },
22
+ mutations: {
23
+ retry: false
24
+ }
25
+ }
26
+ });
8
27
  function ChipiProvider({ children, config }) {
28
+ const queryClient = React.useMemo(() => createDefaultQueryClient(), []);
9
29
  const chipiSDK = React.useMemo(() => new ChipiSDK(config), [config]);
10
30
  const value = React.useMemo(
11
31
  () => ({
@@ -14,7 +34,7 @@ function ChipiProvider({ children, config }) {
14
34
  }),
15
35
  [chipiSDK, config]
16
36
  );
17
- return /* @__PURE__ */ jsx(ChipiContext.Provider, { value, children });
37
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(ChipiContext.Provider, { value, children }) });
18
38
  }
19
39
  function useChipiContext() {
20
40
  const context = useContext(ChipiContext);
@@ -120,22 +140,6 @@ function useApprove() {
120
140
  reset: mutation.reset
121
141
  };
122
142
  }
123
- function useExecuteTransaction() {
124
- const { chipiSDK } = useChipiContext();
125
- const mutation = useMutation({
126
- mutationFn: (params) => chipiSDK.executeTransaction(params)
127
- });
128
- return {
129
- executeTransaction: mutation.mutate,
130
- executeTransactionAsync: mutation.mutateAsync,
131
- data: mutation.data,
132
- isLoading: mutation.isPending,
133
- isError: mutation.isError,
134
- error: mutation.error,
135
- isSuccess: mutation.isSuccess,
136
- reset: mutation.reset
137
- };
138
- }
139
143
  function useStakeVesuUsdc() {
140
144
  const { chipiSDK } = useChipiContext();
141
145
  const mutation = useMutation({
@@ -204,6 +208,6 @@ function useRecordSendTransaction() {
204
208
  };
205
209
  }
206
210
 
207
- export { ChipiProvider, useApprove, useCallAnyContract, useChipiContext, useCreateWallet, useExecuteTransaction, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
211
+ export { ChipiProvider, useApprove, useCallAnyContract, useChipiContext, useCreateWallet, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
208
212
  //# sourceMappingURL=index.mjs.map
209
213
  //# sourceMappingURL=index.mjs.map
@@ -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/useExecuteTransaction.ts","../src/hooks/useStakeVesuUsdc.ts","../src/hooks/useWithdrawVesuUsdc.ts","../src/hooks/useCallAnyContract.ts","../src/hooks/useRecordSendTransaction.ts"],"names":["useMutation"],"mappings":";;;;;;AASA,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AAU1D,SAAS,aAAA,CAAc,EAAE,QAAA,EAAU,MAAA,EAAO,EAAuB;AACtE,EAAA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AS,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":"index.mjs","sourcesContent":["import React, { createContext, useContext, ReactNode } from \"react\";\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/**\n * Provider component that wraps your app and provides Chipi SDK context\n */\nexport function ChipiProvider({ children, config }: ChipiProviderProps) {\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 <ChipiContext.Provider value={value}>{children}</ChipiContext.Provider>\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: Omit<CreateWalletParams, \"nodeUrl\">;\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","\n\"use client\";\n\nimport { useState } from \"react\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { GetWalletParams, WalletDataResponse } from \"@chipi-stack/types\";\nimport { useChipiContext } from \"../context\";\n\n\n\nconst walletKey = (externalUserId: string) => [\"wallet\", externalUserId] as const;\n\nexport function useGetWallet(): {\n getWallet: (params: GetWalletParams) => void;\n getWalletAsync: (params: GetWalletParams) => Promise<WalletDataResponse>;\n data: WalletDataResponse | 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\n const [params, setParams] = useState<GetWalletParams | null>(null);\n\n const query: UseQueryResult<WalletDataResponse, 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\n const getWalletAsync = (walletParams: GetWalletParams): Promise<WalletDataResponse> => {\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: () => { if (params) void query.refetch(); },\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 = Omit<ApproveParams, 'apiPublicKey'>;\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 { ExecuteTransactionParams } from '@chipi-stack/types';\n\ntype ExecuteTransactionInput = Omit<ExecuteTransactionParams, 'apiPublicKey'>;\n\n/**\n * Hook for executing gasless transactions\n */\nexport function useExecuteTransaction(): {\n executeTransaction: (params: ExecuteTransactionInput) => void;\n executeTransactionAsync: (params: ExecuteTransactionInput) => 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, ExecuteTransactionInput> = useMutation({\n mutationFn: (params: ExecuteTransactionInput) => chipiSDK.executeTransaction(params),\n });\n\n return {\n executeTransaction: mutation.mutate,\n executeTransactionAsync: 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 = Omit<StakeVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: StakeVesuUsdcInput) => 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 = Omit<WithdrawVesuUsdcParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: WithdrawVesuUsdcInput) => 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 = Omit<CallAnyContractParams, 'apiPublicKey'>;\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> = useMutation({\n mutationFn: (params: CallAnyContractInput) => 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"],"names":["useMutation"],"mappings":";;;;;;AAUA,IAAM,YAAA,GAAe,cAAwC,IAAI,CAAA;AAQ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ACd,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":"index.mjs","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipi-stack/chipi-react",
3
- "version": "9.0.0",
3
+ "version": "11.0.0",
4
4
  "description": "React hooks and components for Chipi SDK",
5
5
  "keywords": [
6
6
  "chipi",
@@ -74,9 +74,9 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@tanstack/react-query": "^5.85.0",
77
- "@chipi-stack/backend": "^9.0.0",
78
- "@chipi-stack/types": "^9.0.0",
79
- "@chipi-stack/shared": "^9.0.0"
77
+ "@chipi-stack/backend": "^11.0.0",
78
+ "@chipi-stack/shared": "^11.0.0",
79
+ "@chipi-stack/types": "^11.0.0"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "react": ">=16.8.0",