@chipi-stack/chipi-react 14.0.0 → 14.1.1
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 +9 -0
- package/dist/hooks.d.mts +447 -2
- package/dist/hooks.d.ts +447 -2
- package/dist/hooks.js +336 -0
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +336 -3
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +336 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +336 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +33 -16
package/dist/hooks.d.ts
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
|
|
|
@@ -700,6 +700,366 @@ declare function useGetTransactionList(input?: TransactionListInput): {
|
|
|
700
700
|
promise: Promise<PaginatedResponse<Transaction>>;
|
|
701
701
|
};
|
|
702
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
|
+
|
|
703
1063
|
type PurchaseSkuInput = {
|
|
704
1064
|
params: CreateSkuPurchaseParams;
|
|
705
1065
|
bearerToken: string;
|
|
@@ -1648,4 +2008,89 @@ declare function useExecuteWithSession(): {
|
|
|
1648
2008
|
reset: () => void;
|
|
1649
2009
|
};
|
|
1650
2010
|
|
|
1651
|
-
|
|
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 };
|