@chipi-stack/chipi-react 12.8.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/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
 
@@ -168,7 +169,7 @@ function useChipiWallet(config) {
168
169
  return failureCount < 3;
169
170
  }
170
171
  });
171
- const walletPublicKey = walletQuery.data?.publicKey;
172
+ const walletPublicKey = walletQuery.data?.wallet.publicKey;
172
173
  const balanceQuery = reactQuery.useQuery({
173
174
  queryKey: ["chipi-wallet-balance", walletPublicKey, defaultToken],
174
175
  queryFn: async () => {
@@ -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: "STARKNET",
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
@@ -218,8 +220,8 @@ function useChipiWallet(config) {
218
220
  const data = walletQuery.data;
219
221
  return {
220
222
  ...data,
221
- supportsSessionKeys: data.walletType === "CHIPI",
222
- shortAddress: formatAddress(data.publicKey)
223
+ supportsSessionKeys: data.wallet.walletType === "CHIPI",
224
+ shortAddress: formatAddress(data.wallet.publicKey)
223
225
  };
224
226
  }, [walletQuery.data, walletQuery.isLoading]);
225
227
  const formattedBalance = React.useMemo(() => {
@@ -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 === "ETH" || defaultToken === "STRK" ? 6 : 2
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 useCreateSkuTransaction() {
696
+ function usePurchaseSku() {
695
697
  const { chipiSDK } = useChipiContext();
696
698
  const mutation = reactQuery.useMutation({
697
- mutationFn: (input) => chipiSDK.createSkuTransaction({
699
+ mutationFn: (input) => chipiSDK.purchaseSku({
698
700
  params: input.params,
699
701
  bearerToken: input.bearerToken
700
702
  })
701
703
  });
702
704
  return {
703
- createSkuTransaction: mutation.mutate,
704
- createSkuTransactionAsync: mutation.mutateAsync,
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 useGetSkuTransaction(input) {
715
+ function useGetSkuPurchase(input) {
714
716
  const { chipiSDK } = useChipiContext();
715
717
  const queryClient = reactQuery.useQueryClient();
716
718
  const query = reactQuery.useQuery({
717
- queryKey: ["sku-transaction", input?.id],
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.skuTransactions.getSkuTransaction(input.id, bearerToken);
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 fetchSkuTransaction = async (newInput) => {
730
+ const fetchSkuPurchase = async (newInput) => {
729
731
  return queryClient.fetchQuery({
730
- queryKey: ["sku-transaction", newInput?.id],
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) throw new Error("getBearerToken is required");
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.skuTransactions.getSkuTransaction(newInput.id, bearerToken);
739
+ return chipiSDK.getSkuPurchase(newInput.id, bearerToken);
737
740
  }
738
741
  });
739
742
  };
740
743
  return {
741
744
  ...query,
742
- fetchSkuTransaction
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.useGetSkuTransaction = useGetSkuTransaction;
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;