@chipi-stack/chipi-react 12.7.0 → 13.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/dist/hooks.d.mts +33 -33
- package/dist/hooks.d.ts +33 -33
- package/dist/hooks.js +22 -19
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +21 -18
- 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 +22 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/hooks.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { decryptPrivateKey, encryptPrivateKey } from '@chipi-stack/backend';
|
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import { createWalletPasskey, getWalletEncryptKey } from '@chipi-stack/chipi-passkey';
|
|
6
6
|
import { ChipiApiError } from '@chipi-stack/shared';
|
|
7
|
+
import { Chain, ChainToken } from '@chipi-stack/types';
|
|
7
8
|
|
|
8
9
|
// src/hooks/useCreateWallet.ts
|
|
9
10
|
var ChipiContext = createContext(null);
|
|
@@ -131,7 +132,7 @@ function useChipiWallet(config) {
|
|
|
131
132
|
return failureCount < 3;
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
|
-
const walletPublicKey = walletQuery.data?.publicKey;
|
|
135
|
+
const walletPublicKey = walletQuery.data?.wallet.publicKey;
|
|
135
136
|
const balanceQuery = useQuery({
|
|
136
137
|
queryKey: ["chipi-wallet-balance", walletPublicKey, defaultToken],
|
|
137
138
|
queryFn: async () => {
|
|
@@ -140,7 +141,7 @@ function useChipiWallet(config) {
|
|
|
140
141
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
141
142
|
return chipiSDK.getTokenBalance(
|
|
142
143
|
{
|
|
143
|
-
chain:
|
|
144
|
+
chain: Chain.STARKNET,
|
|
144
145
|
chainToken: defaultToken,
|
|
145
146
|
walletPublicKey
|
|
146
147
|
},
|
|
@@ -162,6 +163,7 @@ function useChipiWallet(config) {
|
|
|
162
163
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
163
164
|
return chipiSDK.createWallet({
|
|
164
165
|
params: {
|
|
166
|
+
chain: Chain.STARKNET,
|
|
165
167
|
encryptKey,
|
|
166
168
|
externalUserId,
|
|
167
169
|
walletType
|
|
@@ -181,8 +183,8 @@ function useChipiWallet(config) {
|
|
|
181
183
|
const data = walletQuery.data;
|
|
182
184
|
return {
|
|
183
185
|
...data,
|
|
184
|
-
supportsSessionKeys: data.walletType === "CHIPI",
|
|
185
|
-
shortAddress: formatAddress(data.publicKey)
|
|
186
|
+
supportsSessionKeys: data.wallet.walletType === "CHIPI",
|
|
187
|
+
shortAddress: formatAddress(data.wallet.publicKey)
|
|
186
188
|
};
|
|
187
189
|
}, [walletQuery.data, walletQuery.isLoading]);
|
|
188
190
|
const formattedBalance = useMemo(() => {
|
|
@@ -190,7 +192,7 @@ function useChipiWallet(config) {
|
|
|
190
192
|
const num = Number(balanceQuery.data.balance);
|
|
191
193
|
return num.toLocaleString(void 0, {
|
|
192
194
|
minimumFractionDigits: 2,
|
|
193
|
-
maximumFractionDigits: defaultToken ===
|
|
195
|
+
maximumFractionDigits: defaultToken === ChainToken.ETH || defaultToken === ChainToken.STRK ? 6 : 2
|
|
194
196
|
});
|
|
195
197
|
}, [balanceQuery.data, defaultToken]);
|
|
196
198
|
const refetchWallet = useCallback(async () => {
|
|
@@ -654,17 +656,17 @@ function useGetTransactionList(input) {
|
|
|
654
656
|
fetchTransactionList
|
|
655
657
|
};
|
|
656
658
|
}
|
|
657
|
-
function
|
|
659
|
+
function usePurchaseSku() {
|
|
658
660
|
const { chipiSDK } = useChipiContext();
|
|
659
661
|
const mutation = useMutation({
|
|
660
|
-
mutationFn: (input) => chipiSDK.
|
|
662
|
+
mutationFn: (input) => chipiSDK.purchaseSku({
|
|
661
663
|
params: input.params,
|
|
662
664
|
bearerToken: input.bearerToken
|
|
663
665
|
})
|
|
664
666
|
});
|
|
665
667
|
return {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
+
purchaseSku: mutation.mutate,
|
|
669
|
+
purchaseSkuAsync: mutation.mutateAsync,
|
|
668
670
|
data: mutation.data,
|
|
669
671
|
isLoading: mutation.isPending,
|
|
670
672
|
isError: mutation.isError,
|
|
@@ -673,36 +675,37 @@ function useCreateSkuTransaction() {
|
|
|
673
675
|
reset: mutation.reset
|
|
674
676
|
};
|
|
675
677
|
}
|
|
676
|
-
function
|
|
678
|
+
function useGetSkuPurchase(input) {
|
|
677
679
|
const { chipiSDK } = useChipiContext();
|
|
678
680
|
const queryClient = useQueryClient();
|
|
679
681
|
const query = useQuery({
|
|
680
|
-
queryKey: ["sku-
|
|
682
|
+
queryKey: ["sku-purchase", input?.id],
|
|
681
683
|
queryFn: async () => {
|
|
682
684
|
if (!input?.id) throw new Error("id is required");
|
|
683
685
|
if (!input?.getBearerToken) throw new Error("getBearerToken is required");
|
|
684
686
|
const bearerToken = await input.getBearerToken();
|
|
685
687
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
686
|
-
return chipiSDK.
|
|
688
|
+
return chipiSDK.getSkuPurchase(input.id, bearerToken);
|
|
687
689
|
},
|
|
688
690
|
enabled: Boolean(input?.id && input?.getBearerToken),
|
|
689
691
|
...input?.queryOptions
|
|
690
692
|
});
|
|
691
|
-
const
|
|
693
|
+
const fetchSkuPurchase = async (newInput) => {
|
|
692
694
|
return queryClient.fetchQuery({
|
|
693
|
-
queryKey: ["sku-
|
|
695
|
+
queryKey: ["sku-purchase", newInput?.id],
|
|
694
696
|
queryFn: async () => {
|
|
695
697
|
if (!newInput?.id) throw new Error("id is required");
|
|
696
|
-
if (!newInput?.getBearerToken)
|
|
698
|
+
if (!newInput?.getBearerToken)
|
|
699
|
+
throw new Error("getBearerToken is required");
|
|
697
700
|
const bearerToken = await newInput.getBearerToken();
|
|
698
701
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
699
|
-
return chipiSDK.
|
|
702
|
+
return chipiSDK.getSkuPurchase(newInput.id, bearerToken);
|
|
700
703
|
}
|
|
701
704
|
});
|
|
702
705
|
};
|
|
703
706
|
return {
|
|
704
707
|
...query,
|
|
705
|
-
|
|
708
|
+
fetchSkuPurchase
|
|
706
709
|
};
|
|
707
710
|
}
|
|
708
711
|
function useGetSkuList(input) {
|
|
@@ -1174,6 +1177,6 @@ function useExecuteWithSession() {
|
|
|
1174
1177
|
};
|
|
1175
1178
|
}
|
|
1176
1179
|
|
|
1177
|
-
export { useAddSessionKeyToContract, useApprove, useCallAnyContract, useChipiSession, useChipiWallet, useCreateSessionKey,
|
|
1180
|
+
export { useAddSessionKeyToContract, useApprove, useCallAnyContract, useChipiSession, useChipiWallet, useCreateSessionKey, useCreateUser, useCreateWallet, useExecuteWithSession, useGetSessionData, useGetSku, useGetSkuList, useGetSkuPurchase, useGetTokenBalance, useGetTransactionList, useGetUser, useGetWallet, useMigrateWalletToPasskey, usePurchaseSku, useRecordSendTransaction, useRevokeSessionKey, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc };
|
|
1178
1181
|
//# sourceMappingURL=hooks.mjs.map
|
|
1179
1182
|
//# sourceMappingURL=hooks.mjs.map
|