@cofhe/react 0.0.0-beta-20260313071530 → 0.0.0-beta-20260323135047

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.cjs CHANGED
@@ -748,7 +748,7 @@ __export(index_exports, {
748
748
  TransactionActionType: () => TransactionActionType,
749
749
  TransactionStatus: () => TransactionStatus,
750
750
  actionToString: () => actionToString,
751
- createCofheClient: () => import_web3.createCofheClient,
751
+ createCofheClient: () => import_web4.createCofheClient,
752
752
  createCofheConfig: () => createCofheConfig,
753
753
  encryptedValueToString: () => encryptedValueToString,
754
754
  fheTypeToString: () => fheTypeToString,
@@ -820,7 +820,7 @@ var QueryProvider = ({
820
820
  };
821
821
 
822
822
  // src/providers/CofheProvider.tsx
823
- var import_web2 = require("@cofhe/sdk/web");
823
+ var import_web3 = require("@cofhe/sdk/web");
824
824
 
825
825
  // src/utils/cn.ts
826
826
  var cn = (...classes) => {
@@ -3346,7 +3346,8 @@ var import_sdk5 = require("@cofhe/sdk");
3346
3346
  var import_sdk4 = require("@cofhe/sdk");
3347
3347
  var import_ts_essentials8 = __toESM(require_dist(), 1);
3348
3348
  function useCofheDecrypt({
3349
- input
3349
+ input,
3350
+ onPoll: onPoll2
3350
3351
  }, queryOptions) {
3351
3352
  const { client } = useCofheContext();
3352
3353
  const isCofheErrorActive = useIsCofheErrorActive();
@@ -3357,7 +3358,9 @@ function useCofheDecrypt({
3357
3358
  queryKey: ["decryptCiphertext", input?.ctHash.toString(), input?.utype],
3358
3359
  queryFn: async () => {
3359
3360
  (0, import_ts_essentials8.assert)(input, "input is guaranteed to be defined by enabled condition");
3360
- return client.decryptForView(input.ctHash, input.utype).execute();
3361
+ const builder = client.decryptForView(input.ctHash, input.utype);
3362
+ if (onPoll2) builder.onPoll(onPoll2);
3363
+ return builder.execute();
3361
3364
  },
3362
3365
  meta: {
3363
3366
  persist: true
@@ -3370,6 +3373,21 @@ function useCofheDecrypt({
3370
3373
  });
3371
3374
  }
3372
3375
 
3376
+ // src/utils/isProduction.ts
3377
+ var import_meta = {};
3378
+ var isProduction = () => {
3379
+ if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
3380
+ return false;
3381
+ }
3382
+ if (typeof import_meta !== "undefined") {
3383
+ const metaEnv = import_meta.env;
3384
+ if (metaEnv && metaEnv.MODE === "development" && metaEnv.DEV === true && metaEnv.PROD === false) {
3385
+ return false;
3386
+ }
3387
+ }
3388
+ return true;
3389
+ };
3390
+
3373
3391
  // src/hooks/useCofheReadContractAndDecrypt.ts
3374
3392
  function isEncryptedValue(value) {
3375
3393
  return typeof value === "object" && value !== null && "ctHash" in value && "utype" in value && Object.values(import_sdk5.FheTypes).includes(value.utype);
@@ -3380,6 +3398,11 @@ function convertCofheReturnTypeToEncryptedReturnType(value) {
3380
3398
  "Auto-decryption now only supports a case where the contract function returns a single encrypted value"
3381
3399
  );
3382
3400
  }
3401
+ var onPoll = isProduction() ? void 0 : (context) => {
3402
+ console.debug(
3403
+ `Decryption poll attemptIndex ${context.attemptIndex}. Operation: ${context.operation}. ${context.elapsedMs}ms elapsed. Request ID: ${context.requestId}.`
3404
+ );
3405
+ };
3383
3406
  function useCofheReadContractAndDecrypt(params, {
3384
3407
  readQueryOptions,
3385
3408
  decryptingQueryOptions
@@ -3390,7 +3413,8 @@ function useCofheReadContractAndDecrypt(params, {
3390
3413
  const asEncryptedReturnType = encryptedData ? convertCofheReturnTypeToEncryptedReturnType(encryptedData) : void 0;
3391
3414
  const decrypted = useCofheDecrypt(
3392
3415
  {
3393
- input: asEncryptedReturnType
3416
+ input: asEncryptedReturnType,
3417
+ onPoll
3394
3418
  },
3395
3419
  decryptingQueryOptions
3396
3420
  );
@@ -4999,6 +5023,7 @@ var import_react_query15 = require("@tanstack/react-query");
4999
5023
  var import_react_query_persist_client = require("@tanstack/react-query-persist-client");
5000
5024
  var import_query_async_storage_persister = require("@tanstack/query-async-storage-persister");
5001
5025
  var import_react32 = require("react");
5026
+ var import_web = require("@cofhe/sdk/web");
5002
5027
  function isPersistedQuery(options) {
5003
5028
  const meta = options.meta;
5004
5029
  return meta?.persist === true;
@@ -5023,13 +5048,13 @@ function deserializeWithBigInt(serialized) {
5023
5048
  return v;
5024
5049
  });
5025
5050
  }
5026
- var storage = persistenceConfig.storage === "localStorage" ? window.localStorage : window.sessionStorage;
5027
- var persister = (0, import_query_async_storage_persister.createAsyncStoragePersister)({
5051
+ var storage = !import_web.hasDOM ? (0, import_web.createSsrStorage)() : persistenceConfig.storage === "localStorage" ? window.localStorage : window.sessionStorage;
5052
+ var persister = storage ? (0, import_query_async_storage_persister.createAsyncStoragePersister)({
5028
5053
  storage,
5029
5054
  key: persistenceConfig.key ?? "cofhe:react-query",
5030
5055
  serialize: serializeWithBigInt,
5031
5056
  deserialize: deserializeWithBigInt
5032
- });
5057
+ }) : void 0;
5033
5058
 
5034
5059
  // src/providers/internalQueryHooks.ts
5035
5060
  function applyPersistedDefaults(options) {
@@ -6434,7 +6459,6 @@ var TransactionItem = ({ transaction }) => {
6434
6459
 
6435
6460
  // src/components/FnxFloatingButton/pages/MainPage/BottomNavigation.tsx
6436
6461
  var import_jsx_runtime28 = require("react/jsx-runtime");
6437
- var import_meta = {};
6438
6462
  var iconClassName = "w-4 h-4";
6439
6463
  var ShieldIcon = () => {
6440
6464
  const { totalTokensClaimable } = useCofheClaimableTokens();
@@ -6488,18 +6512,6 @@ var debugNavItem = {
6488
6512
  label: "Debug",
6489
6513
  icon: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_fa.FaBug, { className: iconClassName })
6490
6514
  };
6491
- var isProduction = () => {
6492
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
6493
- return false;
6494
- }
6495
- if (typeof import_meta !== "undefined") {
6496
- const metaEnv = import_meta.env;
6497
- if (metaEnv && metaEnv.MODE === "development" && metaEnv.DEV === true && metaEnv.PROD === false) {
6498
- return false;
6499
- }
6500
- }
6501
- return true;
6502
- };
6503
6515
  var navItems = [...baseNavItems, ...!isProduction() ? [debugNavItem] : []];
6504
6516
  var BottomNavigation = () => {
6505
6517
  const { navigateTo } = usePortalNavigation();
@@ -9590,7 +9602,7 @@ var FnxFloatingButtonWithProvider = (props) => {
9590
9602
  // src/config.ts
9591
9603
  var import_zod = require("zod");
9592
9604
  var import_sdk10 = require("@cofhe/sdk");
9593
- var import_web = require("@cofhe/sdk/web");
9605
+ var import_web2 = require("@cofhe/sdk/web");
9594
9606
  var import_viem23 = require("viem");
9595
9607
  var addressSchema = import_zod.z.string().refine((val) => (0, import_viem23.isAddress)(val), {
9596
9608
  error: "Invalid address"
@@ -9620,7 +9632,7 @@ var CofheReactConfigSchema = import_zod.z.object({
9620
9632
  });
9621
9633
  function createCofheConfig(config) {
9622
9634
  const { react: reactConfigInput = {}, ...webConfig } = config;
9623
- const webClientConfig = (0, import_web.createCofheConfig)({
9635
+ const webClientConfig = (0, import_web2.createCofheConfig)({
9624
9636
  environment: "react",
9625
9637
  ...webConfig
9626
9638
  });
@@ -9651,7 +9663,7 @@ function CofheProvider(props) {
9651
9663
  }
9652
9664
  return createCofheConfig({ supportedChains: Object.values(import_chains5.chains) });
9653
9665
  }, [props.config, props.cofheClient]);
9654
- const cofheClient = (0, import_react64.useMemo)(() => props.cofheClient ?? (0, import_web2.createCofheClient)(config), [props.cofheClient, config]);
9666
+ const cofheClient = (0, import_react64.useMemo)(() => props.cofheClient ?? (0, import_web3.createCofheClient)(config), [props.cofheClient, config]);
9655
9667
  const [position, setPosition] = (0, import_react64.useState)(config.react.position);
9656
9668
  const [theme, setTheme] = (0, import_react64.useState)(config.react.initialTheme);
9657
9669
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
@@ -10001,7 +10013,7 @@ var FnxEncryptInput = ({
10001
10013
  };
10002
10014
 
10003
10015
  // src/index.ts
10004
- var import_web3 = require("@cofhe/sdk/web");
10016
+ var import_web4 = require("@cofhe/sdk/web");
10005
10017
  // Annotate the CommonJS export names for ESM import in node:
10006
10018
  0 && (module.exports = {
10007
10019
  CofheProvider,