-
Notifications
You must be signed in to change notification settings - Fork 132
Add useFlowSchedule hook #2653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add useFlowSchedule hook #2653
Conversation
🦋 Changeset detectedLatest commit: ee91c3f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
The latest updates on your projects. Learn more about Vercel for GitHub.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
.changeset/upset-cities-start.md
Outdated
"@onflow/react-sdk": minor | ||
--- | ||
|
||
Added useFlowSchedule hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this more descriptive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved 👍
High = 2, | ||
} | ||
|
||
export enum TransactionStatus { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this already exported from FCL? If so, should we use that type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this type is specific for Scheduled Transactions
import {CONTRACT_ADDRESSES, CADENCE_UFIX64_PRECISION} from "../constants" | ||
import {parseUnits} from "viem/utils" | ||
|
||
export enum TransactionPriority { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we export this from FCL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this type is specific for Scheduled Transactions
Cancelled = 4, | ||
} | ||
|
||
export interface TransactionInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same q
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is specific to the scripts used to retrieve data from the manager, so it's specific for the implementation
// Gets a transaction by ID | ||
// Equivalent to: flow schedule get <transaction-id> [--include-handler-data] | ||
get: ( | ||
transactionId: bigint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have mixed txId
and transactionId
across the React SDK. We should probably be consistent. I'm for transactionId
for clarity, so this is fine, but curious what everyone else thinks. cc @jribbink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right, we are using txId in react-sdk. i just updated it to have txId instead of transactionId for consistency 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same discussion goes for the numeric values. FCL traditionally uses string
to represent numbers. We don't use/support bigint elsewhere so I'm hesitant to introduce this inconsistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, just updated to string for consistency
There was a problem hiding this 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 adds comprehensive support for Flow blockchain scheduled transactions through new React hooks. The implementation provides setup, listing, fetching, and canceling capabilities for scheduled transactions, following patterns similar to the Flow CLI's scheduled transaction functionality.
Key changes:
- Added four new hooks for scheduled transaction management
- Implemented type-safe transaction status and priority enums
- Integrated contract addresses for scheduler utilities across networks
- Created demo UI for testing the new functionality
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/react-sdk/src/hooks/useFlowScheduledTransactionSetup.ts |
Hook for one-time scheduler manager setup in user accounts |
packages/react-sdk/src/hooks/useFlowScheduledTransactionList.ts |
Hook for listing all scheduled transactions for an account |
packages/react-sdk/src/hooks/useFlowScheduledTransactionCancel.ts |
Hook for canceling scheduled transactions with fee refunds |
packages/react-sdk/src/hooks/useFlowScheduledTransaction.ts |
Hook for fetching individual scheduled transaction details |
packages/react-sdk/src/hooks/index.ts |
Exports the new hooks and types |
packages/react-sdk/src/constants.ts |
Added scheduler contract addresses for all networks |
packages/demo/src/components/hook-cards/use-flow-scheduled-transaction-card.tsx |
Interactive demo component showcasing all scheduler hooks |
packages/demo/src/components/content-sidebar.tsx |
Added sidebar navigation for the demo |
packages/demo/src/components/content-section.tsx |
Integrated demo card into main content |
.changeset/upset-cities-start.md |
Changeset documenting the new feature |
Test files | Comprehensive unit tests for all new hooks |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
FlowTransactionScheduler: "0x0000000000000000", | ||
FlowTransactionSchedulerUtils: "0x0000000000000000", |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The placeholder addresses for mainnet (0x0000000000000000) could cause runtime errors if used before being updated. Consider adding runtime validation to throw a descriptive error when these placeholder addresses are detected, helping developers identify the issue quickly.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Chase Fleming <chasefleming@users.noreply.github.com>
Co-authored-by: Chase Fleming <chasefleming@users.noreply.github.com>
@chasefleming Improved playground card with full description of scheduled transactions and description of each feature in each tab (list, setup, cancel, get) 🚀 |
Added hook with core scheduled transactions functionalities as in flow cli.