@chipi-stack/chipi-react 13.1.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks.d.mts +2 -273
- package/dist/hooks.d.ts +2 -273
- package/dist/hooks.js +0 -172
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +1 -169
- 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 +0 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -170
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useContext, useMemo, useCallback, useState, useEffect } from 'react';
|
|
2
|
-
import { QueryClientProvider, useMutation, useQueryClient, useQuery
|
|
2
|
+
import { QueryClient, QueryClientProvider, useMutation, useQueryClient, useQuery } from '@tanstack/react-query';
|
|
3
3
|
import { ChipiSDK, decryptPrivateKey, encryptPrivateKey } from '@chipi-stack/backend';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
import { createWalletPasskey, getWalletEncryptKey } from '@chipi-stack/chipi-passkey';
|
|
@@ -835,90 +835,6 @@ function useGetSku(input) {
|
|
|
835
835
|
fetchSku
|
|
836
836
|
};
|
|
837
837
|
}
|
|
838
|
-
function useStakeVesuUsdc() {
|
|
839
|
-
const { chipiSDK } = useChipiContext();
|
|
840
|
-
const mutation = useMutation({
|
|
841
|
-
mutationFn: async (params) => {
|
|
842
|
-
let encryptKey = params.params.encryptKey;
|
|
843
|
-
if (params.params.usePasskey) {
|
|
844
|
-
try {
|
|
845
|
-
const key = await getWalletEncryptKey();
|
|
846
|
-
if (!key) {
|
|
847
|
-
throw new Error("Passkey authentication was cancelled");
|
|
848
|
-
}
|
|
849
|
-
encryptKey = key;
|
|
850
|
-
} catch (error) {
|
|
851
|
-
if (error instanceof Error) {
|
|
852
|
-
throw new Error(
|
|
853
|
-
`Passkey authentication failed: ${error.message}`
|
|
854
|
-
);
|
|
855
|
-
}
|
|
856
|
-
throw new Error("Failed to authenticate with passkey");
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
return chipiSDK.stakeVesuUsdc({
|
|
860
|
-
params: {
|
|
861
|
-
...params.params,
|
|
862
|
-
amount: String(params.params.amount),
|
|
863
|
-
encryptKey
|
|
864
|
-
},
|
|
865
|
-
bearerToken: params.bearerToken
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
});
|
|
869
|
-
return {
|
|
870
|
-
stakeVesuUsdc: mutation.mutate,
|
|
871
|
-
stakeVesuUsdcAsync: mutation.mutateAsync,
|
|
872
|
-
data: mutation.data,
|
|
873
|
-
isLoading: mutation.isPending,
|
|
874
|
-
isError: mutation.isError,
|
|
875
|
-
error: mutation.error,
|
|
876
|
-
isSuccess: mutation.isSuccess,
|
|
877
|
-
reset: mutation.reset
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
function useWithdrawVesuUsdc() {
|
|
881
|
-
const { chipiSDK } = useChipiContext();
|
|
882
|
-
const mutation = useMutation({
|
|
883
|
-
mutationFn: async (params) => {
|
|
884
|
-
let encryptKey = params.params.encryptKey;
|
|
885
|
-
if (params.params.usePasskey) {
|
|
886
|
-
try {
|
|
887
|
-
const key = await getWalletEncryptKey();
|
|
888
|
-
if (!key) {
|
|
889
|
-
throw new Error("Passkey authentication was cancelled");
|
|
890
|
-
}
|
|
891
|
-
encryptKey = key;
|
|
892
|
-
} catch (error) {
|
|
893
|
-
if (error instanceof Error) {
|
|
894
|
-
throw new Error(
|
|
895
|
-
`Passkey authentication failed: ${error.message}`
|
|
896
|
-
);
|
|
897
|
-
}
|
|
898
|
-
throw new Error("Failed to authenticate with passkey");
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
return chipiSDK.withdrawVesuUsdc({
|
|
902
|
-
params: {
|
|
903
|
-
...params.params,
|
|
904
|
-
amount: String(params.params.amount),
|
|
905
|
-
encryptKey
|
|
906
|
-
},
|
|
907
|
-
bearerToken: params.bearerToken
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
return {
|
|
912
|
-
withdrawVesuUsdc: mutation.mutate,
|
|
913
|
-
withdrawVesuUsdcAsync: mutation.mutateAsync,
|
|
914
|
-
data: mutation.data,
|
|
915
|
-
isLoading: mutation.isPending,
|
|
916
|
-
isError: mutation.isError,
|
|
917
|
-
error: mutation.error,
|
|
918
|
-
isSuccess: mutation.isSuccess,
|
|
919
|
-
reset: mutation.reset
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
838
|
function useCallAnyContract() {
|
|
923
839
|
const { chipiSDK } = useChipiContext();
|
|
924
840
|
const mutation = useMutation({
|
|
@@ -1028,90 +944,6 @@ function useGetTokenBalance(input) {
|
|
|
1028
944
|
fetchTokenBalance
|
|
1029
945
|
};
|
|
1030
946
|
}
|
|
1031
|
-
function useGetUser(input) {
|
|
1032
|
-
const { chipiSDK } = useChipiContext();
|
|
1033
|
-
const queryClient = useQueryClient();
|
|
1034
|
-
const query = useQuery({
|
|
1035
|
-
queryKey: [
|
|
1036
|
-
"user",
|
|
1037
|
-
input?.params?.id,
|
|
1038
|
-
input?.params?.externalId,
|
|
1039
|
-
input?.params?.username,
|
|
1040
|
-
input?.params?.phone?.phoneCountryCode,
|
|
1041
|
-
input?.params?.phone?.phoneNumber,
|
|
1042
|
-
input?.params?.taxId,
|
|
1043
|
-
input?.params?.includeStarknetWallet
|
|
1044
|
-
],
|
|
1045
|
-
queryFn: async () => {
|
|
1046
|
-
if (!input?.params || !input?.getBearerToken)
|
|
1047
|
-
throw new Error("externalId and getBearerToken are required");
|
|
1048
|
-
const bearerToken = await input.getBearerToken();
|
|
1049
|
-
if (!bearerToken) throw new Error("Bearer token is required");
|
|
1050
|
-
return chipiSDK.getUser(input.params, bearerToken);
|
|
1051
|
-
},
|
|
1052
|
-
enabled: Boolean(
|
|
1053
|
-
input?.params && input?.getBearerToken && // Use truthy check instead of !== "" to handle undefined properly
|
|
1054
|
-
(input.params.externalId?.trim() || input.params.username?.trim() || input.params.phone?.phoneCountryCode !== void 0 && input.params.phone?.phoneNumber !== void 0 || input.params.taxId?.trim())
|
|
1055
|
-
),
|
|
1056
|
-
retry: (failureCount, error) => {
|
|
1057
|
-
if (error instanceof ChipiApiError || error?.status) {
|
|
1058
|
-
return false;
|
|
1059
|
-
}
|
|
1060
|
-
return failureCount < 3;
|
|
1061
|
-
},
|
|
1062
|
-
...input?.queryOptions
|
|
1063
|
-
});
|
|
1064
|
-
const fetchUser = async (input2) => {
|
|
1065
|
-
return queryClient.fetchQuery({
|
|
1066
|
-
queryKey: [
|
|
1067
|
-
"user",
|
|
1068
|
-
input2?.params?.externalId,
|
|
1069
|
-
input2?.params?.id,
|
|
1070
|
-
input2?.params?.username,
|
|
1071
|
-
input2?.params?.phone?.phoneCountryCode,
|
|
1072
|
-
input2?.params?.phone?.phoneNumber,
|
|
1073
|
-
input2?.params?.taxId,
|
|
1074
|
-
input2?.params?.includeStarknetWallet
|
|
1075
|
-
],
|
|
1076
|
-
queryFn: async () => {
|
|
1077
|
-
if (!input2?.getBearerToken)
|
|
1078
|
-
throw new Error("getBearerToken is required");
|
|
1079
|
-
const bearerToken = await input2.getBearerToken();
|
|
1080
|
-
if (!bearerToken) throw new Error("Bearer token is required");
|
|
1081
|
-
if (!input2?.params) throw new Error("params are required");
|
|
1082
|
-
return chipiSDK.getUser(input2.params, bearerToken);
|
|
1083
|
-
},
|
|
1084
|
-
retry: (failureCount, error) => {
|
|
1085
|
-
if (error instanceof ChipiApiError || error?.code) {
|
|
1086
|
-
return false;
|
|
1087
|
-
}
|
|
1088
|
-
return failureCount < 3;
|
|
1089
|
-
}
|
|
1090
|
-
});
|
|
1091
|
-
};
|
|
1092
|
-
return {
|
|
1093
|
-
...query,
|
|
1094
|
-
fetchUser
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
|
-
function useCreateUser() {
|
|
1098
|
-
const { chipiSDK } = useChipiContext();
|
|
1099
|
-
const mutation = useMutation(
|
|
1100
|
-
{
|
|
1101
|
-
mutationFn: (input) => chipiSDK.createUser(input.params, input.bearerToken)
|
|
1102
|
-
}
|
|
1103
|
-
);
|
|
1104
|
-
return {
|
|
1105
|
-
createUser: mutation.mutate,
|
|
1106
|
-
createUserAsync: mutation.mutateAsync,
|
|
1107
|
-
data: mutation.data,
|
|
1108
|
-
isLoading: mutation.isPending,
|
|
1109
|
-
isError: mutation.isError,
|
|
1110
|
-
error: mutation.error,
|
|
1111
|
-
isSuccess: mutation.isSuccess,
|
|
1112
|
-
reset: mutation.reset
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
947
|
function useCreateSessionKey() {
|
|
1116
948
|
const { chipiSDK } = useChipiContext();
|
|
1117
949
|
const mutation = useMutation({
|
|
@@ -1208,6 +1040,6 @@ function useExecuteWithSession() {
|
|
|
1208
1040
|
};
|
|
1209
1041
|
}
|
|
1210
1042
|
|
|
1211
|
-
export { ChipiProvider, useAddSessionKeyToContract, useApprove, useCallAnyContract, useChipiContext, useChipiSession, useChipiWallet, useCreateSessionKey,
|
|
1043
|
+
export { ChipiProvider, useAddSessionKeyToContract, useApprove, useCallAnyContract, useChipiContext, useChipiSession, useChipiWallet, useCreateSessionKey, useCreateWallet, useExecuteWithSession, useGetSessionData, useGetSku, useGetSkuList, useGetSkuPurchase, useGetTokenBalance, useGetTransactionList, useGetWallet, useMigrateWalletToPasskey, usePurchaseSku, useRecordSendTransaction, useRevokeSessionKey, useTransfer };
|
|
1212
1044
|
//# sourceMappingURL=index.mjs.map
|
|
1213
1045
|
//# sourceMappingURL=index.mjs.map
|