@chipi-stack/chipi-react 12.8.0 → 13.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/dist/hooks.d.mts +33 -33
- package/dist/hooks.d.ts +33 -33
- package/dist/hooks.js +19 -16
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +18 -15
- 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 +19 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var backend = require('@chipi-stack/backend');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var chipiPasskey = require('@chipi-stack/chipi-passkey');
|
|
8
8
|
var shared = require('@chipi-stack/shared');
|
|
9
|
+
var types = require('@chipi-stack/types');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
|
|
@@ -177,7 +178,7 @@ function useChipiWallet(config) {
|
|
|
177
178
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
178
179
|
return chipiSDK.getTokenBalance(
|
|
179
180
|
{
|
|
180
|
-
chain:
|
|
181
|
+
chain: types.Chain.STARKNET,
|
|
181
182
|
chainToken: defaultToken,
|
|
182
183
|
walletPublicKey
|
|
183
184
|
},
|
|
@@ -199,6 +200,7 @@ function useChipiWallet(config) {
|
|
|
199
200
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
200
201
|
return chipiSDK.createWallet({
|
|
201
202
|
params: {
|
|
203
|
+
chain: types.Chain.STARKNET,
|
|
202
204
|
encryptKey,
|
|
203
205
|
externalUserId,
|
|
204
206
|
walletType
|
|
@@ -227,7 +229,7 @@ function useChipiWallet(config) {
|
|
|
227
229
|
const num = Number(balanceQuery.data.balance);
|
|
228
230
|
return num.toLocaleString(void 0, {
|
|
229
231
|
minimumFractionDigits: 2,
|
|
230
|
-
maximumFractionDigits: defaultToken ===
|
|
232
|
+
maximumFractionDigits: defaultToken === types.ChainToken.ETH || defaultToken === types.ChainToken.STRK ? 6 : 2
|
|
231
233
|
});
|
|
232
234
|
}, [balanceQuery.data, defaultToken]);
|
|
233
235
|
const refetchWallet = React.useCallback(async () => {
|
|
@@ -691,17 +693,17 @@ function useGetTransactionList(input) {
|
|
|
691
693
|
fetchTransactionList
|
|
692
694
|
};
|
|
693
695
|
}
|
|
694
|
-
function
|
|
696
|
+
function usePurchaseSku() {
|
|
695
697
|
const { chipiSDK } = useChipiContext();
|
|
696
698
|
const mutation = reactQuery.useMutation({
|
|
697
|
-
mutationFn: (input) => chipiSDK.
|
|
699
|
+
mutationFn: (input) => chipiSDK.purchaseSku({
|
|
698
700
|
params: input.params,
|
|
699
701
|
bearerToken: input.bearerToken
|
|
700
702
|
})
|
|
701
703
|
});
|
|
702
704
|
return {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
+
purchaseSku: mutation.mutate,
|
|
706
|
+
purchaseSkuAsync: mutation.mutateAsync,
|
|
705
707
|
data: mutation.data,
|
|
706
708
|
isLoading: mutation.isPending,
|
|
707
709
|
isError: mutation.isError,
|
|
@@ -710,36 +712,37 @@ function useCreateSkuTransaction() {
|
|
|
710
712
|
reset: mutation.reset
|
|
711
713
|
};
|
|
712
714
|
}
|
|
713
|
-
function
|
|
715
|
+
function useGetSkuPurchase(input) {
|
|
714
716
|
const { chipiSDK } = useChipiContext();
|
|
715
717
|
const queryClient = reactQuery.useQueryClient();
|
|
716
718
|
const query = reactQuery.useQuery({
|
|
717
|
-
queryKey: ["sku-
|
|
719
|
+
queryKey: ["sku-purchase", input?.id],
|
|
718
720
|
queryFn: async () => {
|
|
719
721
|
if (!input?.id) throw new Error("id is required");
|
|
720
722
|
if (!input?.getBearerToken) throw new Error("getBearerToken is required");
|
|
721
723
|
const bearerToken = await input.getBearerToken();
|
|
722
724
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
723
|
-
return chipiSDK.
|
|
725
|
+
return chipiSDK.getSkuPurchase(input.id, bearerToken);
|
|
724
726
|
},
|
|
725
727
|
enabled: Boolean(input?.id && input?.getBearerToken),
|
|
726
728
|
...input?.queryOptions
|
|
727
729
|
});
|
|
728
|
-
const
|
|
730
|
+
const fetchSkuPurchase = async (newInput) => {
|
|
729
731
|
return queryClient.fetchQuery({
|
|
730
|
-
queryKey: ["sku-
|
|
732
|
+
queryKey: ["sku-purchase", newInput?.id],
|
|
731
733
|
queryFn: async () => {
|
|
732
734
|
if (!newInput?.id) throw new Error("id is required");
|
|
733
|
-
if (!newInput?.getBearerToken)
|
|
735
|
+
if (!newInput?.getBearerToken)
|
|
736
|
+
throw new Error("getBearerToken is required");
|
|
734
737
|
const bearerToken = await newInput.getBearerToken();
|
|
735
738
|
if (!bearerToken) throw new Error("Bearer token is required");
|
|
736
|
-
return chipiSDK.
|
|
739
|
+
return chipiSDK.getSkuPurchase(newInput.id, bearerToken);
|
|
737
740
|
}
|
|
738
741
|
});
|
|
739
742
|
};
|
|
740
743
|
return {
|
|
741
744
|
...query,
|
|
742
|
-
|
|
745
|
+
fetchSkuPurchase
|
|
743
746
|
};
|
|
744
747
|
}
|
|
745
748
|
function useGetSkuList(input) {
|
|
@@ -1219,19 +1222,19 @@ exports.useChipiContext = useChipiContext;
|
|
|
1219
1222
|
exports.useChipiSession = useChipiSession;
|
|
1220
1223
|
exports.useChipiWallet = useChipiWallet;
|
|
1221
1224
|
exports.useCreateSessionKey = useCreateSessionKey;
|
|
1222
|
-
exports.useCreateSkuTransaction = useCreateSkuTransaction;
|
|
1223
1225
|
exports.useCreateUser = useCreateUser;
|
|
1224
1226
|
exports.useCreateWallet = useCreateWallet;
|
|
1225
1227
|
exports.useExecuteWithSession = useExecuteWithSession;
|
|
1226
1228
|
exports.useGetSessionData = useGetSessionData;
|
|
1227
1229
|
exports.useGetSku = useGetSku;
|
|
1228
1230
|
exports.useGetSkuList = useGetSkuList;
|
|
1229
|
-
exports.
|
|
1231
|
+
exports.useGetSkuPurchase = useGetSkuPurchase;
|
|
1230
1232
|
exports.useGetTokenBalance = useGetTokenBalance;
|
|
1231
1233
|
exports.useGetTransactionList = useGetTransactionList;
|
|
1232
1234
|
exports.useGetUser = useGetUser;
|
|
1233
1235
|
exports.useGetWallet = useGetWallet;
|
|
1234
1236
|
exports.useMigrateWalletToPasskey = useMigrateWalletToPasskey;
|
|
1237
|
+
exports.usePurchaseSku = usePurchaseSku;
|
|
1235
1238
|
exports.useRecordSendTransaction = useRecordSendTransaction;
|
|
1236
1239
|
exports.useRevokeSessionKey = useRevokeSessionKey;
|
|
1237
1240
|
exports.useStakeVesuUsdc = useStakeVesuUsdc;
|