Skip to content

fix(react): pass useCofheTokenDecryptedBalance query options to the decrypt query - #440

Open
0xShadowX wants to merge 1 commit into
FhenixProtocol:masterfrom
0xShadowX:fix/react-decrypted-balance-query-options
Open

0xShadowX wants to merge 1 commit into
FhenixProtocol:masterfrom
0xShadowX:fix/react-decrypted-balance-query-options

Conversation

@0xShadowX

@0xShadowX 0xShadowX commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

useCofheTokenDecryptedBalance(input, options) takes react-query options for the balance, but after pulling out enabled it spreads the rest into the top-level options object of useCofheReadContractAndDecrypt:

{ readQueryOptions: {...}, decryptingQueryOptions: {...}, meta: decryptMeta, ...restOptions }

useCofheReadContractAndDecrypt only reads readQueryOptions, decryptingQueryOptions and meta from that object. So:

  • refetchInterval, staleTime, retry, gcTime etc. never reach a query and are silently ignored
  • a react-query meta lands on the meta key and replaces the decrypt meta, so the card loses its label (token symbol or the caller's input.meta.label)

The options are now spread into decryptingQueryOptions, since the decrypt query is the one whose data the hook returns. refetchOnMount: false stays as the default and select is still set by the hook. A react-query meta now goes through useCofheDecrypt, which already merges it with its own query meta. The spread needs a cast because the hook's decrypt query types resolve to never here (the token ABI is optional), and the options are typed for the bigint balance.

Tests (packages/react/src/hooks/useCofheTokenDecryptedBalance.test.tsx):

cd packages/react
npx vitest run src/hooks/useCofheTokenDecryptedBalance.test.tsx   # 2 passed; both fail on master
npx vitest run                                                    # 80 passed
npx tsc --noEmit
  • refetchInterval / staleTime / retry / meta reach decryptingQueryOptions, select kept
  • the decrypt meta label is kept when a react-query meta is passed
  • changeset added

The options were spread into the top-level options object of
useCofheReadContractAndDecrypt, which only reads readQueryOptions,
decryptingQueryOptions and meta. So everything but enabled was ignored,
and a react-query meta replaced the decrypt meta (its label).

Pass them to the decrypt query instead, which is the query whose data the
hook returns.
@changeset-bot

changeset-bot Bot commented Oct 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8633307

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cofhe/react Patch
@cofhe/example-react Patch
@cofhe/abi Patch
@cofhe/foundry-plugin Patch
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/mock-contracts Patch
@cofhe/sdk Patch
@cofhe/site Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kutluhaneth46 kutluhaneth46 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — restOptions were previously spread onto useCofheReadContractAndDecrypt's top-level bag (ignored except enabled / colliding meta). Parking them under decryptingQueryOptions with the balance select preserved is the right shape, and the SSR probe covers the regression. Nice catch.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants