Skip to content

Conversation

mfbz
Copy link
Contributor

@mfbz mfbz commented Oct 1, 2025

Added hook with core scheduled transactions functionalities as in flow cli.

@mfbz mfbz requested a review from a team as a code owner October 1, 2025 17:17
Copy link

changeset-bot bot commented Oct 1, 2025

🦋 Changeset detected

Latest commit: 35d80ff

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

This PR includes changesets to release 1 package
Name Type
@onflow/react-sdk Minor

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

Copy link

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-sdk-demo Ready Ready Preview Comment Oct 21, 2025 9:16pm

"@onflow/react-sdk": minor
---

Added useFlowSchedule hook
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

@chasefleming chasefleming Oct 1, 2025

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?

Copy link
Contributor Author

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 {
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

Choose a reason for hiding this comment

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

same q

Copy link
Contributor Author

@mfbz mfbz Oct 2, 2025

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,
Copy link
Member

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

Copy link
Contributor Author

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 👍

Copy link
Contributor

@jribbink jribbink Oct 2, 2025

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

Copy link
Contributor Author

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

Copy link
Contributor

@Copilot 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 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.

Comment on lines 30 to 31
FlowTransactionScheduler: "0x0000000000000000",
FlowTransactionSchedulerUtils: "0x0000000000000000",
Copy link

Copilot AI Oct 15, 2025

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.

Copy link
Member

@chasefleming chasefleming left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-10-15 at 10 33 19 AM

Can we capitalize "Scheduled Transactions" here?

Can we also add more context on what they are please?

@mfbz
Copy link
Contributor Author

mfbz commented Oct 15, 2025

Screenshot 2025-10-15 at 10 33 19 AM Can we capitalize "Scheduled Transactions" here?

Can we also add more context on what they are please?

@chasefleming Improved playground card with full description of scheduled transactions and description of each feature in each tab (list, setup, cancel, get) 🚀

Comment on lines 30 to 31
FlowTransactionScheduler: "0x0000000000000000",
FlowTransactionSchedulerUtils: "0x0000000000000000",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can update these now, it's just going to be the service address https://contractbrowser.com/A.e467b9dd11fa00df.FlowServiceAccount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

any concerns about pagination/limits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it make sense even if the number probably won't be that high because it will only show the ones in "Pending" state. To avoid overengineering this (which would be the part of the indexer API), i think we can:

  • Add a limit parameter with a default
  • Update the Cadence script to apply the limit after fetching

Alternatively, we could leverage getTransactionIDsByTimestampRange from the FlowTransactionSchedulerUtils contract for time-based pagination, which feel more natural for scheduled transactions. This would let users fetch transactions by time windows while still applying a limit to prevent unbounded queries.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok sounds good, let's just ship as is then and worry about pagination as future scope 👍

} from "./useFlowScheduledTransactionList"

export interface UseFlowScheduledTransactionArgs {
scheduledTxId?: string
Copy link
Contributor

@jribbink jribbink Oct 21, 2025

Choose a reason for hiding this comment

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

Thoughts about renaming this arg to simply txId everywhere?

From a DevEx angle, we're going to try to mostly hide the distinction between TX ID/scheduled TX ID through SDKs/APIs.

Devs will already be able to use scheduled tx IDs as txId in useFlowTransaction/useFlowTransactionResult, so this would be consistent.

The idea is that if we frame and support scheduled tx id as interchangeable with regular tx IDs everywhere, the developers do not need to learn this distinction between identifier types.

@mfbz mfbz merged commit 9ff0f85 into master Oct 21, 2025
4 checks passed
@mfbz mfbz deleted the mfbz/use-flow-schedule-hook branch October 21, 2025 21:56
@github-actions github-actions bot mentioned this pull request Oct 21, 2025
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.

3 participants