@cofhe/react 0.5.2 → 0.6.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.
@@ -3372,7 +3372,7 @@ function useCofheTokenTransfer(writeMutationOptions) {
3372
3372
  // src/hooks/useCofheTokenShield.ts
3373
3373
  import "@tanstack/react-query";
3374
3374
  import "viem";
3375
- var import_ts_essentials7 = __toESM(require_dist(), 1);
3375
+ var import_ts_essentials7 = __toESM(require_dist());
3376
3376
  function getCofheTokenShieldCallArgs(params) {
3377
3377
  const { token, amount, account } = params;
3378
3378
  const tokenAddress = token.address;
@@ -4675,6 +4675,54 @@ function useCofheSimulateWriteContract(callArgs, queryOptions) {
4675
4675
  });
4676
4676
  }
4677
4677
 
4678
+ // src/stores/portalPersisted.tsx
4679
+ import { create as create9 } from "zustand";
4680
+ import { createJSONStorage as createJSONStorage4, persist as persist4 } from "zustand/middleware";
4681
+ var usePortalPersisted = create9()(
4682
+ persist4(
4683
+ (set, get) => ({
4684
+ hasCreatedFirstPermit: false,
4685
+ setHasCreatedFirstPermit: (hasCreated) => set({ hasCreatedFirstPermit: hasCreated })
4686
+ }),
4687
+ {
4688
+ name: "cofhesdk-react-persisted",
4689
+ storage: createJSONStorage4(() => localStorage)
4690
+ }
4691
+ )
4692
+ );
4693
+
4694
+ // src/hooks/permits/useCofheCreatePermit.ts
4695
+ var useCofheCreatePermit = ({ onSuccess, onError } = {}) => {
4696
+ const cofheClient = useCofheClient();
4697
+ const { setHasCreatedFirstPermit } = usePortalPersisted();
4698
+ return useInternalMutation({
4699
+ onSuccess,
4700
+ onError,
4701
+ onSettled: () => {
4702
+ setHasCreatedFirstPermit(true);
4703
+ },
4704
+ mutationFn: async (args) => {
4705
+ const { name, isSelf, expirationSeconds } = args;
4706
+ const { account } = cofheClient.getSnapshot();
4707
+ if (!account) throw new Error("No connected account found");
4708
+ if (isSelf) {
4709
+ await cofheClient.permits.createSelf({
4710
+ expiration: expirationSeconds,
4711
+ issuer: account,
4712
+ name: name.trim()
4713
+ });
4714
+ return;
4715
+ }
4716
+ await cofheClient.permits.createSharing({
4717
+ expiration: expirationSeconds,
4718
+ issuer: account,
4719
+ recipient: args.receiver,
4720
+ name: name.trim()
4721
+ });
4722
+ }
4723
+ });
4724
+ };
4725
+
4678
4726
  // src/hooks/permits/useCofheNavigateToCreatePermit.tsx
4679
4727
  import { useCallback as useCallback4 } from "react";
4680
4728
  var useCofheNavigateToCreatePermit = () => {
@@ -5093,56 +5141,6 @@ function usePermitDuration(options) {
5093
5141
 
5094
5142
  // src/hooks/permits/usePermitForm.ts
5095
5143
  import { useCallback as useCallback6, useState as useState5 } from "react";
5096
-
5097
- // src/stores/portalPersisted.tsx
5098
- import { create as create9 } from "zustand";
5099
- import { createJSONStorage as createJSONStorage4, persist as persist4 } from "zustand/middleware";
5100
- var usePortalPersisted = create9()(
5101
- persist4(
5102
- (set, get) => ({
5103
- hasCreatedFirstPermit: false,
5104
- setHasCreatedFirstPermit: (hasCreated) => set({ hasCreatedFirstPermit: hasCreated })
5105
- }),
5106
- {
5107
- name: "cofhesdk-react-persisted",
5108
- storage: createJSONStorage4(() => localStorage)
5109
- }
5110
- )
5111
- );
5112
-
5113
- // src/hooks/permits/useCofheCreatePermitMutation.ts
5114
- var useCofheCreatePermitMutation = ({ onSuccess, onError } = {}) => {
5115
- const cofheClient = useCofheClient();
5116
- const { setHasCreatedFirstPermit } = usePortalPersisted();
5117
- return useInternalMutation({
5118
- onSuccess,
5119
- onError,
5120
- onSettled: () => {
5121
- setHasCreatedFirstPermit(true);
5122
- },
5123
- mutationFn: async (args) => {
5124
- const { name, isSelf, expirationSeconds } = args;
5125
- const { account } = cofheClient.getSnapshot();
5126
- if (!account) throw new Error("No connected account found");
5127
- if (isSelf) {
5128
- await cofheClient.permits.createSelf({
5129
- expiration: expirationSeconds,
5130
- issuer: account,
5131
- name: name.trim()
5132
- });
5133
- return;
5134
- }
5135
- await cofheClient.permits.createSharing({
5136
- expiration: expirationSeconds,
5137
- issuer: account,
5138
- recipient: args.receiver,
5139
- name: name.trim()
5140
- });
5141
- }
5142
- });
5143
- };
5144
-
5145
- // src/hooks/permits/usePermitForm.ts
5146
5144
  function usePermitForm(options = {}) {
5147
5145
  const { onSuccess, onError, isDelegate = false } = options;
5148
5146
  const [permitName, setPermitName] = useState5("");
@@ -5151,7 +5149,7 @@ function usePermitForm(options = {}) {
5151
5149
  const [nameError, setNameError] = useState5(null);
5152
5150
  const [receiverError, setReceiverError] = useState5(null);
5153
5151
  const [durationSeconds, setDurationSeconds] = useState5(7 * 24 * 60 * 60);
5154
- const { mutateAsync: createPermitMutateAsync, isPending: isPermitCreationPending } = useCofheCreatePermitMutation({
5152
+ const { mutateAsync: createPermitMutateAsync, isPending: isPermitCreationPending } = useCofheCreatePermit({
5155
5153
  onSuccess,
5156
5154
  onError
5157
5155
  });
@@ -5613,6 +5611,7 @@ export {
5613
5611
  useCofheSimulateWriteContract,
5614
5612
  usePermitDuration,
5615
5613
  usePortalPersisted,
5614
+ useCofheCreatePermit,
5616
5615
  usePermitForm,
5617
5616
  useCofheNavigateToCreatePermit,
5618
5617
  usePermitsList,
@@ -5627,4 +5626,4 @@ export {
5627
5626
  constructTokenAllowanceQueryKeyForInvalidation,
5628
5627
  useTokenAllowance
5629
5628
  };
5630
- //# sourceMappingURL=chunk-N3S7TQY6.js.map
5629
+ //# sourceMappingURL=chunk-C5RYFTRG.js.map