Skip to content

Migrates to call useAllowance lib#1844

Closed
arielmergen wants to merge 2 commits intoreplace-hooks-allowancefrom
replace-hooks-stakeOperation
Closed

Migrates to call useAllowance lib#1844
arielmergen wants to merge 2 commits intoreplace-hooks-allowancefrom
replace-hooks-stakeOperation

Conversation

@arielmergen
Copy link
Copy Markdown
Contributor

@arielmergen arielmergen commented Mar 23, 2026

Description

Migrates stakeOperation.tsx to call @hemilabs/react-hooks/useAllowance directly, removing the dependency on the local wrapper hooks/useAllowance.

Scope

This PR is intentionally limited to one file only:

  • portal/app/[locale]/stake/_components/manageStake/stakeOperation.tsx

What changed

  • Replaced import { useAllowance } from 'hooks/useAllowance' with @hemilabs/react-hooks/useAllowance (lib direct call).
  • The native-token guard, previously implicit inside the wrapper, is now explicit at the call site via query: { enabled: !operatesNativeToken }.
  • AllowanceQuery type defined locally to handle the enabled field, which the lib omits from its query type signature but supports at runtime.
  • UseQueryOptions and Address imported as type only — no runtime impact.

What did not change

  • StakeOperation component public API is unchanged.
  • allowance and isPending fields preserve the same semantics for consumers.
  • Runtime behavior is identical.

Architecture notes

  • AllowanceQuery is duplicated between this file and hooks/useAllowance.ts. This is intentional and temporary — the local wrapper will be removed in PR 4.4 once all callers are migrated.
  • No new runtime dependencies introduced. @tanstack/react-query was already a project dependency.

Validation

  • Lint passes (no errors, no warnings).
  • portal build and type-check passes.
  • No tests exist for this component. N/A.

Related issue(s)

Related to #1843

Checklist

  • Manual testing passed.
  • Automated tests added, or N/A. (N/A)
  • Documentation updated, or N/A. (N/A)
  • Environment variables set in CI, or N/A. (N/A)

@arielmergen arielmergen self-assigned this Mar 23, 2026
Copilot AI review requested due to automatic review settings March 23, 2026 20:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Portal stake flow to use the shared @hemilabs/react-hooks useAllowance hook instead of the Portal-local implementation.

Changes:

  • Switch useAllowance import from hooks/useAllowance to @hemilabs/react-hooks/useAllowance.
  • Update the useAllowance call site to the new hook API shape (owner/spender/token + react-query query options).
  • Add local typing (AllowanceQuery) to constrain/shape the query options passed into the hook.

@arielmergen arielmergen changed the base branch from main to replace-hooks-allowance March 23, 2026 20:44
@arielmergen arielmergen marked this pull request as draft March 23, 2026 20:45
@arielmergen arielmergen requested a review from Copilot March 23, 2026 20:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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