forked from storacha/w3up
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wait for plan selection (storacha#1547)
# Add `wait()` Method to `AccountPlan` Class ## Summary This PR introduces a new `wait()` method to the `AccountPlan` class, which simplifies the process of waiting for a payment plan to be selected. By integrating configurable polling intervals, timeouts, and abort signals, the method abstracts the common logic required in this scenario, making it easier for developers to implement and customize their workflows. ## Changes - **New `wait()` Method**: - The `wait()` method repeatedly checks the account's payment plan status at a given interval until: - A valid plan is selected. - The timeout is reached. - The operation is aborted using an `AbortSignal`. - Available options: - `interval` (default: 1000ms): Sets the polling interval. - `timeout` (default: 15 minutes): Defines the maximum wait time. - `signal`: An optional `AbortSignal` to allow for cancellation. - This method improves the developer experience by abstracting the repetitive logic required to wait for a payment plan and offering flexibility through configurable options. ## How to Test 1. Run the test suite with `npm run build && npm run test`. 2. Ensure all existing tests pass. 3. Verify that the new test cases for the `wait()` method in `account.test.js` are passing, including tests for: - Successful payment plan selection. - Timeout errors. - Aborted operations.
- Loading branch information
Showing
3 changed files
with
127 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters