Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dominant-strategies/quais-polling
https://github.com/dominant-strategies/quais-polling
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dominant-strategies/quais-polling
- Owner: dominant-strategies
- Created: 2023-10-11T03:17:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-14T19:24:40.000Z (about 1 year ago)
- Last Synced: 2024-03-14T23:07:04.955Z (10 months ago)
- Language: JavaScript
- Size: 175 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Quais Polling
Quais Polling is an extension to the [Quais library](https://github.com/dominant-strategies/quais-5.js), designed to provide an easy and efficient way to poll for responses on the client side. Built on top of Quais, it maintains the simplicity and reliability you're accustomed to, with added polling capabilities.
## Features
- Seamless integration with Quais.
- Poll for transaction receipts, contract method results, or any asynchronous process.
- Configurable polling intervals and timeout settings.
- Efficient error handling during the polling process.## Installation
Before you install the Quais Polling, make sure you have Quais installed in your project.
```
npm install quais
```Then, you can install Quais Polling using npm:
```
npm install quais-polling
```Or yarn:
```
yarn add quais-polling
```## Usage
Here's a quick example to get you started:```
const { pollFor } = require('quais-polling');
const quais = require('quais');async function main() {
const provider = new quais.providers.JsonRpcProvider("http://localhost:8610");
const transactionHash = 'your-transaction-hash';try {
const receipt = await pollFor(provider, 'getTransactionReceipt', [transactionHash], 1000, 30000);
console.log(receipt);
} catch (error) {
console.error('Error polling for transaction receipt:', error);
}
}main();
```## API Reference
```
pollFor(provider, methodName, params, initial_polling_interval = 60, request_timeout = 30, max_duration = 180, max_polling_interval = 90)
```
Polls for a method's response.Parameters
* provider: The Quais provider instance.
* methodName: Name of the method you're awaiting a response from.
* params: Parameters to be passed to the method being called.
* initial_polling_interval (optional): Time (in seconds) for the initial interval between polls.
* request_timeout (optional): Time (in seconds) before the request times out.
* max_duration (optional): Maximum duration (in seconds) before the entire polling process times out. Defaults to 180 seconds.
* max_polling_interval (optional): Maximum time (in seconds) allowed between polls. Defaults to 10000 milliseconds.# Contributing
We welcome contributions! Please see our contributing guidelines for details.