@cofhe/react 1.1.0-alpha.5 → 1.1.0-alpha.6

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.
@@ -33279,7 +33279,7 @@ function useCofheTokensClaimable({ tokens, accountAddress: account }, queryOptio
33279
33279
 
33280
33280
  // src/hooks/useCofheTokenShield.ts
33281
33281
  import "viem";
33282
- var import_ts_essentials13 = __toESM(require_dist());
33282
+ var import_ts_essentials13 = __toESM(require_dist(), 1);
33283
33283
  function getCofheTokenShieldCallArgs(params) {
33284
33284
  const { token, amount, account } = params;
33285
33285
  const confidentialityType = token.extensions.fhenix.confidentialityType;
@@ -62769,4 +62769,4 @@ export {
62769
62769
  SettingsPage,
62770
62770
  CofheFloatingButtonWithProvider
62771
62771
  };
62772
- //# sourceMappingURL=chunk-6AIHOKTV.js.map
62772
+ //# sourceMappingURL=chunk-CPAI6WMZ.js.map
package/dist/index.cjs CHANGED
@@ -115,28 +115,28 @@
115
115
 
116
116
 
117
117
 
118
- var _chunkBBZDUNBDcjs = require('./chunk-BBZDUNBD.cjs');
118
+ var _chunk3O3XFKDNcjs = require('./chunk-3O3XFKDN.cjs');
119
119
 
120
120
  // src/hooks/useCofheDecryptForViewList.ts
121
121
  function useCofheDecryptForViewList({ inputs, meta, context, onPoll, chainId, acp, timeoutMs }, queryOptions) {
122
- const { client } = _chunkBBZDUNBDcjs.useCofheContext.call(void 0, );
123
- const connectedChainId = _chunkBBZDUNBDcjs.useCofheChainId.call(void 0, );
122
+ const { client } = _chunk3O3XFKDNcjs.useCofheContext.call(void 0, );
123
+ const connectedChainId = _chunk3O3XFKDNcjs.useCofheChainId.call(void 0, );
124
124
  const decryptChainId = _nullishCoalesce(chainId, () => ( connectedChainId));
125
- const effectiveACP = _chunkBBZDUNBDcjs.useCofheEffectiveACP.call(void 0, { acp, chainId });
125
+ const effectiveACP = _chunk3O3XFKDNcjs.useCofheEffectiveACP.call(void 0, { acp, chainId });
126
126
  const scopedACP = effectiveACP.scoped ? effectiveACP.acp : void 0;
127
- _chunkBBZDUNBDcjs.useDropDecryptsOfInvalidACP.call(void 0, effectiveACP);
127
+ _chunk3O3XFKDNcjs.useDropDecryptsOfInvalidACP.call(void 0, effectiveACP);
128
128
  const {
129
129
  enabled: userEnabled,
130
130
  meta: optionMeta,
131
- retry = _chunkBBZDUNBDcjs.defaultDecryptRetry,
131
+ retry = _chunk3O3XFKDNcjs.defaultDecryptRetry,
132
132
  ...restQueryOptions
133
133
  } = queryOptions || {};
134
- return _chunkBBZDUNBDcjs.useInternalQueries.call(void 0, {
134
+ return _chunk3O3XFKDNcjs.useInternalQueries.call(void 0, {
135
135
  queries: inputs.map((input, index) => {
136
136
  const zero = !!input && BigInt(input.ctHash) === 0n;
137
- const outOfScope = _chunkBBZDUNBDcjs.isHandleOutOfScope.call(void 0, scopedACP, _optionalChain([input, 'optionalAccess', _ => _.ctHash]));
137
+ const outOfScope = _chunk3O3XFKDNcjs.isHandleOutOfScope.call(void 0, scopedACP, _optionalChain([input, 'optionalAccess', _ => _.ctHash]));
138
138
  const enabled = !!input && !zero && !!client && effectiveACP.isValid && !outOfScope && (_nullishCoalesce(userEnabled, () => ( true)));
139
- const query = _chunkBBZDUNBDcjs.cofheDecryptForViewQuery.call(void 0, {
139
+ const query = _chunk3O3XFKDNcjs.cofheDecryptForViewQuery.call(void 0, {
140
140
  client,
141
141
  input,
142
142
  decryptChainId,
@@ -156,17 +156,14 @@ function useCofheDecryptForViewList({ inputs, meta, context, onPoll, chainId, ac
156
156
  ...restQueryOptions,
157
157
  retry,
158
158
  // The zero handle is its own answer: present from the first render, never fetched.
159
- ...zero ? { initialData: _chunkBBZDUNBDcjs.zeroPlaintext.call(void 0, input.utype), staleTime: Infinity } : {}
159
+ ...zero ? { initialData: _chunk3O3XFKDNcjs.zeroPlaintext.call(void 0, input.utype), staleTime: Infinity } : {}
160
160
  };
161
161
  })
162
162
  });
163
163
  }
164
164
 
165
- // src/hooks/useCofheDecrypter.ts
166
- var _react = require('react');
167
-
168
165
  // src/hooks/useCofheDecryptForTx.ts
169
- var import_ts_essentials = _chunkBBZDUNBDcjs.__toESM.call(void 0, _chunkBBZDUNBDcjs.require_dist.call(void 0, ));
166
+ var import_ts_essentials = _chunk3O3XFKDNcjs.__toESM.call(void 0, _chunk3O3XFKDNcjs.require_dist.call(void 0, ));
170
167
  function constructCofheDecryptForTxQueryKey(params) {
171
168
  return ["decryptForTx", params.chainId, params.ctHash, params.acpHash];
172
169
  }
@@ -188,7 +185,7 @@ function cofheDecryptForTxQuery(params) {
188
185
  if (onPoll) builder.onPoll(onPoll);
189
186
  if (timeoutMs !== void 0) builder.setTimeout(timeoutMs);
190
187
  if (retry404TimeoutMs !== void 0) builder.set404RetryTimeout(retry404TimeoutMs);
191
- const abort = _chunkBBZDUNBDcjs.anySignal.call(void 0, [signal, _optionalChain([queryContext, 'optionalAccess', _5 => _5.signal])]);
188
+ const abort = _chunk3O3XFKDNcjs.anySignal.call(void 0, [signal, _optionalChain([queryContext, 'optionalAccess', _5 => _5.signal])]);
192
189
  if (abort) builder.setSignal(abort);
193
190
  const selected = acp === null ? builder.withoutACP() : scopedACP ? builder.withACP(scopedACP) : builder.withACP();
194
191
  return selected.execute();
@@ -208,21 +205,21 @@ function cofheDecryptForTxQuery(params) {
208
205
  };
209
206
  }
210
207
  function useCofheDecryptForTx({ ctHash, acp, chainId, account, onPoll, timeoutMs, retry404TimeoutMs, meta, context }, queryOptions) {
211
- const { client } = _chunkBBZDUNBDcjs.useCofheContext.call(void 0, );
212
- const connectedChainId = _chunkBBZDUNBDcjs.useCofheChainId.call(void 0, );
208
+ const { client } = _chunk3O3XFKDNcjs.useCofheContext.call(void 0, );
209
+ const connectedChainId = _chunk3O3XFKDNcjs.useCofheChainId.call(void 0, );
213
210
  const decryptChainId = _nullishCoalesce(chainId, () => ( connectedChainId));
214
211
  const withoutACP = acp === null;
215
- const effectiveACP = _chunkBBZDUNBDcjs.useCofheEffectiveACP.call(void 0, { acp: _nullishCoalesce(acp, () => ( void 0)), chainId });
212
+ const effectiveACP = _chunk3O3XFKDNcjs.useCofheEffectiveACP.call(void 0, { acp: _nullishCoalesce(acp, () => ( void 0)), chainId });
216
213
  const scopedACP = effectiveACP.scoped ? effectiveACP.acp : void 0;
217
- _chunkBBZDUNBDcjs.useDropDecryptsOfInvalidACP.call(void 0, effectiveACP);
214
+ _chunk3O3XFKDNcjs.useDropDecryptsOfInvalidACP.call(void 0, effectiveACP);
218
215
  const {
219
216
  enabled: userEnabled,
220
217
  meta: optionMeta,
221
- retry = _chunkBBZDUNBDcjs.defaultDecryptRetry,
218
+ retry = _chunk3O3XFKDNcjs.defaultDecryptRetry,
222
219
  staleTime = Infinity,
223
220
  ...restQueryOptions
224
221
  } = queryOptions || {};
225
- const outOfScope = !withoutACP && _chunkBBZDUNBDcjs.isHandleOutOfScope.call(void 0, scopedACP, ctHash);
222
+ const outOfScope = !withoutACP && _chunk3O3XFKDNcjs.isHandleOutOfScope.call(void 0, scopedACP, ctHash);
226
223
  const enabled = ctHash !== void 0 && BigInt(ctHash) > 0n && !!client && (withoutACP || effectiveACP.isValid) && !outOfScope && (_nullishCoalesce(userEnabled, () => ( true)));
227
224
  const query = cofheDecryptForTxQuery({
228
225
  client,
@@ -238,7 +235,7 @@ function useCofheDecryptForTx({ ctHash, acp, chainId, account, onPoll, timeoutMs
238
235
  meta,
239
236
  context
240
237
  });
241
- return _chunkBBZDUNBDcjs.useInternalQuery.call(void 0, {
238
+ return _chunk3O3XFKDNcjs.useInternalQuery.call(void 0, {
242
239
  enabled,
243
240
  queryKey: query.queryKey,
244
241
  queryFn: query.queryFn,
@@ -249,7 +246,55 @@ function useCofheDecryptForTx({ ctHash, acp, chainId, account, onPoll, timeoutMs
249
246
  });
250
247
  }
251
248
 
249
+ // src/hooks/useCofheDecryptForTxList.ts
250
+ function useCofheDecryptForTxList({ inputs, acp, chainId, account, onPoll, timeoutMs, retry404TimeoutMs, meta, context }, queryOptions) {
251
+ const { client } = _chunk3O3XFKDNcjs.useCofheContext.call(void 0, );
252
+ const connectedChainId = _chunk3O3XFKDNcjs.useCofheChainId.call(void 0, );
253
+ const decryptChainId = _nullishCoalesce(chainId, () => ( connectedChainId));
254
+ const withoutACP = acp === null;
255
+ const effectiveACP = _chunk3O3XFKDNcjs.useCofheEffectiveACP.call(void 0, { acp: _nullishCoalesce(acp, () => ( void 0)), chainId });
256
+ const scopedACP = effectiveACP.scoped ? effectiveACP.acp : void 0;
257
+ _chunk3O3XFKDNcjs.useDropDecryptsOfInvalidACP.call(void 0, effectiveACP);
258
+ const {
259
+ enabled: userEnabled,
260
+ meta: optionMeta,
261
+ retry = _chunk3O3XFKDNcjs.defaultDecryptRetry,
262
+ staleTime = Infinity,
263
+ ...restQueryOptions
264
+ } = queryOptions || {};
265
+ return _chunk3O3XFKDNcjs.useInternalQueries.call(void 0, {
266
+ queries: inputs.map((ctHash, index) => {
267
+ const outOfScope = !withoutACP && _chunk3O3XFKDNcjs.isHandleOutOfScope.call(void 0, scopedACP, ctHash);
268
+ const enabled = ctHash !== void 0 && BigInt(ctHash) > 0n && !!client && (withoutACP || effectiveACP.isValid) && !outOfScope && (_nullishCoalesce(userEnabled, () => ( true)));
269
+ const query = cofheDecryptForTxQuery({
270
+ client,
271
+ ctHash,
272
+ decryptChainId,
273
+ chainId,
274
+ account,
275
+ acp: withoutACP ? null : effectiveACP.acp,
276
+ scoped: effectiveACP.scoped,
277
+ onPoll,
278
+ timeoutMs,
279
+ retry404TimeoutMs,
280
+ meta: typeof meta === "function" ? ctHash !== void 0 ? meta(ctHash, index) : void 0 : meta,
281
+ context
282
+ });
283
+ return {
284
+ enabled,
285
+ queryKey: query.queryKey,
286
+ queryFn: query.queryFn,
287
+ meta: { ...query.meta, ...optionMeta },
288
+ staleTime,
289
+ ...restQueryOptions,
290
+ retry
291
+ };
292
+ })
293
+ });
294
+ }
295
+
252
296
  // src/hooks/useCofheDecrypter.ts
297
+ var _react = require('react');
253
298
 
254
299
 
255
300
 
@@ -263,7 +308,7 @@ function assertACPDecrypts(effectiveACP, ctHash, operation) {
263
308
  hint: "Create or activate an ACP, or wait for the chosen one to be checked, before decrypting."
264
309
  });
265
310
  }
266
- if (_chunkBBZDUNBDcjs.isHandleOutOfScope.call(void 0, scoped ? acp : void 0, ctHash)) {
311
+ if (_chunk3O3XFKDNcjs.isHandleOutOfScope.call(void 0, scoped ? acp : void 0, ctHash)) {
267
312
  throw new (0, _sdk.CofheError)({
268
313
  code: _sdk.CofheErrorCode.ACPDenied,
269
314
  message: `${operation}: the handle is not listed in the SNAPSHOT share that would decrypt it`,
@@ -312,12 +357,12 @@ function useCofheDecrypter({
312
357
  acp,
313
358
  concurrency = 4
314
359
  } = {}) {
315
- const { client } = _chunkBBZDUNBDcjs.useCofheContext.call(void 0, );
316
- const queryClient = _chunkBBZDUNBDcjs.useInternalQueryClient.call(void 0, );
317
- const connectedChainId = _chunkBBZDUNBDcjs.useCofheChainId.call(void 0, );
360
+ const { client } = _chunk3O3XFKDNcjs.useCofheContext.call(void 0, );
361
+ const queryClient = _chunk3O3XFKDNcjs.useInternalQueryClient.call(void 0, );
362
+ const connectedChainId = _chunk3O3XFKDNcjs.useCofheChainId.call(void 0, );
318
363
  const decryptChainId = _nullishCoalesce(chainId, () => ( connectedChainId));
319
- const effectiveACP = _chunkBBZDUNBDcjs.useCofheEffectiveACP.call(void 0, { acp, chainId });
320
- _chunkBBZDUNBDcjs.useDropDecryptsOfInvalidACP.call(void 0, effectiveACP);
364
+ const effectiveACP = _chunk3O3XFKDNcjs.useCofheEffectiveACP.call(void 0, { acp, chainId });
365
+ _chunk3O3XFKDNcjs.useDropDecryptsOfInvalidACP.call(void 0, effectiveACP);
321
366
  const limit = _react.useMemo.call(void 0, () => createLimiter(concurrency), [concurrency]);
322
367
  const isReady = !!client && effectiveACP.isValid;
323
368
  const { acp: decryptACP, scoped } = effectiveACP;
@@ -326,9 +371,9 @@ function useCofheDecrypter({
326
371
  if (!client) {
327
372
  throw new (0, _sdk.CofheError)({ code: _sdk.CofheErrorCode.InternalError, message: "CoFHE client not initialized" });
328
373
  }
329
- if (BigInt(input.ctHash) === 0n) return _chunkBBZDUNBDcjs.zeroPlaintext.call(void 0, input.utype);
374
+ if (BigInt(input.ctHash) === 0n) return _chunk3O3XFKDNcjs.zeroPlaintext.call(void 0, input.utype);
330
375
  assertACPDecrypts(effectiveACP, input.ctHash, "decryptForView");
331
- const query = _chunkBBZDUNBDcjs.cofheDecryptForViewQuery.call(void 0, {
376
+ const query = _chunk3O3XFKDNcjs.cofheDecryptForViewQuery.call(void 0, {
332
377
  client,
333
378
  input,
334
379
  decryptChainId,
@@ -347,7 +392,7 @@ function useCofheDecrypter({
347
392
  queryFn: query.queryFn,
348
393
  meta: query.meta,
349
394
  staleTime: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _26 => _26.staleTime]), () => ( Infinity)),
350
- retry: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.retry]), () => ( _chunkBBZDUNBDcjs.defaultDecryptRetry))
395
+ retry: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.retry]), () => ( _chunk3O3XFKDNcjs.defaultDecryptRetry))
351
396
  }),
352
397
  "decryptForView",
353
398
  _optionalChain([options, 'optionalAccess', _28 => _28.signal])
@@ -390,7 +435,7 @@ function useCofheDecrypter({
390
435
  queryFn: query.queryFn,
391
436
  meta: query.meta,
392
437
  staleTime: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _37 => _37.staleTime]), () => ( Infinity)),
393
- retry: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _38 => _38.retry]), () => ( _chunkBBZDUNBDcjs.defaultDecryptRetry))
438
+ retry: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _38 => _38.retry]), () => ( _chunk3O3XFKDNcjs.defaultDecryptRetry))
394
439
  }),
395
440
  "decryptForTx",
396
441
  _optionalChain([options, 'optionalAccess', _39 => _39.signal])
@@ -466,10 +511,10 @@ function categoryFor(fetch, decrypt) {
466
511
  }
467
512
  function useCofheDecryptionActivity(options) {
468
513
  const staleMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.staleMs]), () => ( DEFAULT_STALE_MS));
469
- const queryClient = _chunkBBZDUNBDcjs.useInternalQueryClient.call(void 0, );
470
- const account = _chunkBBZDUNBDcjs.useCofheAccount.call(void 0, );
471
- const chainId = _chunkBBZDUNBDcjs.useCofheChainId.call(void 0, );
472
- const active = _chunkBBZDUNBDcjs.useCofheActiveACP.call(void 0, );
514
+ const queryClient = _chunk3O3XFKDNcjs.useInternalQueryClient.call(void 0, );
515
+ const account = _chunk3O3XFKDNcjs.useCofheAccount.call(void 0, );
516
+ const chainId = _chunk3O3XFKDNcjs.useCofheChainId.call(void 0, );
517
+ const active = _chunk3O3XFKDNcjs.useCofheActiveACP.call(void 0, );
473
518
  const acpObj = _optionalChain([active, 'optionalAccess', _41 => _41.acp]);
474
519
  const pendingSinceRef = _react.useRef.call(void 0, /* @__PURE__ */ new Map());
475
520
  const [version, bump] = _react.useReducer.call(void 0, (n) => n + 1, 0);
@@ -757,5 +802,6 @@ function useCofheDecryptionActivity(options) {
757
802
 
758
803
 
759
804
 
760
- exports.COFHE_STATUS_IDS = _chunkBBZDUNBDcjs.COFHE_STATUS_IDS; exports.CofheACPScope = _chunkBBZDUNBDcjs.CofheACPScope; exports.CofheFloatingButtonProvider = _chunkBBZDUNBDcjs.CofheFloatingButtonProvider; exports.CofheProvider = _chunkBBZDUNBDcjs.CofheProvider; exports.CofheStatusActionIntents = _chunkBBZDUNBDcjs.CofheStatusActionIntents; exports.ETH_ADDRESS_LOWERCASE = _chunkBBZDUNBDcjs.ETH_ADDRESS_LOWERCASE; exports.FheTypesList = _chunkBBZDUNBDcjs.FheTypesList; exports.TransactionActionType = _chunkBBZDUNBDcjs.TransactionActionType; exports.TransactionStatus = _chunkBBZDUNBDcjs.TransactionStatus; exports.actionToString = _chunkBBZDUNBDcjs.actionToString; exports.addCofheTransaction = _chunkBBZDUNBDcjs.addCofheTransaction; exports.asCofhePublicClient = _chunkBBZDUNBDcjs.asCofhePublicClient; exports.asCofheWalletClient = _chunkBBZDUNBDcjs.asCofheWalletClient; exports.cofheDecryptForTxQuery = cofheDecryptForTxQuery; exports.cofheDecryptForViewQuery = _chunkBBZDUNBDcjs.cofheDecryptForViewQuery; exports.constructCofheDecryptForTxQueryKey = constructCofheDecryptForTxQueryKey; exports.constructCofheDecryptForViewQueryKey = _chunkBBZDUNBDcjs.constructCofheDecryptForViewQueryKey; exports.constructCofheReadContractQueryForInvalidation = _chunkBBZDUNBDcjs.constructCofheReadContractQueryForInvalidation; exports.createCofheClient = _web.createCofheClient; exports.createCofheConfig = _chunkBBZDUNBDcjs.createCofheConfig; exports.findMatchingInvalidationContext = _chunkBBZDUNBDcjs.findMatchingInvalidationContext; exports.formatRelativeTime = _chunkBBZDUNBDcjs.formatRelativeTime; exports.getBlockExplorerAddressUrl = _chunkBBZDUNBDcjs.getBlockExplorerAddressUrl; exports.getBlockExplorerTokenUrl = _chunkBBZDUNBDcjs.getBlockExplorerTokenUrl; exports.getBlockExplorerTxUrl = _chunkBBZDUNBDcjs.getBlockExplorerTxUrl; exports.getBlockExplorerUrl = _chunkBBZDUNBDcjs.getBlockExplorerUrl; exports.getCofheTokenClaimUnshieldedCallArgs = _chunkBBZDUNBDcjs.getCofheTokenClaimUnshieldedCallArgs; exports.getCofheTokenShieldCallArgs = _chunkBBZDUNBDcjs.getCofheTokenShieldCallArgs; exports.getCofheTokenUnshieldCallArgs = _chunkBBZDUNBDcjs.getCofheTokenUnshieldCallArgs; exports.getConfidentialDecimals = _chunkBBZDUNBDcjs.getConfidentialDecimals; exports.getPublicDecimals = _chunkBBZDUNBDcjs.getPublicDecimals; exports.getPublicSymbol = _chunkBBZDUNBDcjs.getPublicSymbol; exports.invalidateQueriesWithContext = _chunkBBZDUNBDcjs.invalidateQueriesWithContext; exports.isCustomTransactionActionType = _chunkBBZDUNBDcjs.isCustomTransactionActionType; exports.isEthPair = _chunkBBZDUNBDcjs.isEthPair; exports.isWrappedEthToken = _chunkBBZDUNBDcjs.isWrappedEthToken; exports.maybeWaitUntilRpcAware = _chunkBBZDUNBDcjs.maybeWaitUntilRpcAware; exports.maybeWaitUntilRpcAwareAndReadContract = _chunkBBZDUNBDcjs.maybeWaitUntilRpcAwareAndReadContract; exports.quantizeAmount = _chunkBBZDUNBDcjs.quantizeAmount; exports.resolveReceiptBlockHash = _chunkBBZDUNBDcjs.resolveReceiptBlockHash; exports.scaleAmount = _chunkBBZDUNBDcjs.scaleAmount; exports.sortCofheStatuses = _chunkBBZDUNBDcjs.sortCofheStatuses; exports.statusToString = _chunkBBZDUNBDcjs.statusToString; exports.transactionMatchesToken = _chunkBBZDUNBDcjs.transactionMatchesToken; exports.truncateHash = _chunkBBZDUNBDcjs.truncateHash; exports.tryAsCofhePublicClient = _chunkBBZDUNBDcjs.tryAsCofhePublicClient; exports.tryAsCofheWalletClient = _chunkBBZDUNBDcjs.tryAsCofheWalletClient; exports.useCofheACPScope = _chunkBBZDUNBDcjs.useCofheACPScope; exports.useCofheACPStatus = _chunkBBZDUNBDcjs.useCofheACPStatus; exports.useCofheACPs = _chunkBBZDUNBDcjs.useCofheACPs; exports.useCofheActiveACP = _chunkBBZDUNBDcjs.useCofheActiveACP; exports.useCofheAllACPs = _chunkBBZDUNBDcjs.useCofheAllACPs; exports.useCofheAutoConnect = _chunkBBZDUNBDcjs.useCofheAutoConnect; exports.useCofheClient = _chunkBBZDUNBDcjs.useCofheClient; exports.useCofheConnection = _chunkBBZDUNBDcjs.useCofheConnection; exports.useCofheContext = _chunkBBZDUNBDcjs.useCofheContext; exports.useCofheCreateACP = _chunkBBZDUNBDcjs.useCofheCreateACP; exports.useCofheDecrypt = _chunkBBZDUNBDcjs.useCofheDecrypt; exports.useCofheDecryptForTx = useCofheDecryptForTx; exports.useCofheDecryptForViewList = useCofheDecryptForViewList; exports.useCofheDecrypter = useCofheDecrypter; exports.useCofheDecryptionActivity = useCofheDecryptionActivity; exports.useCofheEnabled = _chunkBBZDUNBDcjs.useCofheEnabled; exports.useCofheEncrypt = _chunkBBZDUNBDcjs.useCofheEncrypt; exports.useCofheEncryptAndWriteContract = _chunkBBZDUNBDcjs.useCofheEncryptAndWriteContract; exports.useCofheImportShared = _chunkBBZDUNBDcjs.useCofheImportShared; exports.useCofheIncomingShares = _chunkBBZDUNBDcjs.useCofheIncomingShares; exports.useCofheNavigateToCreateACP = _chunkBBZDUNBDcjs.useCofheNavigateToCreateACP; exports.useCofhePublicClient = _chunkBBZDUNBDcjs.useCofhePublicClient; exports.useCofheReadContract = _chunkBBZDUNBDcjs.useCofheReadContract; exports.useCofheReadContractAndDecrypt = _chunkBBZDUNBDcjs.useCofheReadContractAndDecrypt; exports.useCofheReadContracts = _chunkBBZDUNBDcjs.useCofheReadContracts; exports.useCofheRemoveACP = _chunkBBZDUNBDcjs.useCofheRemoveACP; exports.useCofheRemoveShare = _chunkBBZDUNBDcjs.useCofheRemoveShare; exports.useCofheRevokeACP = _chunkBBZDUNBDcjs.useCofheRevokeACP; exports.useCofheSelectACP = _chunkBBZDUNBDcjs.useCofheSelectACP; exports.useCofheShareLabels = _chunkBBZDUNBDcjs.useCofheShareLabels; exports.useCofheShareOnChain = _chunkBBZDUNBDcjs.useCofheShareOnChain; exports.useCofheSimulateWriteContract = _chunkBBZDUNBDcjs.useCofheSimulateWriteContract; exports.useCofheStatuses = _chunkBBZDUNBDcjs.useCofheStatuses; exports.useCofheTaskManagerAddress = _chunkBBZDUNBDcjs.useCofheTaskManagerAddress; exports.useCofheToken = _chunkBBZDUNBDcjs.useCofheToken; exports.useCofheTokenApprove = _chunkBBZDUNBDcjs.useCofheTokenApprove; exports.useCofheTokenClaimUnshielded = _chunkBBZDUNBDcjs.useCofheTokenClaimUnshielded; exports.useCofheTokenClaimable = _chunkBBZDUNBDcjs.useCofheTokenClaimable; exports.useCofheTokenClaims = _chunkBBZDUNBDcjs.useCofheTokenClaims; exports.useCofheTokenDecryptedBalance = _chunkBBZDUNBDcjs.useCofheTokenDecryptedBalance; exports.useCofheTokenLists = _chunkBBZDUNBDcjs.useCofheTokenLists; exports.useCofheTokenPublicBalance = _chunkBBZDUNBDcjs.useCofheTokenPublicBalance; exports.useCofheTokenShield = _chunkBBZDUNBDcjs.useCofheTokenShield; exports.useCofheTokenTransactions = _chunkBBZDUNBDcjs.useCofheTokenTransactions; exports.useCofheTokenTransfer = _chunkBBZDUNBDcjs.useCofheTokenTransfer; exports.useCofheTokenUnshield = _chunkBBZDUNBDcjs.useCofheTokenUnshield; exports.useCofheTokens = _chunkBBZDUNBDcjs.useCofheTokens; exports.useCofheTokensClaimable = _chunkBBZDUNBDcjs.useCofheTokensClaimable; exports.useCofheTokensWithExistingEncryptedBalances = _chunkBBZDUNBDcjs.useCofheTokensWithExistingEncryptedBalances; exports.useCofheTransactions = _chunkBBZDUNBDcjs.useCofheTransactions; exports.useCofheWalletClient = _chunkBBZDUNBDcjs.useCofheWalletClient; exports.useCofheWriteContract = _chunkBBZDUNBDcjs.useCofheWriteContract; exports.useCoingeckoContractMarketChartRange = _chunkBBZDUNBDcjs.useCoingeckoContractMarketChartRange; exports.useCoingeckoUsdPrice = _chunkBBZDUNBDcjs.useCoingeckoUsdPrice; exports.useCustomTokensStore = _chunkBBZDUNBDcjs.useCustomTokensStore; exports.useInternalQueryClient = _chunkBBZDUNBDcjs.useInternalQueryClient; exports.useInvalidationContextStore = _chunkBBZDUNBDcjs.useInvalidationContextStore; exports.useKnownCofheToken = _chunkBBZDUNBDcjs.useKnownCofheToken; exports.useResolvedCofheToken = _chunkBBZDUNBDcjs.useResolvedCofheToken; exports.useTokenAllowance = _chunkBBZDUNBDcjs.useTokenAllowance; exports.useTokensWithPublicBalances = _chunkBBZDUNBDcjs.useTokensWithPublicBalances; exports.useTransactionReceiptsByHash = _chunkBBZDUNBDcjs.useTransactionReceiptsByHash; exports.useTransactionStore = _chunkBBZDUNBDcjs.useTransactionStore; exports.withInvalidationContext = _chunkBBZDUNBDcjs.withInvalidationContext;
805
+
806
+ exports.COFHE_STATUS_IDS = _chunk3O3XFKDNcjs.COFHE_STATUS_IDS; exports.CofheACPScope = _chunk3O3XFKDNcjs.CofheACPScope; exports.CofheFloatingButtonProvider = _chunk3O3XFKDNcjs.CofheFloatingButtonProvider; exports.CofheProvider = _chunk3O3XFKDNcjs.CofheProvider; exports.CofheStatusActionIntents = _chunk3O3XFKDNcjs.CofheStatusActionIntents; exports.ETH_ADDRESS_LOWERCASE = _chunk3O3XFKDNcjs.ETH_ADDRESS_LOWERCASE; exports.FheTypesList = _chunk3O3XFKDNcjs.FheTypesList; exports.TransactionActionType = _chunk3O3XFKDNcjs.TransactionActionType; exports.TransactionStatus = _chunk3O3XFKDNcjs.TransactionStatus; exports.actionToString = _chunk3O3XFKDNcjs.actionToString; exports.addCofheTransaction = _chunk3O3XFKDNcjs.addCofheTransaction; exports.asCofhePublicClient = _chunk3O3XFKDNcjs.asCofhePublicClient; exports.asCofheWalletClient = _chunk3O3XFKDNcjs.asCofheWalletClient; exports.cofheDecryptForTxQuery = cofheDecryptForTxQuery; exports.cofheDecryptForViewQuery = _chunk3O3XFKDNcjs.cofheDecryptForViewQuery; exports.constructCofheDecryptForTxQueryKey = constructCofheDecryptForTxQueryKey; exports.constructCofheDecryptForViewQueryKey = _chunk3O3XFKDNcjs.constructCofheDecryptForViewQueryKey; exports.constructCofheReadContractQueryForInvalidation = _chunk3O3XFKDNcjs.constructCofheReadContractQueryForInvalidation; exports.createCofheClient = _web.createCofheClient; exports.createCofheConfig = _chunk3O3XFKDNcjs.createCofheConfig; exports.findMatchingInvalidationContext = _chunk3O3XFKDNcjs.findMatchingInvalidationContext; exports.formatRelativeTime = _chunk3O3XFKDNcjs.formatRelativeTime; exports.getBlockExplorerAddressUrl = _chunk3O3XFKDNcjs.getBlockExplorerAddressUrl; exports.getBlockExplorerTokenUrl = _chunk3O3XFKDNcjs.getBlockExplorerTokenUrl; exports.getBlockExplorerTxUrl = _chunk3O3XFKDNcjs.getBlockExplorerTxUrl; exports.getBlockExplorerUrl = _chunk3O3XFKDNcjs.getBlockExplorerUrl; exports.getCofheTokenClaimUnshieldedCallArgs = _chunk3O3XFKDNcjs.getCofheTokenClaimUnshieldedCallArgs; exports.getCofheTokenShieldCallArgs = _chunk3O3XFKDNcjs.getCofheTokenShieldCallArgs; exports.getCofheTokenUnshieldCallArgs = _chunk3O3XFKDNcjs.getCofheTokenUnshieldCallArgs; exports.getConfidentialDecimals = _chunk3O3XFKDNcjs.getConfidentialDecimals; exports.getPublicDecimals = _chunk3O3XFKDNcjs.getPublicDecimals; exports.getPublicSymbol = _chunk3O3XFKDNcjs.getPublicSymbol; exports.invalidateQueriesWithContext = _chunk3O3XFKDNcjs.invalidateQueriesWithContext; exports.isCustomTransactionActionType = _chunk3O3XFKDNcjs.isCustomTransactionActionType; exports.isEthPair = _chunk3O3XFKDNcjs.isEthPair; exports.isWrappedEthToken = _chunk3O3XFKDNcjs.isWrappedEthToken; exports.maybeWaitUntilRpcAware = _chunk3O3XFKDNcjs.maybeWaitUntilRpcAware; exports.maybeWaitUntilRpcAwareAndReadContract = _chunk3O3XFKDNcjs.maybeWaitUntilRpcAwareAndReadContract; exports.quantizeAmount = _chunk3O3XFKDNcjs.quantizeAmount; exports.resolveReceiptBlockHash = _chunk3O3XFKDNcjs.resolveReceiptBlockHash; exports.scaleAmount = _chunk3O3XFKDNcjs.scaleAmount; exports.sortCofheStatuses = _chunk3O3XFKDNcjs.sortCofheStatuses; exports.statusToString = _chunk3O3XFKDNcjs.statusToString; exports.transactionMatchesToken = _chunk3O3XFKDNcjs.transactionMatchesToken; exports.truncateHash = _chunk3O3XFKDNcjs.truncateHash; exports.tryAsCofhePublicClient = _chunk3O3XFKDNcjs.tryAsCofhePublicClient; exports.tryAsCofheWalletClient = _chunk3O3XFKDNcjs.tryAsCofheWalletClient; exports.useCofheACPScope = _chunk3O3XFKDNcjs.useCofheACPScope; exports.useCofheACPStatus = _chunk3O3XFKDNcjs.useCofheACPStatus; exports.useCofheACPs = _chunk3O3XFKDNcjs.useCofheACPs; exports.useCofheActiveACP = _chunk3O3XFKDNcjs.useCofheActiveACP; exports.useCofheAllACPs = _chunk3O3XFKDNcjs.useCofheAllACPs; exports.useCofheAutoConnect = _chunk3O3XFKDNcjs.useCofheAutoConnect; exports.useCofheClient = _chunk3O3XFKDNcjs.useCofheClient; exports.useCofheConnection = _chunk3O3XFKDNcjs.useCofheConnection; exports.useCofheContext = _chunk3O3XFKDNcjs.useCofheContext; exports.useCofheCreateACP = _chunk3O3XFKDNcjs.useCofheCreateACP; exports.useCofheDecrypt = _chunk3O3XFKDNcjs.useCofheDecrypt; exports.useCofheDecryptForTx = useCofheDecryptForTx; exports.useCofheDecryptForTxList = useCofheDecryptForTxList; exports.useCofheDecryptForViewList = useCofheDecryptForViewList; exports.useCofheDecrypter = useCofheDecrypter; exports.useCofheDecryptionActivity = useCofheDecryptionActivity; exports.useCofheEnabled = _chunk3O3XFKDNcjs.useCofheEnabled; exports.useCofheEncrypt = _chunk3O3XFKDNcjs.useCofheEncrypt; exports.useCofheEncryptAndWriteContract = _chunk3O3XFKDNcjs.useCofheEncryptAndWriteContract; exports.useCofheImportShared = _chunk3O3XFKDNcjs.useCofheImportShared; exports.useCofheIncomingShares = _chunk3O3XFKDNcjs.useCofheIncomingShares; exports.useCofheNavigateToCreateACP = _chunk3O3XFKDNcjs.useCofheNavigateToCreateACP; exports.useCofhePublicClient = _chunk3O3XFKDNcjs.useCofhePublicClient; exports.useCofheReadContract = _chunk3O3XFKDNcjs.useCofheReadContract; exports.useCofheReadContractAndDecrypt = _chunk3O3XFKDNcjs.useCofheReadContractAndDecrypt; exports.useCofheReadContracts = _chunk3O3XFKDNcjs.useCofheReadContracts; exports.useCofheRemoveACP = _chunk3O3XFKDNcjs.useCofheRemoveACP; exports.useCofheRemoveShare = _chunk3O3XFKDNcjs.useCofheRemoveShare; exports.useCofheRevokeACP = _chunk3O3XFKDNcjs.useCofheRevokeACP; exports.useCofheSelectACP = _chunk3O3XFKDNcjs.useCofheSelectACP; exports.useCofheShareLabels = _chunk3O3XFKDNcjs.useCofheShareLabels; exports.useCofheShareOnChain = _chunk3O3XFKDNcjs.useCofheShareOnChain; exports.useCofheSimulateWriteContract = _chunk3O3XFKDNcjs.useCofheSimulateWriteContract; exports.useCofheStatuses = _chunk3O3XFKDNcjs.useCofheStatuses; exports.useCofheTaskManagerAddress = _chunk3O3XFKDNcjs.useCofheTaskManagerAddress; exports.useCofheToken = _chunk3O3XFKDNcjs.useCofheToken; exports.useCofheTokenApprove = _chunk3O3XFKDNcjs.useCofheTokenApprove; exports.useCofheTokenClaimUnshielded = _chunk3O3XFKDNcjs.useCofheTokenClaimUnshielded; exports.useCofheTokenClaimable = _chunk3O3XFKDNcjs.useCofheTokenClaimable; exports.useCofheTokenClaims = _chunk3O3XFKDNcjs.useCofheTokenClaims; exports.useCofheTokenDecryptedBalance = _chunk3O3XFKDNcjs.useCofheTokenDecryptedBalance; exports.useCofheTokenLists = _chunk3O3XFKDNcjs.useCofheTokenLists; exports.useCofheTokenPublicBalance = _chunk3O3XFKDNcjs.useCofheTokenPublicBalance; exports.useCofheTokenShield = _chunk3O3XFKDNcjs.useCofheTokenShield; exports.useCofheTokenTransactions = _chunk3O3XFKDNcjs.useCofheTokenTransactions; exports.useCofheTokenTransfer = _chunk3O3XFKDNcjs.useCofheTokenTransfer; exports.useCofheTokenUnshield = _chunk3O3XFKDNcjs.useCofheTokenUnshield; exports.useCofheTokens = _chunk3O3XFKDNcjs.useCofheTokens; exports.useCofheTokensClaimable = _chunk3O3XFKDNcjs.useCofheTokensClaimable; exports.useCofheTokensWithExistingEncryptedBalances = _chunk3O3XFKDNcjs.useCofheTokensWithExistingEncryptedBalances; exports.useCofheTransactions = _chunk3O3XFKDNcjs.useCofheTransactions; exports.useCofheWalletClient = _chunk3O3XFKDNcjs.useCofheWalletClient; exports.useCofheWriteContract = _chunk3O3XFKDNcjs.useCofheWriteContract; exports.useCoingeckoContractMarketChartRange = _chunk3O3XFKDNcjs.useCoingeckoContractMarketChartRange; exports.useCoingeckoUsdPrice = _chunk3O3XFKDNcjs.useCoingeckoUsdPrice; exports.useCustomTokensStore = _chunk3O3XFKDNcjs.useCustomTokensStore; exports.useInternalQueryClient = _chunk3O3XFKDNcjs.useInternalQueryClient; exports.useInvalidationContextStore = _chunk3O3XFKDNcjs.useInvalidationContextStore; exports.useKnownCofheToken = _chunk3O3XFKDNcjs.useKnownCofheToken; exports.useResolvedCofheToken = _chunk3O3XFKDNcjs.useResolvedCofheToken; exports.useTokenAllowance = _chunk3O3XFKDNcjs.useTokenAllowance; exports.useTokensWithPublicBalances = _chunk3O3XFKDNcjs.useTokensWithPublicBalances; exports.useTransactionReceiptsByHash = _chunk3O3XFKDNcjs.useTransactionReceiptsByHash; exports.useTransactionStore = _chunk3O3XFKDNcjs.useTransactionStore; exports.withInvalidationContext = _chunk3O3XFKDNcjs.withInvalidationContext;
761
807
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/cofhesdk/cofhesdk/packages/react/dist/index.cjs","../src/hooks/useCofheDecryptForViewList.ts","../src/hooks/useCofheDecrypter.ts","../src/hooks/useCofheDecryptForTx.ts","../src/index.ts","../src/hooks/useCofheDecryptionActivity.ts"],"names":["useMemo"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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ACM,MAAA;AACJ,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACK,QAAA;AACL,QAAA;AACQ,QAAA;AACR,QAAA;AACQ,QAAA;AACF,QAAA;AACN,QAAA;AACD,MAAA;AACM,MAAA;AAEH,QAAA;AACE,UAAA;AACA,UAAA;AACM,UAAA;AACN,UAAA;AACA,UAAA;AACD,QAAA;AACH,QAAA;AACA,wBAAA;AACF,MAAA;AACF,IAAA;AACS,IAAA;AACX,EAAA;AAEM,EAAA;AACG,IAAA;AACA,MAAA;AACG,QAAA;AACR,MAAA;AACI,MAAA;AACI,QAAA;AACE,UAAA;AACN,UAAA;AACM,UAAA;AACP,QAAA;AACH,MAAA;AACM,MAAA;AACD,MAAA;AACC,MAAA;AACJ,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACK,QAAA;AACL,QAAA;AACQ,QAAA;AACR,QAAA;AACA,QAAA;AACQ,QAAA;AACF,QAAA;AACN,QAAA;AACD,MAAA;AACM,MAAA;AAEH,QAAA;AACE,UAAA;AACA,UAAA;AACM,UAAA;AACN,UAAA;AACA,UAAA;AACD,QAAA;AACH,QAAA;AACA,wBAAA;AACF,MAAA;AACF,IAAA;AACS,IAAA;AACX,EAAA;AAES,EAAA;AACX;AFmHgB;AACA;AI/NP;AJiOO;AACA;AKtZP;AAwBH;AACS;AAmEN;AACG,EAAA;AACN,EAAA;AACK,IAAA;AACD,EAAA;AACI,IAAA;AACE,IAAA;AACd,EAAA;AACF;AAIS;AACE,EAAA;AACL,EAAA;AACK,IAAA;AACD,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAES;AACH,EAAA;AACU,IAAA;AACD,IAAA;AACL,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAES;AACM,EAAA;AACF,EAAA;AACA,EAAA;AACF,IAAA;AACT,EAAA;AACO,EAAA;AACT;AAKS;AACH,EAAA;AACU,IAAA;AACN,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAGS;AACK,EAAA;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,QAAA;AACN,QAAA;AACA,QAAA;AACO,QAAA;AAA0B,QAAA;AACQ,QAAA;AACD,QAAA;AAEtC,UAAA;AACA,UAAA;AACK,QAAA;AACL,UAAA;AACK,UAAA;AACP,QAAA;AACF,MAAA;AAEE,QAAA;AACA,QAAA;AACF,MAAA;AAEM,MAAA;AACE,MAAA;AACC,QAAA;AACC,QAAA;AACR,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACO,QAAA;AACA,QAAA;AACP,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AACH,IAAA;AAGY,IAAA;AACN,MAAA;AACE,MAAA;AAUE,MAAA;AACD,QAAA;AACG,QAAA;AACR,QAAA;AACQ,QAAA;AACR,QAAA;AACA,QAAA;AACA,QAAA;AACO,QAAA;AACA,QAAA;AACP,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AACH,IAAA;AAGW,IAAA;AACJ,MAAA;AACP,IAAA;AAEM,IAAA;AACG,MAAA;AACE,MAAA;AACA,MAAA;AACF,MAAA;AACE,MAAA;AACF,MAAA;AACT,IAAA;AAGM,IAAA;AACK,MAAA;AACF,MAAA;AACA,MAAA;AACE,MAAA;AACH,MAAA;AACE,MAAA;AACJ,MAAA;AACN,IAAA;AACW,IAAA;AAEL,IAAA;AACG,IAAA;AAEP,EAAA;AAEQ,EAAA;AACd;ALqOgB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/cofhesdk/cofhesdk/packages/react/dist/index.cjs","sourcesContent":[null,"import { useCofheContext, useInternalQueries } from '@/providers';\nimport { isHandleOutOfScope, useCofheEffectiveACP, type CofheACPInput } from './useCofheACPScope';\nimport { useCofheChainId } from './useCofheConnection';\nimport {\n cofheDecryptForViewQuery,\n defaultDecryptRetry,\n useDropDecryptsOfInvalidACP,\n zeroPlaintext,\n type CofheDecryptContext,\n} from './useCofheDecrypt';\nimport type { DecryptPollCallbackFunction, FheTypes, UnsealedItem } from '@cofhe/sdk';\nimport type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport type { EncryptedReturnTypeByUtype } from '@cofhe/abi';\nimport type { CofheDecryptMeta } from '@/meta';\n\nexport type UseCofheDecryptForViewListInput<U extends FheTypes> = {\n /** The handles to decrypt, in the order the results come back; `undefined` entries stay idle. */\n inputs: ReadonlyArray<EncryptedReturnTypeByUtype<U> | undefined>;\n /** Consumer-supplied metadata for debug/activity views, one for all or one per entry. */\n meta?: CofheDecryptMeta | ((input: EncryptedReturnTypeByUtype<U>, index: number) => CofheDecryptMeta);\n /** Structural context from the originating read (address/method), for recognition. */\n context?: CofheDecryptContext;\n onPoll?: DecryptPollCallbackFunction;\n /**\n * The chain the ciphertexts live on — the connected chain by default. Gates on and decrypts\n * with THAT chain's active ACP.\n */\n chainId?: number;\n /**\n * Decrypt with this ACP (or the hash of a stored one) instead of the enclosing\n * `<CofheACPScope>` or the active ACP. The active ACP is not changed.\n */\n acp?: CofheACPInput;\n /** The decrypt's whole budget in milliseconds, submit retries and polling together (5 minutes by default). */\n timeoutMs?: number;\n};\n\n/**\n * `useCofheDecrypt` for a list: one query per handle, the same keys, gate, persistence and\n * activity rows, returned in the order of `inputs`. For a list a component renders, or a total it\n * derives from every value, where the handles are known at render time. The client's\n * `decryptConcurrency` cap bounds how many requests run at once, so a long list is safe.\n *\n * A zero handle — a value never set on chain — reads as the type's zero without a request.\n */\nexport function useCofheDecryptForViewList<U extends FheTypes, TSelectedData = UnsealedItem<U>>(\n { inputs, meta, context, onPoll, chainId, acp, timeoutMs }: UseCofheDecryptForViewListInput<U>,\n queryOptions?: Omit<UseQueryOptions<UnsealedItem<U>, Error, TSelectedData>, 'queryKey' | 'queryFn'>\n): UseQueryResult<TSelectedData, Error>[] {\n const { client } = useCofheContext();\n const connectedChainId = useCofheChainId();\n const decryptChainId = chainId ?? connectedChainId;\n const effectiveACP = useCofheEffectiveACP({ acp, chainId });\n const scopedACP = effectiveACP.scoped ? effectiveACP.acp : undefined;\n useDropDecryptsOfInvalidACP(effectiveACP);\n\n const {\n enabled: userEnabled,\n meta: optionMeta,\n retry = defaultDecryptRetry,\n ...restQueryOptions\n } = queryOptions || {};\n\n return useInternalQueries({\n queries: inputs.map((input, index) => {\n const zero = !!input && BigInt(input.ctHash) === 0n;\n const outOfScope = isHandleOutOfScope(scopedACP, input?.ctHash);\n const enabled = !!input && !zero && !!client && effectiveACP.isValid && !outOfScope && (userEnabled ?? true);\n const query = cofheDecryptForViewQuery<U>({\n client,\n input,\n decryptChainId,\n chainId,\n acp: effectiveACP.acp,\n scoped: effectiveACP.scoped,\n onPoll,\n timeoutMs,\n meta: typeof meta === 'function' ? (input ? meta(input, index) : undefined) : meta,\n context,\n });\n return {\n enabled,\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: { ...query.meta, ...optionMeta },\n ...restQueryOptions,\n retry,\n // The zero handle is its own answer: present from the first render, never fetched.\n ...(zero ? { initialData: zeroPlaintext(input.utype), staleTime: Infinity } : {}),\n };\n }),\n }) as UseQueryResult<TSelectedData, Error>[];\n}\n","import { useCallback, useMemo } from 'react';\nimport { useCofheContext, useInternalQueryClient } from '@/providers';\nimport {\n isHandleOutOfScope,\n useCofheEffectiveACP,\n type CofheACPInput,\n type CofheEffectiveACP,\n} from './useCofheACPScope';\nimport { useCofheChainId } from './useCofheConnection';\nimport {\n cofheDecryptForViewQuery,\n defaultDecryptRetry,\n useDropDecryptsOfInvalidACP,\n zeroPlaintext,\n type CofheDecryptContext,\n} from './useCofheDecrypt';\nimport { cofheDecryptForTxQuery } from './useCofheDecryptForTx';\nimport {\n CofheError,\n CofheErrorCode,\n type FheTypes,\n type DecryptForTxResult,\n type DecryptPollCallbackFunction,\n type UnsealedItem,\n} from '@cofhe/sdk';\nimport type { EncryptedReturnTypeByUtype } from '@cofhe/abi';\nimport type { CofheDecryptMeta } from '@/meta';\n\n/** Per-call options of the function `useCofheDecrypter` returns. */\nexport type CofheDecryptForViewFnOptions = {\n /** Consumer-supplied metadata for debug/activity views. */\n meta?: CofheDecryptMeta;\n /** Structural context from the originating read (address/method), for recognition. */\n context?: CofheDecryptContext;\n onPoll?: DecryptPollCallbackFunction;\n /** The decrypt's whole budget in milliseconds, submit retries and polling together (5 minutes by default). */\n timeoutMs?: number;\n /**\n * A cached plaintext younger than this is returned without a request. `Infinity` by default: a\n * plaintext never changes, so a handle decrypted once (by this function or by `useCofheDecrypt`)\n * is never decrypted again.\n */\n staleTime?: number;\n /** Retry policy of a failed request; by default a `CofheError` is final and anything else is retried 3 times. */\n retry?: boolean | number | ((failureCount: number, error: Error) => boolean);\n /**\n * Stops the call when it fires: a call still waiting for a concurrency slot never starts, a\n * request in flight is aborted, and the call rejects with `Aborted`. A plaintext already in the\n * cache is still returned.\n */\n signal?: AbortSignal;\n};\n\n/** Decrypts one handle; see `useCofheDecrypter`. */\nexport type CofheDecryptForViewFn = <U extends FheTypes>(\n input: EncryptedReturnTypeByUtype<U>,\n options?: CofheDecryptForViewFnOptions\n) => Promise<UnsealedItem<U>>;\n\n/** Per-call options of `decryptForTx`; see `useCofheDecrypter`. */\nexport type CofheDecryptForTxFnOptions = CofheDecryptForViewFnOptions & {\n /**\n * `null`: the contract allowed the handle publicly (`FHE.allowPublic`), so it decrypts without\n * an ACP and does not wait for one. Otherwise the hook's ACP decrypts, as for `decryptForView`.\n */\n acp?: null;\n /** The account whose stored ACPs resolve the active ACP; the connected account by default. */\n account?: string;\n /** How long a submit-time `404 ct_not_found` (handle not indexed yet) is retried; 10 seconds by default. */\n retry404TimeoutMs?: number;\n};\n\n/** Decrypts one handle into a plaintext with the network's signature; see `useCofheDecrypter`. */\nexport type CofheDecryptForTxFn = (\n ctHash: bigint | string,\n options?: CofheDecryptForTxFnOptions\n) => Promise<DecryptForTxResult>;\n\nexport type UseCofheDecrypterOptions = {\n /**\n * The chain the ciphertexts live on — the connected chain by default. Gates on and decrypts\n * with THAT chain's active ACP, e.g. for values read through a chain-pinned read.\n */\n chainId?: number;\n /**\n * Decrypt with this ACP (or the hash of a stored one) instead of the enclosing\n * `<CofheACPScope>` or the active ACP. The active ACP is not changed.\n */\n acp?: CofheACPInput;\n /** How many requests one caller runs at a time; the rest wait their turn. 4 by default. */\n concurrency?: number;\n};\n\nexport type UseCofheDecrypterResult = {\n /** Decrypts one handle through the decrypt cache; rejects without a request while `isReady` is false. */\n decryptForView: CofheDecryptForViewFn;\n /**\n * Decrypts one handle into a plaintext with the threshold network's signature, for a contract to\n * verify on chain, through the same cache as `useCofheDecryptForTx`. With `acp: null` it needs\n * only the client, not `isReady`.\n */\n decryptForTx: CofheDecryptForTxFn;\n /** A client and a valid ACP are at hand, so a call can run. */\n isReady: boolean;\n /** The ACP `decryptForView` uses, with its status: why `isReady` is false, when it is. */\n acp: CofheEffectiveACP;\n};\n\n/** The reasons a call must not be sent: no valid ACP, or a SNAPSHOT share that does not list the handle. */\nfunction assertACPDecrypts(effectiveACP: CofheEffectiveACP, ctHash: bigint | string, operation: string): void {\n const { acp, scoped, status } = effectiveACP;\n if (!effectiveACP.isValid) {\n throw new CofheError({\n code: status === 'expired' ? CofheErrorCode.ACPExpired : CofheErrorCode.ACPRequired,\n message: `${operation}: no valid ACP to decrypt with (${status})`,\n hint: 'Create or activate an ACP, or wait for the chosen one to be checked, before decrypting.',\n });\n }\n if (isHandleOutOfScope(scoped ? acp : undefined, ctHash)) {\n throw new CofheError({\n code: CofheErrorCode.ACPDenied,\n message: `${operation}: the handle is not listed in the SNAPSHOT share that would decrypt it`,\n context: { ctHash: ctHash.toString(), acpHash: acp?.hash },\n });\n }\n}\n\nfunction abortedError(operation: string, signal: AbortSignal): CofheError {\n return new CofheError({\n code: CofheErrorCode.Aborted,\n message: `${operation} aborted by the caller`,\n cause: signal.reason instanceof Error ? signal.reason : undefined,\n });\n}\n\n/**\n * Runs tasks at most `max` at a time, in call order. A task whose `signal` fires while it waits\n * for a slot leaves the queue and rejects without ever starting.\n */\nfunction createLimiter(\n max: number\n): <T>(task: () => Promise<T>, operation: string, signal?: AbortSignal) => Promise<T> {\n let active = 0;\n const waiting: Array<() => void> = [];\n return async (task, operation, signal) => {\n if (signal?.aborted) throw abortedError(operation, signal);\n if (active >= max) {\n await new Promise<void>((resume, reject) => {\n const onAbort = () => {\n const index = waiting.indexOf(start);\n if (index >= 0) waiting.splice(index, 1);\n reject(abortedError(operation, signal!));\n };\n const start = () => {\n signal?.removeEventListener('abort', onAbort);\n resume();\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n waiting.push(start);\n });\n }\n active += 1;\n try {\n return await task();\n } finally {\n active -= 1;\n waiting.shift()?.();\n }\n };\n}\n\n/**\n * The imperative counterpart of `useCofheDecrypt`: a function that decrypts one handle on demand,\n * for the work a component does not render per value — a job the user starts over a list of\n * handles (a history to sum, a set of bids to reveal), from the handler that starts it.\n *\n * Each call is the same query `useCofheDecrypt` would run — same cache key, same gate, same\n * persistence, same activity row — so a handle decrypted either way is decrypted once, and\n * `decryptForView` returns a cached plaintext without a request. Calls run at most `concurrency` at a\n * time; fan out with `Promise.all` freely.\n *\n * Without a valid ACP, or with a SNAPSHOT share that does not list the handle, `decryptForView` rejects\n * with a `CofheError` and sends nothing. A zero handle resolves to the type's zero without a request.\n *\n * `decryptForTx` is the same for a proof — the plaintext with the threshold network's signature,\n * for a contract to verify — through the cache of `useCofheDecryptForTx`. A proof is a read too: a\n * handle maps to one plaintext forever, so a handle proved once is never requested again. `acp:\n * null` decrypts a publicly allowed handle without an ACP, and then needs only the client.\n */\nexport function useCofheDecrypter({\n chainId,\n acp,\n concurrency = 4,\n}: UseCofheDecrypterOptions = {}): UseCofheDecrypterResult {\n const { client } = useCofheContext();\n const queryClient = useInternalQueryClient();\n const connectedChainId = useCofheChainId();\n const decryptChainId = chainId ?? connectedChainId;\n const effectiveACP = useCofheEffectiveACP({ acp, chainId });\n useDropDecryptsOfInvalidACP(effectiveACP);\n const limit = useMemo(() => createLimiter(concurrency), [concurrency]);\n\n const isReady = !!client && effectiveACP.isValid;\n const { acp: decryptACP, scoped } = effectiveACP;\n\n const decryptForView = useCallback<CofheDecryptForViewFn>(\n async (input, options) => {\n if (!client) {\n throw new CofheError({ code: CofheErrorCode.InternalError, message: 'CoFHE client not initialized' });\n }\n if (BigInt(input.ctHash) === 0n) return zeroPlaintext(input.utype);\n assertACPDecrypts(effectiveACP, input.ctHash, 'decryptForView');\n const query = cofheDecryptForViewQuery({\n client,\n input,\n decryptChainId,\n chainId,\n acp: decryptACP,\n scoped,\n onPoll: options?.onPoll,\n timeoutMs: options?.timeoutMs,\n signal: options?.signal,\n meta: options?.meta,\n context: options?.context,\n });\n return limit(\n () =>\n queryClient.fetchQuery({\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: query.meta,\n staleTime: options?.staleTime ?? Infinity,\n retry: options?.retry ?? defaultDecryptRetry,\n }),\n 'decryptForView',\n options?.signal\n );\n },\n [client, queryClient, decryptChainId, chainId, decryptACP, scoped, effectiveACP, limit]\n );\n\n const decryptForTx = useCallback<CofheDecryptForTxFn>(\n async (ctHash, options) => {\n if (!client) {\n throw new CofheError({ code: CofheErrorCode.InternalError, message: 'CoFHE client not initialized' });\n }\n if (BigInt(ctHash) === 0n) {\n throw new CofheError({\n code: CofheErrorCode.DecryptFailed,\n message: 'decryptForTx: the zero handle has no value to prove',\n hint: 'A zero handle is a value never set on chain; nothing can be revealed from it.',\n });\n }\n const withoutACP = options?.acp === null;\n if (!withoutACP) assertACPDecrypts(effectiveACP, ctHash, 'decryptForTx');\n const query = cofheDecryptForTxQuery({\n client,\n ctHash,\n decryptChainId,\n chainId,\n account: options?.account,\n acp: withoutACP ? null : decryptACP,\n scoped,\n onPoll: options?.onPoll,\n timeoutMs: options?.timeoutMs,\n retry404TimeoutMs: options?.retry404TimeoutMs,\n signal: options?.signal,\n meta: options?.meta,\n context: options?.context,\n });\n return limit(\n () =>\n queryClient.fetchQuery({\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: query.meta,\n staleTime: options?.staleTime ?? Infinity,\n retry: options?.retry ?? defaultDecryptRetry,\n }),\n 'decryptForTx',\n options?.signal\n );\n },\n [client, queryClient, decryptChainId, chainId, decryptACP, scoped, effectiveACP, limit]\n );\n\n return { decryptForView, decryptForTx, isReady, acp: effectiveACP };\n}\n","import { useCofheContext, useInternalQuery } from '@/providers';\nimport { isHandleOutOfScope, useCofheEffectiveACP, type CofheACPInput } from './useCofheACPScope';\nimport { useCofheChainId } from './useCofheConnection';\nimport { defaultDecryptRetry, useDropDecryptsOfInvalidACP, type CofheDecryptContext } from './useCofheDecrypt';\nimport type { CofheClient, DecryptForTxResult, DecryptPollCallbackFunction } from '@cofhe/sdk';\nimport type { ACP } from '@cofhe/sdk/acps';\nimport type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { assert } from 'ts-essentials';\nimport type { CofheDecryptMeta, CofheQueryMeta } from '@/meta';\nimport { anySignal } from '@/utils/abortSignal';\n\n/**\n * The cache key of one tx decrypt: a handle decrypted on one chain into a plaintext with the\n * threshold network's signature — `[prefix, chainId, ctHash, acpHash]`. `acpHash` names the ACP\n * that decrypts, or is `null` for a handle the contract allowed publicly, decrypted without one.\n * No `utype` segment: the network signs the plaintext as an integer, whatever the handle's type.\n */\nexport function constructCofheDecryptForTxQueryKey(params: {\n ctHash: string | undefined;\n chainId: number | undefined;\n acpHash: string | null | undefined;\n}): readonly unknown[] {\n return ['decryptForTx', params.chainId, params.ctHash, params.acpHash];\n}\n\n/**\n * The query one tx decrypt runs as — its key, its `queryFn` and its `meta` — shared by\n * `useCofheDecryptForTx` and `useCofheDecrypter`, so a proof fetched either way is the same cache\n * entry. A proof is a read: a handle maps to one plaintext forever and the contract verifies only\n * `(ctHash, value, signature)`, so nothing but the handle and the ACP keys it.\n */\nexport function cofheDecryptForTxQuery(params: {\n client: CofheClient;\n ctHash: bigint | string | undefined;\n /** The chain the decrypt runs on: the caller's `chainId`, else the connected chain. */\n decryptChainId: number | undefined;\n /** The caller's explicit `chainId`, set on the builder when given. */\n chainId?: number;\n /** The account whose stored ACPs resolve the active ACP, set on the builder when given. */\n account?: string;\n /**\n * The ACP that decrypts, and whether it was chosen explicitly (a hook option or a scope);\n * `null` for a publicly allowed handle (`FHE.allowPublic`), which needs none.\n */\n acp: ACP | null | undefined;\n scoped: boolean;\n onPoll?: DecryptPollCallbackFunction;\n timeoutMs?: number;\n retry404TimeoutMs?: number;\n /** The caller's abort signal; React Query's own (query cancelled) is joined to it in `queryFn`. */\n signal?: AbortSignal;\n meta?: CofheDecryptMeta;\n context?: CofheDecryptContext;\n}): {\n queryKey: readonly unknown[];\n queryFn: (context?: { signal?: AbortSignal }) => Promise<DecryptForTxResult>;\n // Also a plain record: that is what `fetchQuery` and `useQuery` type `meta` as.\n meta: Record<string, unknown> & CofheQueryMeta & { persist: boolean };\n} {\n const { client, ctHash, decryptChainId, chainId, account, acp, scoped, onPoll, timeoutMs, retry404TimeoutMs } =\n params;\n const { signal, meta, context } = params;\n const scopedACP = scoped && acp ? acp : undefined;\n return {\n queryKey: constructCofheDecryptForTxQueryKey({\n ctHash: ctHash?.toString(),\n chainId: decryptChainId,\n acpHash: acp === null ? null : acp?.hash,\n }),\n queryFn: async (queryContext) => {\n assert(ctHash !== undefined, 'a tx decrypt query only runs with a handle');\n const builder = client.decryptForTx(ctHash);\n if (chainId !== undefined) builder.setChainId(chainId);\n if (account !== undefined) builder.setAccount(account);\n if (onPoll) builder.onPoll(onPoll);\n if (timeoutMs !== undefined) builder.setTimeout(timeoutMs);\n if (retry404TimeoutMs !== undefined) builder.set404RetryTimeout(retry404TimeoutMs);\n const abort = anySignal([signal, queryContext?.signal]);\n if (abort) builder.setSignal(abort);\n const selected = acp === null ? builder.withoutACP() : scopedACP ? builder.withACP(scopedACP) : builder.withACP();\n return selected.execute();\n },\n meta: {\n // Same rule as a view decrypt: persist what the user own ACP decrypts. A publicly allowed\n // handle's proof is public data, so it persists too; one decrypted with a shared ACP must\n // not outlive the share, so it stays in memory.\n persist: acp === null || acp?.type === 'self',\n kind: 'cofheDecryptForTx',\n ctHash: ctHash?.toString(),\n chainId: context?.chainId ?? decryptChainId,\n address: context?.address,\n functionName: context?.functionName,\n consumer: meta,\n },\n };\n}\n\nexport type UseCofheDecryptForTxInput = {\n /** The handle to decrypt; the query is disabled without one, or for the zero handle. */\n ctHash?: bigint | string;\n /**\n * The ACP to decrypt with: an ACP, the hash of a stored one, the enclosing `<CofheACPScope>`\n * or the active ACP when omitted, or `null` for a handle the contract allowed publicly\n * (`FHE.allowPublic`), which needs none and so never waits for one.\n */\n acp?: CofheACPInput | null;\n /**\n * The chain the handle lives on — the connected chain by default. Gates on and decrypts\n * with THAT chain's active ACP, e.g. for a value read through a chain-pinned read.\n */\n chainId?: number;\n /** The account whose stored ACPs resolve a hash or the active ACP; the connected account by default. */\n account?: string;\n onPoll?: DecryptPollCallbackFunction;\n /** The decrypt's whole budget in milliseconds, submit retries and polling together (5 minutes by default). */\n timeoutMs?: number;\n /** How long a submit-time `404 ct_not_found` (handle not indexed yet) is retried; 10 seconds by default. */\n retry404TimeoutMs?: number;\n /** Consumer-supplied metadata for debug/activity views. */\n meta?: CofheDecryptMeta;\n /** Structural context from the originating read (address/method), for recognition. */\n context?: CofheDecryptContext;\n};\n\n/**\n * Query hook around `client.decryptForTx`: the plaintext of a handle with the threshold network's\n * signature over it, for a contract to verify on chain (`FHE.verifyDecryptResult` /\n * `FHE.publishDecryptResult`). The declarative counterpart of `useCofheDecrypter().decryptForTx`:\n * mount it on the page that will send the transaction and the proof is ready before the click.\n *\n * A proof never changes, so the query is `staleTime: Infinity` by default and a handle proved\n * once (either way) is never requested again. Like `useCofheDecrypt` it waits for a valid ACP\n * rather than prompting for one — unless `acp` is `null`, when no ACP is involved at all.\n */\nexport function useCofheDecryptForTx<TSelectedData = DecryptForTxResult>(\n { ctHash, acp, chainId, account, onPoll, timeoutMs, retry404TimeoutMs, meta, context }: UseCofheDecryptForTxInput,\n queryOptions?: Omit<UseQueryOptions<DecryptForTxResult, Error, TSelectedData>, 'queryKey' | 'queryFn'>\n): UseQueryResult<TSelectedData, Error> {\n const { client } = useCofheContext();\n const connectedChainId = useCofheChainId();\n const decryptChainId = chainId ?? connectedChainId;\n const withoutACP = acp === null;\n // With `acp: null` the ACP below is not used; the hook still runs (hooks are unconditional) and\n // its drop effect is the same one `useCofheDecrypt` runs for that ACP.\n const effectiveACP = useCofheEffectiveACP({ acp: acp ?? undefined, chainId });\n const scopedACP = effectiveACP.scoped ? effectiveACP.acp : undefined;\n useDropDecryptsOfInvalidACP(effectiveACP);\n\n const {\n enabled: userEnabled,\n meta: optionMeta,\n retry = defaultDecryptRetry,\n staleTime = Infinity,\n ...restQueryOptions\n } = queryOptions || {};\n const outOfScope = !withoutACP && isHandleOutOfScope(scopedACP, ctHash);\n const enabled =\n ctHash !== undefined &&\n BigInt(ctHash) > 0n &&\n !!client &&\n (withoutACP || effectiveACP.isValid) &&\n !outOfScope &&\n (userEnabled ?? true);\n\n const query = cofheDecryptForTxQuery({\n client,\n ctHash,\n decryptChainId,\n chainId,\n account,\n acp: withoutACP ? null : effectiveACP.acp,\n scoped: effectiveACP.scoped,\n onPoll,\n timeoutMs,\n retry404TimeoutMs,\n meta,\n context,\n });\n\n return useInternalQuery({\n enabled,\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: { ...query.meta, ...optionMeta },\n staleTime,\n ...restQueryOptions,\n retry,\n });\n}\n","// Providers\nexport { CofheProvider, useCofheContext } from './providers/index';\n\n// Hooks\nexport {\n ETH_ADDRESS_LOWERCASE,\n getCofheTokenClaimUnshieldedCallArgs,\n getCofheTokenShieldCallArgs,\n getCofheTokenUnshieldCallArgs,\n useCofheActiveACP,\n useCofheACPs,\n useCofheAllACPs,\n useCofheClient,\n useCofheConnection,\n useCofheEnabled,\n useCofheTaskManagerAddress,\n useCofheEncrypt,\n useCofhePublicClient,\n useCofheRemoveACP,\n useCofheSelectACP,\n useCofheSimulateWriteContract,\n useCofheStatuses,\n useCofheTokenClaimable,\n useCofheTokenClaims,\n useCofheTokenApprove,\n useCofheTokenClaimUnshielded,\n useCofheTokenDecryptedBalance,\n useCofheTokenPublicBalance,\n useCofheTokenLists,\n useCofheToken,\n useKnownCofheToken,\n useCofheTokens,\n useCofheTokensClaimable,\n useCofheTokenShield,\n useCofheTokensWithExistingEncryptedBalances,\n useCofheTokenTransactions,\n useCofheTokenTransfer,\n useResolvedCofheToken,\n useCofheTransactions,\n addCofheTransaction,\n useCofheTokenUnshield,\n useCofheWalletClient,\n useCofheWriteContract,\n useCoingeckoContractMarketChartRange,\n useCoingeckoUsdPrice,\n useTokenAllowance,\n useTokensWithPublicBalances,\n useTransactionReceiptsByHash,\n type ClaimableAmountByTokenAddress,\n type CoingeckoMarketChartPoint,\n type Erc20Pair,\n type UnshieldClaim,\n type UnshieldClaimsSummary,\n type UnshieldClaimsSummaryByTokenAddress,\n type UseCoingeckoContractMarketChartRangeInput,\n type UseCoingeckoContractMarketChartRangeOptions,\n type UseCoingeckoUsdPriceInput,\n type UseCoingeckoUsdPriceOptions,\n type UseCofheTokenTransactionsInput,\n type UseCofheTokenTransactionsResult,\n type UseTransactionReceiptsByHashInput,\n type AddCofheTransactionInput,\n} from '@/hooks/index';\n\nexport { useCofheEncryptAndWriteContract } from '@/hooks/useCofheEncryptAndWriteContract';\nexport { useCofheReadContractAndDecrypt } from '@/hooks/useCofheReadContractAndDecrypt';\nexport {\n useCofheDecrypt,\n cofheDecryptForViewQuery,\n constructCofheDecryptForViewQueryKey,\n type CofheDecryptContext,\n} from '@/hooks/useCofheDecrypt';\nexport { useCofheDecryptForViewList, type UseCofheDecryptForViewListInput } from '@/hooks/useCofheDecryptForViewList';\nexport {\n useCofheDecrypter,\n type CofheDecryptForViewFn,\n type CofheDecryptForViewFnOptions,\n type CofheDecryptForTxFn,\n type CofheDecryptForTxFnOptions,\n type UseCofheDecrypterOptions,\n type UseCofheDecrypterResult,\n} from '@/hooks/useCofheDecrypter';\nexport {\n useCofheDecryptForTx,\n cofheDecryptForTxQuery,\n constructCofheDecryptForTxQueryKey,\n type UseCofheDecryptForTxInput,\n} from '@/hooks/useCofheDecryptForTx';\nexport {\n CofheACPScope,\n useCofheACPScope,\n useCofheACPStatus,\n type CofheACPInput,\n type CofheACPScopeValue,\n type CofheACPStatus,\n} from '@/hooks/useCofheACPScope';\nexport {\n useCofheIncomingShares,\n useCofheShareOnChain,\n useCofheImportShared,\n useCofheRemoveShare,\n useCofheRevokeACP,\n} from '@/hooks/acps/useOnChainSharing';\nexport {\n useCofheShareLabels,\n type CofheShareLabel,\n type UseCofheShareLabelsResult,\n} from '@/hooks/acps/useCofheShareLabels';\nexport {\n useCofheReadContract,\n constructCofheReadContractQueryForInvalidation,\n type UseCofheReadContractResult,\n type UseCofheReadContractQueryOptions,\n} from '@/hooks/useCofheReadContract';\nexport {\n useCofheReadContracts,\n type CofheReadContractsContract,\n type CofheReadContractsItem,\n type CofheReadContractsData,\n type CofheReadContractsEntry,\n type CofheReadContractsEntries,\n type CofheReadContractsEntryResult,\n type UseCofheReadContractsResult,\n type UseCofheReadContractsQueryOptions,\n} from '@/hooks/useCofheReadContracts';\nexport {\n type useCofheWriteContractOptions,\n type CofheWriteInvalidationTarget,\n type CofheWriteInvalidates,\n type CofheReadInvalidationDescriptor,\n} from '@/hooks/useCofheWriteContract';\n\n// Utils\nexport {\n FheTypesList,\n formatRelativeTime,\n getBlockExplorerAddressUrl,\n getBlockExplorerTokenUrl,\n getBlockExplorerTxUrl,\n getBlockExplorerUrl,\n isEthPair,\n isWrappedEthToken,\n truncateHash,\n} from './utils/index';\n\n// Stores\nexport { useCustomTokensStore } from './stores/customTokensStore';\n\nexport {\n actionToString,\n isCustomTransactionActionType,\n statusToString,\n transactionMatchesToken,\n TransactionActionType,\n TransactionStatus,\n useTransactionStore,\n type Transaction,\n type BuiltInTransactionActionType,\n type CustomTransactionActionType,\n type SharingTransactionActionType,\n type JsonValue,\n type NewTransaction,\n type TransactionActionString,\n type TransactionStatusString,\n type TransactionStore,\n} from './stores/transactionStore';\n\nexport { createCofheConfig } from './config';\nexport type { CofheReactLogger, CofheReactLoggerMethod } from './config';\n\n// Types\nexport type {\n CofheClientConfig,\n CofheContextValue,\n CofheProviderProps,\n TransactionRenderer,\n TransactionRendererProps,\n TransactionRenderers,\n} from './types/index';\n\nexport { createCofheClient } from '@cofhe/sdk/web';\n\nexport { useCofheCreateACP } from '@/hooks/acps/useCofheCreateACP';\nexport { useCofheNavigateToCreateACP } from '@/hooks/acps/useCofheNavigateToCreateACP';\nexport { useCofheAutoConnect } from '@/hooks/useCofheAutoConnect';\nexport { CofheFloatingButtonProvider, sortCofheStatuses } from './components/index';\nexport { COFHE_STATUS_IDS, CofheStatusActionIntents } from './components/CofheFloatingButton/types';\n\nexport type { CofheConfigWithReact as CofhesdkConfigWithReact } from './config';\n\nexport type { CofheStatus, CofheStatusActionIntent, CofheStatusId } from './components/CofheFloatingButton/types';\nexport type { ConfidentialToken } from './types/token';\nexport { getConfidentialDecimals, getPublicDecimals, getPublicSymbol } from './types/token';\nexport { scaleAmount, quantizeAmount } from './utils/format';\n\nexport type { CofheDecryptMeta, CofheQueryMeta } from './meta';\n\nexport { useCofheDecryptionActivity } from '@/hooks/useCofheDecryptionActivity';\nexport type {\n DecryptionActivityRow,\n DecryptionActivityResult,\n DecryptionActivityCategory,\n UseCofheDecryptionActivityOptions,\n FetchStageState,\n DecryptStageState,\n ACPState,\n} from '@/hooks/useCofheDecryptionActivity';\n\nexport { useInternalQueryClient } from './providers/index';\n\n// Type bridges for cross-repo / multi-instance viem peer dependency scenarios\nexport {\n asCofhePublicClient,\n tryAsCofhePublicClient,\n asCofheWalletClient,\n tryAsCofheWalletClient,\n} from './utils/viemClientBridge';\nexport type {\n PublicClientLike as CofhePublicClientLike,\n WalletClientLike as CofheWalletClientLike,\n} from './utils/viemClientBridge';\n\n// Block-aware cache invalidation primitives.\n//\n// These are the building blocks behind the SDK's own \"wait until the serving RPC\n// node has the mined block before returning a read\" behaviour. They are exported\n// so consumers (e.g. a wagmi-based app) can build the same reliability into their\n// own reads + post-tx invalidation, sharing THIS module's single invalidation-\n// context store — so an invalidation registered here is honoured by both the\n// SDK's confidential reads and the consumer's own block-aware queries.\nexport {\n invalidateQueriesWithContext,\n withInvalidationContext,\n findMatchingInvalidationContext,\n type InvalidationContextQueryFilters,\n type QueryFunctionWithInvalidationContext,\n} from './utils/invalidationContext';\nexport {\n maybeWaitUntilRpcAware,\n maybeWaitUntilRpcAwareAndReadContract,\n type WaitUntilRpcAwareAndReadContractOptions,\n type ReadContractResult,\n} from './utils/waitUntilRpcAwareAndReadContract';\nexport { resolveReceiptBlockHash } from './utils/resolveReceiptBlockHash';\nexport { useInvalidationContextStore, type InvalidationContextEntry } from './stores/invalidationContextStore';\n","import { useCallback, useEffect, useMemo, useReducer, useRef } from 'react';\nimport { useInternalQueryClient } from '@/providers';\nimport { useCofheAccount, useCofheChainId } from './useCofheConnection';\nimport { useCofheActiveACP } from './useCofheACPs';\nimport type { CofheQueryMeta } from '@/meta';\n\n// ============================================================================\n// Decryption activity — the lifecycle view of confidential reads + decryptions.\n// ============================================================================\n//\n// A confidential value is a two-stage pipeline, both stages living as react-query\n// queries on the SDK's internal QueryClient:\n// A) FETCH — read the ciphertext handle on-chain (`cofheReadContract`),\n// whose data carries the `ctHash`.\n// B) DECRYPT— decrypt that handle off-chain (`decryptCiphertext`, keyed\n// by chain AND ctHash).\n//\n// This hook observes the cache, correlates the two stages by ctHash, and returns\n// one row per confidential value with a recognizable contract/method/label (from\n// each query's `meta`) — surfacing states a plain error/loading flag can't:\n// • \"blocked\" — gated off by a missing/invalid acp (never runs, never errors)\n// • \"stale\" — fetched, but the decrypt is pending far too long / never lands\n// Consumers render the rows; no query-key parsing or side registries required.\n\nconst DEFAULT_STALE_MS = 25_000;\nconst nowSec = () => Math.floor(Date.now() / 1000);\n\n/** 'idle' = a read/decrypt query exists but is disabled/never-ran (fetchStatus 'idle'), vs 'pending' (in flight). */\nexport type FetchStageState = 'ok' | 'pending' | 'idle' | 'error' | 'empty';\nexport type DecryptStageState = 'ok' | 'pending' | 'idle' | 'stale' | 'error' | 'blocked' | 'absent';\nexport type ACPState = 'valid' | 'expired' | 'unsigned' | 'none';\n/** Coarse bucket for filtering: something wrong / decrypted / nothing conclusive. */\nexport type DecryptionActivityCategory = 'error' | 'success' | 'idle';\n\nexport interface DecryptionActivityRow {\n key: string;\n /** Canonical decimal ctHash, when known. */\n ctHash?: string;\n /** 0x…-shortened ctHash for display. */\n ctHashShort?: string;\n /** The originating query metadata (contract / method / label / consumer fields). */\n meta?: CofheQueryMeta;\n /** Convenience shortcuts pulled from meta. */\n chainId?: number;\n address?: string;\n functionName?: string;\n label?: string;\n fetch: FetchStageState;\n decrypt: DecryptStageState;\n category: DecryptionActivityCategory;\n /** Why the row is blocked, e.g. \"acp none\". */\n blockedReason?: string;\n /** How long the decrypt has been pending, ms (drives \"stale\"). */\n pendingMs?: number;\n updatedAt: number;\n /** Whether re-running is possible (false for gated/idle reads with nothing enabled). */\n canRetry: boolean;\n /** Re-run this value's read and/or decrypt. */\n retry: () => void;\n}\n\nexport interface DecryptionActivityResult {\n rows: DecryptionActivityRow[];\n counts: { total: number; ok: number; pending: number; stale: number; blocked: number; error: number };\n acp: { state: ACPState; expiresInSec?: number };\n /** Wipe the whole SDK query cache; mounted reads/decryptions refetch from scratch. */\n clearCache: () => void;\n}\n\nexport interface UseCofheDecryptionActivityOptions {\n /** How long a decrypt may stay pending before it's reported \"stale\" (default 25s). */\n staleMs?: number;\n}\n\n// Minimal structural view of a cached query — enough to classify without depending\n// on react-query's concrete generic types.\ninterface QueryLike {\n queryKey: unknown;\n queryHash: string;\n meta?: CofheQueryMeta;\n state: { status: 'pending' | 'error' | 'success'; fetchStatus?: string; data?: unknown; dataUpdatedAt?: number };\n}\ninterface CacheLike {\n getAll: () => QueryLike[];\n subscribe: (cb: () => void) => () => void;\n}\ninterface ClientLike {\n getQueryCache: () => CacheLike;\n refetchQueries: (filters: { queryKey: unknown; exact?: boolean }) => Promise<unknown>;\n clear: () => void;\n}\n\nfunction normalizeCt(x: unknown): string | undefined {\n if (x === null || x === undefined) return undefined;\n try {\n return BigInt(x as string | number | bigint).toString();\n } catch {\n const s = String(x);\n return s && s !== '[object Object]' ? s : undefined;\n }\n}\n\n// A ctHash of 0 is not a real handle: reads return it for an absent/encrypted-zero\n// value and the decrypt is gated on `ctHash > 0n`, so treat it as \"no handle\".\nfunction isZeroCt(ct: string | undefined): boolean {\n if (!ct) return false;\n try {\n return BigInt(ct) === 0n;\n } catch {\n return false;\n }\n}\n\nfunction shortCt(decimal: string): string {\n try {\n const hex = BigInt(decimal).toString(16);\n return hex.length > 10 ? `0x${hex.slice(0, 6)}…${hex.slice(-4)}` : `0x${hex}`;\n } catch {\n return decimal;\n }\n}\n\nfunction extractCtHash(data: unknown): string | undefined {\n if (data === null || data === undefined) return undefined;\n if (typeof data === 'bigint') return normalizeCt(data);\n if (typeof data === 'object' && data !== null && 'ctHash' in (data as Record<string, unknown>)) {\n return normalizeCt((data as { ctHash: unknown }).ctHash);\n }\n return undefined;\n}\n\n// The read key bakes the transient activeACPHash + enabled flags into its tail,\n// so the SAME value gets a fresh cache entry each time an ACP appears/rotates.\n// Its stable identity is [prefix, chainId, address, fn, args] (indices 0-4).\nfunction stableReadKey(k: unknown[]): string {\n try {\n return JSON.stringify(k.slice(0, 5));\n } catch {\n return String(k[1]) + '|' + String(k[2]) + '|' + String(k[3]);\n }\n}\n\n// Progress of a read: ran (success/error) > in flight > idle/never-ran.\nfunction readProgress(q: QueryLike): number {\n if (q.state.status === 'success' || q.state.status === 'error') return 2;\n if (q.state.fetchStatus === 'fetching') return 1;\n return 0;\n}\nfunction isFresherRead(candidate: QueryLike, current: QueryLike): boolean {\n const pc = readProgress(candidate);\n const pk = readProgress(current);\n if (pc !== pk) return pc > pk;\n return (candidate.state.dataUpdatedAt ?? 0) > (current.state.dataUpdatedAt ?? 0);\n}\n\nfunction categoryFor(fetch: FetchStageState, decrypt: DecryptStageState): DecryptionActivityCategory {\n if (fetch === 'error' || decrypt === 'error' || decrypt === 'blocked' || decrypt === 'stale') return 'error';\n if (decrypt === 'ok') return 'success';\n return 'idle';\n}\n\n/**\n * Observe the ctHash-fetch → decrypt pipeline on the SDK's QueryClient, correlated\n * by ctHash and cross-referenced against the active acp. Must be used inside the\n * Cofhe provider.\n */\nexport function useCofheDecryptionActivity(options?: UseCofheDecryptionActivityOptions): DecryptionActivityResult {\n const staleMs = options?.staleMs ?? DEFAULT_STALE_MS;\n const queryClient = useInternalQueryClient() as unknown as ClientLike;\n const account = useCofheAccount();\n const chainId = useCofheChainId();\n const active = useCofheActiveACP();\n const acpObj = active?.acp;\n\n // Track when each decrypt first went pending, so \"stale\" is real elapsed time\n // (react-query doesn't expose a fetch-start timestamp for a never-resolved query).\n const pendingSinceRef = useRef(new Map<string, number>());\n\n // Re-render on cache changes AND on a slow tick (staleness is time-based, not\n // event-driven — a query sitting pending emits no cache events).\n //\n // Coalesce cache events to one bump per animation frame. `cache.subscribe` fires\n // synchronously on EVERY cache event (including observer option/result updates),\n // and a consumer re-render can itself emit fresh cache events — an unbounded\n // bump→render→event→bump storm that pins the main thread and starves unrelated\n // updates (e.g. a route change never commits). One bump per frame keeps the view\n // live while capping re-renders so the loop can't run away.\n const [version, bump] = useReducer((n: number) => n + 1, 0);\n useEffect(() => {\n const cache = queryClient.getQueryCache();\n let scheduled = false;\n const schedule = () => {\n if (scheduled) return;\n scheduled = true;\n const run = () => {\n scheduled = false;\n bump();\n };\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(run);\n else setTimeout(run, 16);\n };\n const unsub = cache.subscribe(schedule);\n const tick = setInterval(bump, 5_000);\n return () => {\n unsub();\n clearInterval(tick);\n };\n }, [queryClient]);\n\n const clearCache = useCallback(() => queryClient.clear(), [queryClient]);\n\n const data = useMemo(() => {\n const cache = queryClient.getQueryCache();\n const queries = cache.getAll();\n const now = Date.now();\n\n const refetch = (key: unknown) => void queryClient.refetchQueries({ queryKey: key, exact: true });\n\n const acpState: ACPState = !acpObj\n ? 'none'\n : !acpObj.issuerSignature || acpObj.issuerSignature === '0x'\n ? 'unsigned'\n : acpObj.expiration <= nowSec()\n ? 'expired'\n : 'valid';\n const acpValid = acpState === 'valid';\n\n // Index decrypt queries by ctHash (source contract + label come from meta).\n const decryptByCt = new Map<\n string,\n { state: 'ok' | 'pending' | 'idle' | 'error'; pendingMs?: number; key?: unknown; meta?: CofheQueryMeta }\n >();\n const seenPending = new Set<string>();\n for (const q of queries) {\n const k = q.queryKey;\n // [prefix, chainId, ctHash, utype, acpHash] — see constructCofheDecryptForViewQueryKey.\n if (!Array.isArray(k) || k[0] !== 'decryptCiphertext') continue;\n const ct = normalizeCt(k[2]);\n if (!ct || isZeroCt(ct)) continue;\n const base = { key: q.queryKey, meta: q.meta };\n if (q.state.status === 'success') {\n decryptByCt.set(ct, { state: 'ok', ...base });\n pendingSinceRef.current.delete(ct);\n } else if (q.state.status === 'error') {\n decryptByCt.set(ct, { state: 'error', ...base });\n pendingSinceRef.current.delete(ct);\n } else if (q.state.fetchStatus === 'fetching') {\n seenPending.add(ct);\n let since = pendingSinceRef.current.get(ct);\n if (since === undefined) {\n since = now;\n pendingSinceRef.current.set(ct, since);\n }\n decryptByCt.set(ct, { state: 'pending', pendingMs: now - since, ...base });\n } else {\n // status 'pending' but fetchStatus 'idle' → disabled / never ran.\n pendingSinceRef.current.delete(ct);\n decryptByCt.set(ct, { state: 'idle', ...base });\n }\n }\n\n const rows: DecryptionActivityRow[] = [];\n const usedCt = new Set<string>();\n\n // Collapse per-acp/enabled key rotations to one entry per value.\n const readByValue = new Map<string, QueryLike>();\n for (const q of queries) {\n const k = q.queryKey;\n if (!Array.isArray(k) || k[0] !== 'cofheReadContract') continue;\n const id = stableReadKey(k);\n const existing = readByValue.get(id);\n if (!existing || isFresherRead(q, existing)) readByValue.set(id, q);\n }\n\n const pushRow = (\n row: Omit<DecryptionActivityRow, 'category' | 'canRetry' | 'retry'> & {\n fetchKey?: unknown;\n decryptKey?: unknown;\n }\n ) => {\n const { fetchKey, decryptKey, ...rest } = row;\n const canRetry = rest.fetch !== 'idle' && (fetchKey !== undefined || decryptKey !== undefined);\n rows.push({\n ...rest,\n category: categoryFor(rest.fetch, rest.decrypt),\n canRetry,\n retry: () => {\n if (fetchKey !== undefined) refetch(fetchKey);\n if (decryptKey !== undefined) refetch(decryptKey);\n },\n });\n };\n\n // One row per confidential value; attach its decrypt stage by ctHash.\n for (const q of readByValue.values()) {\n const m = q.meta;\n const ctRaw = q.state.status === 'success' ? extractCtHash(q.state.data) : undefined;\n const ct = ctRaw && !isZeroCt(ctRaw) ? ctRaw : undefined;\n const fetchInFlight = q.state.fetchStatus === 'fetching';\n const fetchState: FetchStageState =\n q.state.status === 'error'\n ? 'error'\n : q.state.status === 'pending'\n ? fetchInFlight\n ? 'pending'\n : 'idle'\n : ct\n ? 'ok'\n : 'empty';\n\n let decrypt: DecryptStageState = 'absent';\n let blockedReason: string | undefined;\n let pendingMs: number | undefined;\n let decryptKey: unknown;\n let decryptMeta: CofheQueryMeta | undefined;\n if (ct) {\n usedCt.add(ct);\n const d = decryptByCt.get(ct);\n decryptKey = d?.key;\n decryptMeta = d?.meta;\n if (d?.state === 'ok') decrypt = 'ok';\n else if (d?.state === 'error') decrypt = 'error';\n else if (d?.state === 'idle') decrypt = 'idle';\n else if (d?.state === 'pending') {\n pendingMs = d.pendingMs;\n decrypt = (d.pendingMs ?? 0) > staleMs ? 'stale' : 'pending';\n } else {\n decrypt = acpValid ? 'absent' : 'blocked';\n if (!acpValid) blockedReason = `acp ${acpState}`;\n }\n } else if (fetchState === 'idle' && !acpValid) {\n // The read is gated off (no valid acp) — blocked before any ctHash.\n decrypt = 'blocked';\n blockedReason = `acp ${acpState}`;\n }\n\n const meta = m ?? decryptMeta;\n pushRow({\n key: q.queryHash,\n ctHash: ct,\n ctHashShort: ct ? shortCt(ct) : undefined,\n meta,\n chainId: meta?.chainId,\n address: meta?.address,\n functionName: meta?.functionName,\n label: meta?.consumer?.label,\n fetch: fetchState,\n decrypt,\n blockedReason,\n pendingMs,\n updatedAt: now,\n fetchKey: q.queryKey,\n decryptKey,\n });\n }\n\n // Orphan decrypts (a ctHash being decrypted with no fetch query in cache).\n for (const [ct, d] of decryptByCt) {\n if (usedCt.has(ct)) continue;\n const decrypt: DecryptStageState =\n d.state === 'ok'\n ? 'ok'\n : d.state === 'error'\n ? 'error'\n : d.state === 'idle'\n ? 'idle'\n : (d.pendingMs ?? 0) > staleMs\n ? 'stale'\n : 'pending';\n pushRow({\n key: `decrypt:${ct}`,\n ctHash: ct,\n ctHashShort: shortCt(ct),\n meta: d.meta,\n chainId: d.meta?.chainId,\n address: d.meta?.address,\n functionName: d.meta?.functionName,\n label: d.meta?.consumer?.label,\n fetch: 'ok',\n decrypt,\n pendingMs: d.pendingMs,\n updatedAt: now,\n decryptKey: d.key,\n });\n }\n\n // Drop ctHashes we no longer see, so the pending-since map can't grow unbounded.\n for (const ct of pendingSinceRef.current.keys()) {\n if (!seenPending.has(ct)) pendingSinceRef.current.delete(ct);\n }\n\n const counts = {\n total: rows.length,\n ok: rows.filter((r) => r.decrypt === 'ok').length,\n pending: rows.filter((r) => r.decrypt === 'pending').length,\n stale: rows.filter((r) => r.decrypt === 'stale').length,\n blocked: rows.filter((r) => r.decrypt === 'blocked').length,\n error: rows.filter((r) => r.decrypt === 'error' || r.fetch === 'error').length,\n };\n\n // Most actionable first: blocked/stale/error, then pending, then done.\n const rank: Record<DecryptStageState, number> = {\n blocked: 0,\n stale: 1,\n error: 2,\n pending: 3,\n idle: 4,\n absent: 5,\n ok: 6,\n };\n rows.sort((a, b) => rank[a.decrypt] - rank[b.decrypt]);\n\n const expiresInSec = acpObj ? acpObj.expiration - nowSec() : undefined;\n return { rows, acp: { state: acpState, expiresInSec }, counts };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [queryClient, account, chainId, acpObj, staleMs, version]);\n\n return { ...data, clearCache };\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/cofhesdk/cofhesdk/packages/react/dist/index.cjs","../src/hooks/useCofheDecryptForViewList.ts","../src/hooks/useCofheDecryptForTx.ts","../src/hooks/useCofheDecryptForTxList.ts","../src/hooks/useCofheDecrypter.ts","../src/index.ts","../src/hooks/useCofheDecryptionActivity.ts"],"names":["useMemo"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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ACQ,QAAA;AACF,QAAA;AACN,QAAA;AACD,MAAA;AACM,MAAA;AAEH,QAAA;AACE,UAAA;AACA,UAAA;AACM,UAAA;AACN,UAAA;AACA,UAAA;AACD,QAAA;AACH,QAAA;AACA,wBAAA;AACF,MAAA;AACF,IAAA;AACS,IAAA;AACX,EAAA;AAES,EAAA;AACX;AJgKgB;AACA;AK3QP;AL6QO;AACA;AMncP;AAwBH;AACS;AAmEN;AACG,EAAA;AACN,EAAA;AACK,IAAA;AACD,EAAA;AACI,IAAA;AACE,IAAA;AACd,EAAA;AACF;AAIS;AACE,EAAA;AACL,EAAA;AACK,IAAA;AACD,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAES;AACH,EAAA;AACU,IAAA;AACD,IAAA;AACL,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAES;AACM,EAAA;AACF,EAAA;AACA,EAAA;AACF,IAAA;AACT,EAAA;AACO,EAAA;AACT;AAKS;AACH,EAAA;AACU,IAAA;AACN,EAAA;AACC,IAAA;AACT,EAAA;AACF;AAGS;AACK,EAAA;AACA,EAAA;AACL,EAAA;AACT;AACS;AACI,EAAA;AACA,EAAA;AACI,EAAA;AACP,EAAA;AACV;AAES;AACO,EAAA;AACV,EAAA;AACG,EAAA;AACT;AAOgB;AACR,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAIA,EAAA;AAWC,EAAA;AACG,EAAA;AACF,IAAA;AACF,IAAA;AACE,IAAA;AACA,MAAA;AACJ,MAAA;AACM,MAAA;AACJ,QAAA;AACK,QAAA;AACP,MAAA;AACI,MAAA;AACC,MAAA;AACP,IAAA;AACM,IAAA;AACA,IAAA;AACC,IAAA;AACC,MAAA;AACN,MAAA;AACF,IAAA;AACE,EAAA;AAEE,EAAA;AAEOA,EAAAA;AACL,IAAA;AACA,IAAA;AACM,IAAA;AAEN,IAAA;AAEA,IAAA;AAOA,IAAA;AAGA,IAAA;AAIA,IAAA;AACK,IAAA;AACC,MA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A,QAAA;AACD,MAAA;AACH,IAAA;AAGW,IAAA;AACJ,MAAA;AACP,IAAA;AAEM,IAAA;AACG,MAAA;AACE,MAAA;AACA,MAAA;AACF,MAAA;AACE,MAAA;AACF,MAAA;AACT,IAAA;AAGM,IAAA;AACK,MAAA;AACF,MAAA;AACA,MAAA;AACE,MAAA;AACH,MAAA;AACE,MAAA;AACJ,MAAA;AACN,IAAA;AACW,IAAA;AAEL,IAAA;AACG,IAAA;AAEP,EAAA;AAEQ,EAAA;AACd;ANkRgB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/cofhesdk/cofhesdk/packages/react/dist/index.cjs","sourcesContent":[null,"import { useCofheContext, useInternalQueries } from '@/providers';\nimport { isHandleOutOfScope, useCofheEffectiveACP, type CofheACPInput } from './useCofheACPScope';\nimport { useCofheChainId } from './useCofheConnection';\nimport {\n cofheDecryptForViewQuery,\n defaultDecryptRetry,\n useDropDecryptsOfInvalidACP,\n zeroPlaintext,\n type CofheDecryptContext,\n} from './useCofheDecrypt';\nimport type { DecryptPollCallbackFunction, FheTypes, UnsealedItem } from '@cofhe/sdk';\nimport type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport type { EncryptedReturnTypeByUtype } from '@cofhe/abi';\nimport type { CofheDecryptMeta } from '@/meta';\n\nexport type UseCofheDecryptForViewListInput<U extends FheTypes> = {\n /** The handles to decrypt, in the order the results come back; `undefined` entries stay idle. */\n inputs: ReadonlyArray<EncryptedReturnTypeByUtype<U> | undefined>;\n /** Consumer-supplied metadata for debug/activity views, one for all or one per entry. */\n meta?: CofheDecryptMeta | ((input: EncryptedReturnTypeByUtype<U>, index: number) => CofheDecryptMeta);\n /** Structural context from the originating read (address/method), for recognition. */\n context?: CofheDecryptContext;\n onPoll?: DecryptPollCallbackFunction;\n /**\n * The chain the ciphertexts live on — the connected chain by default. Gates on and decrypts\n * with THAT chain's active ACP.\n */\n chainId?: number;\n /**\n * Decrypt with this ACP (or the hash of a stored one) instead of the enclosing\n * `<CofheACPScope>` or the active ACP. The active ACP is not changed.\n */\n acp?: CofheACPInput;\n /** The decrypt's whole budget in milliseconds, submit retries and polling together (5 minutes by default). */\n timeoutMs?: number;\n};\n\n/**\n * `useCofheDecrypt` for a list: one query per handle, the same keys, gate, persistence and\n * activity rows, returned in the order of `inputs`. For a list a component renders, or a total it\n * derives from every value, where the handles are known at render time. The client's\n * `decryptConcurrency` cap bounds how many requests run at once, so a long list is safe.\n *\n * A zero handle — a value never set on chain — reads as the type's zero without a request.\n */\nexport function useCofheDecryptForViewList<U extends FheTypes, TSelectedData = UnsealedItem<U>>(\n { inputs, meta, context, onPoll, chainId, acp, timeoutMs }: UseCofheDecryptForViewListInput<U>,\n queryOptions?: Omit<UseQueryOptions<UnsealedItem<U>, Error, TSelectedData>, 'queryKey' | 'queryFn'>\n): UseQueryResult<TSelectedData, Error>[] {\n const { client } = useCofheContext();\n const connectedChainId = useCofheChainId();\n const decryptChainId = chainId ?? connectedChainId;\n const effectiveACP = useCofheEffectiveACP({ acp, chainId });\n const scopedACP = effectiveACP.scoped ? effectiveACP.acp : undefined;\n useDropDecryptsOfInvalidACP(effectiveACP);\n\n const {\n enabled: userEnabled,\n meta: optionMeta,\n retry = defaultDecryptRetry,\n ...restQueryOptions\n } = queryOptions || {};\n\n return useInternalQueries({\n queries: inputs.map((input, index) => {\n const zero = !!input && BigInt(input.ctHash) === 0n;\n const outOfScope = isHandleOutOfScope(scopedACP, input?.ctHash);\n const enabled = !!input && !zero && !!client && effectiveACP.isValid && !outOfScope && (userEnabled ?? true);\n const query = cofheDecryptForViewQuery<U>({\n client,\n input,\n decryptChainId,\n chainId,\n acp: effectiveACP.acp,\n scoped: effectiveACP.scoped,\n onPoll,\n timeoutMs,\n meta: typeof meta === 'function' ? (input ? meta(input, index) : undefined) : meta,\n context,\n });\n return {\n enabled,\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: { ...query.meta, ...optionMeta },\n ...restQueryOptions,\n retry,\n // The zero handle is its own answer: present from the first render, never fetched.\n ...(zero ? { initialData: zeroPlaintext(input.utype), staleTime: Infinity } : {}),\n };\n }),\n }) as UseQueryResult<TSelectedData, Error>[];\n}\n","import { useCofheContext, useInternalQuery } from '@/providers';\nimport { isHandleOutOfScope, useCofheEffectiveACP, type CofheACPInput } from './useCofheACPScope';\nimport { useCofheChainId } from './useCofheConnection';\nimport { defaultDecryptRetry, useDropDecryptsOfInvalidACP, type CofheDecryptContext } from './useCofheDecrypt';\nimport type { CofheClient, DecryptForTxResult, DecryptPollCallbackFunction } from '@cofhe/sdk';\nimport type { ACP } from '@cofhe/sdk/acps';\nimport type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { assert } from 'ts-essentials';\nimport type { CofheDecryptMeta, CofheQueryMeta } from '@/meta';\nimport { anySignal } from '@/utils/abortSignal';\n\n/**\n * The cache key of one tx decrypt: a handle decrypted on one chain into a plaintext with the\n * threshold network's signature — `[prefix, chainId, ctHash, acpHash]`. `acpHash` names the ACP\n * that decrypts, or is `null` for a handle the contract allowed publicly, decrypted without one.\n * No `utype` segment: the network signs the plaintext as an integer, whatever the handle's type.\n */\nexport function constructCofheDecryptForTxQueryKey(params: {\n ctHash: string | undefined;\n chainId: number | undefined;\n acpHash: string | null | undefined;\n}): readonly unknown[] {\n return ['decryptForTx', params.chainId, params.ctHash, params.acpHash];\n}\n\n/**\n * The query one tx decrypt runs as — its key, its `queryFn` and its `meta` — shared by\n * `useCofheDecryptForTx` and `useCofheDecrypter`, so a proof fetched either way is the same cache\n * entry. A proof is a read: a handle maps to one plaintext forever and the contract verifies only\n * `(ctHash, value, signature)`, so nothing but the handle and the ACP keys it.\n */\nexport function cofheDecryptForTxQuery(params: {\n client: CofheClient;\n ctHash: bigint | string | undefined;\n /** The chain the decrypt runs on: the caller's `chainId`, else the connected chain. */\n decryptChainId: number | undefined;\n /** The caller's explicit `chainId`, set on the builder when given. */\n chainId?: number;\n /** The account whose stored ACPs resolve the active ACP, set on the builder when given. */\n account?: string;\n /**\n * The ACP that decrypts, and whether it was chosen explicitly (a hook option or a scope);\n * `null` for a publicly allowed handle (`FHE.allowPublic`), which needs none.\n */\n acp: ACP | null | undefined;\n scoped: boolean;\n onPoll?: DecryptPollCallbackFunction;\n timeoutMs?: number;\n retry404TimeoutMs?: number;\n /** The caller's abort signal; React Query's own (query cancelled) is joined to it in `queryFn`. */\n signal?: AbortSignal;\n meta?: CofheDecryptMeta;\n context?: CofheDecryptContext;\n}): {\n queryKey: readonly unknown[];\n queryFn: (context?: { signal?: AbortSignal }) => Promise<DecryptForTxResult>;\n // Also a plain record: that is what `fetchQuery` and `useQuery` type `meta` as.\n meta: Record<string, unknown> & CofheQueryMeta & { persist: boolean };\n} {\n const { client, ctHash, decryptChainId, chainId, account, acp, scoped, onPoll, timeoutMs, retry404TimeoutMs } =\n params;\n const { signal, meta, context } = params;\n const scopedACP = scoped && acp ? acp : undefined;\n return {\n queryKey: constructCofheDecryptForTxQueryKey({\n ctHash: ctHash?.toString(),\n chainId: decryptChainId,\n acpHash: acp === null ? null : acp?.hash,\n }),\n queryFn: async (queryContext) => {\n assert(ctHash !== undefined, 'a tx decrypt query only runs with a handle');\n const builder = client.decryptForTx(ctHash);\n if (chainId !== undefined) builder.setChainId(chainId);\n if (account !== undefined) builder.setAccount(account);\n if (onPoll) builder.onPoll(onPoll);\n if (timeoutMs !== undefined) builder.setTimeout(timeoutMs);\n if (retry404TimeoutMs !== undefined) builder.set404RetryTimeout(retry404TimeoutMs);\n const abort = anySignal([signal, queryContext?.signal]);\n if (abort) builder.setSignal(abort);\n const selected = acp === null ? builder.withoutACP() : scopedACP ? builder.withACP(scopedACP) : builder.withACP();\n return selected.execute();\n },\n meta: {\n // Same rule as a view decrypt: persist what the user own ACP decrypts. A publicly allowed\n // handle's proof is public data, so it persists too; one decrypted with a shared ACP must\n // not outlive the share, so it stays in memory.\n persist: acp === null || acp?.type === 'self',\n kind: 'cofheDecryptForTx',\n ctHash: ctHash?.toString(),\n chainId: context?.chainId ?? decryptChainId,\n address: context?.address,\n functionName: context?.functionName,\n consumer: meta,\n },\n };\n}\n\nexport type UseCofheDecryptForTxInput = {\n /** The handle to decrypt; the query is disabled without one, or for the zero handle. */\n ctHash?: bigint | string;\n /**\n * The ACP to decrypt with: an ACP, the hash of a stored one, the enclosing `<CofheACPScope>`\n * or the active ACP when omitted, or `null` for a handle the contract allowed publicly\n * (`FHE.allowPublic`), which needs none and so never waits for one.\n */\n acp?: CofheACPInput | null;\n /**\n * The chain the handle lives on — the connected chain by default. Gates on and decrypts\n * with THAT chain's active ACP, e.g. for a value read through a chain-pinned read.\n */\n chainId?: number;\n /** The account whose stored ACPs resolve a hash or the active ACP; the connected account by default. */\n account?: string;\n onPoll?: DecryptPollCallbackFunction;\n /** The decrypt's whole budget in milliseconds, submit retries and polling together (5 minutes by default). */\n timeoutMs?: number;\n /** How long a submit-time `404 ct_not_found` (handle not indexed yet) is retried; 10 seconds by default. */\n retry404TimeoutMs?: number;\n /** Consumer-supplied metadata for debug/activity views. */\n meta?: CofheDecryptMeta;\n /** Structural context from the originating read (address/method), for recognition. */\n context?: CofheDecryptContext;\n};\n\n/**\n * Query hook around `client.decryptForTx`: the plaintext of a handle with the threshold network's\n * signature over it, for a contract to verify on chain (`FHE.verifyDecryptResult` /\n * `FHE.publishDecryptResult`). The declarative counterpart of `useCofheDecrypter().decryptForTx`:\n * mount it on the page that will send the transaction and the proof is ready before the click.\n *\n * A proof never changes, so the query is `staleTime: Infinity` by default and a handle proved\n * once (either way) is never requested again. Like `useCofheDecrypt` it waits for a valid ACP\n * rather than prompting for one — unless `acp` is `null`, when no ACP is involved at all.\n */\nexport function useCofheDecryptForTx<TSelectedData = DecryptForTxResult>(\n { ctHash, acp, chainId, account, onPoll, timeoutMs, retry404TimeoutMs, meta, context }: UseCofheDecryptForTxInput,\n queryOptions?: Omit<UseQueryOptions<DecryptForTxResult, Error, TSelectedData>, 'queryKey' | 'queryFn'>\n): UseQueryResult<TSelectedData, Error> {\n const { client } = useCofheContext();\n const connectedChainId = useCofheChainId();\n const decryptChainId = chainId ?? connectedChainId;\n const withoutACP = acp === null;\n // With `acp: null` the ACP below is not used; the hook still runs (hooks are unconditional) and\n // its drop effect is the same one `useCofheDecrypt` runs for that ACP.\n const effectiveACP = useCofheEffectiveACP({ acp: acp ?? undefined, chainId });\n const scopedACP = effectiveACP.scoped ? effectiveACP.acp : undefined;\n useDropDecryptsOfInvalidACP(effectiveACP);\n\n const {\n enabled: userEnabled,\n meta: optionMeta,\n retry = defaultDecryptRetry,\n staleTime = Infinity,\n ...restQueryOptions\n } = queryOptions || {};\n const outOfScope = !withoutACP && isHandleOutOfScope(scopedACP, ctHash);\n const enabled =\n ctHash !== undefined &&\n BigInt(ctHash) > 0n &&\n !!client &&\n (withoutACP || effectiveACP.isValid) &&\n !outOfScope &&\n (userEnabled ?? true);\n\n const query = cofheDecryptForTxQuery({\n client,\n ctHash,\n decryptChainId,\n chainId,\n account,\n acp: withoutACP ? null : effectiveACP.acp,\n scoped: effectiveACP.scoped,\n onPoll,\n timeoutMs,\n retry404TimeoutMs,\n meta,\n context,\n });\n\n return useInternalQuery({\n enabled,\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: { ...query.meta, ...optionMeta },\n staleTime,\n ...restQueryOptions,\n retry,\n });\n}\n","import { useCofheContext, useInternalQueries } from '@/providers';\nimport { isHandleOutOfScope, useCofheEffectiveACP, type CofheACPInput } from './useCofheACPScope';\nimport { useCofheChainId } from './useCofheConnection';\nimport { defaultDecryptRetry, useDropDecryptsOfInvalidACP, type CofheDecryptContext } from './useCofheDecrypt';\nimport { cofheDecryptForTxQuery } from './useCofheDecryptForTx';\nimport type { DecryptForTxResult, DecryptPollCallbackFunction } from '@cofhe/sdk';\nimport type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport type { CofheDecryptMeta } from '@/meta';\n\nexport type UseCofheDecryptForTxListInput = {\n /** The handles to prove, in the order the results come back; `undefined` entries and the zero handle stay idle. */\n inputs: ReadonlyArray<bigint | string | undefined>;\n /**\n * The ACP to decrypt with: an ACP, the hash of a stored one, the enclosing `<CofheACPScope>`\n * or the active ACP when omitted, or `null` for handles the contract allowed publicly\n * (`FHE.allowPublic`), which need none and so never wait for one.\n */\n acp?: CofheACPInput | null;\n /** The chain the handles live on — the connected chain by default. */\n chainId?: number;\n /** The account whose stored ACPs resolve a hash or the active ACP; the connected account by default. */\n account?: string;\n onPoll?: DecryptPollCallbackFunction;\n /** The decrypt's whole budget in milliseconds, submit retries and polling together (5 minutes by default). */\n timeoutMs?: number;\n /** How long a submit-time `404 ct_not_found` (handle not indexed yet) is retried; 10 seconds by default. */\n retry404TimeoutMs?: number;\n /** Consumer-supplied metadata for debug/activity views, one for all or one per entry. */\n meta?: CofheDecryptMeta | ((ctHash: bigint | string, index: number) => CofheDecryptMeta);\n /** Structural context from the originating read (address/method), for recognition. */\n context?: CofheDecryptContext;\n};\n\n/**\n * `useCofheDecryptForTx` for a list: one proof query per handle, the same keys, gate and\n * persistence, returned in the order of `inputs`. For a page that will send one transaction per\n * item, or one transaction over all of them, with the handles known at render time; the proofs\n * are ready before the click. The client's `decryptConcurrency` cap bounds how many requests run\n * at once.\n */\nexport function useCofheDecryptForTxList<TSelectedData = DecryptForTxResult>(\n { inputs, acp, chainId, account, onPoll, timeoutMs, retry404TimeoutMs, meta, context }: UseCofheDecryptForTxListInput,\n queryOptions?: Omit<UseQueryOptions<DecryptForTxResult, Error, TSelectedData>, 'queryKey' | 'queryFn'>\n): UseQueryResult<TSelectedData, Error>[] {\n const { client } = useCofheContext();\n const connectedChainId = useCofheChainId();\n const decryptChainId = chainId ?? connectedChainId;\n const withoutACP = acp === null;\n const effectiveACP = useCofheEffectiveACP({ acp: acp ?? undefined, chainId });\n const scopedACP = effectiveACP.scoped ? effectiveACP.acp : undefined;\n useDropDecryptsOfInvalidACP(effectiveACP);\n\n const {\n enabled: userEnabled,\n meta: optionMeta,\n retry = defaultDecryptRetry,\n staleTime = Infinity,\n ...restQueryOptions\n } = queryOptions || {};\n\n return useInternalQueries({\n queries: inputs.map((ctHash, index) => {\n const outOfScope = !withoutACP && isHandleOutOfScope(scopedACP, ctHash);\n const enabled =\n ctHash !== undefined &&\n BigInt(ctHash) > 0n &&\n !!client &&\n (withoutACP || effectiveACP.isValid) &&\n !outOfScope &&\n (userEnabled ?? true);\n const query = cofheDecryptForTxQuery({\n client,\n ctHash,\n decryptChainId,\n chainId,\n account,\n acp: withoutACP ? null : effectiveACP.acp,\n scoped: effectiveACP.scoped,\n onPoll,\n timeoutMs,\n retry404TimeoutMs,\n meta: typeof meta === 'function' ? (ctHash !== undefined ? meta(ctHash, index) : undefined) : meta,\n context,\n });\n return {\n enabled,\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: { ...query.meta, ...optionMeta },\n staleTime,\n ...restQueryOptions,\n retry,\n };\n }),\n }) as UseQueryResult<TSelectedData, Error>[];\n}\n","import { useCallback, useMemo } from 'react';\nimport { useCofheContext, useInternalQueryClient } from '@/providers';\nimport {\n isHandleOutOfScope,\n useCofheEffectiveACP,\n type CofheACPInput,\n type CofheEffectiveACP,\n} from './useCofheACPScope';\nimport { useCofheChainId } from './useCofheConnection';\nimport {\n cofheDecryptForViewQuery,\n defaultDecryptRetry,\n useDropDecryptsOfInvalidACP,\n zeroPlaintext,\n type CofheDecryptContext,\n} from './useCofheDecrypt';\nimport { cofheDecryptForTxQuery } from './useCofheDecryptForTx';\nimport {\n CofheError,\n CofheErrorCode,\n type FheTypes,\n type DecryptForTxResult,\n type DecryptPollCallbackFunction,\n type UnsealedItem,\n} from '@cofhe/sdk';\nimport type { EncryptedReturnTypeByUtype } from '@cofhe/abi';\nimport type { CofheDecryptMeta } from '@/meta';\n\n/** Per-call options of the function `useCofheDecrypter` returns. */\nexport type CofheDecryptForViewFnOptions = {\n /** Consumer-supplied metadata for debug/activity views. */\n meta?: CofheDecryptMeta;\n /** Structural context from the originating read (address/method), for recognition. */\n context?: CofheDecryptContext;\n onPoll?: DecryptPollCallbackFunction;\n /** The decrypt's whole budget in milliseconds, submit retries and polling together (5 minutes by default). */\n timeoutMs?: number;\n /**\n * A cached plaintext younger than this is returned without a request. `Infinity` by default: a\n * plaintext never changes, so a handle decrypted once (by this function or by `useCofheDecrypt`)\n * is never decrypted again.\n */\n staleTime?: number;\n /** Retry policy of a failed request; by default a `CofheError` is final and anything else is retried 3 times. */\n retry?: boolean | number | ((failureCount: number, error: Error) => boolean);\n /**\n * Stops the call when it fires: a call still waiting for a concurrency slot never starts, a\n * request in flight is aborted, and the call rejects with `Aborted`. A plaintext already in the\n * cache is still returned.\n */\n signal?: AbortSignal;\n};\n\n/** Decrypts one handle; see `useCofheDecrypter`. */\nexport type CofheDecryptForViewFn = <U extends FheTypes>(\n input: EncryptedReturnTypeByUtype<U>,\n options?: CofheDecryptForViewFnOptions\n) => Promise<UnsealedItem<U>>;\n\n/** Per-call options of `decryptForTx`; see `useCofheDecrypter`. */\nexport type CofheDecryptForTxFnOptions = CofheDecryptForViewFnOptions & {\n /**\n * `null`: the contract allowed the handle publicly (`FHE.allowPublic`), so it decrypts without\n * an ACP and does not wait for one. Otherwise the hook's ACP decrypts, as for `decryptForView`.\n */\n acp?: null;\n /** The account whose stored ACPs resolve the active ACP; the connected account by default. */\n account?: string;\n /** How long a submit-time `404 ct_not_found` (handle not indexed yet) is retried; 10 seconds by default. */\n retry404TimeoutMs?: number;\n};\n\n/** Decrypts one handle into a plaintext with the network's signature; see `useCofheDecrypter`. */\nexport type CofheDecryptForTxFn = (\n ctHash: bigint | string,\n options?: CofheDecryptForTxFnOptions\n) => Promise<DecryptForTxResult>;\n\nexport type UseCofheDecrypterOptions = {\n /**\n * The chain the ciphertexts live on — the connected chain by default. Gates on and decrypts\n * with THAT chain's active ACP, e.g. for values read through a chain-pinned read.\n */\n chainId?: number;\n /**\n * Decrypt with this ACP (or the hash of a stored one) instead of the enclosing\n * `<CofheACPScope>` or the active ACP. The active ACP is not changed.\n */\n acp?: CofheACPInput;\n /** How many requests one caller runs at a time; the rest wait their turn. 4 by default. */\n concurrency?: number;\n};\n\nexport type UseCofheDecrypterResult = {\n /** Decrypts one handle through the decrypt cache; rejects without a request while `isReady` is false. */\n decryptForView: CofheDecryptForViewFn;\n /**\n * Decrypts one handle into a plaintext with the threshold network's signature, for a contract to\n * verify on chain, through the same cache as `useCofheDecryptForTx`. With `acp: null` it needs\n * only the client, not `isReady`.\n */\n decryptForTx: CofheDecryptForTxFn;\n /** A client and a valid ACP are at hand, so a call can run. */\n isReady: boolean;\n /** The ACP `decryptForView` uses, with its status: why `isReady` is false, when it is. */\n acp: CofheEffectiveACP;\n};\n\n/** The reasons a call must not be sent: no valid ACP, or a SNAPSHOT share that does not list the handle. */\nfunction assertACPDecrypts(effectiveACP: CofheEffectiveACP, ctHash: bigint | string, operation: string): void {\n const { acp, scoped, status } = effectiveACP;\n if (!effectiveACP.isValid) {\n throw new CofheError({\n code: status === 'expired' ? CofheErrorCode.ACPExpired : CofheErrorCode.ACPRequired,\n message: `${operation}: no valid ACP to decrypt with (${status})`,\n hint: 'Create or activate an ACP, or wait for the chosen one to be checked, before decrypting.',\n });\n }\n if (isHandleOutOfScope(scoped ? acp : undefined, ctHash)) {\n throw new CofheError({\n code: CofheErrorCode.ACPDenied,\n message: `${operation}: the handle is not listed in the SNAPSHOT share that would decrypt it`,\n context: { ctHash: ctHash.toString(), acpHash: acp?.hash },\n });\n }\n}\n\nfunction abortedError(operation: string, signal: AbortSignal): CofheError {\n return new CofheError({\n code: CofheErrorCode.Aborted,\n message: `${operation} aborted by the caller`,\n cause: signal.reason instanceof Error ? signal.reason : undefined,\n });\n}\n\n/**\n * Runs tasks at most `max` at a time, in call order. A task whose `signal` fires while it waits\n * for a slot leaves the queue and rejects without ever starting.\n */\nfunction createLimiter(\n max: number\n): <T>(task: () => Promise<T>, operation: string, signal?: AbortSignal) => Promise<T> {\n let active = 0;\n const waiting: Array<() => void> = [];\n return async (task, operation, signal) => {\n if (signal?.aborted) throw abortedError(operation, signal);\n if (active >= max) {\n await new Promise<void>((resume, reject) => {\n const onAbort = () => {\n const index = waiting.indexOf(start);\n if (index >= 0) waiting.splice(index, 1);\n reject(abortedError(operation, signal!));\n };\n const start = () => {\n signal?.removeEventListener('abort', onAbort);\n resume();\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n waiting.push(start);\n });\n }\n active += 1;\n try {\n return await task();\n } finally {\n active -= 1;\n waiting.shift()?.();\n }\n };\n}\n\n/**\n * The imperative counterpart of `useCofheDecrypt`: a function that decrypts one handle on demand,\n * for the work a component does not render per value — a job the user starts over a list of\n * handles (a history to sum, a set of bids to reveal), from the handler that starts it.\n *\n * Each call is the same query `useCofheDecrypt` would run — same cache key, same gate, same\n * persistence, same activity row — so a handle decrypted either way is decrypted once, and\n * `decryptForView` returns a cached plaintext without a request. Calls run at most `concurrency` at a\n * time; fan out with `Promise.all` freely.\n *\n * Without a valid ACP, or with a SNAPSHOT share that does not list the handle, `decryptForView` rejects\n * with a `CofheError` and sends nothing. A zero handle resolves to the type's zero without a request.\n *\n * `decryptForTx` is the same for a proof — the plaintext with the threshold network's signature,\n * for a contract to verify — through the cache of `useCofheDecryptForTx`. A proof is a read too: a\n * handle maps to one plaintext forever, so a handle proved once is never requested again. `acp:\n * null` decrypts a publicly allowed handle without an ACP, and then needs only the client.\n */\nexport function useCofheDecrypter({\n chainId,\n acp,\n concurrency = 4,\n}: UseCofheDecrypterOptions = {}): UseCofheDecrypterResult {\n const { client } = useCofheContext();\n const queryClient = useInternalQueryClient();\n const connectedChainId = useCofheChainId();\n const decryptChainId = chainId ?? connectedChainId;\n const effectiveACP = useCofheEffectiveACP({ acp, chainId });\n useDropDecryptsOfInvalidACP(effectiveACP);\n const limit = useMemo(() => createLimiter(concurrency), [concurrency]);\n\n const isReady = !!client && effectiveACP.isValid;\n const { acp: decryptACP, scoped } = effectiveACP;\n\n const decryptForView = useCallback<CofheDecryptForViewFn>(\n async (input, options) => {\n if (!client) {\n throw new CofheError({ code: CofheErrorCode.InternalError, message: 'CoFHE client not initialized' });\n }\n if (BigInt(input.ctHash) === 0n) return zeroPlaintext(input.utype);\n assertACPDecrypts(effectiveACP, input.ctHash, 'decryptForView');\n const query = cofheDecryptForViewQuery({\n client,\n input,\n decryptChainId,\n chainId,\n acp: decryptACP,\n scoped,\n onPoll: options?.onPoll,\n timeoutMs: options?.timeoutMs,\n signal: options?.signal,\n meta: options?.meta,\n context: options?.context,\n });\n return limit(\n () =>\n queryClient.fetchQuery({\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: query.meta,\n staleTime: options?.staleTime ?? Infinity,\n retry: options?.retry ?? defaultDecryptRetry,\n }),\n 'decryptForView',\n options?.signal\n );\n },\n [client, queryClient, decryptChainId, chainId, decryptACP, scoped, effectiveACP, limit]\n );\n\n const decryptForTx = useCallback<CofheDecryptForTxFn>(\n async (ctHash, options) => {\n if (!client) {\n throw new CofheError({ code: CofheErrorCode.InternalError, message: 'CoFHE client not initialized' });\n }\n if (BigInt(ctHash) === 0n) {\n throw new CofheError({\n code: CofheErrorCode.DecryptFailed,\n message: 'decryptForTx: the zero handle has no value to prove',\n hint: 'A zero handle is a value never set on chain; nothing can be revealed from it.',\n });\n }\n const withoutACP = options?.acp === null;\n if (!withoutACP) assertACPDecrypts(effectiveACP, ctHash, 'decryptForTx');\n const query = cofheDecryptForTxQuery({\n client,\n ctHash,\n decryptChainId,\n chainId,\n account: options?.account,\n acp: withoutACP ? null : decryptACP,\n scoped,\n onPoll: options?.onPoll,\n timeoutMs: options?.timeoutMs,\n retry404TimeoutMs: options?.retry404TimeoutMs,\n signal: options?.signal,\n meta: options?.meta,\n context: options?.context,\n });\n return limit(\n () =>\n queryClient.fetchQuery({\n queryKey: query.queryKey,\n queryFn: query.queryFn,\n meta: query.meta,\n staleTime: options?.staleTime ?? Infinity,\n retry: options?.retry ?? defaultDecryptRetry,\n }),\n 'decryptForTx',\n options?.signal\n );\n },\n [client, queryClient, decryptChainId, chainId, decryptACP, scoped, effectiveACP, limit]\n );\n\n return { decryptForView, decryptForTx, isReady, acp: effectiveACP };\n}\n","// Providers\nexport { CofheProvider, useCofheContext } from './providers/index';\n\n// Hooks\nexport {\n ETH_ADDRESS_LOWERCASE,\n getCofheTokenClaimUnshieldedCallArgs,\n getCofheTokenShieldCallArgs,\n getCofheTokenUnshieldCallArgs,\n useCofheActiveACP,\n useCofheACPs,\n useCofheAllACPs,\n useCofheClient,\n useCofheConnection,\n useCofheEnabled,\n useCofheTaskManagerAddress,\n useCofheEncrypt,\n useCofhePublicClient,\n useCofheRemoveACP,\n useCofheSelectACP,\n useCofheSimulateWriteContract,\n useCofheStatuses,\n useCofheTokenClaimable,\n useCofheTokenClaims,\n useCofheTokenApprove,\n useCofheTokenClaimUnshielded,\n useCofheTokenDecryptedBalance,\n useCofheTokenPublicBalance,\n useCofheTokenLists,\n useCofheToken,\n useKnownCofheToken,\n useCofheTokens,\n useCofheTokensClaimable,\n useCofheTokenShield,\n useCofheTokensWithExistingEncryptedBalances,\n useCofheTokenTransactions,\n useCofheTokenTransfer,\n useResolvedCofheToken,\n useCofheTransactions,\n addCofheTransaction,\n useCofheTokenUnshield,\n useCofheWalletClient,\n useCofheWriteContract,\n useCoingeckoContractMarketChartRange,\n useCoingeckoUsdPrice,\n useTokenAllowance,\n useTokensWithPublicBalances,\n useTransactionReceiptsByHash,\n type ClaimableAmountByTokenAddress,\n type CoingeckoMarketChartPoint,\n type Erc20Pair,\n type UnshieldClaim,\n type UnshieldClaimsSummary,\n type UnshieldClaimsSummaryByTokenAddress,\n type UseCoingeckoContractMarketChartRangeInput,\n type UseCoingeckoContractMarketChartRangeOptions,\n type UseCoingeckoUsdPriceInput,\n type UseCoingeckoUsdPriceOptions,\n type UseCofheTokenTransactionsInput,\n type UseCofheTokenTransactionsResult,\n type UseTransactionReceiptsByHashInput,\n type AddCofheTransactionInput,\n} from '@/hooks/index';\n\nexport { useCofheEncryptAndWriteContract } from '@/hooks/useCofheEncryptAndWriteContract';\nexport { useCofheReadContractAndDecrypt } from '@/hooks/useCofheReadContractAndDecrypt';\nexport {\n useCofheDecrypt,\n cofheDecryptForViewQuery,\n constructCofheDecryptForViewQueryKey,\n type CofheDecryptContext,\n} from '@/hooks/useCofheDecrypt';\nexport { useCofheDecryptForViewList, type UseCofheDecryptForViewListInput } from '@/hooks/useCofheDecryptForViewList';\nexport { useCofheDecryptForTxList, type UseCofheDecryptForTxListInput } from '@/hooks/useCofheDecryptForTxList';\nexport {\n useCofheDecrypter,\n type CofheDecryptForViewFn,\n type CofheDecryptForViewFnOptions,\n type CofheDecryptForTxFn,\n type CofheDecryptForTxFnOptions,\n type UseCofheDecrypterOptions,\n type UseCofheDecrypterResult,\n} from '@/hooks/useCofheDecrypter';\nexport {\n useCofheDecryptForTx,\n cofheDecryptForTxQuery,\n constructCofheDecryptForTxQueryKey,\n type UseCofheDecryptForTxInput,\n} from '@/hooks/useCofheDecryptForTx';\nexport {\n CofheACPScope,\n useCofheACPScope,\n useCofheACPStatus,\n type CofheACPInput,\n type CofheACPScopeValue,\n type CofheACPStatus,\n} from '@/hooks/useCofheACPScope';\nexport {\n useCofheIncomingShares,\n useCofheShareOnChain,\n useCofheImportShared,\n useCofheRemoveShare,\n useCofheRevokeACP,\n} from '@/hooks/acps/useOnChainSharing';\nexport {\n useCofheShareLabels,\n type CofheShareLabel,\n type UseCofheShareLabelsResult,\n} from '@/hooks/acps/useCofheShareLabels';\nexport {\n useCofheReadContract,\n constructCofheReadContractQueryForInvalidation,\n type UseCofheReadContractResult,\n type UseCofheReadContractQueryOptions,\n} from '@/hooks/useCofheReadContract';\nexport {\n useCofheReadContracts,\n type CofheReadContractsContract,\n type CofheReadContractsItem,\n type CofheReadContractsData,\n type CofheReadContractsEntry,\n type CofheReadContractsEntries,\n type CofheReadContractsEntryResult,\n type UseCofheReadContractsResult,\n type UseCofheReadContractsQueryOptions,\n} from '@/hooks/useCofheReadContracts';\nexport {\n type useCofheWriteContractOptions,\n type CofheWriteInvalidationTarget,\n type CofheWriteInvalidates,\n type CofheReadInvalidationDescriptor,\n} from '@/hooks/useCofheWriteContract';\n\n// Utils\nexport {\n FheTypesList,\n formatRelativeTime,\n getBlockExplorerAddressUrl,\n getBlockExplorerTokenUrl,\n getBlockExplorerTxUrl,\n getBlockExplorerUrl,\n isEthPair,\n isWrappedEthToken,\n truncateHash,\n} from './utils/index';\n\n// Stores\nexport { useCustomTokensStore } from './stores/customTokensStore';\n\nexport {\n actionToString,\n isCustomTransactionActionType,\n statusToString,\n transactionMatchesToken,\n TransactionActionType,\n TransactionStatus,\n useTransactionStore,\n type Transaction,\n type BuiltInTransactionActionType,\n type CustomTransactionActionType,\n type SharingTransactionActionType,\n type JsonValue,\n type NewTransaction,\n type TransactionActionString,\n type TransactionStatusString,\n type TransactionStore,\n} from './stores/transactionStore';\n\nexport { createCofheConfig } from './config';\nexport type { CofheReactLogger, CofheReactLoggerMethod } from './config';\n\n// Types\nexport type {\n CofheClientConfig,\n CofheContextValue,\n CofheProviderProps,\n TransactionRenderer,\n TransactionRendererProps,\n TransactionRenderers,\n} from './types/index';\n\nexport { createCofheClient } from '@cofhe/sdk/web';\n\nexport { useCofheCreateACP } from '@/hooks/acps/useCofheCreateACP';\nexport { useCofheNavigateToCreateACP } from '@/hooks/acps/useCofheNavigateToCreateACP';\nexport { useCofheAutoConnect } from '@/hooks/useCofheAutoConnect';\nexport { CofheFloatingButtonProvider, sortCofheStatuses } from './components/index';\nexport { COFHE_STATUS_IDS, CofheStatusActionIntents } from './components/CofheFloatingButton/types';\n\nexport type { CofheConfigWithReact as CofhesdkConfigWithReact } from './config';\n\nexport type { CofheStatus, CofheStatusActionIntent, CofheStatusId } from './components/CofheFloatingButton/types';\nexport type { ConfidentialToken } from './types/token';\nexport { getConfidentialDecimals, getPublicDecimals, getPublicSymbol } from './types/token';\nexport { scaleAmount, quantizeAmount } from './utils/format';\n\nexport type { CofheDecryptMeta, CofheQueryMeta } from './meta';\n\nexport { useCofheDecryptionActivity } from '@/hooks/useCofheDecryptionActivity';\nexport type {\n DecryptionActivityRow,\n DecryptionActivityResult,\n DecryptionActivityCategory,\n UseCofheDecryptionActivityOptions,\n FetchStageState,\n DecryptStageState,\n ACPState,\n} from '@/hooks/useCofheDecryptionActivity';\n\nexport { useInternalQueryClient } from './providers/index';\n\n// Type bridges for cross-repo / multi-instance viem peer dependency scenarios\nexport {\n asCofhePublicClient,\n tryAsCofhePublicClient,\n asCofheWalletClient,\n tryAsCofheWalletClient,\n} from './utils/viemClientBridge';\nexport type {\n PublicClientLike as CofhePublicClientLike,\n WalletClientLike as CofheWalletClientLike,\n} from './utils/viemClientBridge';\n\n// Block-aware cache invalidation primitives.\n//\n// These are the building blocks behind the SDK's own \"wait until the serving RPC\n// node has the mined block before returning a read\" behaviour. They are exported\n// so consumers (e.g. a wagmi-based app) can build the same reliability into their\n// own reads + post-tx invalidation, sharing THIS module's single invalidation-\n// context store — so an invalidation registered here is honoured by both the\n// SDK's confidential reads and the consumer's own block-aware queries.\nexport {\n invalidateQueriesWithContext,\n withInvalidationContext,\n findMatchingInvalidationContext,\n type InvalidationContextQueryFilters,\n type QueryFunctionWithInvalidationContext,\n} from './utils/invalidationContext';\nexport {\n maybeWaitUntilRpcAware,\n maybeWaitUntilRpcAwareAndReadContract,\n type WaitUntilRpcAwareAndReadContractOptions,\n type ReadContractResult,\n} from './utils/waitUntilRpcAwareAndReadContract';\nexport { resolveReceiptBlockHash } from './utils/resolveReceiptBlockHash';\nexport { useInvalidationContextStore, type InvalidationContextEntry } from './stores/invalidationContextStore';\n","import { useCallback, useEffect, useMemo, useReducer, useRef } from 'react';\nimport { useInternalQueryClient } from '@/providers';\nimport { useCofheAccount, useCofheChainId } from './useCofheConnection';\nimport { useCofheActiveACP } from './useCofheACPs';\nimport type { CofheQueryMeta } from '@/meta';\n\n// ============================================================================\n// Decryption activity — the lifecycle view of confidential reads + decryptions.\n// ============================================================================\n//\n// A confidential value is a two-stage pipeline, both stages living as react-query\n// queries on the SDK's internal QueryClient:\n// A) FETCH — read the ciphertext handle on-chain (`cofheReadContract`),\n// whose data carries the `ctHash`.\n// B) DECRYPT— decrypt that handle off-chain (`decryptCiphertext`, keyed\n// by chain AND ctHash).\n//\n// This hook observes the cache, correlates the two stages by ctHash, and returns\n// one row per confidential value with a recognizable contract/method/label (from\n// each query's `meta`) — surfacing states a plain error/loading flag can't:\n// • \"blocked\" — gated off by a missing/invalid acp (never runs, never errors)\n// • \"stale\" — fetched, but the decrypt is pending far too long / never lands\n// Consumers render the rows; no query-key parsing or side registries required.\n\nconst DEFAULT_STALE_MS = 25_000;\nconst nowSec = () => Math.floor(Date.now() / 1000);\n\n/** 'idle' = a read/decrypt query exists but is disabled/never-ran (fetchStatus 'idle'), vs 'pending' (in flight). */\nexport type FetchStageState = 'ok' | 'pending' | 'idle' | 'error' | 'empty';\nexport type DecryptStageState = 'ok' | 'pending' | 'idle' | 'stale' | 'error' | 'blocked' | 'absent';\nexport type ACPState = 'valid' | 'expired' | 'unsigned' | 'none';\n/** Coarse bucket for filtering: something wrong / decrypted / nothing conclusive. */\nexport type DecryptionActivityCategory = 'error' | 'success' | 'idle';\n\nexport interface DecryptionActivityRow {\n key: string;\n /** Canonical decimal ctHash, when known. */\n ctHash?: string;\n /** 0x…-shortened ctHash for display. */\n ctHashShort?: string;\n /** The originating query metadata (contract / method / label / consumer fields). */\n meta?: CofheQueryMeta;\n /** Convenience shortcuts pulled from meta. */\n chainId?: number;\n address?: string;\n functionName?: string;\n label?: string;\n fetch: FetchStageState;\n decrypt: DecryptStageState;\n category: DecryptionActivityCategory;\n /** Why the row is blocked, e.g. \"acp none\". */\n blockedReason?: string;\n /** How long the decrypt has been pending, ms (drives \"stale\"). */\n pendingMs?: number;\n updatedAt: number;\n /** Whether re-running is possible (false for gated/idle reads with nothing enabled). */\n canRetry: boolean;\n /** Re-run this value's read and/or decrypt. */\n retry: () => void;\n}\n\nexport interface DecryptionActivityResult {\n rows: DecryptionActivityRow[];\n counts: { total: number; ok: number; pending: number; stale: number; blocked: number; error: number };\n acp: { state: ACPState; expiresInSec?: number };\n /** Wipe the whole SDK query cache; mounted reads/decryptions refetch from scratch. */\n clearCache: () => void;\n}\n\nexport interface UseCofheDecryptionActivityOptions {\n /** How long a decrypt may stay pending before it's reported \"stale\" (default 25s). */\n staleMs?: number;\n}\n\n// Minimal structural view of a cached query — enough to classify without depending\n// on react-query's concrete generic types.\ninterface QueryLike {\n queryKey: unknown;\n queryHash: string;\n meta?: CofheQueryMeta;\n state: { status: 'pending' | 'error' | 'success'; fetchStatus?: string; data?: unknown; dataUpdatedAt?: number };\n}\ninterface CacheLike {\n getAll: () => QueryLike[];\n subscribe: (cb: () => void) => () => void;\n}\ninterface ClientLike {\n getQueryCache: () => CacheLike;\n refetchQueries: (filters: { queryKey: unknown; exact?: boolean }) => Promise<unknown>;\n clear: () => void;\n}\n\nfunction normalizeCt(x: unknown): string | undefined {\n if (x === null || x === undefined) return undefined;\n try {\n return BigInt(x as string | number | bigint).toString();\n } catch {\n const s = String(x);\n return s && s !== '[object Object]' ? s : undefined;\n }\n}\n\n// A ctHash of 0 is not a real handle: reads return it for an absent/encrypted-zero\n// value and the decrypt is gated on `ctHash > 0n`, so treat it as \"no handle\".\nfunction isZeroCt(ct: string | undefined): boolean {\n if (!ct) return false;\n try {\n return BigInt(ct) === 0n;\n } catch {\n return false;\n }\n}\n\nfunction shortCt(decimal: string): string {\n try {\n const hex = BigInt(decimal).toString(16);\n return hex.length > 10 ? `0x${hex.slice(0, 6)}…${hex.slice(-4)}` : `0x${hex}`;\n } catch {\n return decimal;\n }\n}\n\nfunction extractCtHash(data: unknown): string | undefined {\n if (data === null || data === undefined) return undefined;\n if (typeof data === 'bigint') return normalizeCt(data);\n if (typeof data === 'object' && data !== null && 'ctHash' in (data as Record<string, unknown>)) {\n return normalizeCt((data as { ctHash: unknown }).ctHash);\n }\n return undefined;\n}\n\n// The read key bakes the transient activeACPHash + enabled flags into its tail,\n// so the SAME value gets a fresh cache entry each time an ACP appears/rotates.\n// Its stable identity is [prefix, chainId, address, fn, args] (indices 0-4).\nfunction stableReadKey(k: unknown[]): string {\n try {\n return JSON.stringify(k.slice(0, 5));\n } catch {\n return String(k[1]) + '|' + String(k[2]) + '|' + String(k[3]);\n }\n}\n\n// Progress of a read: ran (success/error) > in flight > idle/never-ran.\nfunction readProgress(q: QueryLike): number {\n if (q.state.status === 'success' || q.state.status === 'error') return 2;\n if (q.state.fetchStatus === 'fetching') return 1;\n return 0;\n}\nfunction isFresherRead(candidate: QueryLike, current: QueryLike): boolean {\n const pc = readProgress(candidate);\n const pk = readProgress(current);\n if (pc !== pk) return pc > pk;\n return (candidate.state.dataUpdatedAt ?? 0) > (current.state.dataUpdatedAt ?? 0);\n}\n\nfunction categoryFor(fetch: FetchStageState, decrypt: DecryptStageState): DecryptionActivityCategory {\n if (fetch === 'error' || decrypt === 'error' || decrypt === 'blocked' || decrypt === 'stale') return 'error';\n if (decrypt === 'ok') return 'success';\n return 'idle';\n}\n\n/**\n * Observe the ctHash-fetch → decrypt pipeline on the SDK's QueryClient, correlated\n * by ctHash and cross-referenced against the active acp. Must be used inside the\n * Cofhe provider.\n */\nexport function useCofheDecryptionActivity(options?: UseCofheDecryptionActivityOptions): DecryptionActivityResult {\n const staleMs = options?.staleMs ?? DEFAULT_STALE_MS;\n const queryClient = useInternalQueryClient() as unknown as ClientLike;\n const account = useCofheAccount();\n const chainId = useCofheChainId();\n const active = useCofheActiveACP();\n const acpObj = active?.acp;\n\n // Track when each decrypt first went pending, so \"stale\" is real elapsed time\n // (react-query doesn't expose a fetch-start timestamp for a never-resolved query).\n const pendingSinceRef = useRef(new Map<string, number>());\n\n // Re-render on cache changes AND on a slow tick (staleness is time-based, not\n // event-driven — a query sitting pending emits no cache events).\n //\n // Coalesce cache events to one bump per animation frame. `cache.subscribe` fires\n // synchronously on EVERY cache event (including observer option/result updates),\n // and a consumer re-render can itself emit fresh cache events — an unbounded\n // bump→render→event→bump storm that pins the main thread and starves unrelated\n // updates (e.g. a route change never commits). One bump per frame keeps the view\n // live while capping re-renders so the loop can't run away.\n const [version, bump] = useReducer((n: number) => n + 1, 0);\n useEffect(() => {\n const cache = queryClient.getQueryCache();\n let scheduled = false;\n const schedule = () => {\n if (scheduled) return;\n scheduled = true;\n const run = () => {\n scheduled = false;\n bump();\n };\n if (typeof requestAnimationFrame === 'function') requestAnimationFrame(run);\n else setTimeout(run, 16);\n };\n const unsub = cache.subscribe(schedule);\n const tick = setInterval(bump, 5_000);\n return () => {\n unsub();\n clearInterval(tick);\n };\n }, [queryClient]);\n\n const clearCache = useCallback(() => queryClient.clear(), [queryClient]);\n\n const data = useMemo(() => {\n const cache = queryClient.getQueryCache();\n const queries = cache.getAll();\n const now = Date.now();\n\n const refetch = (key: unknown) => void queryClient.refetchQueries({ queryKey: key, exact: true });\n\n const acpState: ACPState = !acpObj\n ? 'none'\n : !acpObj.issuerSignature || acpObj.issuerSignature === '0x'\n ? 'unsigned'\n : acpObj.expiration <= nowSec()\n ? 'expired'\n : 'valid';\n const acpValid = acpState === 'valid';\n\n // Index decrypt queries by ctHash (source contract + label come from meta).\n const decryptByCt = new Map<\n string,\n { state: 'ok' | 'pending' | 'idle' | 'error'; pendingMs?: number; key?: unknown; meta?: CofheQueryMeta }\n >();\n const seenPending = new Set<string>();\n for (const q of queries) {\n const k = q.queryKey;\n // [prefix, chainId, ctHash, utype, acpHash] — see constructCofheDecryptForViewQueryKey.\n if (!Array.isArray(k) || k[0] !== 'decryptCiphertext') continue;\n const ct = normalizeCt(k[2]);\n if (!ct || isZeroCt(ct)) continue;\n const base = { key: q.queryKey, meta: q.meta };\n if (q.state.status === 'success') {\n decryptByCt.set(ct, { state: 'ok', ...base });\n pendingSinceRef.current.delete(ct);\n } else if (q.state.status === 'error') {\n decryptByCt.set(ct, { state: 'error', ...base });\n pendingSinceRef.current.delete(ct);\n } else if (q.state.fetchStatus === 'fetching') {\n seenPending.add(ct);\n let since = pendingSinceRef.current.get(ct);\n if (since === undefined) {\n since = now;\n pendingSinceRef.current.set(ct, since);\n }\n decryptByCt.set(ct, { state: 'pending', pendingMs: now - since, ...base });\n } else {\n // status 'pending' but fetchStatus 'idle' → disabled / never ran.\n pendingSinceRef.current.delete(ct);\n decryptByCt.set(ct, { state: 'idle', ...base });\n }\n }\n\n const rows: DecryptionActivityRow[] = [];\n const usedCt = new Set<string>();\n\n // Collapse per-acp/enabled key rotations to one entry per value.\n const readByValue = new Map<string, QueryLike>();\n for (const q of queries) {\n const k = q.queryKey;\n if (!Array.isArray(k) || k[0] !== 'cofheReadContract') continue;\n const id = stableReadKey(k);\n const existing = readByValue.get(id);\n if (!existing || isFresherRead(q, existing)) readByValue.set(id, q);\n }\n\n const pushRow = (\n row: Omit<DecryptionActivityRow, 'category' | 'canRetry' | 'retry'> & {\n fetchKey?: unknown;\n decryptKey?: unknown;\n }\n ) => {\n const { fetchKey, decryptKey, ...rest } = row;\n const canRetry = rest.fetch !== 'idle' && (fetchKey !== undefined || decryptKey !== undefined);\n rows.push({\n ...rest,\n category: categoryFor(rest.fetch, rest.decrypt),\n canRetry,\n retry: () => {\n if (fetchKey !== undefined) refetch(fetchKey);\n if (decryptKey !== undefined) refetch(decryptKey);\n },\n });\n };\n\n // One row per confidential value; attach its decrypt stage by ctHash.\n for (const q of readByValue.values()) {\n const m = q.meta;\n const ctRaw = q.state.status === 'success' ? extractCtHash(q.state.data) : undefined;\n const ct = ctRaw && !isZeroCt(ctRaw) ? ctRaw : undefined;\n const fetchInFlight = q.state.fetchStatus === 'fetching';\n const fetchState: FetchStageState =\n q.state.status === 'error'\n ? 'error'\n : q.state.status === 'pending'\n ? fetchInFlight\n ? 'pending'\n : 'idle'\n : ct\n ? 'ok'\n : 'empty';\n\n let decrypt: DecryptStageState = 'absent';\n let blockedReason: string | undefined;\n let pendingMs: number | undefined;\n let decryptKey: unknown;\n let decryptMeta: CofheQueryMeta | undefined;\n if (ct) {\n usedCt.add(ct);\n const d = decryptByCt.get(ct);\n decryptKey = d?.key;\n decryptMeta = d?.meta;\n if (d?.state === 'ok') decrypt = 'ok';\n else if (d?.state === 'error') decrypt = 'error';\n else if (d?.state === 'idle') decrypt = 'idle';\n else if (d?.state === 'pending') {\n pendingMs = d.pendingMs;\n decrypt = (d.pendingMs ?? 0) > staleMs ? 'stale' : 'pending';\n } else {\n decrypt = acpValid ? 'absent' : 'blocked';\n if (!acpValid) blockedReason = `acp ${acpState}`;\n }\n } else if (fetchState === 'idle' && !acpValid) {\n // The read is gated off (no valid acp) — blocked before any ctHash.\n decrypt = 'blocked';\n blockedReason = `acp ${acpState}`;\n }\n\n const meta = m ?? decryptMeta;\n pushRow({\n key: q.queryHash,\n ctHash: ct,\n ctHashShort: ct ? shortCt(ct) : undefined,\n meta,\n chainId: meta?.chainId,\n address: meta?.address,\n functionName: meta?.functionName,\n label: meta?.consumer?.label,\n fetch: fetchState,\n decrypt,\n blockedReason,\n pendingMs,\n updatedAt: now,\n fetchKey: q.queryKey,\n decryptKey,\n });\n }\n\n // Orphan decrypts (a ctHash being decrypted with no fetch query in cache).\n for (const [ct, d] of decryptByCt) {\n if (usedCt.has(ct)) continue;\n const decrypt: DecryptStageState =\n d.state === 'ok'\n ? 'ok'\n : d.state === 'error'\n ? 'error'\n : d.state === 'idle'\n ? 'idle'\n : (d.pendingMs ?? 0) > staleMs\n ? 'stale'\n : 'pending';\n pushRow({\n key: `decrypt:${ct}`,\n ctHash: ct,\n ctHashShort: shortCt(ct),\n meta: d.meta,\n chainId: d.meta?.chainId,\n address: d.meta?.address,\n functionName: d.meta?.functionName,\n label: d.meta?.consumer?.label,\n fetch: 'ok',\n decrypt,\n pendingMs: d.pendingMs,\n updatedAt: now,\n decryptKey: d.key,\n });\n }\n\n // Drop ctHashes we no longer see, so the pending-since map can't grow unbounded.\n for (const ct of pendingSinceRef.current.keys()) {\n if (!seenPending.has(ct)) pendingSinceRef.current.delete(ct);\n }\n\n const counts = {\n total: rows.length,\n ok: rows.filter((r) => r.decrypt === 'ok').length,\n pending: rows.filter((r) => r.decrypt === 'pending').length,\n stale: rows.filter((r) => r.decrypt === 'stale').length,\n blocked: rows.filter((r) => r.decrypt === 'blocked').length,\n error: rows.filter((r) => r.decrypt === 'error' || r.fetch === 'error').length,\n };\n\n // Most actionable first: blocked/stale/error, then pending, then done.\n const rank: Record<DecryptStageState, number> = {\n blocked: 0,\n stale: 1,\n error: 2,\n pending: 3,\n idle: 4,\n absent: 5,\n ok: 6,\n };\n rows.sort((a, b) => rank[a.decrypt] - rank[b.decrypt]);\n\n const expiresInSec = acpObj ? acpObj.expiration - nowSec() : undefined;\n return { rows, acp: { state: acpState, expiresInSec }, counts };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [queryClient, account, chainId, acpObj, staleMs, version]);\n\n return { ...data, clearCache };\n}\n"]}