@chipi-stack/chipi-react 13.13.0 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +51 -33
- package/dist/hooks.d.mts +460 -11
- package/dist/hooks.d.ts +460 -11
- package/dist/hooks.js +456 -115
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +456 -118
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +457 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +457 -123
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Chipi Pay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,43 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @chipi-stack/chipi-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React hooks for Chipi Pay. Provides wallet creation, transfers, SKU purchases, and session management.
|
|
4
4
|
|
|
5
|
-
##
|
|
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).
|
|
5
|
+
## Install
|
|
14
6
|
|
|
15
7
|
```bash
|
|
16
|
-
npm install @chipi-stack/chipi-react
|
|
17
|
-
# or
|
|
18
|
-
yarn add @chipi-stack/chipi-react
|
|
8
|
+
npm install @chipi-stack/chipi-react @chipi-stack/backend @chipi-stack/types
|
|
19
9
|
```
|
|
20
10
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { ChipiProvider, useChipiWallet, useTransfer } from "@chipi-stack/chipi-react";
|
|
15
|
+
import type { ChainToken } from "@chipi-stack/types";
|
|
16
|
+
|
|
17
|
+
function App() {
|
|
18
|
+
return (
|
|
19
|
+
<ChipiProvider config={{ apiPublicKey: "your-key" }}>
|
|
20
|
+
<Wallet />
|
|
21
|
+
</ChipiProvider>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function Wallet() {
|
|
26
|
+
const { wallet } = useChipiWallet({
|
|
27
|
+
externalUserId: "user-123",
|
|
28
|
+
getBearerToken: async () => "your-bearer-token",
|
|
29
|
+
});
|
|
30
|
+
const { transfer, isLoading } = useTransfer();
|
|
31
|
+
|
|
32
|
+
if (!wallet) return <p>Loading wallet...</p>;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<button
|
|
36
|
+
onClick={() =>
|
|
37
|
+
transfer({
|
|
38
|
+
params: {
|
|
39
|
+
wallet,
|
|
40
|
+
token: "USDC" as ChainToken,
|
|
41
|
+
recipient: "0x...",
|
|
42
|
+
amount: 10,
|
|
43
|
+
encryptKey: "user-pin",
|
|
44
|
+
},
|
|
45
|
+
bearerToken: "your-bearer-token",
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
{isLoading ? "Sending..." : "Send 10 USDC"}
|
|
50
|
+
</button>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
36
54
|
|
|
37
|
-
##
|
|
55
|
+
## Documentation
|
|
38
56
|
|
|
39
|
-
|
|
57
|
+
Full docs at [docs.chipipay.com](https://docs.chipipay.com)
|
|
40
58
|
|
|
41
|
-
|
|
59
|
+
## License
|
|
42
60
|
|
|
43
|
-
|
|
61
|
+
MIT
|
package/dist/hooks.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateWalletParams, CreateWalletResponse, GetWalletParams, GetWalletResponse, ChainToken, GetTokenBalanceResponse, WalletType, WalletData, SessionKeyData, SessionDataResponse, CreateSessionKeyParams, SessionConfig, Call, MigrateWalletToPasskeyParams, UpdateWalletEncryptionParams, UpdateWalletEncryptionResponse, TransferHookInput, ApproveHookInput, GetTransactionListQuery, PaginatedResponse, Transaction, CreateSkuPurchaseParams, GetSkuListQuery, Sku, CallAnyContractParams, RecordSendTransactionParams, GetTokenBalanceParams, AddSessionKeyParams, RevokeSessionKeyParams, GetSessionDataParams, ExecuteWithSessionParams } from '@chipi-stack/types';
|
|
1
|
+
import { CreateWalletParams, CreateWalletResponse, GetWalletParams, GetWalletResponse, ChainToken, GetTokenBalanceResponse, WalletType, WalletData, SessionKeyData, SessionDataResponse, CreateSessionKeyParams, SessionConfig, Call, MigrateWalletToPasskeyParams, UpdateWalletEncryptionParams, UpdateWalletEncryptionResponse, TransferHookInput, ApproveHookInput, GetTransactionListQuery, PaginatedResponse, Transaction, TransactionStatusResponse, CreateSkuPurchaseParams, GetSkuListQuery, Sku, CallAnyContractParams, RecordSendTransactionParams, GetTokenBalanceParams, AddSessionKeyParams, RevokeSessionKeyParams, GetSessionDataParams, ExecuteWithSessionParams, PaymentRequirement, PaymentPayload } from '@chipi-stack/types';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -524,10 +524,14 @@ declare function useApprove(): {
|
|
|
524
524
|
type TransactionListInput = {
|
|
525
525
|
query: GetTransactionListQuery;
|
|
526
526
|
getBearerToken?: () => Promise<string | null | undefined>;
|
|
527
|
-
queryOptions?: Omit<UseQueryOptions<PaginatedResponse<Transaction>, Error>,
|
|
527
|
+
queryOptions?: Omit<UseQueryOptions<PaginatedResponse<Transaction>, Error>, "queryKey" | "queryFn">;
|
|
528
|
+
};
|
|
529
|
+
type FetchTransactionListInput = {
|
|
530
|
+
query: GetTransactionListQuery;
|
|
531
|
+
getBearerToken: () => Promise<string | null | undefined>;
|
|
528
532
|
};
|
|
529
533
|
declare function useGetTransactionList(input?: TransactionListInput): {
|
|
530
|
-
fetchTransactionList: (newInput:
|
|
534
|
+
fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
|
|
531
535
|
data: PaginatedResponse<Transaction>;
|
|
532
536
|
error: Error;
|
|
533
537
|
isError: true;
|
|
@@ -555,7 +559,7 @@ declare function useGetTransactionList(input?: TransactionListInput): {
|
|
|
555
559
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
556
560
|
promise: Promise<PaginatedResponse<Transaction>>;
|
|
557
561
|
} | {
|
|
558
|
-
fetchTransactionList: (newInput:
|
|
562
|
+
fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
|
|
559
563
|
data: PaginatedResponse<Transaction>;
|
|
560
564
|
error: null;
|
|
561
565
|
isError: false;
|
|
@@ -583,7 +587,7 @@ declare function useGetTransactionList(input?: TransactionListInput): {
|
|
|
583
587
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
584
588
|
promise: Promise<PaginatedResponse<Transaction>>;
|
|
585
589
|
} | {
|
|
586
|
-
fetchTransactionList: (newInput:
|
|
590
|
+
fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
|
|
587
591
|
data: undefined;
|
|
588
592
|
error: Error;
|
|
589
593
|
isError: true;
|
|
@@ -611,7 +615,7 @@ declare function useGetTransactionList(input?: TransactionListInput): {
|
|
|
611
615
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
612
616
|
promise: Promise<PaginatedResponse<Transaction>>;
|
|
613
617
|
} | {
|
|
614
|
-
fetchTransactionList: (newInput:
|
|
618
|
+
fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
|
|
615
619
|
data: undefined;
|
|
616
620
|
error: null;
|
|
617
621
|
isError: false;
|
|
@@ -639,7 +643,7 @@ declare function useGetTransactionList(input?: TransactionListInput): {
|
|
|
639
643
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
640
644
|
promise: Promise<PaginatedResponse<Transaction>>;
|
|
641
645
|
} | {
|
|
642
|
-
fetchTransactionList: (newInput:
|
|
646
|
+
fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
|
|
643
647
|
data: undefined;
|
|
644
648
|
error: null;
|
|
645
649
|
isError: false;
|
|
@@ -667,7 +671,7 @@ declare function useGetTransactionList(input?: TransactionListInput): {
|
|
|
667
671
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
668
672
|
promise: Promise<PaginatedResponse<Transaction>>;
|
|
669
673
|
} | {
|
|
670
|
-
fetchTransactionList: (newInput:
|
|
674
|
+
fetchTransactionList: (newInput: FetchTransactionListInput) => Promise<PaginatedResponse<Transaction>>;
|
|
671
675
|
data: PaginatedResponse<Transaction>;
|
|
672
676
|
isError: false;
|
|
673
677
|
error: null;
|
|
@@ -696,6 +700,366 @@ declare function useGetTransactionList(input?: TransactionListInput): {
|
|
|
696
700
|
promise: Promise<PaginatedResponse<Transaction>>;
|
|
697
701
|
};
|
|
698
702
|
|
|
703
|
+
type GetTransactionInput = {
|
|
704
|
+
hashOrId?: string;
|
|
705
|
+
getBearerToken?: () => Promise<string | null | undefined>;
|
|
706
|
+
queryOptions?: Omit<UseQueryOptions<Transaction, Error>, "queryKey" | "queryFn">;
|
|
707
|
+
};
|
|
708
|
+
type FetchTransactionInput = {
|
|
709
|
+
hashOrId: string;
|
|
710
|
+
getBearerToken: () => Promise<string | null | undefined>;
|
|
711
|
+
};
|
|
712
|
+
declare function useGetTransaction(input?: GetTransactionInput): {
|
|
713
|
+
fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
|
|
714
|
+
data: Transaction;
|
|
715
|
+
error: Error;
|
|
716
|
+
isError: true;
|
|
717
|
+
isPending: false;
|
|
718
|
+
isLoading: false;
|
|
719
|
+
isLoadingError: false;
|
|
720
|
+
isRefetchError: true;
|
|
721
|
+
isSuccess: false;
|
|
722
|
+
isPlaceholderData: false;
|
|
723
|
+
status: "error";
|
|
724
|
+
dataUpdatedAt: number;
|
|
725
|
+
errorUpdatedAt: number;
|
|
726
|
+
failureCount: number;
|
|
727
|
+
failureReason: Error | null;
|
|
728
|
+
errorUpdateCount: number;
|
|
729
|
+
isFetched: boolean;
|
|
730
|
+
isFetchedAfterMount: boolean;
|
|
731
|
+
isFetching: boolean;
|
|
732
|
+
isInitialLoading: boolean;
|
|
733
|
+
isPaused: boolean;
|
|
734
|
+
isRefetching: boolean;
|
|
735
|
+
isStale: boolean;
|
|
736
|
+
isEnabled: boolean;
|
|
737
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
|
|
738
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
739
|
+
promise: Promise<Transaction>;
|
|
740
|
+
} | {
|
|
741
|
+
fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
|
|
742
|
+
data: Transaction;
|
|
743
|
+
error: null;
|
|
744
|
+
isError: false;
|
|
745
|
+
isPending: false;
|
|
746
|
+
isLoading: false;
|
|
747
|
+
isLoadingError: false;
|
|
748
|
+
isRefetchError: false;
|
|
749
|
+
isSuccess: true;
|
|
750
|
+
isPlaceholderData: false;
|
|
751
|
+
status: "success";
|
|
752
|
+
dataUpdatedAt: number;
|
|
753
|
+
errorUpdatedAt: number;
|
|
754
|
+
failureCount: number;
|
|
755
|
+
failureReason: Error | null;
|
|
756
|
+
errorUpdateCount: number;
|
|
757
|
+
isFetched: boolean;
|
|
758
|
+
isFetchedAfterMount: boolean;
|
|
759
|
+
isFetching: boolean;
|
|
760
|
+
isInitialLoading: boolean;
|
|
761
|
+
isPaused: boolean;
|
|
762
|
+
isRefetching: boolean;
|
|
763
|
+
isStale: boolean;
|
|
764
|
+
isEnabled: boolean;
|
|
765
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
|
|
766
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
767
|
+
promise: Promise<Transaction>;
|
|
768
|
+
} | {
|
|
769
|
+
fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
|
|
770
|
+
data: undefined;
|
|
771
|
+
error: Error;
|
|
772
|
+
isError: true;
|
|
773
|
+
isPending: false;
|
|
774
|
+
isLoading: false;
|
|
775
|
+
isLoadingError: true;
|
|
776
|
+
isRefetchError: false;
|
|
777
|
+
isSuccess: false;
|
|
778
|
+
isPlaceholderData: false;
|
|
779
|
+
status: "error";
|
|
780
|
+
dataUpdatedAt: number;
|
|
781
|
+
errorUpdatedAt: number;
|
|
782
|
+
failureCount: number;
|
|
783
|
+
failureReason: Error | null;
|
|
784
|
+
errorUpdateCount: number;
|
|
785
|
+
isFetched: boolean;
|
|
786
|
+
isFetchedAfterMount: boolean;
|
|
787
|
+
isFetching: boolean;
|
|
788
|
+
isInitialLoading: boolean;
|
|
789
|
+
isPaused: boolean;
|
|
790
|
+
isRefetching: boolean;
|
|
791
|
+
isStale: boolean;
|
|
792
|
+
isEnabled: boolean;
|
|
793
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
|
|
794
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
795
|
+
promise: Promise<Transaction>;
|
|
796
|
+
} | {
|
|
797
|
+
fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
|
|
798
|
+
data: undefined;
|
|
799
|
+
error: null;
|
|
800
|
+
isError: false;
|
|
801
|
+
isPending: true;
|
|
802
|
+
isLoading: true;
|
|
803
|
+
isLoadingError: false;
|
|
804
|
+
isRefetchError: false;
|
|
805
|
+
isSuccess: false;
|
|
806
|
+
isPlaceholderData: false;
|
|
807
|
+
status: "pending";
|
|
808
|
+
dataUpdatedAt: number;
|
|
809
|
+
errorUpdatedAt: number;
|
|
810
|
+
failureCount: number;
|
|
811
|
+
failureReason: Error | null;
|
|
812
|
+
errorUpdateCount: number;
|
|
813
|
+
isFetched: boolean;
|
|
814
|
+
isFetchedAfterMount: boolean;
|
|
815
|
+
isFetching: boolean;
|
|
816
|
+
isInitialLoading: boolean;
|
|
817
|
+
isPaused: boolean;
|
|
818
|
+
isRefetching: boolean;
|
|
819
|
+
isStale: boolean;
|
|
820
|
+
isEnabled: boolean;
|
|
821
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
|
|
822
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
823
|
+
promise: Promise<Transaction>;
|
|
824
|
+
} | {
|
|
825
|
+
fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
|
|
826
|
+
data: undefined;
|
|
827
|
+
error: null;
|
|
828
|
+
isError: false;
|
|
829
|
+
isPending: true;
|
|
830
|
+
isLoadingError: false;
|
|
831
|
+
isRefetchError: false;
|
|
832
|
+
isSuccess: false;
|
|
833
|
+
isPlaceholderData: false;
|
|
834
|
+
status: "pending";
|
|
835
|
+
dataUpdatedAt: number;
|
|
836
|
+
errorUpdatedAt: number;
|
|
837
|
+
failureCount: number;
|
|
838
|
+
failureReason: Error | null;
|
|
839
|
+
errorUpdateCount: number;
|
|
840
|
+
isFetched: boolean;
|
|
841
|
+
isFetchedAfterMount: boolean;
|
|
842
|
+
isFetching: boolean;
|
|
843
|
+
isLoading: boolean;
|
|
844
|
+
isInitialLoading: boolean;
|
|
845
|
+
isPaused: boolean;
|
|
846
|
+
isRefetching: boolean;
|
|
847
|
+
isStale: boolean;
|
|
848
|
+
isEnabled: boolean;
|
|
849
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
|
|
850
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
851
|
+
promise: Promise<Transaction>;
|
|
852
|
+
} | {
|
|
853
|
+
fetchTransaction: (newInput: FetchTransactionInput) => Promise<Transaction>;
|
|
854
|
+
data: Transaction;
|
|
855
|
+
isError: false;
|
|
856
|
+
error: null;
|
|
857
|
+
isPending: false;
|
|
858
|
+
isLoading: false;
|
|
859
|
+
isLoadingError: false;
|
|
860
|
+
isRefetchError: false;
|
|
861
|
+
isSuccess: true;
|
|
862
|
+
isPlaceholderData: true;
|
|
863
|
+
status: "success";
|
|
864
|
+
dataUpdatedAt: number;
|
|
865
|
+
errorUpdatedAt: number;
|
|
866
|
+
failureCount: number;
|
|
867
|
+
failureReason: Error | null;
|
|
868
|
+
errorUpdateCount: number;
|
|
869
|
+
isFetched: boolean;
|
|
870
|
+
isFetchedAfterMount: boolean;
|
|
871
|
+
isFetching: boolean;
|
|
872
|
+
isInitialLoading: boolean;
|
|
873
|
+
isPaused: boolean;
|
|
874
|
+
isRefetching: boolean;
|
|
875
|
+
isStale: boolean;
|
|
876
|
+
isEnabled: boolean;
|
|
877
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<Transaction, Error>>;
|
|
878
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
879
|
+
promise: Promise<Transaction>;
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
type GetTransactionStatusInput = {
|
|
883
|
+
hash?: string;
|
|
884
|
+
getBearerToken?: () => Promise<string | null | undefined>;
|
|
885
|
+
/** Polling interval in ms. Defaults to 3000. Set to false to disable polling. */
|
|
886
|
+
refetchInterval?: number | false;
|
|
887
|
+
queryOptions?: Omit<UseQueryOptions<TransactionStatusResponse, Error>, "queryKey" | "queryFn" | "refetchInterval">;
|
|
888
|
+
};
|
|
889
|
+
type FetchTransactionStatusInput = {
|
|
890
|
+
hash: string;
|
|
891
|
+
getBearerToken: () => Promise<string | null | undefined>;
|
|
892
|
+
};
|
|
893
|
+
declare function useGetTransactionStatus(input?: GetTransactionStatusInput): {
|
|
894
|
+
fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
|
|
895
|
+
data: TransactionStatusResponse;
|
|
896
|
+
error: Error;
|
|
897
|
+
isError: true;
|
|
898
|
+
isPending: false;
|
|
899
|
+
isLoading: false;
|
|
900
|
+
isLoadingError: false;
|
|
901
|
+
isRefetchError: true;
|
|
902
|
+
isSuccess: false;
|
|
903
|
+
isPlaceholderData: false;
|
|
904
|
+
status: "error";
|
|
905
|
+
dataUpdatedAt: number;
|
|
906
|
+
errorUpdatedAt: number;
|
|
907
|
+
failureCount: number;
|
|
908
|
+
failureReason: Error | null;
|
|
909
|
+
errorUpdateCount: number;
|
|
910
|
+
isFetched: boolean;
|
|
911
|
+
isFetchedAfterMount: boolean;
|
|
912
|
+
isFetching: boolean;
|
|
913
|
+
isInitialLoading: boolean;
|
|
914
|
+
isPaused: boolean;
|
|
915
|
+
isRefetching: boolean;
|
|
916
|
+
isStale: boolean;
|
|
917
|
+
isEnabled: boolean;
|
|
918
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
|
|
919
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
920
|
+
promise: Promise<TransactionStatusResponse>;
|
|
921
|
+
} | {
|
|
922
|
+
fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
|
|
923
|
+
data: TransactionStatusResponse;
|
|
924
|
+
error: null;
|
|
925
|
+
isError: false;
|
|
926
|
+
isPending: false;
|
|
927
|
+
isLoading: false;
|
|
928
|
+
isLoadingError: false;
|
|
929
|
+
isRefetchError: false;
|
|
930
|
+
isSuccess: true;
|
|
931
|
+
isPlaceholderData: false;
|
|
932
|
+
status: "success";
|
|
933
|
+
dataUpdatedAt: number;
|
|
934
|
+
errorUpdatedAt: number;
|
|
935
|
+
failureCount: number;
|
|
936
|
+
failureReason: Error | null;
|
|
937
|
+
errorUpdateCount: number;
|
|
938
|
+
isFetched: boolean;
|
|
939
|
+
isFetchedAfterMount: boolean;
|
|
940
|
+
isFetching: boolean;
|
|
941
|
+
isInitialLoading: boolean;
|
|
942
|
+
isPaused: boolean;
|
|
943
|
+
isRefetching: boolean;
|
|
944
|
+
isStale: boolean;
|
|
945
|
+
isEnabled: boolean;
|
|
946
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
|
|
947
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
948
|
+
promise: Promise<TransactionStatusResponse>;
|
|
949
|
+
} | {
|
|
950
|
+
fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
|
|
951
|
+
data: undefined;
|
|
952
|
+
error: Error;
|
|
953
|
+
isError: true;
|
|
954
|
+
isPending: false;
|
|
955
|
+
isLoading: false;
|
|
956
|
+
isLoadingError: true;
|
|
957
|
+
isRefetchError: false;
|
|
958
|
+
isSuccess: false;
|
|
959
|
+
isPlaceholderData: false;
|
|
960
|
+
status: "error";
|
|
961
|
+
dataUpdatedAt: number;
|
|
962
|
+
errorUpdatedAt: number;
|
|
963
|
+
failureCount: number;
|
|
964
|
+
failureReason: Error | null;
|
|
965
|
+
errorUpdateCount: number;
|
|
966
|
+
isFetched: boolean;
|
|
967
|
+
isFetchedAfterMount: boolean;
|
|
968
|
+
isFetching: boolean;
|
|
969
|
+
isInitialLoading: boolean;
|
|
970
|
+
isPaused: boolean;
|
|
971
|
+
isRefetching: boolean;
|
|
972
|
+
isStale: boolean;
|
|
973
|
+
isEnabled: boolean;
|
|
974
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
|
|
975
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
976
|
+
promise: Promise<TransactionStatusResponse>;
|
|
977
|
+
} | {
|
|
978
|
+
fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
|
|
979
|
+
data: undefined;
|
|
980
|
+
error: null;
|
|
981
|
+
isError: false;
|
|
982
|
+
isPending: true;
|
|
983
|
+
isLoading: true;
|
|
984
|
+
isLoadingError: false;
|
|
985
|
+
isRefetchError: false;
|
|
986
|
+
isSuccess: false;
|
|
987
|
+
isPlaceholderData: false;
|
|
988
|
+
status: "pending";
|
|
989
|
+
dataUpdatedAt: number;
|
|
990
|
+
errorUpdatedAt: number;
|
|
991
|
+
failureCount: number;
|
|
992
|
+
failureReason: Error | null;
|
|
993
|
+
errorUpdateCount: number;
|
|
994
|
+
isFetched: boolean;
|
|
995
|
+
isFetchedAfterMount: boolean;
|
|
996
|
+
isFetching: boolean;
|
|
997
|
+
isInitialLoading: boolean;
|
|
998
|
+
isPaused: boolean;
|
|
999
|
+
isRefetching: boolean;
|
|
1000
|
+
isStale: boolean;
|
|
1001
|
+
isEnabled: boolean;
|
|
1002
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
|
|
1003
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1004
|
+
promise: Promise<TransactionStatusResponse>;
|
|
1005
|
+
} | {
|
|
1006
|
+
fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
|
|
1007
|
+
data: undefined;
|
|
1008
|
+
error: null;
|
|
1009
|
+
isError: false;
|
|
1010
|
+
isPending: true;
|
|
1011
|
+
isLoadingError: false;
|
|
1012
|
+
isRefetchError: false;
|
|
1013
|
+
isSuccess: false;
|
|
1014
|
+
isPlaceholderData: false;
|
|
1015
|
+
status: "pending";
|
|
1016
|
+
dataUpdatedAt: number;
|
|
1017
|
+
errorUpdatedAt: number;
|
|
1018
|
+
failureCount: number;
|
|
1019
|
+
failureReason: Error | null;
|
|
1020
|
+
errorUpdateCount: number;
|
|
1021
|
+
isFetched: boolean;
|
|
1022
|
+
isFetchedAfterMount: boolean;
|
|
1023
|
+
isFetching: boolean;
|
|
1024
|
+
isLoading: boolean;
|
|
1025
|
+
isInitialLoading: boolean;
|
|
1026
|
+
isPaused: boolean;
|
|
1027
|
+
isRefetching: boolean;
|
|
1028
|
+
isStale: boolean;
|
|
1029
|
+
isEnabled: boolean;
|
|
1030
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
|
|
1031
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1032
|
+
promise: Promise<TransactionStatusResponse>;
|
|
1033
|
+
} | {
|
|
1034
|
+
fetchTransactionStatus: (newInput: FetchTransactionStatusInput) => Promise<TransactionStatusResponse>;
|
|
1035
|
+
data: TransactionStatusResponse;
|
|
1036
|
+
isError: false;
|
|
1037
|
+
error: null;
|
|
1038
|
+
isPending: false;
|
|
1039
|
+
isLoading: false;
|
|
1040
|
+
isLoadingError: false;
|
|
1041
|
+
isRefetchError: false;
|
|
1042
|
+
isSuccess: true;
|
|
1043
|
+
isPlaceholderData: true;
|
|
1044
|
+
status: "success";
|
|
1045
|
+
dataUpdatedAt: number;
|
|
1046
|
+
errorUpdatedAt: number;
|
|
1047
|
+
failureCount: number;
|
|
1048
|
+
failureReason: Error | null;
|
|
1049
|
+
errorUpdateCount: number;
|
|
1050
|
+
isFetched: boolean;
|
|
1051
|
+
isFetchedAfterMount: boolean;
|
|
1052
|
+
isFetching: boolean;
|
|
1053
|
+
isInitialLoading: boolean;
|
|
1054
|
+
isPaused: boolean;
|
|
1055
|
+
isRefetching: boolean;
|
|
1056
|
+
isStale: boolean;
|
|
1057
|
+
isEnabled: boolean;
|
|
1058
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<TransactionStatusResponse, Error>>;
|
|
1059
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1060
|
+
promise: Promise<TransactionStatusResponse>;
|
|
1061
|
+
};
|
|
1062
|
+
|
|
699
1063
|
type PurchaseSkuInput = {
|
|
700
1064
|
params: CreateSkuPurchaseParams;
|
|
701
1065
|
bearerToken: string;
|
|
@@ -892,7 +1256,7 @@ declare function useGetSkuPurchase(input?: GetSkuPurchaseInput): {
|
|
|
892
1256
|
type SkuListInput = {
|
|
893
1257
|
query: GetSkuListQuery;
|
|
894
1258
|
getBearerToken?: () => Promise<string | null | undefined>;
|
|
895
|
-
queryOptions?: Omit<UseQueryOptions<PaginatedResponse<Sku>, Error>,
|
|
1259
|
+
queryOptions?: Omit<UseQueryOptions<PaginatedResponse<Sku>, Error>, "queryKey" | "queryFn">;
|
|
896
1260
|
};
|
|
897
1261
|
declare function useGetSkuList(input?: SkuListInput): {
|
|
898
1262
|
fetchSkuList: (newInput: SkuListInput) => Promise<PaginatedResponse<Sku>>;
|
|
@@ -1275,7 +1639,7 @@ declare function useRecordSendTransaction(): {
|
|
|
1275
1639
|
type GetTokenBalanceInput = {
|
|
1276
1640
|
params?: GetTokenBalanceParams;
|
|
1277
1641
|
getBearerToken?: () => Promise<string | null | undefined>;
|
|
1278
|
-
queryOptions?: Omit<UseQueryOptions<GetTokenBalanceResponse, Error>,
|
|
1642
|
+
queryOptions?: Omit<UseQueryOptions<GetTokenBalanceResponse, Error>, "queryKey" | "queryFn">;
|
|
1279
1643
|
};
|
|
1280
1644
|
declare function useGetTokenBalance(input?: GetTokenBalanceInput): {
|
|
1281
1645
|
fetchTokenBalance: (newInput: GetTokenBalanceInput) => Promise<GetTokenBalanceResponse>;
|
|
@@ -1644,4 +2008,89 @@ declare function useExecuteWithSession(): {
|
|
|
1644
2008
|
reset: () => void;
|
|
1645
2009
|
};
|
|
1646
2010
|
|
|
1647
|
-
|
|
2011
|
+
/**
|
|
2012
|
+
* Configuration for useX402Payment hook
|
|
2013
|
+
*/
|
|
2014
|
+
interface UseX402PaymentConfig {
|
|
2015
|
+
/** Wallet data */
|
|
2016
|
+
wallet: WalletData | null | undefined;
|
|
2017
|
+
/** Encryption key for signing */
|
|
2018
|
+
encryptKey: string;
|
|
2019
|
+
/** Function to get the bearer token for API calls */
|
|
2020
|
+
getBearerToken?: () => Promise<string | null | undefined>;
|
|
2021
|
+
/** Static bearer token string (alternative to getBearerToken) */
|
|
2022
|
+
bearerToken?: string;
|
|
2023
|
+
/** Max amount per payment (USDC, human-readable e.g. "1.00") */
|
|
2024
|
+
maxPaymentAmount?: string;
|
|
2025
|
+
/** Alias for maxPaymentAmount */
|
|
2026
|
+
maxAmount?: string;
|
|
2027
|
+
/** Allowed recipient addresses (whitelist). Empty = allow all. */
|
|
2028
|
+
allowedRecipients?: string[];
|
|
2029
|
+
/** Active session for automatic payments (optional) */
|
|
2030
|
+
session?: SessionKeyData | null;
|
|
2031
|
+
/** Callback on successful payment */
|
|
2032
|
+
onPaymentComplete?: (txHash: string, amount: string) => void | Promise<void>;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Last payment info returned by the hook
|
|
2036
|
+
*/
|
|
2037
|
+
interface LastPaymentInfo {
|
|
2038
|
+
txHash: string | null;
|
|
2039
|
+
amount: string | null;
|
|
2040
|
+
timestamp: number;
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Return type for useX402Payment hook
|
|
2044
|
+
*/
|
|
2045
|
+
interface UseX402PaymentReturn {
|
|
2046
|
+
/** Fetch wrapper that auto-handles 402 payments */
|
|
2047
|
+
x402Fetch: (url: string, init?: Record<string, any>) => Promise<Response>;
|
|
2048
|
+
/** Alias for x402Fetch */
|
|
2049
|
+
payFetch: (url: string, init?: Record<string, any>) => Promise<Response>;
|
|
2050
|
+
/** Manual payment signing (for custom flows) */
|
|
2051
|
+
signPayment: (requirement: PaymentRequirement) => Promise<PaymentPayload>;
|
|
2052
|
+
/** Whether a payment is in progress */
|
|
2053
|
+
isPaying: boolean;
|
|
2054
|
+
/** Last payment transaction hash */
|
|
2055
|
+
lastTxHash: string | null;
|
|
2056
|
+
/** Last payment amount (human-readable USDC) */
|
|
2057
|
+
lastAmount: string | null;
|
|
2058
|
+
/** Last payment info (txHash + amount + timestamp) */
|
|
2059
|
+
lastPayment: LastPaymentInfo | null;
|
|
2060
|
+
/** Total USDC spent in this session (human-readable) */
|
|
2061
|
+
totalSpent: string;
|
|
2062
|
+
/** Error from last payment attempt */
|
|
2063
|
+
error: Error | null;
|
|
2064
|
+
/** Total payments made in this session */
|
|
2065
|
+
paymentCount: number;
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* React hook for x402 payment protocol support.
|
|
2069
|
+
*
|
|
2070
|
+
* Wraps fetch calls with automatic HTTP 402 payment handling.
|
|
2071
|
+
* When a server returns 402, the hook:
|
|
2072
|
+
* 1. Parses the payment requirement
|
|
2073
|
+
* 2. Validates against configured limits
|
|
2074
|
+
* 3. Signs using the wallet (or session key for automatic payments)
|
|
2075
|
+
* 4. Retries with the X-PAYMENT header
|
|
2076
|
+
*
|
|
2077
|
+
* @example
|
|
2078
|
+
* ```tsx
|
|
2079
|
+
* const { x402Fetch, isPaying, lastTxHash, paymentCount } = useX402Payment({
|
|
2080
|
+
* wallet,
|
|
2081
|
+
* encryptKey: pin,
|
|
2082
|
+
* getBearerToken: getToken,
|
|
2083
|
+
* maxPaymentAmount: "1.00",
|
|
2084
|
+
* onPaymentComplete: (txHash, amount) => {
|
|
2085
|
+
* console.log(`Paid ${amount} USDC, tx: ${txHash}`);
|
|
2086
|
+
* },
|
|
2087
|
+
* });
|
|
2088
|
+
*
|
|
2089
|
+
* // Automatic 402 handling
|
|
2090
|
+
* const response = await x402Fetch("https://api.example.com/premium");
|
|
2091
|
+
* const data = await response.json();
|
|
2092
|
+
* ```
|
|
2093
|
+
*/
|
|
2094
|
+
declare function useX402Payment(config: UseX402PaymentConfig): UseX402PaymentReturn;
|
|
2095
|
+
|
|
2096
|
+
export { type ChipiWalletData, type SessionState, type SessionWallet, type UseChipiSessionConfig, type UseChipiSessionReturn, type UseChipiWalletConfig, type UseChipiWalletReturn, type UseX402PaymentConfig, type UseX402PaymentReturn, useAddSessionKeyToContract, useApprove, useCallAnyContract, useChipiSession, useChipiWallet, useCreateSessionKey, useCreateWallet, useExecuteWithSession, useGetSessionData, useGetSku, useGetSkuList, useGetSkuPurchase, useGetTokenBalance, useGetTransaction, useGetTransactionList, useGetTransactionStatus, useGetWallet, useMigrateWalletToPasskey, usePurchaseSku, useRecordSendTransaction, useRevokeSessionKey, useTransfer, useUpdateWalletEncryption, useX402Payment };
|